> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cosmos.network/llms.txt
> Use this file to discover all available pages before exploring further.

# Executing a route

> This page documents the executeRoute function, used to execute a token transfer/swap using a route from /v2/fungible/route API

## 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).

<Info> This function handles validation of addresses and gas balances, prepares the route messages, and executes transactions in order across Cosmos, Evm, and Svm chains. </Info>

```ts theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
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.

<Warning> 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. </Warning>

`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).

`batchSignTxs` If true, all transactions in a multi-transaction route will be signed upfront before broadcasting; if false, each transaction will be signed individually just before broadcasting. (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).

`getCosmosPriorityFeeDenom` function that takes a chainId and returns a `Promise<string>` for the priority fee denom to use for Cosmos transactions.

example:

```ts theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
await executeRoute({
  // ...executeRoute params
  getCosmosPriorityFeeDenom: async (chainId) => {
      // this will set the priority fee as ATOM for noble-1 chain
      if (chainId === "noble-1")
        return "ibc/EF48E6B1A1A19F47ECAEA62F5670C37C0580E86A9E88498B7E393EB6F49F33C0";
      return undefined;
    },
});
```

## Callbacks

You can optionally provide the following callbacks:

`onTransactionSignRequested` Called when a transaction is ready to be signed on the wallet.

`onTransactionBroadcast` Called after each transaction is broadcasted.

`onTransactionCompleted` Called after each transaction is confirmed.

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

`onValidateGasBalance` Called while the transaction is calculating the gas and balance validation

`onApproveAllownace` Called when the allowance tx is being executed (only in evm txs).

```ts theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
await executeRoute({
  route,
  userAddresses: [
    { chainId: "osmosis-1", address: osmoAddress },
    { chainId: "ethereum", address: evmAddress },
  ],
  simulate: true,
  batchSignTxs: 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})`);
  },
  onTransactionTracked: ({ chainId, txHash, status }) => {
    console.log(`Tracking ${chainId}: ${txHash} (Status: ${status})`);
  },
  onTransactionSignRequested: ({ chainId, signerAddress }) => {
    console.log(`Sign requested for ${chainId}`, signerAddress);
  },
});
```
