Trade tokens (buy or sell)
Prepares a transaction to buy or sell tokens. Supports multiple trade types:
- Buy exact input: Spend specific USD amount
- Buy exact output: Receive specific token amount
- Sell exact input: Sell specific token amount
- Sell exact output: Receive specific USD amount
Automatically uses RobinSwap or UniswapV3 based on token graduation status.
USD Rewards Attribution:
- Builder attribution: Set custom builder fees (in basis points) to earn USD rewards on transactions
- Token referral: Enable affiliate programs by specifying referral addresses for token trades
- USD rewards are processed in real-time on-chain with no third parties involved
- Token referrals have no additional cost to users - enabling affiliate programs onchain
Authorizations
JWT token or API key
Body
Blockchain identifier. Supported chains: solana-devnet, base, base-sepolia, avalanche, bnb, bnb-testnet, unichain, unichain-testnet, abstract, polygon, zkSync, zkSync-testnet
solana-devnet, base, base-sepolia, avalanche, bnb, bnb-testnet, unichain, unichain-testnet, abstract, polygon, zkSync, zkSync-testnet "base-sepolia"
buy, sell User wallet address (optional - if not provided, will use user's Privy wallet from user_wallets table)
^0x[a-fA-F0-9]{40}$"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
Builder attribution information (optional). Includes address and fee in bps.
Token referral address for attribution (optional - defaults to zero address). Used to attribute referral fees to a specific address.
^0x[a-fA-F0-9]{40}$"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
x > 0x > 0x > 0x > 0