Integration Guide
This guide walks you through integrating the XOXNO Aggregator API into your application.
Overview
The integration flow consists of three main steps:
Get a Quote - Fetch optimal routing and transaction data
Build Transaction - Construct the transaction with user's wallet
Submit Transaction - Sign and broadcast to the network
Prerequisites
MultiversX wallet integration (xPortal, DeFi Wallet, or Web Wallet)
Understanding of MultiversX transaction structure
Node.js/JavaScript or equivalent HTTP client
Step 1: Get a Quote
First, request a quote for the desired swap:
const BASE_URL = 'https://swap.xoxno.com';
async function getQuote(params) {
const queryParams = new URLSearchParams({
from: params.tokenIn,
to: params.tokenOut,
amountIn: params.amountIn,
slippage: params.slippage || '0.01'
});
const response = await fetch(`${BASE_URL}/api/v1/quote?${queryParams}`);
if (!response.ok) {
const error = await response.json();
throw new Error(error.error || 'Quote request failed');
}
return response.json();
}
// Example usage
const quote = await getQuote({
tokenIn: 'WEGLD-bd4d79',
tokenOut: 'USDC-c76f1f',
amountIn: '1000000000000000000', // 1 EGLD
slippage: 0.01 // 1%
});
console.log(`Expected output: ${quote.amountOutShort} USDC`);
console.log(`Minimum output: ${quote.amountOutMinShort} USDC`);Step 2: Build the Transaction
Use the quote response to construct a transaction:
Step 3: Handle Token Transfers
For ESDT token swaps, you need to include the token transfer:
Step 4: Sign and Submit
Sign the transaction using the user's wallet and submit:
Complete Example
Here's a full working example:
Error Handling
Implement robust error handling for production:
Best Practices
Quote Freshness
Quotes are computed in real-time and reflect current pool states. For best execution:
Gas Estimation
The API provides estimatedBuiltinCalls to help estimate gas:
Slippage Protection
Always set appropriate slippage based on trade size:
Next Steps
Response Format - Detailed response structure
Relayer WebSocket - Real-time transaction tracking
Last updated
Was this helpful?