Prerequisites
- OKX API credentials (API key, secret key, passphrase, project ID)
- TON wallet address for swap data queries
- Basic understanding of TON token addresses
Setup
Common Token Addresses
TON uses base64-encoded addresses:| Token | Address |
|---|---|
| TON (Native) | EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c |
| USDC | EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs |
Getting a Quote
Fetch a swap quote to preview rates and output amounts:Understanding Quote Response
The quote response contains detailed information about the swap:Getting Swap Data
For more detailed swap information including transaction data:Complete Example
Here’s a complete working example:Quote Parameters
All available parameters for TON quotes:| Parameter | Type | Required | Description |
|---|---|---|---|
chainIndex | string | Yes | Chain ID for TON ('607') |
fromTokenAddress | string | Yes | Source token address |
toTokenAddress | string | Yes | Destination token address |
amount | string | Yes | Amount in smallest units |
slippagePercent | string | Yes | Max slippage (e.g., '0.1' for 0.1%) |
Swap Data Parameters
Additional parameters when getting swap data:Understanding TON Amounts
TON uses 9 decimals for native tokens:Best Practices
Check Quote Response
Always verify
quote.code === '0' before using dataUse Appropriate Slippage
Set 0.1-0.5% for stable pairs, higher for volatile pairs
Handle Errors Gracefully
Check response codes and handle API errors
Monitor Price Impact
Review price impact before executing large swaps
Error Handling
Response Structure
Typical quote response structure:Next Steps
TRON Quotes
Learn how to get quotes on TRON
API Reference
View complete quote API documentation