For the complete documentation index, see llms.txt. This page is also available as Markdown.

Intent Relay API

Error handling conventions: Failures from submitTransaction / relayTxAndWaitPacket follow the relay-layer contract: error.message is one of the literal strings exported as RELAY_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 into SodaxError<SwapErrorCode> with context.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

  1. submit — Submit a transaction to the intent relay service.

  2. get_transaction_packets — Get all packets associated with a transaction.

  3. 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

For 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