Ethereum
eth_newFilter
eth_newFilter is the log-watching member of the filter family. You hand the node a filter object — a contract address (or list of them), a set of indexed topics, and an optional fromBlock/toBlock window — and it returns a hex filter ID that remembers those criteria. From then on you poll eth_getFilterChanges with the ID to pull only the matching event logs that appeared since your last call, without resending the whole query each time. It is the polling cousin of eth_getLogs, trading one big historical scan for a running incremental feed. Register the filter at https://ethereum.therpc.io/YOUR_API_KEY on chain ID 1. Topics encode signatures like an ERC-20 Transfer or a Uniswap Swap, so you can target exactly the events you care about.
Use cases
- Track an ERC-20 token's
Transferevents by registering its address and theTransfertopic once, then polling roughly each 12-second slot for new hits instead of re-sending the full filter every time. - Keep a long-running indexer pointed at a Uniswap pair contract, watching its
Swaptopic so your service ingests trades as blocks land.
Parameters
| # | Name | Type | Required | Description |
|---|---|---|---|---|
| 1 | filter | object | Yes | Filter object. Fields: `fromBlock` (string), `toBlock` (string), `address` (string | string[]), `topics` ((string | string[] | null)[]). |
Response
| Type | Description |
|---|---|
| string | Hex filter ID. Pass this to eth_getFilterChanges, eth_getFilterLogs, or eth_uninstallFilter. |
Example request
Try it live in the Ethereum playground.
Errors & troubleshooting
| Code | Message | Cause |
|---|---|---|
-32000 | filter not found | Provider rejected filter creation, or filter limit per connection was reached. |
-32602 | invalid argument | Malformed filter object or invalid topic format. |
Common pitfalls
- A few minutes of not polling and the node drops the filter. When
eth_getFilterChangesreturns filter-not-found, recreate the filter and continue from the last block you processed. - Filter state lives on the node and is scoped to your connection, so a reconnect can lose it. Always keep the filter object around so you can re-register on demand.
- If you want a true push feed rather than a poll loop,
eth_subscribewith alogssubscription over WebSocket delivers the same events without the recreation dance.
Supported networks
- Mainnet — Chain ID: 1
- Sepolia — Chain ID: 11155111
See also
Parameters
Filter object. Fields: `fromBlock` (string), `toBlock` (string), `address` (string | string[]), `topics` ((string | string[] | null)[]).