eth_call

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_call will 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:
a) the gas_price parameter is populated, or
b) the contract function being called (i.e. in data modifies blockchain state)

In these two cases, even though the eth_call requests don't consume any gas, the from address must have enough gas to execute the call as if it were a write transaction because eth_call is being used to simulate the transaction.

Parameters

  • OBJECT - The transaction call object
KeyRequiredTypeDetail
from❌StringAddress the transaction is sent from.
toβœ…StringAddress the transaction is directed to.
gas❌StringA hex code of an integer that represents the gas provided for the transaction execution.
gasPrice❌StringA hex code of an integer that represents the price used for each paid gas.
value❌StringA hex code of an integer that represents the value sent with this transaction.
data❌StringHash of method signature and encoded parameters. Learn more here.
  • BLOCK PARAMETER
Object NameRequiredTypeDetail
BLOCK PARAMETERβœ…String/ObjectA hex code of an integer that represents the block number, "latest", "earliest" , "pending" , or the hash of a block. The hash of a block is an object specified as: {"blockHash": "\<hash_value>"}. Learn more here.

🚧

NOTE: eth_call has a timeout restriction at the node level. Batching multiple eth_call together 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.

"params": [
    {
        "from": "0xd3904de9f2cd7b888125f5bb2d29427fb911d899",
        "to": "0xd3904de9f2cd7b888125f5bb2d29427fb911d899"
    }, 
    "latest"
]

Result

The return value of the executed contract method.

Example

Request

curl <your-endpoint> \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"eth_call","params":[{"from": "0xd3904de9f2cd7b888125f5bb2d29427fb911d899","to": "0xd3904de9f2cd7b888125f5bb2d29427fb911d899"}, "latest"],"id":1}'

Return

{
    "id": 1,
    "jsonrpc": "2.0",
    "result": "0x"
}
Language
Click Try It! to start a request and see the response here!