eth_getLogs - opBNB

Example code for the eth_getLogs JSON-RPC method. Сomplete guide on how to use eth_getLogs JSON-RPC in GetBlock.io Web3 documentation.

This method returns the logs that match a given filter. Filters specify a block range, an address, and indexed topics, enabling efficient retrieval of contract events, such as ERC-20 transfers or Uniswap-style swaps.

Parameters

Parameter
Type
Required
Description

filterObject

object

Yes

Filter with optional fromBlock, toBlock, address (single or array), topics (array of topic filters)

Request Example

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "eth_getLogs",
    "params": [
        {
            "fromBlock": "0x2d4e89f",
            "toBlock": "latest",
            "address": "0x9e7c5e3e3a3b8e1aa0e2d4c7f9d4b0c8b8d5f1a2",
            "topics": [
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
            ]
        }
    ],
    "id": "getblock.io"
}'

Response Example

Response Parameters

Field
Type
Description

result

array

Array of log objects matching the filter

result[].address

string

Contract address that emitted the log

result[].topics

array of string

Indexed event topics; topic 0 is typically the event signature hash

result[].data

string

Non-indexed event data (ABI-encoded)

result[].blockNumber

string

Block number containing the log

result[].transactionHash

string

Hash of the transaction that emitted the log

result[].removed

boolean

true if the log was removed due to a reorg

Use Cases

  • Indexing ERC-20 / BEP-20 transfers

  • Tracking DEX swap events for analytics

  • Building real-time event-driven dApps

  • Backfilling historical contract activity

Error Handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid <ACCESS-TOKEN>

-32602

Invalid params

Request parameters are missing or malformed

-32601

Method not found

The method is not supported by this node

429

Too Many Requests

Rate limit exceeded for your plan

-32005

Limit exceeded

Block range or returned result set exceeds the provider's limit; narrow your filter

SDK Integration

Last updated

Was this helpful?