Ethereum
准备好在生产环境中调用了吗?
免费套餐涵盖个人项目。按量付费,无需绑卡即可扩展。
Ethereum
免费套餐涵盖个人项目。按量付费,无需绑卡即可扩展。
eth_getLogs is the workhorse for reading Ethereum events. Every emit in a Solidity contract — an ERC-20 Transfer, a Uniswap Swap, an Aave borrow — leaves a log on Ethereum mainnet (chain ID 1, the EVM network where gas is paid in ETH), and this method pulls back all the logs that match a filter object you describe. You filter by address (one contract or several), by indexed topics, and by a block range with fromBlock/toBlock, or pin a single block with blockHash. Unlike the stateful filter API, it's a one-shot query: no eth_newFilter registration, no polling cursor. That makes it the standard tool for backfilling and indexing event history. Send the request to https://ethereum.therpc.io/YOUR_API_KEY.
Transfer history by setting address to the token and topics[0] to the Transfer(address,address,uint256) signature hash, walking the range in chunks.Swap, Mint, and Burn events from Uniswap pools or borrow events from Aave to reconstruct volumes and TVL over time.blockHash and matching on the contract address and topic.| # | 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|---|
| 1 | filter | object | 是 | Filter object. Fields: `fromBlock` (string, default "latest"), `toBlock` (string, default "latest"), `address` (string | string[]), `topics` ((string | string[] | null)[]), `blockHash` (string — mutually exclusive with fromBlock/toBlock). |
| 类型 | 描述 |
|---|---|
| array | Array of log objects. Each log: `address`, `blockHash`, `blockNumber`, `data`, `logIndex`, `removed` (bool — true on reorg), `topics`, `transactionHash`, `transactionIndex`. |
Try it live in the Ethereum playground.
| 错误码 | 错误信息 | 原因 |
|---|---|---|
-32005 | query exceeds max block range | The fromBlock–toBlock window exceeds the provider's block-range cap. |
-32005 | query returned more than 10000 results | Too many matching logs; narrow the filter or paginate. |
-32602 | invalid argument | blockHash combined with fromBlock/toBlock, or malformed topic format. |
removed field, and for anything that moves value, re-query once the block reaches finalized (roughly 12.8 minutes, two epochs, after it was proposed).address or topics makes the node scan far too much and you'll hit a block-range cap or the 10,000-result ceiling — both surface as -32005. Paginate in chunks of about 1,000 to 5,000 blocks and always narrow by address or topic.eth_getLogs with fromBlock: "latest" to fake a live feed is wasteful and races the chain head. For streaming, use eth_newFilter + eth_getFilterChanges, or subscribe to logs over WebSocket with eth_subscribe.参数
Filter object. Fields: `fromBlock` (string, default "latest"), `toBlock` (string, default "latest"), `address` (string | string[]), `topics` ((string | string[] | null)[]), `blockHash` (string — mutually exclusive with fromBlock/toBlock).