API Reference
Complete API documentation for @tetherto/wdk-wallet-spark
Table of Contents
Main class for managing Spark wallets. Extends WalletManager from @tetherto/wdk-wallet.
Individual Spark wallet account implementation. Implements IWalletAccount.
WalletManagerSpark
The main class for managing Spark wallets.
Extends WalletManager from @tetherto/wdk-wallet.
Constructor
new WalletManagerSpark(seed, config)Parameters:
seed(string | Uint8Array): BIP-39 mnemonic seed phrase or seed bytesconfig(object, optional): Configuration objectnetwork(string, optional): 'MAINNET', 'TESTNET', or 'REGTEST' (default: 'MAINNET')
Methods
getAccount(index)
Returns a wallet account at the specified index
Promise<WalletAccountSpark>
getFeeRates()
Returns current fee rates for transactions (always zero for Spark)
Promise<{normal: bigint, fast: bigint}>
dispose()
Disposes all wallet accounts, clearing private keys from memory
void
getAccount(index)
Returns a wallet account at the specified index using BIP-44 derivation path.
Parameters:
index(number, optional): The index of the account to get (default: 0)
Returns: Promise<WalletAccountSpark> - The wallet account
Example:
Note: Uses derivation path pattern m/44'/998'/{networkNumber}'/0/{index} where 998 is the coin type for Spark and networkNumber is 0 for MAINNET, 1 for TESTNET, 2 for SIGNET, or 3 for REGTEST.
getFeeRates()
Returns current fee rates for transactions. On Spark network, transactions have zero fees.
Returns: Promise<{normal: bigint, fast: bigint}> - Object containing fee rates (always {normal: 0n, fast: 0n})
Example:
dispose()
Disposes all wallet accounts and clears sensitive data from memory.
Returns: void
Example:
Important Notes:
getAccountByPath(path)is not supported and will throw an errorCustom derivation paths are not available - only indexed accounts
All Spark transactions have zero fees
Network configuration is limited to predefined values
WalletAccountSpark
Represents an individual Spark wallet account. Implements IWalletAccount from @tetherto/wdk-wallet.
Note: WalletAccountSpark instances are created internally by WalletManagerSpark.getAccount() and are not intended to be constructed directly.
Methods
getAddress()
Returns the account's Spark address
Promise<SparkAddressFormat>
sign(message)
Signs a message using the account's identity key
Promise<string>
verify(message, signature)
Verifies a message signature
Promise<boolean>
sendTransaction(tx)
Sends a Spark transaction
Promise<{hash: string, fee: bigint}>
quoteSendTransaction(tx)
Estimates transaction fee (always 0)
Promise<{fee: bigint}>
transfer(options)
Transfers tokens to another address
Promise<{hash: string, fee: bigint}>
quoteTransfer(options)
Quotes the costs of a transfer operation
Promise<{fee: bigint}>
getBalance()
Returns the native token balance in satoshis
Promise<bigint>
getTokenBalance(tokenAddress)
Returns the balance for a specific token
Promise<bigint>
getTransactionReceipt(hash)
Gets the transaction receipt for a given transaction hash
Promise<SparkTransactionReceipt | null>
getTransfers(options?)
Returns the account's transfer history
Promise<SparkTransfer[]>
getSingleUseDepositAddress()
Generates a single-use Bitcoin deposit address
Promise<string>
getUnusedDepositAddresses()
Gets all unused single-use deposit addresses
Promise<string[]>
getStaticDepositAddress()
Gets static deposit address for Bitcoin deposits
Promise<string>
claimDeposit(txId)
Claims a Bitcoin deposit to the wallet
Promise<WalletLeaf[] | undefined>
claimStaticDeposit(txId)
Claims a static Bitcoin deposit to the wallet
Promise<WalletLeaf[] | undefined>
refundStaticDeposit(options)
Refunds a static deposit back to a Bitcoin address
Promise<string>
quoteWithdraw(options)
Gets a fee quote for withdrawing funds
Promise<CoopExitFeeQuote>
withdraw(options)
Withdraws funds to a Bitcoin address
Promise<CoopExitRequest | null | undefined>
createLightningInvoice(options)
Creates a Lightning invoice
Promise<LightningReceiveRequest>
getLightningReceiveRequest(invoiceId)
Gets Lightning receive request by id
Promise<LightningReceiveRequest | null>
getLightningSendRequest(requestId)
Gets Lightning send request by id
Promise<LightningSendRequest | null>
payLightningInvoice(options)
Pays a Lightning invoice
Promise<LightningSendRequest>
quotePayLightningInvoice(options)
Gets fee estimate for Lightning payments
Promise<bigint>
createSparkSatsInvoice(options)
Creates a Spark invoice for receiving sats
Promise<SparkAddressFormat>
createSparkTokensInvoice(options)
Creates a Spark invoice for receiving tokens
Promise<SparkAddressFormat>
paySparkInvoice(invoices)
Pays one or more Spark invoices
Promise<FulfillSparkInvoiceResponse>
getSparkInvoices(invoices)
Queries the status of Spark invoices
Promise<QuerySparkInvoicesResponse>
toReadOnlyAccount()
Creates a read-only version of this account
Promise<WalletAccountReadOnlySpark>
cleanupConnections()
Cleans up network connections and resources
Promise<void>
dispose()
Disposes the wallet account, clearing private keys
void
getAddress()
Returns the account's Spark network address.
Returns: Promise<SparkAddressFormat> - The Spark address
Example:
sign(message)
Signs a message using the account's identity key.
Parameters:
message(string): The message to sign
Returns: Promise<string> - The message signature
Example:
verify(message, signature)
Verifies a message signature against the account's identity key.
Parameters:
message(string): The original messagesignature(string): The signature to verify
Returns: Promise<boolean> - True if the signature is valid
Example:
sendTransaction({to, value})
Sends a Spark transaction.
Parameters:
to(string): Recipient's Spark addressvalue(number): Amount in satoshis
Returns: Promise<{hash: string, fee: bigint}> (fee is always 0)
Example:
quoteSendTransaction({to, value})
Estimates the fee for a Spark transaction (always returns 0).
Parameters:
to(string): Recipient's Spark addressvalue(number): Amount in satoshis
Returns: Promise<{fee: bigint}> - Fee estimate (always 0)
Example:
transfer(options)
Transfers tokens to another address.
Parameters:
options(object): Transfer optionstoken(string): Token identifier (Bech32m token identifier, e.g.,btkn1...)amount(bigint): Amount of tokens to transferrecipient(string): Recipient Spark address
Returns: Promise<{hash: string, fee: bigint}> - Transfer result
Example:
quoteTransfer(options)
Quotes the costs of a transfer operation.
Parameters:
options(object): Transfer options (same astransfer)
Returns: Promise<{fee: bigint}> - Transfer fee quote
Example:
getBalance()
Returns the account's native token balance in satoshis.
Returns: Promise<bigint> - Balance in satoshis
Example:
getTokenBalance(tokenAddress)
Returns the balance for a specific token.
Parameters:
tokenAddress(string): Token contract address
Returns: Promise<bigint> - Token balance in base unit
Example:
getTransactionReceipt(hash)
Gets the transaction receipt for a given transaction hash.
Parameters:
hash(string): Transaction hash
Returns: Promise<SparkTransactionReceipt | null> - Transaction receipt details, or null if not found
Example:
getTransfers(options?)
Returns the account's transfer history with filtering options.
Parameters:
options(object, optional): Filter optionsdirection(string): 'all', 'incoming', or 'outgoing' (default: 'all')limit(number): Maximum transfers to return (default: 10)skip(number): Number of transfers to skip (default: 0)
Returns: Promise<SparkTransfer[]> - Array of transfer objects (type alias for WalletTransfer from @buildonspark/spark-sdk)
Example:
getSingleUseDepositAddress()
Generates a single-use Bitcoin deposit address for funding the Spark wallet.
Returns: Promise<string> - Bitcoin deposit address
Example:
getUnusedDepositAddresses()
Gets all unused single-use deposit addresses.
Returns: Promise<string[]> - List of unused deposit addresses
Example:
getStaticDepositAddress()
Gets static deposit address for Bitcoin deposits from layer 1. This address can be reused.
Returns: Promise<string> - The static deposit address
Example:
claimDeposit(txId)
Claims a Bitcoin deposit to add funds to the Spark wallet.
Parameters:
txId(string): Bitcoin transaction ID of the deposit
Returns: Promise<WalletLeaf[] | undefined> - Wallet leaves created from the deposit
Example:
claimStaticDeposit(txId)
Claims a static Bitcoin deposit to add funds to the Spark wallet.
Parameters:
txId(string): Bitcoin transaction ID of the deposit
Returns: Promise<WalletLeaf[] | undefined> - Wallet leaves created from the deposit
Example:
refundStaticDeposit(options)
Refunds a deposit made to a static deposit address back to a specified Bitcoin address. The minimum fee is 300 satoshis.
Parameters:
options(object): Refund optionsdepositTransactionId(string): The transaction ID of the original depositoutputIndex(number): The output index of the depositdestinationAddress(string): The Bitcoin address to send the refund tosatsPerVbyteFee(number): The fee rate in sats per vbyte for the refund transaction
Returns: Promise<string> - The refund transaction as a hex string that needs to be broadcast
Example:
quoteWithdraw(options)
Gets a fee quote for withdrawing funds from Spark cooperatively to an on-chain Bitcoin address.
Parameters:
options(object): Withdrawal quote optionswithdrawalAddress(string): The Bitcoin address where the funds should be sentamountSats(number): The amount in satoshis to withdraw
Returns: Promise<CoopExitFeeQuote> - The withdrawal fee quote
Example:
withdraw(options)
Withdraws funds from the Spark network to an on-chain Bitcoin address.
Parameters:
options(WithdrawOptions): Withdrawal options objectonchainAddress(string): Bitcoin address to withdraw toamountSats(number): Amount in satoshis to withdrawAdditional options from
WithdrawParamsmay be supported
Returns: Promise<CoopExitRequest | null | undefined> - Withdrawal request details
Example:
createLightningInvoice(options)
Creates a Lightning invoice for receiving payments.
Parameters:
options(CreateLightningInvoiceParams): Invoice options objectamountSats(number, optional): Amount in satoshismemo(string, optional): Invoice descriptionAdditional options from
CreateLightningInvoiceParamsmay be supported
Returns: Promise<LightningReceiveRequest> - Lightning invoice details
Example:
getLightningReceiveRequest(invoiceId)
Gets details of a previously created Lightning receive request.
Parameters:
invoiceId(string): Invoice ID
Returns: Promise<LightningReceiveRequest | null> - Invoice details, or null if not found
Example:
getLightningSendRequest(requestId)
Gets a Lightning send request by id.
Parameters:
requestId(string): The id of the Lightning send request
Returns: Promise<LightningSendRequest | null> - The Lightning send request
Example:
payLightningInvoice(options)
Pays a Lightning invoice.
Parameters:
options(PayLightningInvoiceParams): Payment options objectencodedInvoice(string): BOLT11 Lightning invoicemaxFeeSats(number, optional): Maximum fee willing to pay in satoshisAdditional options from
PayLightningInvoiceParamsmay be supported
Returns: Promise<LightningSendRequest> - Payment details
Example:
quotePayLightningInvoice(options)
Estimates the fee for paying a Lightning invoice.
Parameters:
options(LightningSendFeeEstimateInput): Fee estimation optionsencodedInvoice(string): BOLT11 Lightning invoiceAdditional options may be supported
Returns: Promise<bigint> - Estimated fee in satoshis
Example:
createSparkSatsInvoice(options)
Creates a Spark invoice for receiving a sats payment.
Parameters:
options(object): Invoice optionsamount(number, optional): The amount of sats to receive (optional for open invoices)memo(string, optional): Optional memo/description for the paymentsenderSparkAddress(SparkAddressFormat, optional): Optional Spark address of the expected senderexpiryTime(Date, optional): Optional expiry time for the invoice
Returns: Promise<SparkAddressFormat> - A Spark invoice that can be paid by another Spark wallet
Example:
createSparkTokensInvoice(options)
Creates a Spark invoice for receiving a token payment.
Parameters:
options(object): Invoice optionstokenIdentifier(string, optional): The Bech32m token identifier (e.g.,btkn1...)amount(bigint, optional): The amount of tokens to receivememo(string, optional): Optional memo/description for the paymentsenderSparkAddress(SparkAddressFormat, optional): Optional Spark address of the expected senderexpiryTime(Date, optional): Optional expiry time for the invoice
Returns: Promise<SparkAddressFormat> - A Spark invoice that can be paid by another Spark wallet
Example:
paySparkInvoice(invoices)
Fulfills one or more Spark invoices by paying them.
Parameters:
invoices(SparkInvoice[]): Array of invoices to fulfillEach invoice has:
invoice(SparkAddressFormat): The Spark invoice to payamount(bigint, optional): Amount to pay (required for invoices without encoded amount)
Returns: Promise<FulfillSparkInvoiceResponse> - Response containing transaction results and errors
Example:
getSparkInvoices(invoices)
Queries the status of Spark invoices.
Parameters:
invoices(string[]): Array of invoice addresses to query
Returns: Promise<QuerySparkInvoicesResponse> - Response containing invoice status information
Example:
toReadOnlyAccount()
Creates a read-only version of this account that can query data but not sign transactions.
Returns: Promise<WalletAccountReadOnlySpark> - Read-only account instance
Example:
cleanupConnections()
Cleans up network connections and resources.
Returns: Promise<void>
Example:
dispose()
Disposes the wallet account, securely erasing private keys from memory.
Returns: void
Example:
Properties
index
number
The derivation path index of this account
path
string
The full BIP-44 derivation path
keyPair
KeyPair
The account's public and private key pair
Types
SparkWalletConfig
SparkTransaction
TransactionResult
KeyPair
LightningReceiveRequest
LightningSendRequest
WalletLeaf
CoopExitRequest
SparkTransactionReceipt
Type alias for TxV1Response from @sparkscan/api-node-sdk-client. Key properties include:
TransferOptions
SparkTransfer
Type alias for WalletTransfer from @buildonspark/spark-sdk. Key properties include:

