Skip to main content
Use Trails to choose a destination for an owned wallet asset, quote the selected pair, and prepare the required origin transaction. OMS Wallet submits that transaction, then Trails executes and tracks the intent to its destination.
For a prebuilt React interface, render the Trails Swap component. The widget can manage wallet connections itself or share an app-owned wallet through Trails adapters. For example, you can share an OMS Wallet session through the OMS Wallet connector and the Trails wagmi adapter. This guide instead uses OMS Wallet directly and implements the Trails intent lifecycle without the widget.

Prerequisites

  • An active OMS Wallet session from the TypeScript quickstart
  • A Trails API key
  • A positive balance of the selected source asset and enough balance in an available fee token when the origin transaction is not sponsored
Use the OMS Indexer to populate the source-asset picker from the wallet’s actual balances. See balances and history.
This guide submits mainnet transactions with real funds. Show the user the route, expected and minimum output, fees, price impact, and expiry before requesting confirmation.

Install the dependencies

Choose a destination asset

The example starts with native POL on Polygon PoS as the source asset. Use the zero address for a native token or the contract address for an ERC-20 token. Use getTokenList to populate the destination picker, then filter the result to networks supported by OMS Wallet. This example searches for USDC on Polygon PoS to keep the flow focused:
Add other OMS-supported chain IDs to chainIds when your picker supports cross-chain destinations. The token catalog provides destination candidates; quoteIntent confirms whether Trails has a live route for the selected pair and amount. This guide selects native USDC on Polygon from the catalog. In your application, replace this selection with the token chosen in your asset picker:

Quote the selected route

Request an exact-input quote for the selected amount. A successful quote confirms the live route, and Trails selects the swap and bridge providers automatically:
The 1% slippageTolerance applies to this quote. Request a new quote when the amount or either asset changes, or when expiresAt passes. Do not commit the intent until the user confirms the current values.

Commit and submit the origin transaction

Commit the quoted intent, then submit the exact deposit transaction returned by that intent through OMS Wallet:
Validate that the deposit network, token, and amount still match the quote the user confirmed before submitting it. Preserve both the OMS txnId and the Trails intentId so your application can recover an uncertain status without submitting the origin transaction again.

Execute and monitor the intent

Give Trails the confirmed origin transaction hash, then wait for the intent to reach a terminal state:
Refresh the source and destination balances through the OMS Indexer after the receipt succeeds. A completed origin transaction does not by itself mean the destination asset has arrived. Bound receipt waiting in your application. If it times out, resume with the stored intentId instead of submitting the origin transaction again. For provider overrides and other advanced configuration, see route providers. For details about quoting, committing, executing, and monitoring intents, see the Trails API SDK reference.