Creates a SparkReadonlyClient authenticated with an identity key derived from a mnemonic or seed. Can query private wallets the key owns.
Method Signature
static async createWithMasterKey(
config: ConfigOptions | undefined,
mnemonicOrSeed: Uint8Array | string,
accountNumber?: number,
): Promise<SparkReadonlyClient>
Parameters
config
ConfigOptions | undefined
required
Configuration options including network selection. Pass undefined for defaults.
mnemonicOrSeed
Uint8Array | string
required
BIP-39 mnemonic phrase, hex-encoded seed string, or raw seed bytes.
Account index for key derivation. Defaults to 0 for REGTEST, 1 otherwise.
Returns
client
Promise<SparkReadonlyClient>
required
An authenticated wallet viewer. Requests include an identity key signature for access to private wallet data.
Example
import { SparkReadonlyClient } from "@buildonspark/spark-sdk";
const client = await SparkReadonlyClient.createWithMasterKey(
{ network: "MAINNET" },
"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about",
);
// Can see private wallet data
const balance = await client.getAvailableBalance("sp1...");