eth_call
This is the common JSON-RPC method. It is used to read the data in the smart contract in the blockchain. Because it is a read-only method, the call does not consume any gas fee.
We can call any function of the smart contract using the eth_call method, which returns data in hexadecimal format.
eth_call is used to call read-only functions of smart contracts. for example: call the balanceOf
function of the ERC20 token contract.
Parameters
Object - [required] transaction call object
from
[required] The address the transaction is sent from.to
[required] The address the transaction is directed to.gas
[optional] 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
[optional] hexadecimal value of the gasPrice used for each paid gas.maxPriorityFeePerGas
[optional] Maximum fee, in Wei, the sender is willing to pay per gas above the base fee. See EIP-1559 transactions。maxFeePerGas
[optional] Maximum total fee (base fee + priority fee), in Wei, the sender is willing to pay per gas. See EIP-1559 transactions。value
[optional] hexadecimal value of the value sent with this transaction.data
[optional] Hash of the method signature and encoded parameters. See the Ethereum ABI specification.
Block-Number - [required] a hexadecimal block number, or the string
latest
,earliest
orpending
. See the default block parameter.
Request
The following example shows the balanceOf
function querying an ERC20 token.
Response
Return the contract execution result.
Last updated