Skip to content

eth_call

Executes a new message call immediately without creating a transaction on the blockchain. Commonly used to read data from smart contracts.

  1. Object — The transaction call object:

    FieldTypeRequiredDescription
    fromDATANoSender address
    toDATAYesContract address
    gasQUANTITYNoGas limit
    gasPriceQUANTITYNoGas price
    valueQUANTITYNoValue sent
    dataDATANoABI-encoded function call
  2. QUANTITY|TAG — Block number, or "latest", "earliest", "pending".

DATA — The return value of the executed contract function.

Terminal window
# Read ERC-20 totalSupply() on USDC contract
curl -X POST https://eth-mainnet.blockreq.com/v1/rpc/public \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_call",
"params": [{
"to": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"data": "0x18160ddd"
}, "latest"],
"id": 1
}'
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x0000000000000000000000000000000000000000000000000000001234567890"
}
import { JsonRpcProvider, Contract } from "ethers";
const provider = new JsonRpcProvider("https://eth-mainnet.blockreq.com/v1/rpc/YOUR_API_KEY");
const usdc = new Contract("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", [
"function totalSupply() view returns (uint256)",
], provider);
const supply = await usdc.totalSupply();
console.log("USDC supply:", supply.toString());
from web3 import Web3
w3 = Web3(Web3.HTTPProvider("https://eth-mainnet.blockreq.com/v1/rpc/YOUR_API_KEY"))
result = w3.eth.call({
"to": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"data": "0x18160ddd"
})
print("Total supply:", int(result.hex(), 16))
MethodCost
eth_call20 RU