eth_getLogs
include monitoring smart contract events, tracking token transfers, and analyzing blockchain data.
object
— the filter parameters:
fromBlock
— (optional, default: latest
) integer that specifies the starting block number from which the logs should be fetched.toBlock
— (optional, default: latest
) integer that specifies the ending block number until which the logs should be fetched.address
— (optional) the contract address from which the logs should be fetched. It can be a single address or an array of addresses.topics
— (optional) an array of DATA
topics. The event topics for which the logs should be fetched. It can be a single topic or an array of topics.blockhash
— (optional) the hash of the specific block. Limits logs to a specific block with a 32-byte hash value. It takes precedence over fromBlock
and toBlock
.latest
— the most recent block in the blockchain and the current state of the blockchain at the most recent block.safe
— the block that received justification from the beacon chain. Although this block could be involved in a chain reorganization, it would necessitate either a coordinated attack by the majority of validators or an instance of severe propagation latency.finalized
— the block accepted as canonical by more than 2/3 of the validators. A chain reorganization is extremely unlikely, and it would require at least 1/3 of the staked ETH to be burned.earliest
— the earliest available or genesis block.pending
— the pending state and transactions block. The current state of transactions that have been broadcast to the network but have not yet been included in a block.array
— an array of log objects that match the specified filter or an empty array if there have been no new events since the last poll:
address
— the contract address from which the event originatedtopics
— an array of 32-byte data fields containing indexed event parametersdata
— the non-indexed data that was emitted along with the eventblocknumber
— the block number in which the event was included. null
if it is pending.transactionhash
— the hash of the transaction that triggered the event. null
if pending.transactionindex
— the integer index of the transaction within the block’s list of transactions. null
if it is pending.blockhash
— the hash of the block in which the event was included. null
if it is pending.logindex
— the integer identifying the index of the event within the block’s list of events. null
if pending.removed
— the boolean value indicating if the event was removed from the blockchain due to a chain reorganization. True
if the log was removed. False
if it is a valid log.eth_getLogs
code exampleseth_getLogs
method.eth_getLogs
is a powerful tool, it’s crucial to understand its limitations, particularly when working with different EVM-compatible chains, as these networks often have different constraints. The eth_getLogs
method allows you to select a range of blocks to get events from and is important to exercise proper management.
In general, eth_getLogs
is a very resource-intensive method and although Chainstack does not pose any arbitrary limitation, some blockchain clients do, and a very large block range can impact your node’s performance.
We recommend to keep the block range limit of 10,000 blocks for eth_getLogs
on Gnosis to maintain a good balance between node and application performance.
fromBlock
and toBlock
parameters should not exceed the given block range when querying logs.eth_getLogs
is to retrieve the transfer events for a specific Token ID from an ERC-721 smart contract. ERC-721 is a token standard for non-fungible tokens (NFTs), and each token transfer is recorded as an event on the blockchain. By retrieving these events, developers can track the movement of NFTs and build applications that interact with them.An array of log objects matching the specified filter.
The response is of type object
.