- Websocket Subscriptions: This is the recommended and most efficient method. By subscribing via websocket, the Gelato backend will automatically push updates for all your tasks to your Relay SDK client. To start receiving these updates, you must register a callback function which will be triggered every time one of your tasks gets updated.
- Polling for Updates: Alternatively, you can periodically query the Gelato task status API for updates. If you’re using the Gelato Relay SDK, the getTaskStatus method makes this easy.
Websocket Subscriptions
Using Gelato Relay SDK
Support for Websocket Subscriptions was introduced in Gelato Relay SDK version 5.5.0, make sure to update your package. You can subscribe to websocket updates by registering a callback handler function like this:Using websocket API
You can interact with the websocket API directly by connecting to this endpoint:Polling for Updates
Using Gelato Relay SDK
To query the latest task status you can use the following method:Querying from Gelato API
Task Status Response
The task status response object has the following format:Task states
For the taskState key, these are the possible values:- CheckPending: the relay request has been received by Gelato Relay (pending simulation).
- ExecPending: the relay task is executable and is awaiting inclusion into the blockchain.
- WaitingForConfirmation: the task was included into the blockchain but is still awaiting the required amount of blocks confirmations.
- ExecSuccess: the task has been successfully executed.
- Cancelled: the task has been cancelled due to failed simulations or other errors. The error message will be shown in the lastCheckMessage key.
- ExecReverted: the task transaction has been reverted.