Skip to main content
POST
/
eth_newBlockFilter
curl --request POST \
  --url https://monad-testnet.core.chainstack.com/9c5b265f20b3ea5df4f54f70eb74b800/ \
  --header 'Content-Type: application/json' \
  --data '{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "eth_newBlockFilter",
  "params": []
}'
{
  "jsonrpc": "<string>",
  "id": 123,
  "result": "<string>"
}
Monad API method that creates a filter in the node to notify when a new block arrives. Use eth_getFilterChanges to poll for new blocks.
Get you own node endpoint todayStart for free and get your app to production levels immediately. No credit card required.You can sign up with your GitHub, X, Google, or Microsoft account.

Parameters

  • none

Response

  • result — the filter ID, used to poll for new blocks with eth_getFilterChanges.

eth_newBlockFilter code examples

const { ethers } = require("ethers");

const provider = new ethers.JsonRpcProvider("CHAINSTACK_NODE_URL");

async function createBlockFilter() {
  const filterId = await provider.send("eth_newBlockFilter", []);
  console.log("Filter ID:", filterId);

  // Poll for new blocks
  setInterval(async () => {
    const changes = await provider.send("eth_getFilterChanges", [filterId]);
    if (changes.length > 0) {
      console.log("New blocks:", changes);
    }
  }, 2000);
}

createBlockFilter();

Use case

A practical use case for eth_newBlockFilter is building applications that need to react to new blocks as they are mined, such as block explorers, monitoring tools, or applications that need to track chain progress without using WebSocket subscriptions.

Body

application/json
id
integer
default:1
jsonrpc
string
default:2.0
method
string
default:eth_newBlockFilter
params
any[]

Response

200 - application/json

A filter ID that can be used with eth_getFilterChanges to poll for new blocks

jsonrpc
string
id
integer
result
string

The filter ID