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

pendingLogs - Flashblocks

Example code for the pendingLogs Flashblocks method. Complete guide on how to use pendingLogs Flashblocks in GetBlock Web3 documentation.

This Subscribes to contract event logs emitted by preconfirmed transactions — sub-block latency for on-chain events. Filter by contract address (single or array) and event topics (same format as eth_getLogs).

This is the fastest way to react to on-chain events, up to ~1.8 seconds ahead of the standard logs subscription.

Parameters

Parameter
Type
Required
Description

subscriptionType

string

Yes

Must be "pendingLogs"

filter

object

No

Filter object: address (single address or array), topics (same format as eth_getLogs)

Request Example

# WebSocket-only. Use wscat (or similar) to connect first:
wscat -c 'wss://go.getblock.io/<ACCESS-TOKEN>/'

# Then send:
{"jsonrpc": "2.0", "method": "eth_subscribe", "params": ["pendingLogs", {"address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]}], "id": "getblock.io"}
import WebSocket from 'ws';

const ws = new WebSocket('wss://go.getblock.io/<ACCESS-TOKEN>/');

ws.on('open', () => {
    ws.send(JSON.stringify({
    "jsonrpc": "2.0",
    "method": "eth_subscribe",
    "params": [
        "pendingLogs",
        {
            "address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
            "topics": [
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
            ]
        }
    ],
    "id": "getblock.io"
}));
});

ws.on('message', (data) => {
    const msg = JSON.parse(data.toString());
    if (msg.method === 'eth_subscription') {
        // Preconfirmed data update
        console.log(msg.params.result);
    } else {
        // Subscription ID response
        console.log('Subscribed:', msg.result);
    }
});

Response Example

{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": "0x7e2ef8b9c0d1e2f3a4b5c6d7e8f9a0b1"
}

Response Parameters

Field
Type
Description

result

string

Hex-encoded subscription ID. Each subsequent notification carries a Log object matching the filter, from a preconfirmed transaction

Use Cases

  • Real-time event indexers — the lowest-latency way to react to on-chain events

  • Trading bots watching for specific ERC-20 transfers, DEX swaps, or oracle updates

  • Liquidation bots watching for Aave/Compound account state changes

  • Social/gaming applications reacting to on-chain events with instant UX feedback

Error Handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid <ACCESS-TOKEN>

-32602

Invalid params

Request parameters are missing or malformed

-32603

Internal error

Server-side error while processing the request

429

Too Many Requests

Rate limit exceeded for your plan

-32600

Invalid Request

Subscription called over HTTP; use WebSocket

-32602

Invalid filter

Filter object malformed — check address and topics format

SDK Integration

Last updated

Was this helpful?