How it works
When you initiate a transfer:- Select the token you want to send
- Enter the recipient’s wallet address
- Choose the destination network
- Get a quote for the transfer cost
- Confirm and execute the transfer
Implementation
TransferForm component
The transfer interface is implemented incomponents/TransferForm.tsx:
app/(trading)/transfer/page.tsx
Transfer flow
The transfer form manages three key pieces of state:components/TransferForm.tsx
Address validation
The form validates recipient addresses in real-time:components/TransferForm.tsx
Both standard Ethereum addresses (0x…) and ENS names (.eth) are supported for recipients.
Getting transfer quotes
Transfer quotes work similarly to swap quotes, but include the recipient’s address:<chain_id>:<address>
Chain selection
Users can select the destination network from all supported chains:components/TransferForm.tsx
Transfer cost calculation
Transfer quotes include the cost of bridging tokens to the destination chain. This is automatically calculated and displayed to the user before execution.Quote details
The quote shows:- Amount to be sent
- Destination network
- Bridge fee (if applicable)
- Gas cost (covered by paymaster)
- Estimated delivery time
Percentage-based amounts
The transfer form includes quick-select buttons for common percentages:components/TransferForm.tsx
Supported networks
You can transfer tokens to any network supported by OneBalance. The list is fetched dynamically:lib/hooks/useChains.ts
Transfer execution
Executing a transfer follows the same pattern as swaps:- Get a valid quote with recipient information
- Sign the quote with your embedded wallet
- Submit the signed quote for execution
- Monitor transaction status until completion
Error states
The transfer form handles several error scenarios:Invalid recipient address
Invalid recipient address
Shows an inline error message when the address format is incorrect.
Insufficient balance
Insufficient balance
Disables the transfer button and shows “Insufficient Balance” text.
Missing recipient information
Missing recipient information
The transfer button remains disabled until both address and chain are selected.
Transaction monitoring
After initiating a transfer, the application polls for status updates:lib/hooks/useQuotes.ts
Best practices
1
Verify recipient address
Always double-check the recipient address before confirming. Blockchain transactions cannot be reversed.
2
Choose the right network
Consider the recipient’s preferred network. Some networks have lower fees or faster confirmation times.
3
Account for bridge time
Cross-chain transfers may take longer than same-chain transactions due to bridge confirmation times.
4
Review transfer costs
Check the quote details to understand any fees associated with the transfer.
API reference
For more details on transfer-related endpoints:- Get Quote (with recipient address)
- Execute Quote
- Get Chains