kaia_getLogs
The eth_getLogs method returns an array of all logs matching a given filter object. This method is essential for querying historical event logs emitted by smart contracts, enabling applications to track contract events, monitor specific transactions, and build event-driven features.
You can filter by block range, addresses, and specific event topics to efficiently retrieve relevant logs. Developers use this extensively for indexing blockchain events, tracking token transfers, monitoring contract activity, building notification systems, and analyzing smart contract interactions. The method supports flexible filtering with multiple addresses and topic combinations, making it powerful for complex event queries. Note that most nodes limit the block range to prevent excessive resource usage.
Parameters
parameter | type | description |
|---|---|---|
filterObject | object (required) | Filter options to specify which logs to retrieve |
Filter Object Properties:
property | type | description |
|---|---|---|
fromBlock | string (optional) | Block number in hex or tag (latest, earliest, pending). Starting block for the logs query |
toBlock | string (optional) | Block number in hex or tag (latest, earliest, pending). Ending block for the logs query |
address | string or array (optional) | Contract address (20-byte string) or array of addresses to filter logs from. Omit to get logs from all contracts |
topics | array (optional) | Array of 32-byte data topics. Topics are order-dependent. Use null in a position to match any topic. Each position can also be an array to match multiple options |
blockHash | string (optional) | 32-byte block hash. Alternative to fromBlock/toBlock, restricts results to a single block. Cannot be used with fromBlock/toBlock |
Return Object
The method returns an array of log objects matching the filter criteria. Each log object contains the following fields:
field | type | description |
|---|---|---|
address | string | Address of the contract that emitted the log (20 bytes) |
topics | array | Array of 0 to 4 indexed log arguments (each 32 bytes). The first topic is usually the event signature hash |
data | string | The non-indexed log data (hex-encoded) |
blockNumber | string | Block number where this log appeared (hex) |
blockHash | string | Hash of the block where this log appeared (32 bytes) |
transactionHash | string | Hash of the transaction that created this log (32 bytes) |
transactionIndex | string | Transaction index position in the block (hex) |
logIndex | string | Log index position in the block (hex) |
removed | boolean | True if the log was removed due to a chain reorganization, false if it's a valid log |
Request Example
Response Example