Documentation Index
Fetch the complete documentation index at: https://docs.trails.build/llms.txt
Use this file to discover all available pages before exploring further.
Highlights
- Trails v1.5 intent protocol is now live in production with many improvements to the intent protocol from gas savings, flexibility, 1-click gasless flows, and expanding chain routes.
- The Trails API supports both v1 (original) and v1.5 (new) intent protocols out-of-the-box and apps using older Trails SDK versions will default to using the v1 intent protocol as before.
- We recommend apps to upgrade to the latest
[email protected]sdk to take advantage of many upgrades and the newv1.5intent protocol. - Please review the upgrade / migration notes below in detail.
Upgrade / Migration Notes
This guide covers the breaking changes in SDK 0.15.0 and intent protocol v1.5, and how to update your integration.Summary checklist
Migrate useQuote to structured inputs
Replace flat props (
fromTokenAddress, fromChainId, etc.) with from: { token, chain, amount } and to: { token, chain, recipient, ... }.Update amount units
Change
from.amount / to.amount in useQuote and tokenAmount / fromAmount in useTrailsSendTransaction from raw wei to human-readable decimal strings or use the raw value amount props.Breaking changes
useQuote amount units changed
NOTE: useQuote hook is an optional low-level integration some developers use. If you’re using
Trails with just the widget, this secton does not apply to you. If you are using useQuote please
please the notes and upgrade.
from.amount and to.amount are now human-readable decimal strings (e.g. "1.5"), not raw smallest-unit integers. They are scaled internally using parseUnits with the token’s decimals.
Use from.amountRaw or to.amountRaw for passing raw values.
from.amountRaw or to.amountRaw instead of from.amount / to.amount.
The same applies to useTrailsSendTransaction: tokenAmount and fromAmount are now human-readable decimal strings. Native value remains raw wei bigint (wagmi-compatible). Use tokenAmountRaw or fromAmountRaw to pass raw values. You can also pass tokenDecimals / fromDecimals overrides to skip the registry or on-chain decimal lookup.
useQuote restructured inputs
useQuote now takes structured from and to objects instead of flat props. The flat fields — fromTokenAddress, fromChainId, toTokenAddress, toChainId, toAddress, toApprove, toCalldata, swapAmount, tradeType — are all gone.
Trade type is now inferred: set from.amount for exact-input, to.amount for exact-output.
useQuote to.calldata deprecated
Passing to.calldata on useQuote now logs a runtime deprecation warning and is mutually exclusive with actions and to.calls. Migrate to one of:
actions— composable DeFi primitives (lend,deposit,swap, etc.)to.calls— raw ABI-encodedCall[]for custom contracts
paymasterUrls removed from TrailsWidget
The paymasterUrls prop has been removed from TrailsWidget. Remove it from your configuration — it has no replacement.
Widget lifecycle callback renames
AllTrailsWidget checkout lifecycle callbacks were renamed. The onCheckout prefix is gone.
| Before (0.13.x) | After (0.15.0) |
|---|---|
onCheckoutStart | onStart |
onCheckoutQuote | onQuote |
onCheckoutSignatureRequest | onSignRequest |
onCheckoutSignatureConfirmed | onSign |
onCheckoutSignatureRejected | onSignReject |
onCheckoutComplete | onSuccess |
onCheckoutError | onError |
onCheckoutStatusUpdate | onStatus |
onCheckoutApprovalRequest | onApproveRequest |
onCheckoutApprovalConfirmed | onApprove |
onCheckoutApprovalRejected | onApproveReject |
New features
Composable actions
useQuote gains an actions array for composing destination-side DeFi flows:
All amount props for actions are in human-readable form only.
swap, lend, deposit, custom, assertCondition
- Use
lendfor lending markets (Aave),depositfor ERC-4626 vaults (Morpho, Yearn). - Discover
marketIdvalues withuseEarnMarketsfiltered bytype: "lending"ortype: "vault".
dynamic()— resolves to the intent wallet’s ERC-20 balance at execution timeself()— resolves toaddress(this)(the intent wallet underDELEGATECALL)
useQuote({ to: { calls } }) accepts raw Call[] (or Call[][]) for hand-rolled ABI-encoded transactions. Calls support dynamicAmountToken, hydrateEntries, and sweepTokens for runtime hydration and dust recovery.
New hooks
| Hook | Purpose |
|---|---|
useEarnMarkets | Discover lending and vault markets usable with lend / deposit |
useEarnBalances | Read a user’s balances across earn markets |
useEarnProviders | List supported earn protocols |
useResolveActions | Resolve ActionItem[] into encoded destination Call[] |
Mode-specific widget components
New typed wrappers exported from0xtrails/widget, each with a tighter prop shape than the generic TrailsWidget:
| Component | Use case |
|---|---|
Pay | Payments to a recipient — structured to/from, paymentMethod discriminator |
Fund | Fund a wallet from any source |
Swap | Swap-only flows |
Earn | Deposit and withdraw from earn markets |
Withdraw | Withdrawal flows |
TrailsWidget with mode="pay" | "fund" | "swap" | "earn" | "withdraw" continues to work. These wrappers are additive.
Other additions
intentProtocolVersionprop onTrailsWidget— pin the intent protocol version per-instance.fromAmountprop onTrailsWidget— pre-populate source amount in human-readable units (e.g."1.5").fundOptionsadditions onTrailsWidget— newpaymentMethodTypefield (Meld payment method pre-selection, e.g."CREDIT_DEBIT_CARD") andmeshExchangeKeyfield (Mesh exchange pre-selection, e.g."coinbase").- Wallet-less quote preview — pass
walletAddresstouseQuotebefore a wallet is connected. - Auto-refresh expired quotes (widget only) — The Trails Widget now schedule a refetch when a quote’s expiresAt passes (waking on the next user interaction), so the “Intent quote has expired” pre-signing error no longer appears in the built-in UI.
- New utilities:
erc20Utils,buildCall,buildApproveAndCall,buildErc20Approve,getAmountWithSlippage,resolveChainId,resolveChainName. - API helpers:
getEarnMarkets,getEarnBalances,getEarnProviders. - New error codes:
CHAIN_MISMATCH,CALL_RESOLUTION_FAILED. 0xtrails/hydratesubpath — Hydrate builders, selectors, and calldata helpers for v1.5 execution flows.