executeSwap by allowing you to work with Solana’s instruction-based architecture directly.
Method signature
How it works
This method:- Calls
getSolanaSwapInstructionto get swap instructions - Constructs a Solana transaction from the instructions
- Signs the transaction with your configured wallet
- Submits the transaction to the Solana network
- Waits for confirmation
Parameters
Must be
"501" for Solana mainnetSource token address (SPL token or
So11111111111111111111111111111111111111112 for SOL)Destination token address (SPL token address)
Amount to swap in smallest unit (lamports for SOL, base units for SPL tokens)
Solana wallet address executing the swap
Maximum acceptable slippage as a decimal (e.g.,
"0.005" for 0.5%)Either slippagePercent or autoSlippage must be provided.Enable automatic slippage calculation based on market conditions
Maximum slippage when using auto slippage (required if
autoSlippage is true)Compute unit price in micro-lamports for priority fees
Maximum compute units to use for the transaction
Response
ReturnsSwapResult containing:
Whether the swap completed successfully
Solana transaction signature
URL to view the transaction on OKX explorer
Additional swap details
Prerequisites
Example
When to use this method
- Use instruction method
- Use standard method
Choose
executeSolanaSwapInstructions when you need:- More control over transaction construction
- To add custom instructions before/after the swap
- To inspect instructions before execution
- To work with Solana’s native instruction format
Error handling
Configuration options
Compute units and priority fees
Auto slippage
See also
- getSolanaSwapInstruction - Get instructions without executing
- executeSwap - Standard swap method (works for all chains)
- Solana swaps guide - Complete tutorial with examples