Install
The SDK is pre-release. Until the mainnet npm publish, install it from a git tag. Add this to yourpackage.json:
--ignore-scripts matters. @flashnet/sdk’s prepare hook runs rollup -c against its devDependencies before your installer has linked them, so a plain npm install may fail with Cannot find module 'rollup'. The --ignore-scripts flag avoids that ordering. npm still builds the package on its own pass, so you end up with a working dist/.
If you prefer bun and the dist isn’t there after install, build it manually:
Create the clients
ExecutionClient reads the wallet’s network and picks up the matching gateway endpoints from a built-in preset. For localnet or a custom deployment, pass an override: new ExecutionClient(sparkWallet, { gatewayUrl, rpcUrl, chainId }).
"regtest" loads the staging contract preset (Conductor, QuoterV2, V3 factory, position manager, WBTC, Permit2), so swaps, quotes, and liquidity resolve without passing addresses. For another deployment, pass an explicit TradingConfig instead.
authenticate() derives the Execution-side EVM address from the same identity key that controls the Spark wallet. There is no separate signup, faucet, or funding step.
Swap BTC for USDB
useAvailableBalance: true makes the SDK pull the input from your Spark wallet, run the swap, and dispatch the output back to Spark in one signed intent. Nothing needs to sit on the EVM side before or after.
What just happened
- The SDK pulled
100_000sats from your Spark wallet and sent them to the gateway’s deposit address. - It bundled that Spark transfer id, the Conductor swap call, and the USDB withdrawal into one canonical intent and signed it with your identity key.
- The gateway admitted the intent. The sequencer included it once the deposit oracle confirmed the Spark transfer. Validators finalized the block.
- SparkGateway emitted a
SparkWithdrawalevent for the USDB output. The settlement layer scanned the log and dispatched the matching Spark token transfer back to your Spark wallet.
trading.swap() resolves when the gateway admits the intent (status ACCEPTED); it does not wait for the block to finalize. Poll the intent to follow it to FINALIZED, or watch your Spark wallet for the inbound transfer. See Intents.
Next steps
Deposits
Move sats and Spark tokens in without swapping.
Withdrawals
Sweep balances back to Spark on demand.
Deploy your own contract
Sign and submit arbitrary EVM transactions through
ExecutionClient.execute.Reading state
Token info, balances, allowances, fees.