Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.polygon.technology/llms.txt

Use this file to discover all available pages before exploring further.

Trails Fund mode consolidates every funding path into a single integration. Users can deposit from their existing crypto balance, from a wallet on another chain, or via fiat onramp — credit card, debit card, or bank account — without leaving your app. You add one widget; Trails handles routing, bridging, gas, and onramp compliance automatically.

What users can fund from

  • Crypto wallet: any token on any supported chain — Polygon, Ethereum, Base, Arbitrum, and more
  • Another app or exchange: funds held in Coinbase, Binance, or any other wallet the user connects
  • Credit or debit card: card payments convert to USDC and land in your destination address in one flow
  • Bank account: ACH and bank transfer onramp, built in
All three paths appear automatically in the widget. No separate onramp integration required.

Drop-in widget

The fastest integration is the Fund mode widget:
import { Fund } from "0xtrails/widget";

<Fund
  apiKey="YOUR_API_KEY"
  to={{
    recipient: "0xYourDepositAddress",
    chain: "polygon",
    token: "USDC",
  }}
  buttonText="Add funds"
  onFundingSuccess={({ sessionId }) => {
    // verify server-side and update the user's balance
    console.log("Funded:", sessionId);
  }}
/>
The widget surfaces crypto funding, cross-chain options, and card/bank onramp in a single UI. Users pick their preferred source; Trails routes from there.

Pre-set the source

Pass from when you want to start with a specific source chain, token, or amount. Amounts are human-readable strings:
<Fund
  apiKey="YOUR_API_KEY"
  paymentMethod="CONNECTED_WALLET"
  from={{
    chain: "base",
    token: "USDC",
    amount: "100",
  }}
  to={{
    recipient: "0xYourDepositAddress",
    chain: "polygon",
    token: "USDC",
  }}
  buttonText="Add $100"
  onFundingSuccess={({ sessionId }) => updateBalance(sessionId)}
/>

Start with card onramp

Set paymentMethod="CREDIT_DEBIT_CARD" when you want the funding flow to start with card onramp. You can optionally pass a fiat from.amount to pre-fill the amount the user will pay:
<Fund
  apiKey="YOUR_API_KEY"
  paymentMethod="CREDIT_DEBIT_CARD"
  from={{
    currency: "USD",
    amount: "100",
  }}
  to={{
    recipient: "0xYourDepositAddress",
    chain: "polygon",
    token: "USDC",
  }}
  buttonText="Add funds by card"
  onFundingSuccess={({ sessionId }) => updateBalance(sessionId)}
/>

Fund and deposit into a protocol

For supported earn destinations, use the Earn mode widget. It gives users a drop-in flow for funding from any supported source and depositing into a supported vault or lending market:
import { Earn } from "0xtrails/widget";

<Earn
  apiKey="YOUR_API_KEY"
  paymentMethod="CONNECTED_WALLET"
  from={{
    chain: "base",
    token: "USDC",
    amount: "100",
  }}
  to={{
    chain: "polygon",
    token: "USDC",
    amount: "100",
  }}
  buttonText="Deposit into vault"
  onEarnSuccess={({ sessionId }) => updateVaultBalance(sessionId)}
/>
For a custom UI or a specific action sequence, use composable actions instead of hand-encoded calldata. The example below routes funds to Polygon USDC and deposits them into an ERC-4626 vault in the same intent:
import { useQuote, deposit } from "0xtrails";

const morphoMarketId = "MARKET_ID_FROM_USE_EARN_MARKETS";

export function DepositToVaultButton({
  walletAddress,
}: {
  walletAddress: `0x${string}`;
}) {
  const { send, isLoadingQuote, quoteError } = useQuote({
    walletAddress,
    from: { chain: "base", token: "USDC", amount: "100" },
    to: { chain: "polygon", token: "USDC" },
    actions: [
      deposit({
        marketId: morphoMarketId,
        amount: "100",
        receiverAddress: walletAddress,
      }),
    ],
  });

  if (isLoadingQuote) return <button disabled>Quoting...</button>;
  if (quoteError) return <p>{quoteError.message}</p>;

  return <button disabled={!send} onClick={() => send?.()}>Deposit to vault</button>;
}
Use useEarnMarkets({ chain: "polygon", type: "vault" }) to discover live marketId values instead of hard-coding them. Use lend({ marketId, amount }) for lending markets such as Aave, and deposit({ marketId, amount }) for vaults such as Morpho.

