Optimism
Optimism
Optimism
免费套餐涵盖个人项目。按量付费,无需绑卡即可扩展。
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.| # | 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|---|
| 1 | subscriptionId | string | 是 | The hex subscription ID returned by eth_subscribe. |
| 类型 | 描述 |
|---|---|
| boolean | `true` if the subscription was found and cancelled. `false` if it did not exist. |
Try it live in the Optimism playground.
| 错误码 | 错误信息 | 原因 |
|---|---|---|
-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.参数
The hex subscription ID returned by eth_subscribe.