L0vdL0vd

eth_newFilter

Creates a log filter on the node and returns its ID; poll it with eth_getFilterChanges.

Filters live on one node and expire after about 5 minutes without polling. For history use eth_getLogs; filters are for following new events.

curl https://eth.l0vdinfra.com/YOUR_KEY \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","id":1,"method":"eth_newFilter","params":[{"address":"0xdAC17F958D2ee523a2206206994597C13D831ec7","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]}]}'

Example response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x0400000000000000b27af21a8da84662"
}
Params and your endpoint

Parameters

filterobjectrequired
fromBlock, toBlock, address and topics, as in eth_getLogs.

Returns

string Filter ID.

When to use it

Follow new events without managing block ranges: create a filter once, then poll eth_getFilterChanges every few seconds.

How to read the result

The result is an opaque filter ID; keep it and pass it to the polling methods.

Tips

  • A filter that is not polled for about 5 minutes is removed; create a new one if polling returns "filter not found".
  • For history and backfills use eth_getLogs with block ranges: filters only see new blocks.
  • Call eth_uninstallFilter when you are done.

Related methods