Skip to main content
Lasso supports Ethereum JSON-RPC subscriptions over WebSocket for real-time blockchain events. Use 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:
Response:
The 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:
This example subscribes to Transfer events from USDC on Ethereum. Response:
Subscription Events: As matching logs are emitted, the server pushes events:

Log Filter Options

The logs subscription accepts a filter object with: Examples: All events from a contract:
Specific event signature across all contracts:
Event from multiple contracts:
Event with indexed parameter filter:
This filters for Transfer events where the second indexed parameter (recipient) matches the specified address.

Unsubscribing

Cancel a subscription using eth_unsubscribe: Request:
Response:
A result of true indicates successful unsubscription. After unsubscribing, no more events will be pushed for that subscription ID.

Full Example

Here’s a complete subscription flow using wscat:

Subscription Lifecycle

Automatic Cleanup

Subscriptions are automatically cleaned up when:
  • The WebSocket connection closes
  • The connection times out (see Connection Lifecycle)
  • An eth_unsubscribe request is received

Multiple Subscriptions

You can create multiple subscriptions on a single WebSocket connection:
Each subscription receives a unique subscription ID and events are tagged with the corresponding ID.

Error Handling

Invalid Subscription Type

Request:
Response:
For 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:
Response:
A result of false indicates the subscription ID was not found.

Best Practices

Track Subscription IDs

Always store subscription IDs returned by eth_subscribe to unsubscribe later:

Handle Reconnection

Subscriptions don’t persist across reconnections. Re-subscribe after reconnecting:

Filter Logs Efficiently

Use specific filters to reduce network traffic:

Rate Limiting

Lasso RPC Core has no built-in incoming customer quota mechanism. Enforce ingress connection/request limits at your proxy and account for upstream-provider limits and subscription volume. Use bounded filters and follow the recovery and checkpoint guide. Cloud limits are a separate managed-service contract.