Prerequisites

  • Node.js installed (16 or later)

Installation

yarn add @buildonspark/spark-sdk

or via npm

npm i @buildonspark/spark-sdk

Initialize the Wallet

A wallet requires either a mnemonic or raw seed for initialization. The initialize() function accepts both. If no input is given, it will auto-generate a mnemonic and return it. Persist it somewhere safe — losing it means losing access.

// import the SparkWallet and wallet-config from the spark-sdk
import { SparkWallet } from "@buildonspark/spark-sdk";

// Initialize a new wallet instance
  const { wallet, mnemonic } = await SparkWallet.initialize({
    mnemonicOrSeed: "optional-mnemonic-or-seed",
    options: {
        network: "REGTEST"
    }
  });

 console.log("Wallet initialized successfully:", mnemonic));

Mnemonic Phrases

A mnemonic is a human-readable encoding of your wallet’s seed. It’s a 12- or 24-word phrase from the BIP-39 wordlist, used to derive the cryptographic keys that control your wallet.

Raw Seed

A raw seed is the byte-level representation of your wallet’s entropy. It directly maps to the private keys that control your wallet.

Next Steps

Now that you’ve created your first wallet, you can:

  1. Fetch your balance
  2. Deposit Bitcoin
  3. Send & Receive on Lightning
  4. Send & Receive on Spark

Need Help?