Overview
The OKX DEX SDK provides cross-chain bridging capabilities through theBridgeAPI, allowing you to transfer tokens between different blockchain networks seamlessly.
Prerequisites
Before using cross-chain bridging, make sure you have:- An initialized
OKXDexClientinstance - Valid API credentials
- Understanding of source and destination chains
Getting Cross-Chain Quote
Before executing a cross-chain swap, get a quote to see the expected output and fees.Slippage must be between 0.002 (0.2%) and 0.5 (50%). The SDK will validate this range automatically.
Building Cross-Chain Swap Transaction
Once you have a quote, build the actual swap transaction.Advanced Options
Bridge Selection
Control which bridges to use or exclude:Price Impact Protection
Protect against excessive price impact:Bridge-Only Mode
Force using only bridges without DEX aggregation:Checking Supported Chains and Tokens
Get Supported Tokens
Get Supported Bridges
Get Bridge Token Pairs
Complete Example
API Reference
getCrossChainQuote
Parameters:fromChainIndex- Source chain indextoChainIndex- Destination chain indexfromChainId- Source chain IDtoChainId- Destination chain IDfromTokenAddress- Source token contract addresstoTokenAddress- Destination token contract addressamount- Amount to bridge (in base units)slippagePercent- Slippage tolerance (0.002 to 0.5)sort(optional) - Sort order for routesdexIds(optional) - Comma-separated list of DEX IDsallowBridge(optional) - Allowed bridge protocolsdenyBridge(optional) - Excluded bridge protocolspriceImpactProtectionPercentage(optional) - Maximum allowed price impact
buildCrossChainSwap
Parameters: Inherits all parameters fromgetCrossChainQuote, plus:
userWalletAddress- User’s wallet address (required)receiveAddress(optional) - Different receiving addressreferrerAddress(optional) - Referrer’s addressfeePercent(optional) - Additional fee percentageonlyBridge(optional) - Use only bridges, no DEX aggregationmemo(optional) - Transaction memo
Next Steps
Transaction Broadcasting
Learn how to broadcast cross-chain transactions
Order Tracking
Track your cross-chain swap status