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

eth_newBlockFilter - Blast

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

This method creates a filter that reports the hashes of new blocks as they are produced, and returns a filter ID.

Parameters

This method does not require any parameters. Send the request with an empty params array.

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_newBlockFilter",
    "params": [],
    "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_newBlockFilter',
    params: [],
    id: 'getblock.io'
}, {
    headers: { 'Content-Type': 'application/json' }
});

console.log(response.data.result);
example.py
import requests

response = requests.post(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
    headers={'Content-Type': 'application/json'},
    json={
        'jsonrpc': '2.0',
        'method': 'eth_newBlockFilter',
        'params': [],
        'id': 'getblock.io'
    }
)

print(response.json())

Response

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

Response Parameters

Parameter
Type
Description

jsonrpc

string

JSON-RPC protocol version ("2.0")

id

string

Request identifier matching the request

result

string

Hex-encoded filter ID

Use Cases

  • New Block Polling: Detect new blocks without a WebSocket subscription

  • Cadence Sampling: Observe the ~1 second block cadence via polling

  • Trigger Pipelines: Kick off work when a new block appears

  • Lightweight Watching: Track the chain tip where subscriptions are unavailable

Error Handling

Error Code
Message
Description

-32603

Internal error

The node failed to register the block filter

-32601

Method not found

Filters are disabled on the client build

Web3 Integration

Last updated

Was this helpful?