eth_getLogs - AVAX

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

Returns C-Chain logs matching a given filter. Filters specify a block range, an address, and indexed topics, enabling efficient retrieval of contract events, such as ERC-20 transfers.

Parameters

Parameter
Type
Required
Description

filterObject

object

Yes

Filter with optional fromBlock, toBlock, address, topics

Request Example

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/ext/bc/C/rpc' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "eth_getLogs",
    "params": [
        {
            "fromBlock": "0x44b8a37",
            "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)

Use Cases

  • Indexing ERC-20 transfers on C-Chain

  • Tracking DEX swap events for analytics

  • Building real-time event-driven dApps

Error Handling

Status Code
Error Message
Cause

404

Not Found

Missing or invalid <ACCESS-TOKEN>

-32602

Invalid params

Request parameters are missing or malformed

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?