L0vdL0vd

eth_call

Executes a read-only contract call against the state of a given block, without sending a transaction.

归档 · 可查询任意历史区块

With a past block this answers questions like a token balance or price at any moment in history. No gas is spent.

curl https://eth.l0vdinfra.com/YOUR_KEY \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","id":1,"method":"eth_call","params":[{"to":"0xdAC17F958D2ee523a2206206994597C13D831ec7","data":"0x18160ddd"},"0x1208a5f"]}'

响应示例

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x00000000000000000000000000000000000000000000000000953de484d045c9"
}
参数与您的端点

参数

transactionobject必填
Call object.
blockstring必填
Block number in hex (e.g. "0x1208a5f") or a tag: "latest", "safe", "finalized", "earliest" or "pending". L0vd endpoints run archive nodes, so any historical block works.
stateOverridesobject可选
Optional map of address to overridden balance, nonce, code or storage, applied before the call.

返回值

string Return data of the call, ABI-encoded hex.

适用场景

Run any view function, or simulate a state-changing one, against the state at a block. Nothing is broadcast and no gas is paid.

With a past block number this is the core archive read: token balances (balanceOf), prices from pools (slot0, getReserves), positions and oracle values at any moment in history.

如何解读结果

The result is ABI-encoded return data. Decode it with the function's ABI: viem decodeFunctionResult, ethers Interface.decodeFunctionResult, web3.py contract.decode_function_output.

Example: totalSupply() on USDT at block 18,908,895 returns 0x…953de484d045c9 = 42,007,823,219,967,433 units ≈ 42,007,823,219.97 USDT (6 decimals).

提示

  • Build call data with the ABI: the 4-byte selector of keccak256("balanceOf(address)") is 0x70a08231, followed by the 32-byte padded address.
  • A revert comes back as a JSON-RPC error with the revert data in error.data; decode it with the contract's error ABI.
  • Use the third parameter (state overrides) to test what-if scenarios, e.g. give an address a balance before calling.
  • For many reads at one block, batch them or use Multicall3 (0xcA11bde05977b3631167028862bE2a173976CA11).

相关方法