eth_newBlockFilter
Last updated:
`eth_newBlockFilter` registers a new block filter on the server and returns a hex filter ID. From then on, the server tracks the hash of every block that is added to the chain after the filter was created. You retrieve those hashes by calling [`eth_getFilterChanges`](eth_getFilterChanges.md) with the ID; each poll returns the block hashes seen since your previous poll and advances the filter's cursor.
This is the HTTP-based alternative to a WebSocket subscription (`eth_subscribe` with `newHeads`): instead of the server pushing new blocks to you over a persistent connection, you create a filter once and poll it on an interval. On Polygon, where block time is roughly 2 seconds, a polling loop of about that interval keeps you close to the chain tip. It is the right choice for clients that cannot hold a WebSocket open — serverless functions, simple cron jobs, or environments behind restrictive proxies.
A filter is a **stateful server-side resource**. It is not tied to the lifetime of any single request, so a filter you create but never clean up lingers as an orphan and can accumulate over time. Always release a filter you are done with by calling [`eth_uninstallFilter`](eth_uninstallFilter.md). Filters also expire after a period of inactivity; once expired, polling them returns `-32000 filter not found`, which is your signal to recreate the filter and resume.
Parameters
This method takes no parameters.
Returns
| Field | Type |
|---|---|
| result | object |
Examples
curl https://<your-endpoint>/ \
-X POST -H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"eth_newBlockFilter","params":[]}'const res = await fetch("https://<your-endpoint>/", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"id": 1,
"method": "eth_newBlockFilter",
"params": [],
"jsonrpc": "2.0"
}),
});
const data = await res.json();import requests
resp = requests.post("https://<your-endpoint>/", json={"id":1,"method":"eth_newBlockFilter","params":[],"jsonrpc":"2.0"})
print(resp.json()){
"id": 1,
"result": "0x828a383d145a175873bfc2e0c1d4dcfd",
"jsonrpc": "2.0"
}Usage
- Transport: HTTP (JSON-RPC).
- Networks: mainnet.
- Credit cost: 1 per call.
FAQ
- What does eth_newBlockFilter do?
- Creates a server-side block filter and returns a filter ID you can poll for newly arrived block hashes.
- How many credits does eth_newBlockFilter cost?
- eth_newBlockFilter costs 1 credit(s) per call on Triport by default.
- Is eth_newBlockFilter available over WebSocket?
- eth_newBlockFilter is an HTTP JSON-RPC method.