
Company News
Free Business Plan Upgrades for Open Source Maintainers
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.
@buildonspark/spark-sdk
Advanced tools
Spark is the fastest, cheapest, and most UX-friendly way to build financial apps and launch assets natively on Bitcoin. It’s a Bitcoin L2 that lets developers move Bitcoin and Bitcoin-native assets (including stablecoins) instantly, at near-zero cost, while staying fully connected to Bitcoin’s infrastructure.
For complete documentation, visit https://docs.spark.money
npm install @buildonspark/spark-sdk
# or
yarn add @buildonspark/spark-sdk
# or
pnpm add @buildonspark/spark-sdk
import { SparkWallet } from "@buildonspark/spark-sdk";
// Create a new wallet (generates a new mnemonic)
const { wallet, mnemonic } = await SparkWallet.initialize({
options: {
network: "MAINNET", // or "REGTEST" for testing
},
});
// Or initialize with an existing mnemonic
const { wallet } = await SparkWallet.initialize({
mnemonicOrSeed: "your twelve word mnemonic phrase here ...",
options: {
network: "MAINNET",
},
});
const balance = await wallet.getBalance();
console.log(`Bitcoin balance: ${balance.balance} sats`);
console.log(`Token balances:`, balance.tokenBalances);
// Single-use deposit address (one-time use)
const address = await wallet.getSingleUseDepositAddress();
console.log(`Deposit Bitcoin to: ${address}`);
Static deposit addresses are reusable and allow you to receive multiple deposits to the same address.
// Get a reusable static deposit address
const staticAddress = await wallet.getStaticDepositAddress();
console.log(`Static deposit address: ${staticAddress}`);
// After sending Bitcoin to the address from an external wallet,
// get a quote for claiming the deposit
const quote = await wallet.getClaimStaticDepositQuote(transactionId);
console.log(`Credit amount: ${quote.creditAmountSats} sats`);
console.log(`Fee: ${quote.feeSats} sats`);
// Claim the deposit with the quote
await wallet.claimStaticDeposit({
transactionId,
creditAmountSats: quote.creditAmountSats,
sspSignature: quote.signature,
});
// Or use the convenience method with a max fee
await wallet.claimStaticDepositWithMaxFee({
transactionId,
maxFee: 500, // Will throw if fee exceeds this amount
});
// Query all your static deposit addresses
const addresses = await wallet.queryStaticDepositAddresses();
// Get confirmed UTXOs for a deposit address
const utxos = await wallet.getUtxosForDepositAddress(staticAddress);
for (const utxo of utxos) {
console.log(`UTXO: ${utxo.txid}:${utxo.vout}`);
}
// Transfer to another Spark address
const transfer = await wallet.transfer({
receiverSparkAddress: "sp1q...",
amountSats: 10000,
});
// Withdraw to on-chain Bitcoin address
const withdrawal = await wallet.withdraw({
onchainAddress: "bc1q...",
amountSats: 50000,
exitSpeed: "FAST", // or "MEDIUM", "SLOW"
});
// Create a Lightning invoice
const invoice = await wallet.createLightningInvoice({
amountSats: 1000,
memo: "Payment for services",
});
console.log(`Invoice: ${invoice.invoice.encodedInvoice}`);
// Pay a Lightning invoice
const payment = await wallet.payLightningInvoice({
invoice: "lnbc...",
maxFeeSats: 100,
});
// Get token balances
const { tokenBalances } = await wallet.getBalance();
for (const [tokenId, info] of tokenBalances) {
console.log(`${info.tokenMetadata.tokenName}: ${info.balance}`);
}
// Transfer tokens
const tokenTransfer = await wallet.transferTokens({
tokenIdentifier: "spark1...",
receiverSparkAddress: "sp1q...",
tokenAmount: 100n,
});
import { SparkWalletEvent } from "@buildonspark/spark-sdk";
// Listen for incoming transfers
wallet.on(SparkWalletEvent.TransferClaimed, (transferId, newBalance) => {
console.log(`Received transfer ${transferId}, new balance: ${newBalance}`);
});
// Listen for confirmed deposits
wallet.on(SparkWalletEvent.DepositConfirmed, (depositId, newBalance) => {
console.log(`Deposit ${depositId} confirmed, new balance: ${newBalance}`);
});
The SDK supports multiple JavaScript runtimes:
FAQs
Spark SDK
The npm package @buildonspark/spark-sdk receives a total of 17,831 weekly downloads. As such, @buildonspark/spark-sdk popularity was classified as popular.
We found that @buildonspark/spark-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.