eth_unsubscribe
JSON-RPC method allows developers to cancel an active WebSocket subscription on the Hyperliquid EVM blockchain. This method is used to stop receiving notifications for subscriptions created with eth_subscribe
, helping to manage resources and control data flow in applications.
Get your own node endpoint todayStart for free and get your app to production levels immediately. No credit card required.You can sign up with your GitHub, X, Google, or Microsoft account.
Parameters
- subscription ID (string, required): The subscription identifier returned by
eth_subscribe
when the subscription was created
Response
The method returns a boolean value indicating whether the unsubscribe operation was successful.Response structure
true
— the subscription was successfully cancelledfalse
— the subscription was not found or could not be cancelled
Usage example
Basic implementation
Note that subscriptions require a WebSocket connection. Install WebSocket cat for testing:
wscat
JavaScript implementation with subscription management
Python implementation with context manager
Subscription lifecycle management
Use cases
Theeth_unsubscribe
method is essential for:
- Resource management: Free up server and client resources by canceling unused subscriptions
- Dynamic subscription control: Change subscription parameters by unsubscribing and resubscribing
- Application lifecycle management: Clean up subscriptions when components unmount or disconnect
- Rate limiting compliance: Manage the number of active subscriptions to stay within limits
- Cost optimization: Reduce bandwidth and processing costs by removing unnecessary subscriptions
- Error recovery: Cancel problematic subscriptions that are causing issues
- Testing and development: Clean up test subscriptions during development
- User preference changes: Update subscriptions when users change monitoring preferences
- Performance optimization: Remove subscriptions that are no longer needed to improve performance
- Connection management: Properly clean up before reconnecting or switching endpoints
eth_unsubscribe
ensures efficient resource utilization and clean application shutdown, preventing memory leaks and unnecessary network traffic.