Skip to main content
Core methods for wallet initialization, identity management, and basic operations.

initialize({ mnemonicOrSeed, signer, options }: SparkWalletProps)

Creates and initializes a new SparkWallet instance.
interface SparkWalletProps {
  mnemonicOrSeed?: Uint8Array | string;
  accountNumner?: number
  signer?: SparkSigner;
  options?: ConfigOptions;
}

static async initialize(props: SparkWalletProps): Promise<{
  wallet: SparkWallet;
  mnemonic?: string;
}>
Parameters:
  • props: Object containing:
    • mnemonicOrSeed: (Optional) BIP-39 mnemonic phrase or raw seed
    • accountNumber: (Optional) number used to generate multiple identity keys from the same mnemonic
    • signer: (Optional) Custom signer implementation
    • options: (Optional) Wallet configuration options
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.
Returns:
  • Object containing:
    • wallet: The initialized SparkWallet instance
    • mnemonic: The mnemonic if one was generated (undefined for raw seed)

getIdentityPublicKey()

Gets the identity public key of the wallet.
async getIdentityPublicKey(): Promise<string>
Returns:
  • Promise<string>: The identity public key as a hex string

getSparkAddress()

Gets the Spark Address of the wallet.
async getSparkAddress(): Promise<SparkAddressFormat>
Returns:
  • Promise<SparkAddressFormat>: The Spark Address

getBalance()

Gets the current balance of the wallet. You can use the forceRefetch option to synchronize your wallet and claim any pending incoming lightning payment, spark transfer, or bitcoin deposit before returning the balance.
async getBalance(): Promise<{
  balance: bigint;
  tokenBalances: Map<string, { balance: bigint, bech32mTokenIdentifier: string }>;
}>
Returns:
  • Object containing:
    • balance: The wallet’s current balance in satoshis
    • tokenBalances: Map of token public keys to token balances with Bech32m token identifiers

getTransfers(limit?: number, offset?: number)

Gets all transfers for the wallet.
async getTransfers(
  limit: number = 20,
  offset: number = 0
): Promise<{
  transfers: WalletTransfer[];
  offset: number;
}>
Parameters:
  • limit: (Optional, default: 20) Maximum number of transfers to return
  • offset: (Optional, default: 0) Offset for pagination
Returns:
  • Promise<{ transfers: WalletTransfer[]; offset: number; }>: Response containing the list of transfers and offset