Updated on 2024-11-14 GMT+08:00

eth_getFilterLogs

Introduction

This API returns an array of all the logs matching the given filter ID. It consumes 500 CUs.

Parameter Description

Parameter

Type

Description

address

String

(Optional) A 20-byte contract address or a list of addresses from which logs should originate.

fromBlock

String

(Optional) A hexadecimal block number, or the string (earliest, latest, or pending). Latest is set by default.

toBlock

String

(Optional) A hexadecimal block number, or the string (earliest, latest, or pending). Latest is set by default.

topics

String

(Optional) An array of 32-byte data topics. Topics are order-dependent.

blockhash

String

(Optional) It restricts the logs returned to the single block referenced in the 32-byte hash blockHash. Using blockHash is equivalent to setting fromBlock and toBlock to the block number referenced in the blockHash. If blockHash is present in in the filter criteria, then neither fromBlock nor toBlock are allowed.

Return Value

  • Log object array: an array of log objects that match the filter. For an array of logs that occurred since the last poll, use eth_getFilterChanges. Log objects contain the following keys and their values:
    • address: the address from which this log originated.
    • blockHash: the hash of the block where this log was in. It is null for a pending log.
    • blockNumber: the number of the block where this log was in. It is null for a pending log.
    • data: the non-indexed arguments of the log.
    • logIndex: the hexadecimal of the log index position in the block. It is null for a pending log.
    • removed: true when the log was removed due to a chain reorganization. false if it is a valid log.
    • topics: an array of zero to four 32-byte data of the index log arguments. In Solidity, the first topic is the hash of the signature of the event (e.g. Deposit(address,bytes32,uint256)), except you declare the event with the anonymous specifier.
    • transactionHash: the hash of the transaction from which this log was created. It is null for a pending log.
    • transactionIndex: the hexadecimal of the transactions index position from which the log created. It is null for a pending log.

Request

curl https://your-http-endpoint/v1/<API-KEY> \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"eth_getFilterLogs","params":["0x16"],"id":74}'