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_unsubscribe cancels an active WebSocket subscription on OP Mainnet — the OP Stack rollup that settles to Ethereum L1 and pays gas in ETH — by passing the hex ID that eth_subscribe returned. Once cancelled, the node stops pushing further eth_subscription notifications for that stream, which keeps your connection lean when you no longer need newHeads, logs, or pending-transaction events. Issue the call over the same WebSocket at https://optimism.therpc.io/YOUR_API_KEY (chain ID 10, 0xa). It returns true if the subscription was found and removed, or false if it did not exist.
newHeads subscription when a user leaves a live OP Mainnet block view, so the node stops streaming updates the UI no longer renders.logs subscriptions by unsubscribing the old ID before opening a new one with updated address or topic filters, avoiding overlapping duplicate streams.| # | Nombre | Tipo | Requerido | Descripción |
|---|---|---|---|---|
| 1 | subscriptionId | string | Sí | The hex subscription ID returned by eth_subscribe. |
| Tipo | Descripción |
|---|---|
| boolean | `true` if the subscription was found and cancelled. `false` if it did not exist. |
Try it live in the Optimism playground.
| Código | Mensaje | Causa |
|---|---|---|
-32602 | invalid subscription id | The subscription ID is malformed or belongs to a different connection. |
-32000 | subscription not found | The subscription was already cancelled or never existed. |
false.eth_unsubscribe is optional on teardown — but it is still good practice when you keep a long-lived connection open and only want to drop one stream.Parámetros
The hex subscription ID returned by eth_subscribe.