githubEdit

eth_unsubscribe - Arbitrum

Example code for the eth_unsubscribe JSON RPC method. Сomplete guide on how to use eth_unsubscribe JSON RPC in GetBlock Web3 documentation.

This method allows developers to cancel a subscription by its subscription ID

circle-info

This method is only available through a WebSocket endpoint.

Parameters

Field
Type
Required
Description

subscription ID

string

Yes

The identifier of the subscription to cancel.

Request

circle-check
$ wscat -c wss://go.getblock.us/<ACCESS_TOKEN>
# Wait for the connection to be established

Connected (press CTRL+C to quit)

> {"id":1,"jsonrpc":"2.0","method":"eth_unsubscribe","params":["0x9c7c3f3c3c63b1b89ac0c1e0b0d3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8090a1b"]}

Response

{
  "jsonrpc": "2.0",
  "id": "getblock.io",
  "result": true
}

Reponse Parameter Definition

Field name
Data type
Description

result

boolean

A boolean indicating whether the subscription was successfully canceled.

Error handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid ACCESS_TOKEN.

-32000

  • subrsciption not found

  • the subcription ID is missing or incorrect

Integration with Web3

The eth_unsubscribe helps developers to:

  • Manage live event listeners more efficiently in Web3 frontends.

  • Prevent unnecessary loads by stopping subscriptions when components unmount.

  • Improve the performance of dashboards that need to toggle between live and static views.

  • Support mobile dApps where bandwidth consumption must remain low.

  • Dynamically pause or resume event streaming depending on user actions.

Last updated

Was this helpful?