Integration Guide
Prerequisites
Overview
Token Amounts
function toSmallestUnits(amount, decimals) {
// Use BigInt to avoid floating-point precision loss
return (BigInt(Math.round(amount * 1e9)) * BigInt(10 ** decimals) / BigInt(1e9)).toString();
}
// 1 WEGLD (18 decimals) β "1000000000000000000"
toSmallestUnits(1, 18);
// 100 USDC (6 decimals) β "100000000"
toSmallestUnits(100, 6);Step 1: Validate the Pair
Step 2: Get a Quote
Step 3: Build the Transaction
EGLD / WEGLD Swaps
ESDT Token Swaps
Step 4: Sign and Submit
Gas Estimation
Route Type
Estimated Gas
Error Handling
Retry Logic
Error Classification
Complete Example
Best Practices
Quote Freshness
Slippage Guidelines
Trade size (USD)
Recommended slippage
High-Frequency Polling
Related Topics
Last updated
Was this helpful?