Optimism
¿Listo para usar esto en producción?
El plan gratuito cubre proyectos personales. El pago por uso escala sin necesidad de tarjeta.
Optimism
El plan gratuito cubre proyectos personales. El pago por uso escala sin necesidad de tarjeta.
eth_newFilter creates a server-side log filter on OP Mainnet — the ETH-gas OP Stack rollup at chain ID 10 (0xa) — and returns a hex filter ID. You define the criteria once (a block range, one or more contract addresses, and indexed topics), then poll the ID with eth_getFilterChanges to pull only the matching logs emitted since your last poll, without re-sending the full filter each time. This is the polling counterpart to a WebSocket eth_subscribe logs subscription. Create the filter against https://optimism.therpc.io/YOUR_API_KEY.
Transfer events on an OP Mainnet token by setting address and the Transfer topic once, then calling eth_getFilterChanges on a short interval — every couple of blocks, since OP Mainnet produces one roughly every 2 seconds.Swap events in a long-running process — for example a Velodrome pool — by registering its address and topic and incrementally draining new logs as trades land.| # | Nombre | Tipo | Requerido | Descripción |
|---|---|---|---|---|
| 1 | filter | object | Sí | Filter object. Fields: `fromBlock` (string), `toBlock` (string), `address` (string | string[]), `topics` ((string | string[] | null)[]). |
| Tipo | Descripción |
|---|---|
| string | Hex filter ID. Pass this to eth_getFilterChanges, eth_getFilterLogs, or eth_uninstallFilter. |
Try it live in the Optimism playground.
| Código | Mensaje | Causa |
|---|---|---|
-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. |
eth_getFilterChanges returns filter not found, you re-register the filter and continue from the last block you processed.eth_subscribe logs subscription is more efficient than repeatedly polling a filter — reserve eth_newFilter for HTTP-only or batch-style consumers.Parámetros
Filter object. Fields: `fromBlock` (string), `toBlock` (string), `address` (string | string[]), `topics` ((string | string[] | null)[]).