API client setup
The application uses an Axios-based API client configured to proxy requests through Next.js API routes:lib/api.ts
API modules
The API is organized into specialized modules, each handling a specific domain:Quotes API
Handle quote generation and execution for swaps and transfers.lib/api/quotes.ts
POST /v1/quote- Request a quote for a swap or transferPOST /quotes/execute-quote- Execute a signed quoteGET /status/get-execution-status- Check quote execution status
Assets API
Retrieve information about supported aggregated assets.lib/api/assets.ts
GET /assets/list- Get all supported aggregated assets
Balances API
Track aggregated balances across multiple chains.lib/api/balances.ts
GET /v2/balances/aggregated-balance- Get aggregated balance for an address
Chains API
Get information about supported blockchain networks.lib/api/chains.ts
GET /chains/supported-list- Get all supported chains
Account API
Manage account information and address prediction.lib/api/account.ts
POST /account/predict-address- Get predicted account address
Transactions API
Retrieve transaction history and status.lib/api/transactions.ts
GET /status/get-tx-history- Get paginated transaction history
Quote workflow
The quote workflow is the core of the chain abstraction experience:1
Request a quote
Submit a quote request with source and destination assets
2
Sign the quote
Sign chain operations using the user’s wallet
3
Execute the quote
Submit the signed quote for execution
4
Poll for status
Monitor execution status until completion
Quote types
Quote request structure
lib/types/quote.ts
Quote response structure
lib/types/quote.ts
Quotes expire after 30 seconds. Always check the
expirationTimestamp before executing.Chain operation structure
lib/types/quote.ts
Custom hooks
The application provides React hooks that wrap the API modules:useQuotes hook
Manages quote requests, signing, and execution with automatic status polling.lib/hooks/useQuotes.ts
lib/hooks/useQuotes.ts:1.
useBalances hook
Fetches aggregated balances across chains.lib/hooks/useBalances.ts:1.
Error handling
The API proxy handles errors consistently:app/api/[...path]/route.ts
Best practices
Cache quote data
Store quote responses to avoid redundant API calls during the 30-second validity window.
Handle expiration
Always validate
expirationTimestamp before executing quotes to prevent failed transactions.Poll efficiently
Use 1-2 second intervals for status polling and stop immediately on COMPLETED or FAILED status.
Show progress
Display loading states during quote requests, signing, and execution to improve UX.
Next steps
Privy wallet integration
Learn how to integrate Privy for wallet signing and authentication