参数
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).