Use the fdx call swapTokens command to swap between tokens via decentralized exchanges on any supported chain. Unlike centralized exchange swaps, these execute directly on-chain through DEX protocols.
fdx status
If the wallet is not authenticated, refer to the authenticate skill.
Verify the wallet holds enough of the source token:
fdx call getWalletOverview --chainKey <chain>
fdx call swapTokens \
--chainKey <chain> \
--tokenIn <token> \
--tokenOut <token> \
--amount <amount>
| Parameter | Required | Description |
|---|---|---|
| ------------------- | -------- | -------------------------------------------------------------------- |
--chainKey | Yes | Blockchain to swap on (e.g. ethereum, polygon, base, solana) |
--tokenIn | Yes | Source token — symbol (e.g. USDC, ETH) or contract address |
--tokenOut | Yes | Destination token — symbol or contract address |
--amount | Yes | Amount of tokenIn to swap (human-readable) |
--mode | No | Swap mode (e.g. exact input, exact output) |
--objective | No | Optimization objective (e.g. best price, lowest gas) |
--maxSlippageBps | No | Maximum slippage tolerance in basis points (100 = 1%) |
--deadlineSeconds | No | Transaction deadline in seconds |
# Swap 100 USDC for ETH on Ethereum
fdx call swapTokens \
--chainKey ethereum \
--tokenIn USDC \
--tokenOut ETH \
--amount 100
# Swap 0.05 ETH for USDC on Base
fdx call swapTokens \
--chainKey base \
--tokenIn ETH \
--tokenOut USDC \
--amount 0.05
# Swap SOL for USDC on Solana
fdx call swapTokens \
--chainKey solana \
--tokenIn SOL \
--tokenOut USDC \
--amount 2
# Swap with 0.5% max slippage
fdx call swapTokens \
--chainKey ethereum \
--tokenIn USDC \
--tokenOut ETH \
--amount 500 \
--maxSlippageBps 50
# Swap using explicit token contract addresses
fdx call swapTokens \
--chainKey ethereum \
--tokenIn 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 \
--tokenOut 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 \
--amount 100
fdx statusfdx call getWalletOverview --chainKey fdx call swapTokensfdx call getWalletOverviewImportant: DEX swaps are subject to slippage — the final output amount may differ slightly from the quoted amount. For large swaps, consider setting --maxSlippageBps explicitly.
fdx status to check, see authenticate skill)fund-wallet skillfdx setup first, or see authenticate skillgetWalletOverview; see fund-wallet skilltokenIn and tokenOut must be different--maxSlippageBps共 1 个版本