Polygon
Polygon
Polygon
免费套餐涵盖个人项目。按量付费,无需绑卡即可扩展。
eth_unsubscribe cancels an active WebSocket subscription on a Polygon PoS node by its subscription ID — the hex value returned by eth_subscribe — and stops the node from pushing further eth_subscription notifications for that stream. It is the counterpart to eth_subscribe: when your client no longer needs new Polygon block headers, contract logs, or pending MATIC transactions, this releases the stream cleanly. Issue the call over the same WebSocket connection to the Polygon mainnet endpoint at https://polygon.therpc.io/YOUR_API_KEY (chain ID 137, 0x89).
newHeads subscription when a user navigates away from a live Polygon block view, so the node stops pushing ~2-second block updates you no longer render.logs subscriptions by unsubscribing the old one before creating a new one with updated filter params — for example switching from QuickSwap pool events to USDT Transfer events without leaking the previous stream.| # | 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|---|
| 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 Polygon 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. |
eth_unsubscribe must be called on the same WebSocket connection that created the subscription. A subscription ID from one connection cannot be cancelled from another, and doing so returns an invalid-subscription error.参数
The hex subscription ID returned by eth_subscribe.