> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chainstack.com/llms.txt
> Use this file to discover all available pages before exploring further.

# eth_newBlockFilter | Fantom

> Fantom API method that creates a filter that watches for new blocks on the blockchain. eth_newBlockFilter on Fantom via Chainstack.

Fantom 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](https://docs.chainstack.com/reference/fantom-getfilterchanges.md) method. The `eth_newBlockFilter` method is useful for developers who must be notified of new blocks on the blockchain in real-time.

## Parameters

* `none`

## Response

* `result` — a hexadecimal string representing the ID of the newly created filter.

The filters created are stored on the blockchain client instance. The filter fill is automatically deleted if not polled within a certain time (5 minutes by default).

Use the following methods with the filter ID:

* [eth\_getFilterChanges](https://docs.chainstack.com/reference/fantom-getfilterchanges.md) to retrieve updates
* [eth\_uninstallFilter](https://docs.chainstack.com/reference/fantom-uninstallfilter.md) to remove the filter

## `eth_newBlockFilter` code examples

> [!NOTE]
>
> **web3.eth.filterdeprecation**
>
> Note that the `web3.eth.filter` methods have been deprecated and replaced with the `web3.eth.subscribe` in web3.js. See [web3.js subscriptions](https://docs.chainstack.com/reference/ethereum-web3js-subscriptions-methods.md).

```javascript ethers.js theme={"system"}
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();
```

```python web3.py theme={"system"}
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 for `eth_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.


## OpenAPI

````yaml openapi/fantom_node_api/eth_newBlockFilter.json POST /mt_c524ad9781ae5dccd9ac6f5b0370e
openapi: 3.0.0
info:
  title: Fantom Node API
  version: 1.0.0
  description: This is an API for interacting with a Fantom node.
servers:
  - url: https://fantom-mainnet.core.chainstack.com
security: []
paths:
  /mt_c524ad9781ae5dccd9ac6f5b0370e:
    post:
      summary: eth_newBlockFilter
      operationId: newBlockFilter
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                jsonrpc:
                  type: string
                  default: '2.0'
                method:
                  type: string
                  default: eth_newBlockFilter
                params:
                  type: array
                  default: []
                id:
                  type: integer
                  default: 1
      responses:
        '200':
          description: The new filter ID.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    type: string
                  id:
                    type: integer
                  result:
                    type: array
                    items:
                      type: string

````