eth_subscribe to create subscriptions and eth_unsubscribe to cancel them.
Subscription Types
Lasso supports the following subscription types:Creating Subscriptions
Subscribe to New Block Headers
Request:result field contains the subscription ID. Save this ID to unsubscribe later.
Subscription Events:
As new blocks arrive, the server pushes events:
Subscribe to Logs
Request with filter:Log Filter Options
Thelogs subscription accepts a filter object with:
Examples:
All events from a contract:
Unsubscribing
Cancel a subscription usingeth_unsubscribe:
Request:
true indicates successful unsubscription. After unsubscribing, no more events will be pushed for that subscription ID.
Full Example
Here’s a complete subscription flow usingwscat:
Subscription Lifecycle
Automatic Cleanup
Subscriptions are automatically cleaned up when:- The WebSocket connection closes
- The connection times out (see Connection Lifecycle)
- An
eth_unsubscriberequest is received
Multiple Subscriptions
You can create multiple subscriptions on a single WebSocket connection:Error Handling
Invalid Subscription Type
Request:logs, Core accepts a filter object and forwards it to the selected
upstream. An unsupported field is not rejected locally with a fixed “malformed
filter” response; upstream validation and error details can vary.
Unsubscribe Non-Existent Subscription
Request:false indicates the subscription ID was not found.
Best Practices
Track Subscription IDs
Always store subscription IDs returned byeth_subscribe to unsubscribe later: