executeSwapTransaction
Executes a swap transaction on-chain using the connected wallet. This handles token approvals (when needed) and the main swap transaction signing, delegating to the wallet provider.When using the checkout flow,
submitCheckoutTransaction calls this function internally. Use executeSwapTransaction directly only when building a standalone swap flow or a custom checkout signing flow.Usage
Parameters
| Parameter | Type | Description |
|---|---|---|
walletAccount | WalletAccount | The connected wallet account to execute the swap with. Must be on a supported chain. |
signingPayload | SwapTransactionSigningPayload | The signing payload from a quote response (via getSwapQuote or getCheckoutTransactionQuote). |
onStepChange | (step: 'approval' | 'transaction') => void (optional) | Callback invoked when the execution step changes. 'approval' fires for ERC-20 token allowance approval; 'transaction' fires for the main swap. |
Returns
Promise<{ transactionHash: string }> - The on-chain transaction hash.
Step Lifecycle
| Step | Description |
|---|---|
approval | Signing a token approval transaction. Only fires for ERC-20 tokens when the current allowance is insufficient for the swap amount. |
transaction | Signing the main swap transaction. |
Examples
Standalone swap
With progress UI
This example uses React; the JavaScript SDK is framework-agnostic and can be used with any frontend or in Node.
Supported Chains
executeSwapTransaction supports EVM and Solana chains. Attempting to use an unsupported chain throws an error.
Related
getSwapQuote- Get a swap quote with signing payloadgetSwapStatus- Check swap execution statussubmitCheckoutTransaction- Full checkout flow (uses this internally)