Skip to main content
Tempo API method that creates a filter for new block notifications. The filter can be polled with eth_getFilterChanges to get new block hashes. With Tempo’s ~0.5 second block times, this filter will receive frequent updates.

Parameters

  • none

Response

  • result — the filter ID

eth_newBlockFilter code examples

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

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

    // Poll for new blocks
    const newBlocks = await provider.send("eth_getFilterChanges", [filterId]);
    console.log(`New block hashes: ${newBlocks}`);
  };

createBlockFilter();