Returns all logs (events) that match a filter over a block range.
归档 · 可查询任意历史区块
A very large range or result can be rejected with error -32005. Split big backfills into chunks of about 1,000 blocks (10 on the free test key) and run them in parallel within your RPS cap.
fromBlock and toBlock (hex or tag), address (one address or a list), topics (up to four positions; each a topic, a list of alternatives or null), or blockHash instead of the range.
返回值
arrayMatching log objects.
addressstring
Contract that emitted the log.
topicsarray
Up to four indexed topics; topic 0 is the event signature hash.
datastring
Non-indexed event arguments, ABI-encoded.
blockNumberstring
Block number, hex.
transactionHashstring
Hash of the transaction that emitted the log.
logIndexstring
Position of the log in the block, hex.
removedboolean
true if the log was removed by a reorg.
适用场景
Fetch events emitted by contracts over a block range: token transfers, swaps, mints, governance votes.
This is the backbone of indexers and backfills: scan history once, then follow new blocks.
如何解读结果
Each log has the emitting address, up to four topics and data. topics[0] is keccak256 of the event signature; indexed arguments follow in topics[1..3]; the rest is ABI-encoded in data.
Decode with the event ABI: viem decodeEventLog, ethers Interface.parseLog, web3.py contract.events.Transfer().process_log.
提示
Always filter by address and topics[0]. Unfiltered ranges return huge payloads.
Walk long histories in chunks of about 1,000 blocks, and halve the chunk when you get error -32005 (too many results). The free test key allows 10 blocks per request; paid plans don't have this limit.
Run chunks in parallel up to your RPS cap; on L0vd you pay a flat price, so a full backfill costs nothing extra.
Use blockHash instead of a range to read one block's logs consistently during reorgs.