Skip to main content

eth_getLogs

Returns an array of all logs matching a given filter object on Ethereum.

Why Ethereum? Build on the world's leading smart contract platform with the largest developer ecosystem with battle-tested security, institutional adoption, and unmatched ecosystem with $166B+ TVL.

Use Cases#

The eth_getLogs method is essential for:

  • Event indexing - Track contract events for DeFi protocols (60% market share), NFT marketplaces, DAOs, and enterprise dApps
  • Token transfers - Monitor ERC20/ERC721 transfers
  • DeFi analytics - Track swaps, liquidity events, and more
  • Notification systems - Alert on specific on-chain events

Parameters#

ParameterTypeRequiredDescription
fromBlockQUANTITY|TAGNoStarting block (default: "latest")
toBlockQUANTITY|TAGNoEnding block (default: "latest")
addressDATA|ArrayNoContract address(es) to filter
topicsArrayNoArray of topic filters
blockHashDATANoFilter single block by hash

Request#

{
"jsonrpc": "2.0",
"method": "eth_getLogs",
"params": [{
"fromBlock": "latest",
"toBlock": "latest",
"address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
"topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]
}],
"id": 1
}

Returns#

Array of log objects:

FieldTypeDescription
addressDATAContract that emitted the log
topicsArrayArray of indexed topics
dataDATANon-indexed log data
blockNumberQUANTITYBlock number
transactionHashDATATransaction hash
logIndexQUANTITYLog index in block

Response#

{
"jsonrpc": "2.0",
"id": 1,
"result": [{
"address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
"topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", "0x...", "0x..."],
"data": "0x...",
"blockNumber": "0x5BAD55",
"transactionHash": "0x...",
"logIndex": "0x0"
}]
}

Code Examples#

curl -X POST https://api-ethereum-mainnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getLogs",
"params": [{
"fromBlock": "latest",
"toBlock": "latest",
"address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
"topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]
}],
"id": 1
}'

Error Handling#

Error CodeMessageDescription
-32005Query returned more than 10000 resultsReduce block range
-32602Invalid paramsInvalid filter parameters