Skip to main content

eth_getLogs

Returns an array of all logs matching a given filter object on the Unichain network. Essential for querying historical events and monitoring smart contract activity.

Parameters​

  • filter (object, required): The filter object with the following optional properties:
    • fromBlock (string, optional): Block number or tag ("earliest", "latest", "pending", "safe", "finalized") to start searching from
    • toBlock (string, optional): Block number or tag to stop searching at
    • address (string or array, optional): Contract address or array of addresses to filter logs from
    • topics (array, optional): Array of 32-byte DATA topics. Topics are order-dependent:
      • First topic is usually the event signature hash
      • Use null to match any value at a specific position
      • Can provide arrays for "OR" conditions at each position
    • blockHash (string, optional): Restricts logs to a specific block (incompatible with fromBlock/toBlock)

Returns​

An array of log objects, each containing:

  • address (string): Address from which this log originated
  • topics (array of strings): Array of 0 to 4 32-byte DATA topics
  • data (string): Contains non-indexed arguments of the log
  • blockNumber (string): Block number where this log was included
  • blockHash (string): Hash of the block where this log was included
  • transactionHash (string): Hash of the transaction that created this log
  • transactionIndex (string): Transaction index position in the block
  • logIndex (string): Integer of the log index position in the block
  • removed (boolean): true when the log was removed due to a chain reorganization

Implementation Example​

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

Response Example​

{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"address": "0x1234567890abcdef1234567890abcdef12345678",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000009876543210fedcba9876543210fedcba98765432",
"0x000000000000000000000000fedcba0987654321fedcba0987654321fedcba09"
],
"data": "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000",
"blockNumber": "0x1b4",
"blockHash": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
"transactionHash": "0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321",
"transactionIndex": "0x1",
"logIndex": "0x0",
"removed": false
}
]
}

Advanced Usage​

Filter by Multiple Addresses​

{
"address": [
"0x1234567890abcdef1234567890abcdef12345678",
"0xabcdef1234567890abcdef1234567890abcdef12"
]
}

Complex Topic Filtering​

{
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
null, // Any value for second topic
[ // OR condition for third topic
"0x0000000000000000000000001234567890abcdef1234567890abcdef12345678",
"0x000000000000000000000000abcdef1234567890abcdef1234567890abcdef12"
]
]
}

Notes​

  • Block Range Limits: Free plans typically limited to 5 blocks, paid plans up to 10,000 blocks
  • Topics are Order-Dependent: The first topic is usually the event signature hash
  • Use null for Wildcards: In the topics array, use null to match any value at that position
  • Performance: Large block ranges or broad filters may result in slower responses
  • Block Tags: Supports "earliest", "latest", "pending", "safe", and "finalized"

Need help? Contact our support team or check the Unichain documentation.