Setting Up Your Test Environment

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, you can run:

git clone https://github.com/buildonspark/spark-sdk.git

Go to the examples folder:

cd sdks/js/packages/spark-sdk/src/examples

Install dependencies:

yarn install
yarn build

Start the CLI tool: Pick network as mainnet or regtest

yarn tsx ./example.ts <network>

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

CommandHow to Run
initwalletinitwallet <mnemonic/seed> - Creates a new wallet instance. If no mnemonic provided, generates one
getbalancegetbalance - Gets the current wallet balance as well the token balance
getdepositaddressgetdepositaddress - Generates a Bitcoin deposit address
getsparkaddressgetsparkaddress - Gets a new Spark address for receiving transfers
sendtransfersendtransfer <amount> <receiverSparkAddress> - Sends a Spark transfer
createinvoicecreateinvoice <amount> <memo> - Creates a new Lightning invoice
payinvoicepayinvoice <invoice> - Pays a Lightning invoice
tokentransfertokentransfer <tokenPubKey> <amount> <receiverSparkAddress> - Sends a token transfer to given receiver spark address
withdrawwithdraw <onchainAddress> <amount> - Withdraws funds to a Bitcoin address
helphelp - Shows the help menu
exitexit or quit - Exits the CLI tool

Demp application

The Demo Application presented at the Hackation is available Here