⚠️Blast API (blastapi.io) ends Oct 31. Migrate to Dwellir and skip Alchemy's expensive compute units.
Switch Today →
Skip to main content

eth_getLogs

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

When to Use This Method

Use eth_getLogs to:

  • Query Contract Events - Find specific emitted events
  • Monitor Cross-Chain Activity - Track omnichain events
  • Build Event Indexes - Create searchable event databases
  • Analyze Historical Data - Query past events
  • Real-time Monitoring - Watch for new events

Parameters

Filter object with:

  • fromBlock - Starting block (optional)
  • toBlock - Ending block (optional)
  • address - Contract address or array of addresses (optional)
  • topics - Array of topics to filter (optional)
  • blockHash - Restrict to single block (optional)
{
"jsonrpc": "2.0",
"method": "eth_getLogs",
"params": [{
"fromBlock": "0x5d9000",
"toBlock": "0x5da000",
"address": "0x239e96c8f17C85c30100AC26F635Ea15f23E9c67",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
]
}],
"id": 1
}

Returns

Array of log objects with:

  • address - Address that emitted the event
  • topics - Array of indexed parameters
  • data - Non-indexed parameters
  • blockNumber - Block containing the log
  • transactionHash - Transaction that created the log
  • transactionIndex - Transaction position
  • blockHash - Hash of the block
  • logIndex - Log position in block
  • removed - True if log was removed (reorg)

Implementation Examples


curl -X POST https://api-xdc-mainnet.n.dwellir.com/YOUR_API_KEY -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"blockHash":"0xc7dca4af5d0b7050e9f64bb83c4cccb349a8e8315cd604edd54392a800ea292e","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]}],"id":1}'
  • eth_newFilter - Create event filter (create filter with your node)
  • eth_getFilterChanges - Poll for new log events
  • eth_getTransactionReceipt - Get logs from receipt