Executing a Quote
After receiving a quote from the API, you'll need to handle the transaction execution process. This involves managing token approvals (if needed) and executing the main transfer transaction.
Prerequisites
Ethers.js v6 or later
A Web3-enabled browser (MetaMask or similar)
A valid quote response from the API
Quote Response Types from Request Quote
Direct Transfer Response :
Swap Transactions Response:
Response Field Details
Common Fields
transactionId: Unique identifier for tracking the transfer
type: Indicates transfer type ("Direct" or "Provider")
gas: Estimated gas limit in hexadecimal
Transaction Parameters
to: Target contract or recipient address
data: Encoded transaction data (empty for native transfers)
value: Amount in wei (used for native token transfers)
Approval Parameters
Present only when token approval is needed
Contains parameters for approving token spending
Must be executed before the main transfer
Basic Implementation
Best Practices
Approval Handling
Always check for approvalTxParams before proceeding
Wait for approval confirmation before executing the main transfer
Handle approval failures appropriately
Transaction Execution
Use proper gas estimation from the quote
Handle both direct and cross-chain transfers
Monitor transaction status until completion
User Experience
Show clear loading states during transactions
Provide feedback during approval and transfer steps
Handle errors gracefully with user-friendly messages
Security
Validate all transaction parameters
Never modify gas limits without proper estimation
Always wait for transaction confirmations
Complete Implementation with Error Handling and Status Monitoring:
Error Handling
The implementation handles common errors including:
User rejection
Insufficient funds
Network issues
Failed transactions
Timeout errors
Status Monitoring
The transaction status can be one of:
Pending
Transaction is in progressCompleted
Transaction successfully completedFailed
Transaction failed
Learn more about Transaction Status endpoint here.
Last updated