POST
/
efb0a5eccd2caa5135eb54eba6f7f300
curl --request POST \
  --url https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300 \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "method": "eth_newFilter",
  "id": 1,
  "params": [
    {
      "fromBlock": "latest",
      "address": "0x350a791Bfc2C21F9Ed5d10980Dad2e2638ffa7f6",
      "topics": [
        "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
      ]
    }
  ]
}'
{
  "jsonrpc": "<string>",
  "id": 123,
  "result": "<string>"
}

Optimism API method eth_newFilter creates a new filter object for monitoring log entries that match specified criteria. This method is crucial for applications that need to track events or changes in smart contracts.

The example tracks all transfers of the Chainlink token.

Once you install the filter, track the changes with eth_getFilterChanges.

Get you own node endpoint today

Start 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

  • filterObject — an object containing filter options:
    • fromBlock — (optional) the block number (in hexadecimal) or one of the strings "earliest", "latest", or "pending" from where to start filtering. Default is "latest".
    • address — (optional) an address or a list of addresses to only get logs from specific contracts.
    • topics — (optional) an array of topics to filter for log entries. Each event signature generated by the EVM logging mechanism has a unique topic.

Response

  • result — the ID of the created filter. This ID is used to identify and manage the filter with other filter methods like eth_getFilterChanges or eth_getFilterLogs.

Use case

The eth_newFilter method is essential for:

  • DApps that need to react to specific events emitted by smart contracts, such as token transfers or contract state changes.
  • Wallets and services that provide users with notifications based on contract interactions.
  • Developers and analysts monitoring specific contracts or topics for changes or patterns.

Body

application/json
jsonrpc
string
default:2.0
method
string
default:eth_newFilter
id
integer
default:1
params
object[]

Response

200 - application/json
The ID of the created filter
jsonrpc
string
id
integer
result
string