Skip to main content

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.

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

routes.toChain
string
required
The destination chain ID as a string. For example, "8453" targets Base mainnet. This must be a chain the Trustware backend supports.
routes.toToken
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.

Optional fields

routes.fromToken
string
A preferred source token. When set, the widget pre-selects this token on the source side. The user can still change it.
routes.fromAddress
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.
routes.toAddress
string
Override the destination wallet address. You can also set this at runtime using Trustware.setDestinationAddress(address) without rebuilding the provider.
routes.defaultSlippage
number
default:"1"
Slippage tolerance as a percentage. Defaults to 1 (1%). Increase this for volatile pairs or routes with low liquidity.
routes.routeType
"swap" | "deposit" | "withdraw" | "cross"
default:"\"swap\""
The type of route the SDK will request. Defaults to "swap". Use "cross" for cross-chain bridging without a swap step.

routes.options

The nested options object controls route refresh behavior and amount constraints.
routes.options.routeRefreshMs
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.
options: {
  routeRefreshMs: 15000, // refresh every 15 seconds
}
routes.options.fixedFromAmount
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.
options: {
  fixedFromAmount: "25", // USD amount, cannot be changed by the user
}
routes.options.minAmountOut
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.
routes.options.maxAmountOut
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.

Examples

Minimal required config

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

Full route config with all options

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

Fixed-amount checkout

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

Min/max amount guardrails

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

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:
import { Trustware } from "@trustware/sdk";

Trustware.setDestinationAddress("0xYourDestinationAddress");
Trustware.setDestinationAddress overwrites routes.toAddress for the current session. You do not need to unmount and remount the provider.