> ## 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_newFilter | Cronos

> Cronos API method that generates a filter object based on the filter parameters. Available on Cronos via Chainstack JSON-RPC nodes.

Cronos API method that generates a filter object based on the filter parameters. It returns a filter ID, which can be used to retrieve the filter results using the `eth_getFilterChanges` method. By creating a filter for specific events, developers can receive notifications when those events occur and use them to trigger actions in their applications.

<Check>
  **Get your own node endpoint today**

  [Start for free](https://console.chainstack.com/) and get your app to production levels immediately. No credit card required.

  You can sign up with your GitHub, X, Google, or Microsoft account.
</Check>

## Parameters

* `object` — the filter parameters:
  * `fromBlock` — (optional, default: `latest`) integer that specifies the starting block number from which the logs should be fetched.
  * `toBlock` — (optional, default: `latest`) integer that specifies the ending block number until which the logs should be fetched.
  * `address` — (optional) the contract address from which the logs should be fetched. It can be a single address or an array of addresses.
  * `topics` — (optional) an array of `DATA` topics. The event topics for which the logs should be fetched. It can be a single topic or an array of topics.
  * `blockhash` — (optional) the hash of the specific block. Limits logs to a specific block with a 32-byte hash value. It takes precedence over `fromBlock` and `toBlock`.

<Note>
  **Possible tags forfromBlockandtoBlock**

  * `latest` — the most recent block in the blockchain and the current state of the blockchain at the most recent block.
  * `safe` — the block that received justification from the beacon chain. Although this block could be involved in a chain reorganization, it would necessitate either a coordinated attack by the majority of validators or an instance of severe propagation latency.
  * `finalized` — the block accepted as canonical by more than 2/3 of the validators. A chain reorganization is extremely unlikely, and it would require at least 1/3 of the staked ETH to be burned.
  * `earliest` — the earliest available or genesis block.
  * `pending` — the pending state and transactions block. The current state of transactions that have been broadcast to the network but have not yet been included in a block.

  See the [default block parameter](https://ethereum.org/en/developers/docs/apis/json-rpc/#default-block) and [How The Merge Impacts Ethereum’s Application Layer](https://blog.ethereum.org/2021/11/29/how-the-merge-impacts-app-layer).
</Note>

## Response

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

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

## `eth_newFilter` code examples

<Note>
  Note that the `web3.eth.filter` methods have been deprecated and replaced with the `web3.eth.subscribe` in web3.js. See [web3.js subscriptions](/reference/ethereum-web3js-subscriptions-methods).
</Note>

<CodeGroup>
  ```javascript ethers.js theme={"system"}
  const ethers = require('ethers');
  const NODE_URL = "CHAINSTACK_NODE_URL";
  const provider = new ethers.JsonRpcProvider(NODE_URL);

  const filter = {
    toBlock: 'latest',
    address: '0x5C7F8A570d578ED84E63fdFA7b1eE72dEae1AE23',
    topics: ['0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef']
  };

  const createFilter = async () => {
    try {
      const filterId = await provider.send('eth_newFilter', [filter]);
      console.log(filterId); // the filter ID returned by eth_newFilter
      return filterId
    } catch (error) {
      console.log(error);
    }
  };

  createFilter();
  ```

  ```python web3.py theme={"system"}
  const ethers = require('ethers');
  const NODE_URL = "CHAINSTACK_NODE_URL";
  const provider = new ethers.JsonRpcProvider(NODE_URL);

  const filter = {
    toBlock: 'latest',
    address: '0x5C0x5C7F8A570d578ED84E63fdFA7b1eE72dEae1AE23'
    topics: ['0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef']
  };

  const createFilter = async () => {
    try {
      const filterId = await provider.send('eth_newFilter', [filter]);
      console.log(filterId); // the filter ID returned by eth_newFilter
      return filterId
    } catch (error) {
      console.log(error);
    }
  };

  createFilter();
  ```
</CodeGroup>

## Use case

You can use `eth_newFilter` to create a filter for a specific action on a smart contract, for example, to monitor the transfer transactions from the [Wrapped CRO token](https://cronoscan.com/token/0x5c7f8a570d578ed84e63fdfa7b1ee72deae1ae23).

The idea is to create a filter using the `eth_newFilter` method to monitor an ERC-20 smart contract, WCRO in this case.


## OpenAPI

````yaml /openapi/cronos_node_api/eth_newFilter.json POST /b9b0fb92029d58b396139a9e89cf479b
openapi: 3.0.0
info:
  title: Cronos Node API
  version: 1.0.0
  description: This is an API for interacting with a Cronos node.
servers:
  - url: https://nd-907-114-772.p2pify.com
security: []
paths:
  /b9b0fb92029d58b396139a9e89cf479b:
    post:
      tags:
        - logs
      summary: eth_newFilter
      operationId: newFilter
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                method:
                  type: string
                  default: eth_newFilter
                params:
                  type: array
                  items:
                    type: object
                    properties:
                      fromBlock:
                        type: string
                        title: from block
                        description: >-
                          The block number or tag to start searching for logs
                          from.
                        default: latest
                      address:
                        type: string
                        title: smart contract address
                        description: The contract address to retrieve the logs for.
                      topics:
                        type: array
                        title: topics
                        items:
                          type: string
                        description: >-
                          An array of 32-byte topics to filter for. Each topic
                          is treated as an OR condition.
                  default:
                    - fromBlock: latest
                      address: '0x5C7F8A570d578ED84E63fdFA7b1eE72dEae1AE23'
                      topics:
                        - >-
                          0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
                id:
                  type: integer
                  default: 1
                jsonrpc:
                  type: string
                  default: '2.0'
      responses:
        '200':
          description: The filter ID.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    type: string
                  id:
                    type: integer
                  result:
                    type: string

````