eth_getLogs - Monad

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

This method returns an array of all logs matching a given filter object.

Parameters

Parameter
Type
Required
Description

filter

object

Yes

The filter options.

filter.fromBlock

string

No

Start block (hex or tag). Default: "latest".

filter.toBlock

string

No

End block (hex or tag). Default: "latest".

filter.address

string/array

No

Contract address or list of addresses.

filter.topics

array

No

Array of 32-byte topic filters.

filter.blockHash

string

No

Restricts logs to a single block (cannot be used with fromBlock/toBlock).

Request

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": "0x1",
        "toBlock": "0xa",
        "address": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
        "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]
    }],
    "id": "getblock.io"
}'

Response

Response Parameters

Field
Type
Description

address

string

Address from which log originated.

topics

array

Array of 0-4 indexed log topics.

data

string

Non-indexed log data.

blockNumber

string

Block number where log was in (hex).

transactionHash

string

Transaction hash.

transactionIndex

string

Transaction index in the block (hex).

blockHash

string

Block hash.

logIndex

string

Log index in the block (hex).

removed

boolean

True if log was removed due to chain reorganization.

Use Case

The eth_getLogs method is essential for:

  • Tracking token transfers (ERC-20, ERC-721)

  • Monitoring DeFi protocol events

  • Building event-driven applications

  • Indexing blockchain data

  • Transaction history analysis

  • Real-time event notifications

Error Handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid ACCESS-TOKEN.

-32602

Invalid params

Invalid filter parameters.

-32005

Limit exceeded

Too many results or block range too large.

-32000

Resource not found

Block not found.

Web3 Integration

Block Range Limit

Performance Tips

1

Use specific addresses

Always filter by contract address when possible.

2

Use topics

Filter by event signatures to reduce results.

3

Paginate

For large queries, break into smaller block ranges.

4

Use blockHash

When querying a single block, use the blockHash parameter.

Last updated

Was this helpful?