Skip to main content

Overview

Withdraw mode provides a guided flow for moving assets out of a wallet while keeping fee options and routing handled by Trails. Users can choose the amount to withdraw and the destination token/chain, or you can pre-configure those selections. Trade Types: Supports both EXACT_INPUT and EXACT_OUTPUT trade types.

Configuration

Required Props

PropTypeDescription
mode"withdraw"Sets the widget to withdraw mode

Optional Props

PropTypeDescription
fromChainIdnumberPre-select origin chain
fromTokenstringPre-select origin token
fromAccountstringPre-select a connected wallet if multiple wallets are connected
toChainIdnumberControlled destination chain (locks selection)
toTokenstringControlled destination token (locks selection)
defaultToChainIdnumberDefault destination chain (user can change)
defaultToTokenstringDefault destination token (user can change)
toAddressstringRecipient address (defaults to connected account if omitted)
toAmountstringExact output amount for withdrawals

Widget Implementation

Basic Withdraw Widget

Minimal configuration - users select everything:
import { TrailsWidget } from '0xtrails/widget'

<TrailsWidget
  apiKey="YOUR_API_KEY"
  mode="withdraw"
  onCheckoutComplete={({ sessionId }) => {
    console.log('Withdrawal completed:', sessionId)
  }}
>
  <button>Withdraw</button>
</TrailsWidget>

Pre-configured Withdraw

Pre-select origin and destination details:
<TrailsWidget
  apiKey="YOUR_API_KEY"
  mode="withdraw"
  fromChainId={1} // Ethereum
  fromToken="USDC"
  defaultToChainId={8453} // Base
  defaultToToken="ETH"
  toAddress="0x97c4A952b46bEcaD0663f76357d3776ba11566E1"
  onCheckoutComplete={({ sessionId }) => {
    console.log('Withdrawal completed:', sessionId)
  }}
>
  <button>Withdraw USDC</button>
</TrailsWidget>
Recipient inputs accept .eth ENS names in the widget UI and resolve them automatically.