eth_call
Executes a new message call immediately without creating a transaction on the blockchain. Commonly used to read data from smart contracts.
Parameters
Section titled “Parameters”-
Object— The transaction call object:Field Type Required Description from DATA No Sender address to DATA Yes Contract address gas QUANTITY No Gas limit gasPrice QUANTITY No Gas price value QUANTITY No Value sent data DATA No ABI-encoded function call -
QUANTITY|TAG— Block number, or"latest","earliest","pending".
Returns
Section titled “Returns”DATA — The return value of the executed contract function.
Request
Section titled “Request”# Read ERC-20 totalSupply() on USDC contractcurl -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 }'Response
Section titled “Response”{ "jsonrpc": "2.0", "id": 1, "result": "0x0000000000000000000000000000000000000000000000000000001234567890"}Code Examples
Section titled “Code Examples”JavaScript (ethers.js v6)
Section titled “JavaScript (ethers.js v6)”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());Python (web3.py)
Section titled “Python (web3.py)”from web3 import Web3w3 = 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))RU Cost
Section titled “RU Cost”| Method | Cost |
|---|---|
| eth_call | 20 RU |