What is OKX DEX SDK?
OKX DEX SDK is a powerful TypeScript library that enables developers to build sophisticated decentralized exchange applications across 6+ blockchain networks. Execute token swaps, access real-time quotes, and leverage OKX’s advanced trading infrastructure with just a few lines of code. The SDK abstracts away the complexity of interacting with multiple blockchain protocols, providing a unified interface for:- EVM-compatible chains (Ethereum, Base, Polygon, Arbitrum, Optimism, and 20+ more)
- Solana - High-performance blockchain
- Sui - Move-based smart contract platform
- TON - Telegram Open Network
- TRON - High-throughput blockchain
Quick Links
Installation
Get started by installing the SDK via npm, yarn, or pnpm
Quickstart
Execute your first token swap in under 5 minutes
API Reference
Explore the complete API documentation
GitHub Repository
View the source code and contribute
Why OKX DEX SDK?
Multi-Chain Aggregation
Stop writing separate integrations for each blockchain. The SDK provides a single, consistent API that works across all supported networks. Switch from Ethereum to Solana by changing just one parameter.Enterprise-Grade Infrastructure
Benefit from OKX’s proven trading infrastructure:- MEV Protection - Safeguard against front-running and sandwich attacks
- Smart Order Routing - Automatically find the best prices across DEXs
- Real-time Liquidity - Access deep liquidity pools across protocols
- Transaction Broadcasting - Direct submission through OKX infrastructure for faster execution
Developer Experience First
Full TypeScript Support
Full TypeScript Support
Complete type safety with IntelliSense support. Catch errors at compile time, not runtime.
Built-in Retry Logic
Built-in Retry Logic
Automatic retries with exponential backoff for network failures and rate limits.
Comprehensive Error Handling
Comprehensive Error Handling
Detailed error messages with actionable insights. Know exactly what went wrong and how to fix it.
Extensive Examples
Extensive Examples
Ready-to-use code samples for every chain and use case. Copy, paste, and customize.
Core Features
Token Swaps
Execute swaps across 25+ blockchains with automatic routing and slippage protection
Real-time Quotes
Get accurate pricing, route information, and price impact calculations
Token Approvals
Automated ERC-20 approval handling with proper allowance management
Gas Estimation
Accurate gas limit calculation using onchain data
Transaction Simulation
Pre-execution validation and risk assessment before submitting transactions
Order Tracking
Real-time transaction status monitoring and history
Solving DEX Aggregation Complexity
The Problem
Building multi-chain DEX applications is challenging:- Each blockchain has different APIs, wallet formats, and transaction structures
- Finding the best swap routes requires querying multiple DEX protocols
- Managing slippage, gas fees, and MEV protection adds complexity
- Handling errors and edge cases across chains is time-consuming
The Solution
OKX DEX SDK solves these challenges by:Built-in Protection
Slippage protection, MEV mitigation, and transaction simulation built into the SDK.
Supported Networks
The SDK supports 25+ blockchain networks with full swap, quote, and approval functionality:Major EVM Chains
- Ethereum (Chain ID: 1)
- Base (Chain ID: 8453)
- Polygon (Chain ID: 137)
- Avalanche (Chain ID: 43114)
- BSC (Chain ID: 56)
- Arbitrum (Chain ID: 42161)
- Optimism (Chain ID: 10)
Layer 2 & Scaling Solutions
- Polygon zkEVM (1101)
- zkSync Era (324)
- Linea (59144)
- Scroll (534352)
- Mantle (5000)
- Blast (81457)
- Sonic (146)
Other EVM Networks
- Fantom, Gnosis, X Layer, Manta Pacific, Metis, Cronos, and more
Non-EVM Chains
- Solana (501)
- Sui (784)
- TON (607)
- TRON (195)
All EVM chains support the full feature set: swaps, quotes, approvals, broadcasting, and order tracking.
What You Can Build
DEX Aggregators
Build your own DEX aggregator UI that finds the best prices across protocols
Trading Bots
Automate trading strategies with programmatic access to DEX liquidity
Portfolio Managers
Create multi-chain portfolio management tools with automated rebalancing
Payment Solutions
Build payment systems that accept any token and auto-convert to preferred assets
Next Steps
Ready to start building?
Install the SDK and execute your first swap in minutes