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

eth_newBlockFilter - Ethereum

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

This method creates a filter that fires each time a new block is added to the chain. Returns a filter ID that subsequent eth_getFilterChanges calls poll to receive block hashes. Lighter-weight than log filters — no criteria, just chain-tip advancement notifications.

Parameters

This method takes no parameters.

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": "0x1a"
}

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 — pass to eth_getFilterChanges to receive new block hashes

Use Cases

  • New Block Notifications: Poll to receive block hashes for each newly produced block without subscribing over WSS

  • Simple Chain-Progress Indicators: Feed a UI 'live block' badge without full block details

  • Trigger Periodic Work: Kick off backend work (indexer runs, reorg checks) once per new block

Error Handling

Error Code
Message
Description

-32603

Internal error

Node failed to create the filter

Web3 Integration

Last updated

Was this helpful?