WDK logoWDK documentation

Get Started

Install the Spark wallet package and create your first account.

This guide explains how to install the package, create a wallet, get your first account, and optionally convert the account to read-only.

1. Install the Package

Prerequisites

  • Node.js: version 18 or higher.
  • npm: usually comes with Node.js.

Install @tetherto/wdk-wallet-spark:

Install @tetherto/wdk-wallet-spark
npm install @tetherto/wdk-wallet-spark

The WDK Spark wallet module uses ES Modules (import / export). Set "type": "module" in package.json, or run in an environment that supports ESM.

2. Create a Wallet

You can create a wallet manager using the WalletManagerSpark constructor with a BIP-39 seed phrase:

Create Spark Wallet
import WalletManagerSpark from '@tetherto/wdk-wallet-spark'

const seedPhrase = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'

const wallet = new WalletManagerSpark(seedPhrase)

const walletRegtest = new WalletManagerSpark(seedPhrase, {
  network: 'REGTEST'
})

Secure the seed phrase: Store this seed phrase securely. If it is lost, the user will permanently lose access to their funds.

For development on REGTEST, you can request test funds from the Lightspark Regtest Faucet.

The Spark wallet uses @buildonspark/spark-sdk. Network options are MAINNET, SIGNET, or REGTEST. There is no custom RPC provider option.

3. Get Your First Account

  1. Call wallet.getAccount() with index 0.
  2. Call account.getAddress() to read the Spark address.

You can retrieve the first account using wallet.getAccount():

Get First Account
const account = await wallet.getAccount(0)
const address = await account.getAddress()
console.log('Account address:', address)

4. (optional) Convert to Read-Only

You can create a read-only view of the account using account.toReadOnlyAccount():

Convert to Read-Only
const readOnlyAccount = await account.toReadOnlyAccount()

Next Steps

With your wallet ready, learn how to manage multiple accounts.

On this page