Skip to main content
Create and initialize Spark wallets with full key control.
Create a Wallet

Initialize Wallet

The initialize method is the primary way to create or restore a Spark wallet. Leave mnemonicOrSeed blank to generate a new wallet, or provide an existing mnemonic seed phrase to import an existing wallet.

Essential Wallet Operations

After creating your wallet, you can perform these essential operations getIdentityPublicKey() Gets the identity public key of the wallet
getSparkAddress() Gets the Spark address of the wallet
getBalance() Gets the current balance of the wallet, including Bitcoin and token balances.
cleanupConnections() Properly closes all network connections and cleans up resources when you’re done using the wallet.

Network Configuration

Spark supports both mainnet and regtest networks:
Always use REGTEST for development and testing. Only use MAINNET for production applications with real Bitcoin.
Account number defaults differ by network. REGTEST defaults to account 0, MAINNET defaults to account 1. If you test on REGTEST without specifying accountNumber, then deploy to MAINNET with the same mnemonic, your wallet will be empty because funds are on a different account. Always explicitly set accountNumber for consistent behavior.

Account Derivation

You can create multiple accounts from the same mnemonic by specifying different account numbers:

API Reference

Wallet Methods: