Using the SDK
WebSockets are enabled by default in the@gelatocloud/gasless SDK. Methods automatically race WebSocket notifications against HTTP polling for the fastest result.
To disable WebSockets:
Subscribe to a Single Transaction
Subscribe to All Transactions
Unsubscribe
WebSocket API
Real-time updates for transactions via WebSocket connections.Authentication
All WebSocket endpoints require API key authentication. Pass key inAuthorization header:
wss://api.gelato.cloud/ws?apiKey=YOUR_API_KEY
Simple Transaction Subscription
Auto-subscribes to a specific transaction. Uses JSON-RPC 2.0 format for all messages. URL:wss://api.gelato.cloud/ws/transactions/:id
Advanced Subscription (JSON-RPC)
Flexible filtering: multiple transactions, chains, event types. Subscribe/unsubscribe dynamically. URL:wss://api.gelato.cloud/ws
Protocol: JSON-RPC 2.0
Method: subscribe
Params:
transactionId(string, optional): Specific transaction ID (max 200 chars)chainIds(string[], optional): Chain IDs to filter (max 50)eventTypes(string[], optional): Event type patterns (max 20)
transaction.* for all events or * for everything.
Unsubscribe
Works on both/ws/transactions/:id and /ws connections.
Method: unsubscribe
Params: [subscriptionId]
Message Types
Connection Confirmation (JSON-RPC) Sent when connection established on/ws:
/ws/transactions/:id:
Connection Health
Server Heartbeat The server sends native WebSocket ping frames every 30 seconds. Clients should respond with pong frames (most WebSocket libraries handle this automatically). If the server doesn’t receive a pong within 60 seconds, it will close the connection with code1000.
This is separate from the JSON
{type: "ping"} message, which is also supported for backward compatibility.Events & Status Codes
Use
transaction.* to subscribe to all transaction events, or * for all events.
Base Fields (All Statuses)
All status objects include:
id(string): Transaction identifierstatus(number): Status code (100/110/200/400/500)chainId(string): Chain IDcreatedAt(number): Unix timestamp (seconds)
- Pending (100)
- Submitted (110)
- Success (200)
- Rejected (400)
- Reverted (500)
For complete RPC method documentation, see
relayer_getStatus.