The eth_call
method executes a new message call immediately without creating a transaction on the blockchain. This method is perfect for reading data from smart contracts without spending gas or modifying the blockchain state, making it one of the most frequently used methods for DApp development.
This method allows interaction with deployed smart contracts in a read-only manner with optional state overrides. The state overrides feature is particularly useful for testing "what-if" scenarios.
The transaction call object which contains the following fields:
The address from which the transaction is sent
The address to which the transaction is addressed
The integer of gas provided for the transaction execution
The integer of gasPrice used for each paid gas encoded as hexadecimal
The integer of value sent with this transaction encoded as hexadecimal
The hash of the method signature and encoded parameters. For more information, see the Contract ABI description in the Solidity documentation
The block number in hexadecimal format or one of the string tags: latest, earliest, pending, safe or finalized (safe and finalized tags are only supported on Ethereum, Gnosis, Arbitrum, Arbitrum Nova and Avalanche C-chain)
The State Override Set option allows you to change the state of a contract before executing the call
The fake balance to set for the account before executing the call
The fake nonce to set for the account before executing the call
The fake EVM bytecode to inject into the account before executing the call
The fake key-value mapping to override all slots in the account storage before executing the call
The fake key-value mapping to override individual slots in the account storage before executing the call
The return value of the executed contract method
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x00000000000000000000000000000000000000000000015af1d78b58c4000000"
}
One of the most common uses of eth_call
is to check ERC20 token balances. The data field typically contains the function signature followed by the parameters:
0x70a08231
+ padded address0x313ce567
0x95d89b41
0x18160ddd
The response will need to be decoded according to the expected return type.