Executes a new message call immediately without creating a transaction on the block chain.
Executes a new message call immediately without creating a transaction on the blockchain. This is one of the most commonly used API calls. It is used to read from the blockchain which includes executing smart contracts, but does not publish anything to the blockchain. This call does not consume any Ether.
Starting from Geth 1.9.13,
eth_callwill check the balance of the sender (to make sure that the sender has enough gas to complete the request) before executing the call, when one of the following conditions is true:
- The
gas_priceparameter is populated, or- The contract function being called (i.e. in
datamodifies blockchain state)In these two cases, even though the
eth_callrequests don't consume any gas, thefromaddress must have enough gas to execute the call as if it were a write transaction becauseeth_callis being used to simulate the transaction.
PARAMETERS
Transaction- (required) A transaction object with the following fields:from- (optional) The address the transaction is sent from.to- (required) The address the transaction is directed to.gas- (optional) The gas provided for the transaction execution.eth_callconsumes zero gas, but this parameter may be needed by some executions. NOTE: this parameter has a cap of 550 Million gas per request. Reach out to us at [email protected] if you want to increase this limit!gasPrice- (optional) The gas price used for each paid gas.value- (optional) The value sent with this transaction.data- (optional) Hash of the method signature and encoded parameters. For details see Ethereum Contract ABI.
Block Number- (optional) An integer block number, or the string"latest","earliest"or"pending"(see the default block parameter), OR the block hash (in accordance with EIP-1898). NOTE: the parameter is an object instead of a string and should be specified as:{"blockHash": "0x {some-hash}}." Learn more here.
Note:
eth_callhas a timeout restriction at the node level. Batching multipleeth_calltogether on-chain using pre-deployed smart contracts might result in unexpected timeouts that cause none of your calls to complete. Instead, consider serializing these calls, or using smaller batches if they fail with a node error code.
REQUEST
{
"jsonrpc":"2.0",
"method":"eth_call",
"params":[
{
"from": "0x871f1181AA63c988325539cF4b502E092595B50E",
"to": "0x5300000000000000000000000000000000000002",
"gas": "0x76c0",
"gasPrice": "0x9184e72a000",
"value": "0x9184e72a",
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
},
"latest"
],
"id":1
}RESPONSE
Result - The return value of the executed contract.
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x"
}