Executing a cross-chain route

The executeRoute function is used to execute a route, including optional support for simulating transactions, injecting custom Cosmos messages, and tracking transaction status. You must provide a list of user addresses (one per chain in route.requiredChainAddresses), along with the route object returned from route (/v2/fungible/route).

This function handles validation of addresses and gas balances, prepares the route messages, and executes transactions in order across Cosmos, Evm, and Svm chains.
async executeRoute(options: ExecuteRouteOptions): Promise<void>

Required fields

route A RouteResponse containing swap or transfer operations.

userAddresses One user address per chain in the same order as route.requiredChainAddresses.

All user addresses must match the chain ids expected in the route, and must be valid for the corresponding chain type (Cosmos, Evm, or Svm). An error will be thrown if the addresses are mismatched or malformed.

getCosmosSigner Function that takes a chainId and returns a Promise<OfflineSigner>

getEvmSigner Function that takes a chainId and returns a Promise<WalletClient>

getSvmSigner Function that returns a Promise<OfflineSigner>

Optional fields

slippageTolerancePercent Set the maximum slippage tolerance for the route (defaults to “1”).

simulate Whether to simulate transactions before executing (defaults to true).

batchSimulate If true, simulate all transactions in a batch before execution; if false, simulate each transaction individually. (defaults to true).

beforeMsg / afterMsg Optional Cosmos messages to inject at the beginning or end of the route execution.

useUnlimitedApproval If true, sets Evm token allowances to MAX_UINT256. (defaults to false).

bypassApprovalCheck If true, skips token approval checks on Evm. (defaults to false).

timeoutSeconds Time in seconds to wait for message preparation before timing out.

getGasPrice Override the gas price per chain.

getFallbackGasAmount Fallback gas to use if simulation fails.

gasAmountMultiplier Overrides the default simulation multiplier (default is 1.5).

Lifecycle callbacks

You can optionally provide the following callbacks:

onTransactionBroadcast Called after each transaction is broadcasted.

onTransactionCompleted Called after each transaction is confirmed.

onTransactionTracked Called during confirmation polling, useful for progress tracking uis.

await executeRoute({
  route,
  userAddresses: [
    { chainId: "osmosis-1", address: osmoAddress },
    { chainId: "ethereum", address: evmAddress },
  ],
  simulate: true,
  slippageTolerancePercent: "0.5",
  beforeMsg: cosmosMsg1,
  afterMsg: cosmosMsg2,
  getCosmosSigner: (chainId) => {},
  getEvmSigner: (chainId) => {},
  getSvmSigner: () => {},
  onTransactionBroadcast: ({ chainId, txHash }) => {
    console.log(`Broadcasted on ${chainId}: ${txHash}`);
  },
  onTransactionCompleted: ({ chainId, txHash, status }) => {
    console.log(`Completed on ${chainId}: ${txHash} (Status: ${status})`);
  },
});