ethereum / ethereum/execution-apis

JSONRPC: eth_multiCall

Open
#616 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Io
Stars
1.1k
Forks
530
Avg merge
5d 8h
Merged PRs (30d)
9

Description

### 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](https://docs.metamask.io/services/concepts/transaction-types/#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](https://docs.metamask.io/services/concepts/transaction-types/#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](https://docs.soliditylang.org/en/latest/abi-spec.html).
- `block parameter`: [Required] A hexadecimal block number, or one of the string tags latest, earliest, pending, safe, or finalized. See the [default block parameter](https://ethereum.org/en/developers/docs/apis/json-rpc/#default-block).

```json
{
"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`

```json
{
"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",
}
}
]
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.