Skip to content

JSONRPC: eth_multiCall #616

Open
Open
@Kriys94

Description

@Kriys94

Motivation


Some Dapps/Wallets use https://www.multicall3.com/ to read multiple smart contracts data in a single JSON-RPC request. However, this is computationally inefficient and slow because the Reads are executed in the EVM runtime context, which is fully sequential. This proposal enables the simultaneous reading of multiple contracts and boosts read performance. To avoid any race condition, the sub-reads are executed independently.

Spec


Parameters:

  • List
    • Object
      • from: 20 bytes [Required] Address the transaction is sent from
      • to: 20 bytes - Address the transaction is directed to
      • gas: Hexadecimal value of the gas provided for the transaction execution. eth_call consumes zero gas, but this parameter may be needed by some executions.
      • gasPrice: Hexadecimal value of the gasPrice used for each paid gas.
      • maxPriorityFeePerGas: Maximum fee, in wei, the sender is willing to pay per gas above the base fee. See EIP-1559 transactions.
      • maxFeePerGas: Maximum total fee (base fee + priority fee), in wei, the sender is willing to pay per gas. See EIP-1559 transactions.
      • value: Hexadecimal of the value sent with this transaction.
      • data: Hash of the method signature and encoded parameters. See Ethereum contract ABI specification.
  • block parameter: [Required] A hexadecimal block number, or one of the string tags latest, earliest, pending, safe, or finalized. See the default block parameter.
{
  "jsonrpc": "2.0",
  "method": "eth_multiCall",
  "params": [
      [
        {
         "from": "0x0000000000000000000000000000000000000000", 
         "to": "0xdac17f958d2ee523a2206206994597c13d831ec7",
          "data": "0x70a082310000000000000000000000007B071A4C0a77B525e0a9446A598fc97AFaB5E6Ab"
        },
        {
         "from": "0x0000000000000000000000000000000000000000", 
          "to": "0xB8c77482e45F1F44dE1745F52C74426C631bDD52",
          "data": "0x70a082310000000000000000000000007B071A4C0a77B525e0a9446A598fc97AFaB5E6Ab"
        },
        {
         "from": "0x0000000000000000000000000000000000000000", 
          "to": "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
          "data": "0x70a082310000000000000000000000007B071A4C0a77B525e0a9446A598fc97AFaB5E6Ab"
        },
      ],
      "latest"
  ],
  "id": 1
}

Response:

  • List
    • Object
      • OR
        • data: The return value of the executed contract method
        • Object:
          • data
          • code
          • message
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    {
      "data": "0x000000000000000000000000000000000000000000000000000000000000000a"
    },
    {
      "error": {
        "code": -32000,
        "message": "execution reverted: ERC721: invalid token ID",
        "data": "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001a4552433732313a20696e76616c696420746f6b656e2049440000000000000000",
      }
    },
    {
      "error": {
        "code": -32000,
        "message": "invalid address",
        "data": "0x",
      } 
    }
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions