A Spark Transfer is a Bitcoin transfer that occurs entirely within the Spark network. Unlike traditional Bitcoin transactions that go through the blockchain, Spark transfers are:
Instant - No waiting for blockchain confirmations
Low cost - Minimal fees compared to on-chain transactions
Private - Transfers are not visible on the public blockchain
Efficient - Uses Spark’s layer 2 infrastructure
Spark transfers are ideal for frequent Bitcoin transactions, micro-payments, and applications requiring instant settlement.
Monitor your transfers and track their status using transfer queries and events.getTransfers(limit?, offset?)Gets all transfers for the wallet with optional pagination.
getTransfers() includes Spark transfers, Lightning sends/receives, and cooperative exits. For token transaction details, use queryTokenTransactions().
Copy
Ask AI
// Get recent transfersconst transfers = await wallet.getTransfers(10);console.log("Recent transfers:", transfers.transfers);// Check specific transfer statusconst recentTransfer = transfers.transfers[0];console.log("Transfer ID:", recentTransfer.id);console.log("Transfer status:", recentTransfer.status);console.log("Amount:", recentTransfer.totalValue, "sats");
Monitor transfer status in real-time using event listeners.
Copy
Ask AI
// Listen for incoming transfer eventswallet.on("transfer:claimed", (transferId, updatedBalance) => { console.log(`Incoming transfer ${transferId} claimed! New balance: ${updatedBalance} sats`);});// Note: There are no events for outgoing transfers.// The transfer() method returns immediately when the transfer completes.
The transfer:claimed event only fires for incoming transfers. For outgoing transfers, the transfer() method returns a WalletTransfer object when complete.