Prerequisites

For TypeScript:
  • Node.js installed (16 or later)
For React Native:
  • React Native development environment set up
  • iOS: Xcode and iOS Simulator (run pod install after installing dependencies)
  • Android: Android Studio and Android SDK

Installation

yarn add @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. An account number can be optionally provided to generate multiple identity keys from the same mnemonicOrSeed.
If no account number is provided, our JS-SDK defaults accountNumber to 1 to support backwards compatability for mainnet wallets created with earlier versions of the SDK.
// 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",
  accountNumber: "optional-number"
  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.

React Native Current Status

The React Native SDK is currently in beta with active development. We’re shipping improvements weekly.
Current Limitations:
  • Uses polling for updates instead of real-time streams
  • Some edge cases may have rough handling

React Native Examples

For complete React Native example applications, check out these working examples in the buildonspark/spark repository: Clone the repository and follow the README in either example directory to get started immediately.

Need Help?