Manage Bitcoin wallets on Spark (L2) with Flashnet AMM trading. Send/receive BTC and tokens instantly on Spark, bridge to/from Lightning and L1, buy/sell tokens via Flashnet. Use when the user wants to check wallet balance, send Bitcoin, receive payments, withdraw to L1, trade tokens, or manage Spark wallets.
Manage Bitcoin wallets on Spark with trading via Flashnet AMM.
cd {baseDir} && node scripts/spark-wallet.mjs <command> [args]
| Command | Description |
|---|---|
create <name> [mnemonic] | Create new wallet or import existing |
list | List all wallets |
use <name> | Set default wallet |
balance [wallet] | Get BTC + token balances |
address [wallet] | Get Spark address + L1 deposit address |
# Buy $5 worth of BTC, paying with USDB
node scripts/spark-wallet.mjs buy 5 btc
# Buy $10 worth of a token, paying with BTC
node scripts/spark-wallet.mjs buy 10 btkn16w9v5shwtv78... btc
# Get quote first
node scripts/spark-wallet.mjs swap-quote usdb btc 5
# Execute swap (5 USDB -> BTC, 1% slippage)
node scripts/spark-wallet.mjs swap usdb btc 5
# With custom slippage (50 = 0.5%)
node scripts/spark-wallet.mjs swap usdb btc 5 50
node scripts/spark-wallet.mjs pools
node scripts/spark-wallet.mjs price
| Command | Description |
|---|---|
send <spark_addr> <sats> [wallet] | Send BTC to Spark address |
send-tokens <spark_addr> <token_id> <amount> [wallet] | Send tokens |
| Command | Description |
|---|---|
ln-invoice <sats> [memo] [wallet] | Create BOLT11 invoice to receive |
ln-pay <bolt11> [max_fee] [wallet] | Pay Lightning invoice |
ln-fee <bolt11> [wallet] | Estimate payment fee |
| Command | Description |
|---|---|
l1-withdraw <btc_addr> <sats> [speed] [wallet] | Withdraw to L1 |
l1-withdraw-quote <btc_addr> <sats> [wallet] | Get fee quote first |
check-deposits | Check mempool for pending deposits |
claim-deposit <txid> [wallet] | Claim confirmed L1 deposit |
Known tokens:
020202020202020202020202020202020202020202020202020202020202020202btkn1xgrvjwey5ngcagvap2dzzvsy4uk8ua9x69k82dwvt5e7ef9drm9qztux87For trading, you can use short names: btc, usdb, or full token IDs.
Flashnet uses raw amounts (no decimals):
The buy command handles USD→token conversion automatically using live BTC price from Kraken.
node scripts/spark-wallet.mjs buy 5 btc
# Fetches BTC price, calculates USDB needed, executes swap
node scripts/spark-wallet.mjs swap usdb btc 100
node scripts/spark-wallet.mjs balance
All commands accept optional [wallet] parameter:
node scripts/spark-wallet.mjs buy 5 btc main
node scripts/spark-wallet.mjs balance trading
Add to HEARTBEAT.md:
cd /root/clawd/skills/spark-wallet && node scripts/spark-wallet.mjs check-deposits
Wallets stored in {baseDir}/wallets.json. Contains mnemonics - keep secure!
Override location: SPARK_WALLETS_FILE=/path/to/wallets.json
Network: SPARK_NETWORK=MAINNET (default) or REGTEST