eth_newBlockFilter
curl --request POST \
--url https://bsc-mainnet.core.chainstack.com/35848e183f3e3303c8cfeacbea831cab \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"method": "eth_newBlockFilter",
"params": [],
"id": 1
}
'import requests
url = "https://bsc-mainnet.core.chainstack.com/35848e183f3e3303c8cfeacbea831cab"
payload = {
"jsonrpc": "2.0",
"method": "eth_newBlockFilter",
"params": [],
"id": 1
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({jsonrpc: '2.0', method: 'eth_newBlockFilter', params: [], id: 1})
};
fetch('https://bsc-mainnet.core.chainstack.com/35848e183f3e3303c8cfeacbea831cab', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://bsc-mainnet.core.chainstack.com/35848e183f3e3303c8cfeacbea831cab",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'jsonrpc' => '2.0',
'method' => 'eth_newBlockFilter',
'params' => [
],
'id' => 1
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://bsc-mainnet.core.chainstack.com/35848e183f3e3303c8cfeacbea831cab"
payload := strings.NewReader("{\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_newBlockFilter\",\n \"params\": [],\n \"id\": 1\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://bsc-mainnet.core.chainstack.com/35848e183f3e3303c8cfeacbea831cab")
.header("Content-Type", "application/json")
.body("{\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_newBlockFilter\",\n \"params\": [],\n \"id\": 1\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://bsc-mainnet.core.chainstack.com/35848e183f3e3303c8cfeacbea831cab")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_newBlockFilter\",\n \"params\": [],\n \"id\": 1\n}"
response = http.request(request)
puts response.read_body{
"jsonrpc": "<string>",
"id": 123,
"result": [
"<string>"
]
}BNB node API
eth_newBlockFilter | BNB Chain
BNB API method that creates a filter that watches for new blocks on the blockchain. eth_newBlockFilter on BNB Chain via Chainstack.
POST
/
35848e183f3e3303c8cfeacbea831cab
eth_newBlockFilter
curl --request POST \
--url https://bsc-mainnet.core.chainstack.com/35848e183f3e3303c8cfeacbea831cab \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"method": "eth_newBlockFilter",
"params": [],
"id": 1
}
'import requests
url = "https://bsc-mainnet.core.chainstack.com/35848e183f3e3303c8cfeacbea831cab"
payload = {
"jsonrpc": "2.0",
"method": "eth_newBlockFilter",
"params": [],
"id": 1
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({jsonrpc: '2.0', method: 'eth_newBlockFilter', params: [], id: 1})
};
fetch('https://bsc-mainnet.core.chainstack.com/35848e183f3e3303c8cfeacbea831cab', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://bsc-mainnet.core.chainstack.com/35848e183f3e3303c8cfeacbea831cab",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'jsonrpc' => '2.0',
'method' => 'eth_newBlockFilter',
'params' => [
],
'id' => 1
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://bsc-mainnet.core.chainstack.com/35848e183f3e3303c8cfeacbea831cab"
payload := strings.NewReader("{\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_newBlockFilter\",\n \"params\": [],\n \"id\": 1\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://bsc-mainnet.core.chainstack.com/35848e183f3e3303c8cfeacbea831cab")
.header("Content-Type", "application/json")
.body("{\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_newBlockFilter\",\n \"params\": [],\n \"id\": 1\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://bsc-mainnet.core.chainstack.com/35848e183f3e3303c8cfeacbea831cab")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_newBlockFilter\",\n \"params\": [],\n \"id\": 1\n}"
response = http.request(request)
puts response.read_body{
"jsonrpc": "<string>",
"id": 123,
"result": [
"<string>"
]
}BNB API method that creates a filter that watches for new blocks on the blockchain. It returns a filter ID, which can be used to retrieve the results using the eth_getFilterChanges method. The
eth_newBlockFilter method is useful for developers who must be notified of new blocks on the blockchain in real-time.
Get your 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— a hexadecimal string representing the ID of the newly created filter.
- eth_getFilterChanges to retrieve updates
- eth_uninstallFilter to remove the filter
eth_newBlockFilter code examples
web3.eth.filterdeprecationNote that the
web3.eth.filter methods have been deprecated and replaced with the web3.eth.subscribe in web3.js. See web3.js subscriptions.const ethers = require('ethers');
const NODE_URL = "CHAINSTACK_NODE_URL";
const provider = new ethers.JsonRpcProvider(NODE_URL);
const createFilter = async () => {
try {
const filterId = await provider.send('eth_newBlockFilter', []);
console.log(filterId); // the filter ID returned by eth_newFilter
return filterId
} catch (error) {
console.log(error);
}
};
createFilter();
from web3 import Web3
node_url = "CHAINSTACK_NODE_URL"
web3 = Web3(Web3.HTTPProvider(node_url))
def get_new_blocks():
try:
blocks_filter = web3.eth.filter('latest')
return blocks_filter
except Exception as e:
print(e)
blocks = get_new_blocks()
filter_id = blocks.filter_id
print(filter_id)
Use case
One use case foreth_newBlockFilter in a simple DApp is to listen for new blocks and update the user interface with the latest block information.
When the DApp starts, it creates a new filter using eth_newBlockFilter to listen for new blocks. When a new block is added to the blockchain, the filter is triggered, and the DApp retrieves the latest block information using a Web3 library.Last modified on June 22, 2026
Was this page helpful?