Our goal at Relay is to make multichain payments feel instant. Even when transactions confirm quickly onchain, API polling latency can degrade user experience. Connecting your app to Relay Websockets means your users get streamed updates of the status of their Relays for a speedier experience.
Relay Status Websockets
Relay Status Websockets specifically stream transaction statuses for both cross and same-chain status, though the stages differ slightly.
Integrating Relay Websockets
Refer to the guide below on how to integrate the websocket into your application. You may also refer to the websocket reference for more details.
Events
Authentication
The Websocket Service is available for anyone with strict rate limits. For customers with an API key it can be used for authentication for higher rate limits, the service is available at the following URL wss://ws.relay.link
To connect using an API key, provide your API key as a query param in the connection url:
Authentication is generally not required in client-side applications.
The websocket server needs to restart to deploy updatesThe websocket server uses a rolling restart mechanism to deploy new changes. This will disconnect you and require you to reconnect to the websocket server. There is no downtime, as you are only disconnected once the new server is up and running. Please make sure to include logic in your implementation to handle these restarts, and reconnect accordingly.
Interacting with the Websocket
Before sending any messages over the Websocket, wait for a ready message back from the server. The message looks like:
Subscribing with Filters
Below is an example on how to subscribe to a websocket using filters.
Unsubscribing
Unsubscribing is not required if disconnecting from the websocket as the server cleans up automatically.
Example
Javascript