Skip to main content

Prerequisites

Using our Spark CLI tool

We have a CLI tool that allows you to test your wallet operations on Spark. No coding is required!To install the CLI tool:
git clone https://github.com/buildonspark/spark.git

cd spark/sdks/js

yarn && yarn build

cd examples/spark-cli

yarn cli
This will start the CLI tool and you will be able to interact with the wallet. Run help to see the available commands.

Command Reference

Wallet Setup & Information

CommandUsage
initwalletinitwallet [mnemonic | seed] - Create a new wallet from a mnemonic or seed. If no mnemonic or seed is provided, a new mnemonic will be generated.
getbalanceGet the wallet's balance
identityGet the wallet's identity public key
getsparkaddressGet the wallet's spark address
gettransfersgettransfers [limit] [offset] - Get a list of transfers

Address Operations

CommandUsage
encodeaddressencodeaddress <identityPublicKey> <network> - Encodes a identity public key to a spark address (network: mainnet, regtest, testnet, signet, local)
decodesparkaddressdecodesparkaddress <sparkAddress> <network> - Decode a spark address to get the identity public key (network: MAINNET|REGTEST|SIGNET|TESTNET|LOCAL)

Deposits

CommandUsage
getstaticdepositaddressGet a static address to deposit funds from L1 to Spark
getlatesttxgetlatesttx <address> - Get the latest deposit transaction id for an address
getutxosfordepositaddressgetutxosfordepositaddress <depositAddress> <excludeClaimed(true|false)> - Get all UTXOs for a deposit address
claimstaticdepositquoteclaimstaticdepositquote <txid> [outputIndex] - Get a quote for claiming a static deposit
claimstaticdepositclaimstaticdeposit <txid> <creditAmountSats> <sspSignature> [outputIndex] - Claim a static deposits
claimstaticdepositwithmaxfeeclaimstaticdepositwithmaxfee <txid> <maxFee> [outputIndex] - Claim a static deposit with a max fee

Refunds

CommandUsage
refundstaticdepositlegacyrefundstaticdepositlegacy <depositTransactionId> <destinationAddress> <fee> [outputIndex] - Refund a static deposit legacy
refundstaticdepositrefundstaticdeposit <depositTransactionId> <destinationAddress> <satsPerVbyteFee> [outputIndex] - Refund a static deposit
refundandbroadcaststaticdepositrefundandbroadcaststaticdeposit <depositTransactionId> <destinationAddress> <satsPerVbyteFee> [outputIndex] - Refund and broadcast a static deposit

Lightning Network

CommandUsage
createinvoicecreateinvoice <amount> <memo> <includeSparkAddress> [receiverIdentityPubkey] [descriptionHash] - Create a new lightning invoice
payinvoicepayinvoice <invoice> <maxFeeSats> <preferSpark> [amountSatsToSend] - Pay a lightning invoice
lightningsendfeelightningsendfee <invoice> - Get a fee estimate for a lightning send
getlightningsendrequestgetlightningsendrequest <requestId> - Get a lightning send request by ID
getlightningreceiverequestgetlightningreceiverequest <requestId> - Get a lightning receive request by ID

Spark Transfers

CommandUsage
createsparkinvoicecreatesparkinvoice <asset("btc" | tokenIdentifier)> [amount] [memo] [senderPublicKey] [expiryTime] - Create a spark payment request. Amount is optional. Use _ for empty optional fields
sendtransfersendtransfer <amount> <receiverSparkAddress> - Send a spark transfer
fulfillsparkinvoicefulfillsparkinvoice <invoice1[:amount1]> <invoice2[:amount2]> ... - Fulfill one or more Spark token invoices (append :amount if invoice has no preset amount)
querysparkinvoicesquerysparkinvoices <invoice1> <invoice2> ... - Query Spark token invoices raw invoice strings

Withdrawals

CommandUsage
withdrawwithdraw <amount> <onchainAddress> <exitSpeed(FAST|MEDIUM|SLOW)> [deductFeeFromWithdrawalAmount(true|false)] - Withdraw funds to an L1 address
withdrawalfeewithdrawalfee <amount> <withdrawalAddress> - Get a fee estimate for a withdrawal (cooperative exit)
getcoopexitrequestgetcoopexitrequest <requestId> - Get a coop exit request by ID

Unilateral Exit

CommandUsage
unilateralexitunilateralexit [testmode=true] - Interactive unilateral exit flow (normal mode: timelocks must be naturally expired, test mode: automatically expires timelocks)
getleavesGet all leaves owned by the wallet
checktimelockchecktimelock <leafId> - Get the remaining timelock for a given leaf
leafidtohexleafidtohex <leafId1> [leafId2] [leafId3] ... - Convert leaf ID to hex string for unilateral exit
generatefeebumppackagetobroadcastgeneratefeebumppackagetobroadcast <feeRate> <utxo1:txid:vout:value:script:publicKey> [utxo2:...] [nodeHexString1] [nodeHexString2 ...] - Get fee bump packages for unilateral exit transactions (if no nodes provided, uses all wallet leaves)
generatefeebumptxgeneratefeebumptx <cpfpTx> - Generate a fee bump transaction for a given cpfp transaction
signfeebumpsignfeebump <feeBumpPsbt> <privateKey> - Sign a fee bump package with the utxo private key

Tokens

CommandUsage
createtokencreatetoken <tokenName> <tokenTicker> <decimals> <maxSupply> <isFreezable> - Create a new token
transfertokenstransfertokens <tokenIdentifier> <receiverAddress> <amount> - Transfer tokens
batchtransfertokensbatchtransfertokens <tokenIdentifier> <receiverAddress1:amount1> <receiverAddress2:amount2> ... - Transfer tokens with multiple outputs
minttokensminttokens <amount> - Mint new tokens
burntokensburntokens <amount> - Burn tokens
freezetokensfreezetokens <sparkAddress> - Freeze tokens for a specific address
unfreezetokensunfreezetokens <sparkAddress> - Unfreeze tokens for a specific address
querytokentransactionsquerytokentransactions [--ownerPublicKeys] [--issuerPublicKeys] [--tokenTransactionHashes] [--tokenIdentifiers] [--outputIds] - Query token transaction history
decodetokenidentifierdecodetokenidentifier <tokenIdentifier> - Returns the raw token identifier as a hex string

Token Issuer Operations

CommandUsage
getissuertokenbalanceGet the issuer's token balance
getissuertokenmetadataGet the issuer's token metadata
getissuertokenidentifierGet the issuer's token identifier
getissuertokenpublickeyGet the issuer's token public key
gettokenl1addressGet the L1 address for on-chain token operations

Testing & Development

CommandUsage
testonly_generateexternalwalletGenerate test wallet to fund utxos for fee bumping
testonly_generateutxostringtestonly_generateutxostring <txid> <vout> <value> <publicKey> - Generate correctly formatted UTXO string from your public key

System

CommandUsage
enableloggingenablelogging <true|false> - Enable or disable logging
setloggerlevelsetloggerlevel <trace|info> - Set the logging level
helpShow this help message
exit/quitExit the program