spark_flashnet_executeSwap
Use the spark_flashnet_executeSwap method to request a Flashnet swap directly from the userβs Spark wallet.
Your app provides the swap parameters (pool, assets, amount, slippage, etc.), and the wallet handles the full Flashnet swap process.
This abstracts all back-and-forth with Flashnet into a single request, making swaps simple and secure.
Parameters
π Become an Xverse Partner to enable integrator fees for your app β reach out to get started
poolId
a string representing the Flashnet liquidity pool to use
assetInAddress
a string representing the address of the Spark asset being swapped in
assetOutAddress
a string representing the address of the Spark asset being swapped out
amountIn
a string representing the amount of input asset (in sats or smallest unit)
maxSlippageBps
Max slippage in basis points (e.g. 50 = 0.5%)
minAmountOut
βΉοΈ Optional - a string representing the minimum acceptable output amount
totalIntegratorFeeRateBps
Fee (in basis points) your app requests for routing the swap. β οΈTo activate your app fee, you must be an approved Xverse partner. If youβre not approved, Xverse will ignore this value and apply its own default fee instead. π Contact Xverse to become a partner and activate your app fee.
integratorPublicKey
Public key where your integrator fees should be sent. β οΈ Only partner-approved (whitelisted) keys are accepted. If you pass a non-partner key, Xverse will replace it with its own. π Contact Xverse to become a partner and get your key whitelisted.
userPublicKey
a string which must match the connected user's Spark public key
nonce
βΉοΈ Optional - a string representing a unique swap nonce
Example
What spark_flashnet_executeSwap does
spark_flashnet_executeSwap doesWhen called, this method:
Shows the user a confirmation screen with the swap details (pool, asset in/out, amount, fees, slippage).
On confirmation, the wallet:
Initiates the Spark transfer and authenticates your user with a Flashnet JWT
Generates the swap intent
Signs with the userβs Spark key
Submits to Flashnet
Returns the result (success or rejection)
Displays a progress screen while the steps complete.
Returns the swap result to the dApp.

Responses
The method returns a Promise that resolves to the SparkFlashnetSwapResultobject
β
Success
β Failure
Last updated