Optimism
Pronto para usar isso em produção?
O plano gratuito cobre projetos pessoais. O pay-as-you-go escala sem cartão de crédito.
Optimism
O plano gratuito cobre projetos pessoais. O pay-as-you-go escala sem cartão de crédito.
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.| # | Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|---|
| 1 | subscriptionId | string | Sim | The hex subscription ID returned by eth_subscribe. |
| Tipo | Descrição |
|---|---|
| boolean | `true` if the subscription was found and cancelled. `false` if it did not exist. |
Try it live in the Optimism playground.
| Código | Mensagem | 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.