Intent Relay API
Error handling conventions: Failures from
submitTransaction/relayTxAndWaitPacketfollow the relay-layer contract:error.messageis one of the literal strings exported asRELAY_ERROR_CODES('SUBMIT_TX_FAILED','RELAY_TIMEOUT'). Modules other than swap (moneyMarket, bridge, dex, migration, staking) propagate these errors raw. The swap module wraps them intoSodaxError<SwapErrorCode>withcontext.relayCode(see SWAPS.md Error Handling).
The Intent Relay API Service provides functionality for submitting transactions and retrieving transaction packets across different chains. This service is part of the cross-chain communication infrastructure.
Source: packages/sdk/src/shared/services/intentRelay/IntentRelayApiService.ts
Available Actions
submit— Submit a transaction to the intent relay service.get_transaction_packets— Get all packets associated with a transaction.get_packet— Get a specific packet by connection sequence number.
Transaction Status Types
pending— No signatures yet.validating— Not enough signatures collected.executing— Enough signatures collected, no confirmed destination tx hash yet.executed— Has a confirmed destination transaction hash.
Chain IDs vs Chain Keys
The relay API uses its own numeric chain ID space (IntentRelayChainId) — bigint values defined in RelayChainIdMap — that is distinct from the SpokeChainKey string keys used everywhere else in the SDK. For example, Sonic's relay chain ID is 146n while its chain key is ChainKeys.SONIC_MAINNET.
Use getIntentRelayChainId(chainKey) (from @sodax/sdk) to convert a SpokeChainKey to its IntentRelayChainId. The relay API wire format expects these IDs serialized as strings (call .toString() before passing them in chain_id fields).
PacketData fields src_chain_id and dst_chain_id are returned as number by the relay API; use getChainKeyFromRelayChainId() to convert back to a SpokeChainKey if needed.
Result<T> Return Types
All public functions in this module return Promise<Result<T>>:
On failure, check result.error.message for CODE-form errors such as 'SUBMIT_TX_FAILED' or 'RELAY_TIMEOUT'. Check result.error.cause for the underlying error when present. There are no typed error discriminators (RelayError, etc.) — those have been removed.
High-Level Entry Point: relayTxAndWaitPacket
relayTxAndWaitPacketFor most use cases, call relayTxAndWaitPacket rather than invoking submitTransaction / waitUntilIntentExecuted separately. It submits the transaction and polls until the relay packet reaches 'executed' status.
Solana and Bitcoin note: These chains use split transactions — the on-chain tx carries only a verification hash, while the full call data is submitted off-chain via the relayer. Pass a RelayExtraData object as data:
Low-Level API Examples
Submit Transaction
Get Transaction Packets
Get Packet
Type Definitions
All types are exported from packages/sdk/src/shared/services/intentRelay/IntentRelayApiService.ts.
Last updated