For the complete documentation index, see llms.txt. This page is also available as Markdown.

eth_getLogs - Ethereum

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

This method returns all logs matching the given criteria across a block range — the most direct way to query historical events without creating a persistent filter. Ideal for one-off historical queries, indexer backfills, and any workflow where the filter criteria change per query.

Parameters

Parameter
Type
Required
Description

filter

object

Yes

Filter criteria — same shape as eth_newFilter filter object

Request

curl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "eth_getLogs",
    "params": [
        {
            "fromBlock": "0x171f000",
            "toBlock": "0x1720340",
            "address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
            "topics": [
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                "0x000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045"
            ]
        }
    ],
    "id": "getblock.io"
}'
example.js
const axios = require('axios');

const response = await axios.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', {
    jsonrpc: '2.0',
    method: 'eth_getLogs',
    params: [
        {
            "fromBlock": "0x171f000",
            "toBlock": "0x1720340",
            "address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
            "topics": [
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                "0x000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045"
            ]
        }
    ],
    id: 'getblock.io'
}, {
    headers: { 'Content-Type': 'application/json' }
});

console.log(response.data.result);

Response

Response Parameters

Parameter
Type
Description

jsonrpc

string

JSON-RPC protocol version ("2.0")

id

string

Request identifier matching the request

result

array of object

Matching log entries in ascending order by (blockNumber, logIndex)

Use Cases

  • Indexer Backfill: Iterate through historical block ranges to backfill contract events into an indexer database

  • Wallet Activity History: Query all Transfer events for a specific address (as sender or receiver) across a block range

  • Analytics Queries: Aggregate Swap events, deposits, or governance actions over time windows

  • Airdrop Snapshotting: Retrieve all Transfer events for a token up to a snapshot block to compute historical holders

Error Handling

Error Code
Message
Description

-32602

Invalid params

Filter is malformed or block range is invalid

403

Request block range exceeds the limit(1500 blocks)

Block range too wide — narrow the range or use pagination

-32603

Internal error

Node failed to retrieve matching logs

Web3 Integration

Last updated

Was this helpful?