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

eth_getLogs - Flashblocks

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

This returns query logs from pre-confirmed transactions, updated every ~200ms.

Parameters

Parameter
Type
Required
Description

filterObject

object

Yes

Filter options object

Filter Object

Field
Type
Required
Description

fromBlock

string

No

Start block number (hex) or "latest", "earliest" or "pending"

toBlock

string

No

End block number (hex) or "latest", "earliest"

address

string/array

No

Contract address or array of addresses

topics

array

No

Array of topic filters (up to 4 topics)

blockHash

string

No

Specific block hash (alternative to 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": "pending",
      "toBlock": "pending",
      "address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
      "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]
    }],
    "id": 1
  }'
const axios = require('axios');

// Query ERC-20 Transfer events
const transferTopic = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef';

const response = await axios.post('https://go.getblock.io/<ACCESS-TOKEN>/', {
    "jsonrpc": "2.0",
    "method": "eth_getLogs",
    "params": [{
      "fromBlock": "pending",
      "toBlock": "pending",
      "address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
    }],
    "id": 1
  }, {
    headers: { 'Content-Type': 'application/json' }
});

const logs = response.data.result;
console.log('Found', logs.length, 'transfer events');
logs.forEach(log => {
    console.log('Block:', parseInt(log.blockNumber, 16));
    console.log('Tx:', log.transactionHash);
});

Response

Response Parameters

Parameter
Type
Description

address

string

Contract address that emitted the log

topics

array

Indexed event parameters (up to 4)

data

string

Non-indexed event data (hex)

blockNumber

string

Block number in hex

transactionHash

string

Transaction hash

transactionIndex

string

Transaction index in block (hex)

blockHash

string

Block hash

logIndex

string

Log index in block (hex)

removed

boolean

True if log was removed due to chain reorg

Use Cases

  • Token Transfer Tracking: Monitor ERC-20/ERC-721 transfers

  • DEX Event Processing: Track swaps, liquidity events

  • Contract Event Indexing: Build event-driven databases

  • Real-time Notifications: Alert on specific events

  • Historical Analysis: Analyze past contract activity

Error Handling

Error Code
Message
Description

-32602

Invalid params

Invalid filter object

-32603

Internal error

Query range too large or node failure

-32005

Query returned more than limit

Too many logs in response

SDK Integration

Last updated

Was this helpful?