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

# Route configuration: chains, tokens, and amounts

> The routes field sets the destination chain and token, slippage tolerance, route type, and amount constraints like fixed deposits and min/max guardrails.

The `routes` field in `TrustwareConfigOptions` defines the destination for every transaction the widget processes. At a minimum you must tell the SDK which chain and token to route to. Everything else (source token preference, slippage, amount constraints) is optional and can be configured incrementally.

## Required fields

<ParamField path="routes.toChain" type="string" required>
  The destination chain ID as a string. For example, `"8453"` targets Base
  mainnet. This must be a chain the Trustware backend supports.
</ParamField>

<ParamField path="routes.toToken" type="string" required>
  The destination token address on the target chain. Pass the ERC-20 contract
  address. For example, `"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"` is the
  conventional address used for the native gas token on EVM chains.
</ParamField>

## Optional fields

<ParamField path="routes.fromToken" type="string">
  A preferred source token. When set, the widget pre-selects this token on the
  source side. The user can still change it.
</ParamField>

<ParamField path="routes.fromAddress" type="string">
  Override the source wallet address used when building routes. Useful when you
  want to pre-specify the sending address independently of the connected wallet.
</ParamField>

<ParamField path="routes.toAddress" type="string">
  Override the destination wallet address. You can also set this at runtime
  using `Trustware.setDestinationAddress(address)` without rebuilding the
  provider.
</ParamField>

<ParamField path="routes.defaultSlippage" type="number" default="1">
  Slippage tolerance as a percentage. Defaults to `1` (1%). Increase this for
  volatile pairs or routes with low liquidity.
</ParamField>

## routes.options

The nested `options` object controls route refresh behavior and amount constraints.

<ParamField path="routes.options.routeRefreshMs" type="number">
  How often (in milliseconds) the widget automatically re-fetches a fresh route
  preview while the user is on the amount entry screen. If omitted, routes are
  not automatically refreshed.

  ```ts theme={null}
  options: {
    routeRefreshMs: 15000, // refresh every 15 seconds
  }
  ```
</ParamField>

<ParamField path="routes.options.fixedFromAmount" type="string | number">
  Locks the widget's amount input to a specific USD amount. When set, the user
  cannot change the amount; the widget behaves as a fixed-price checkout.

  ```ts theme={null}
  options: {
    fixedFromAmount: "25", // USD amount, cannot be changed by the user
  }
  ```
</ParamField>

<ParamField path="routes.options.minAmountOut" type="string | number">
  The minimum USD amount the user is allowed to enter. Amounts below this
  threshold are rejected by the widget before a route is requested.
</ParamField>

<ParamField path="routes.options.maxAmountOut" type="string | number">
  The maximum USD amount the user is allowed to enter. Amounts above this
  threshold are rejected by the widget before a route is requested.
</ParamField>

## Setting the destination address at runtime

If you only know the destination address after the provider has mounted (for example, after a user logs in), use `Trustware.setDestinationAddress` instead of rebuilding the config:

```ts theme={null}
import { Trustware } from "@trustware/sdk";

Trustware.setDestinationAddress("0xYourDestinationAddress");
```

<Note>
  `Trustware.setDestinationAddress` overwrites `routes.toAddress` for the
  current session. You do not need to unmount and remount the provider.
</Note>

## Examples

### Minimal required config

```ts theme={null}
const config = {
  apiKey: process.env.NEXT_PUBLIC_TRUSTWARE_API_KEY!,
  routes: {
    toChain: "8453",
    toToken: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
  },
} satisfies TrustwareConfigOptions;
```

### Full route config with all options

```ts theme={null}
const config = {
  apiKey: process.env.NEXT_PUBLIC_TRUSTWARE_API_KEY!,
  routes: {
    toChain: "8453",
    toToken: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
    defaultSlippage: 1,
    options: {
      routeRefreshMs: 15000,
    },
  },
} satisfies TrustwareConfigOptions;
```

### Fixed-amount checkout

```ts theme={null}
const config = {
  apiKey: process.env.NEXT_PUBLIC_TRUSTWARE_API_KEY!,
  routes: {
    toChain: "8453",
    toToken: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
    options: {
      fixedFromAmount: "25",
    },
  },
} satisfies TrustwareConfigOptions;
```

### Min/max amount guardrails

```ts theme={null}
const config = {
  apiKey: process.env.NEXT_PUBLIC_TRUSTWARE_API_KEY!,
  routes: {
    toChain: "8453",
    toToken: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
    options: {
      minAmountOut: "10",
      maxAmountOut: "250",
      routeRefreshMs: 10000,
    },
  },
} satisfies TrustwareConfigOptions;
```
