Skip to main content

Documentation Index

Fetch the complete documentation index at: https://anypay-docs-sdk-0-15-0-updates.mintlify.app/llms.txt

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

Overview

Withdraw mode provides a guided flow for moving assets out of a wallet. Fee options and routing are handled automatically — users choose the amount and destination, or you can pre-configure those. Trade types: EXACT_INPUT and EXACT_OUTPUT.

Quick start

import { Withdraw } from '0xtrails/widget'

<Withdraw
  apiKey="YOUR_API_KEY"
  from={{ currency: "USDC", chain: "base" }}
/>

Props

Required

PropTypeDescription
apiKeystringTrails API key

Source (optional)

PropTypeDescription
from.currencystringPre-select source token symbol or address
from.chainChainIdentifierPre-select source chain — name, ID, or viem Chain
from.amountstring | numberPre-fill withdrawal amount
from.walletAddressstringSource wallet address (defaults to connected wallet)

Destination (optional)

PropTypeDescription
to.recipientstringRecipient address (defaults to connected wallet)
to.currencystringControlled destination token — locks selection
to.chainChainIdentifierControlled destination chain — locks selection
to.defaultCurrencystringDefault destination token — user can change
to.defaultChainChainIdentifierDefault destination chain — user can change
to.amountstring | numberExact output amount
to.calldatastringABI-encoded calldata to execute at the destination
Recipient inputs accept .eth ENS names and resolve them automatically.

Lifecycle callbacks

CallbackSignatureWhen it fires
onWithdrawStart({ sessionId }) => voidUser begins the withdrawal flow
onWithdrawSuccess({ sessionId }) => voidWithdrawal completes successfully
onWithdrawError({ sessionId, error }) => voidWithdrawal encounters an error

Examples

Basic withdraw — user selects everything

import { Withdraw } from '0xtrails/widget'

<Withdraw
  apiKey="YOUR_API_KEY"
  onWithdrawSuccess={({ sessionId }) => console.log("withdrawn", sessionId)}
>
  <button>Withdraw</button>
</Withdraw>

Pre-configured withdrawal

<Withdraw
  apiKey="YOUR_API_KEY"
  from={{ currency: "USDC", chain: "base" }}
  to={{
    recipient: "0xRecipientAddress",
    defaultCurrency: "ETH",
    defaultChain: "ethereum",
  }}
  onWithdrawSuccess={({ sessionId }) => console.log("withdrawn", sessionId)}
/>

Locked destination

<Withdraw
  apiKey="YOUR_API_KEY"
  from={{ currency: "USDC", chain: "base" }}
  to={{
    currency: "USDC",
    chain: "polygon",
  }}
/>

See also