Setting Up Your Test Environment

Prerequisites

Testing on Regtest

You can test your wallet operations in the Regtest environment.

For testing on Regtest, you can visit Spark Regtest Faucet to obtain funds and interact with spark.

  • Username: hackathon

  • Password: MakeBitcoinMoneyAgain

Keep your balance on Spark below 100,000 sats otherwise you may run into issues.

Paying an invoice directly from regtest

You can pay invoices using the Lightning Command Line tool in the spark repo. Below are the set up instructions:

Git clone the repo:

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

Go to the tools folder:

cd spark-sdk/tools/paylightning

Install dependencies:

brew install rust

Verify rust is installed:

rustc --version
cargo --version

Run the Tool:

cargo run -- "your-lightning-invoice"

The first time you run the tool it will download additional dependencies. and then will process the lightning invoice payment. Second time you run it, it will process the payment faster.

Testing on Mainnet

You can test your wallet operations in the mainnet environment.

mempool

In mainnet, we recommend you maintain the balance below 1000 sats.

You can test send/receive Lightning payments to/from any Lightning-compatible wallet or exchange. Here are some popular options:

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