Widget props

PropTypeDescription
apiKeystringYour Trails API key
to.recipientstringDestination wallet address. Defaults to the connected wallet when omitted
to.chainstring | numberDestination chain name or ID. When used with to.token, locks the destination chain and token
to.tokenstringDestination token symbol or address. Locks the destination token
to.defaultChainstring | numberPre-selected destination chain that the user can change
to.defaultTokenstringPre-selected destination token that the user can change
to.tokenListstring[]Destination token allowlist. Ignored when to.token locks the destination
to.calldatastringLow-level encoded destination call. Prefer composable actions with useQuote for protocol deposits
from.chainstring | numberOptional source chain
from.tokenstringOptional source token symbol or address
from.currencystringSource token/currency alias. For card onramp, use fiat currency codes such as "USD"
from.amountstring | numberOptional source amount in human-readable units
from.walletAddressstringOptional source wallet address. Defaults to the connected wallet
from.exchangestringOptional exchange key when paymentMethod="EXCHANGE"
paymentMethod"CONNECTED_WALLET" | "CRYPTO_TRANSFER" | "CREDIT_DEBIT_CARD" | "EXCHANGE"Optional funding method to start from
defaultInputMode"fiat" | "token"Initial amount input unit. "fiat" lets the user enter a fiat value that is converted into the selected crypto amount; "token" lets the user enter the token amount directly
hideSwapbooleanHide the swap tab in the fund screen header
hideWalletsstring[]Wallet addresses to exclude from funding wallet selection
fundMethodsListstring[]Ordered funding methods to show, such as "connected-wallet", "crypto-transfer", "cc-onramp", or "exchange"
hideUnlistedFundMethodsbooleanFully hide funding methods not listed in fundMethodsList
buttonTextstringCustom CTA label
appMetadata{ name?: string; url?: string; imageUrl?: string; description?: string }App metadata shown in the widget
themeobjectWidget theme overrides
intentProtocolVersionstringPin the intent protocol version for this widget instance
onFundingStartfunctionCalled when deposit is initiated
onFundingSuccess({ sessionId }) => voidCalled on successful deposit
onFundingErrorfunctionCalled on failure
onQuotefunctionCalled when a quote is created
onStatusfunctionCalled when transaction status updates
onOpen / onClosefunctionCalled when the widget opens or closes
Fund widget amounts are human-readable strings or numbers. Raw base-unit inputs are available in the headless SDK with from.amountRaw or to.amountRaw.

Headless SDK

For custom UI, use useQuote from the headless SDK. You control the presentation; Trails handles execution:
import { useQuote } from "0xtrails";

const { quote, send, isLoadingQuote, quoteError } = useQuote({
  from: { chain: "base", token: "USDC", amount: "100" },
  to: {
    chain: "polygon",
    token: "USDC",
    recipient: "0xYourDepositAddress",
  },
  onStatusUpdate: (status) => console.log("Fund status:", status),
});

// Show quote.fees, quote.estimatedTime in your UI, then:
await send?.();
If you already have a raw onchain amount, use amountRaw instead of amount:
const { send } = useQuote({
  from: { chain: "base", token: "USDC", amountRaw: "100000000" },
  to: {
    chain: "polygon",
    token: "USDC",
    recipient: "0xYourDepositAddress",
  },
});

Supported chains and tokens

Trails supports all major EVM chains. Users can fund from any supported chain regardless of where your destination address lives.
// Query tokens available on a specific chain
const { tokens } = await trails.getTokenList({ chainId: 137 });
See Supported Chains for the full network list.

Next steps

Cross-chain movement

Move tokens between wallets and chains without protocol interaction.

Yield accounts

Route funded USDC directly into a Morpho yield vault on arrival.

Smart Sessions

Automate recurring deposits without per-transaction prompts.

Trails API reference

Full endpoint reference, SDK docs, and widget customization options.