In deposit mode, funds route to a destination you configure in
routes. In swap mode, funds settle to the user’s own connected wallet. The Route Handler and the quote, route, sign, broadcast, receipt, and status lifecycle are identical; only the configuration and where funds settle change.Enable swap mode
Setmode: "swap" on the top-level config. Because the user picks both sides of the trade in the widget, routes is not required in swap mode. With no destination flags set, the user selects the output token themselves. This is the open, Uniswap-style configuration.
TrustwareProvider:
mode defaults to "deposit", which keeps the widget in deposit mode. Inputs are never restricted: users can always pay in from any supported asset on any supported chain. Only the output can be restricted, using the fields below.
features.swapMode still works in 1.1.9 and is treated as equivalent to
mode: "swap", but it is deprecated and logs a deprecation warning to the
console. Prefer mode in new integrations.Lock the destination token
To settle every swap into one token, setswapDefaultDestToken and lock it with swapLockDestToken: true. For example, a client on Base can lock the output so users only ever receive USDC on Base, paying in from any asset on any chain.
Restrict outputs to an allowlist
To allow a small set of output tokens, list them inswapAllowedDestTokens. The destination-token picker is limited to this list; everything else is locked out. This restricts outputs only. Users can still pay in with any supported asset on any chain.
Config reference
mode is a top-level field on TrustwareConfigOptions. The three swap destination fields and the deprecated swapMode flag live under features. See the configuration overview for the full config reference.
Destination locking supports EVM chains only.
SwapTokenRef.chainId is
numeric, and Cosmos chains are identified by named strings such as
cataclysm-1, so Cosmos destinations cannot be set through
swapDefaultDestToken or swapAllowedDestTokens.React to route changes
In swap mode, the SDK emits aswap_route_changed event whenever the resolved route updates, for example when the user changes the source or destination chain, token, or amount. Subscribe with onEvent to keep your own UI in sync.
fromChain, fromToken, toChain, toToken, and an optional amount. See lifecycle events for the full event reference.
Swap with an embedded wallet
Swap mode also works when the host wallet is an embedded wallet your app provisions, for example through Privy. Adapt the wallet’s EIP-1193 provider withuseEIP1193, pass it to TrustwareProvider through the wallet prop, and set autoDetect={false} so the SDK does not run its own wallet discovery alongside it.
Works with every integration style
Swap mode is a configuration flag, so it works with all four integration paths without code changes.Drop-in widget
The fastest path: render
TrustwareWidget with swap mode enabled in your config.Host wallet
Pass your app’s existing Wagmi or viem wallet and run it in swap mode.
Controlled widget
Open and close the swap widget programmatically from your own UI.
Headless core
Build a custom swap interface on top of the routing and transaction APIs.
