Learn how to check your wallet balance, view transfer history, and monitor activity on the Spark network. This guide covers balance queries, transfer tracking, and real-time event monitoring.
Get your current Bitcoin balance and token holdings in your Spark wallet.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.
Track all incoming and outgoing transfers for your wallet with pagination support.getTransfers(limit?, offset?)Gets all transfers for the wallet with optional pagination.
Copy
Ask AI
// Get first 20 transfersconst transfers = await wallet.getTransfers();console.log("Transfers:", transfers.transfers);// Get next 10 transfers with paginationconst nextTransfers = await wallet.getTransfers(10, 20);console.log("Next page:", nextTransfers.transfers);
Monitor wallet activity in real-time using EventEmitter methods for instant updates.on(event, listener)Adds a listener for the specified event to monitor wallet activity.
Copy
Ask AI
// Listen for transfer claimswallet.on("transfer:claimed", (transferId, updatedBalance) => { console.log(`Transfer ${transferId} claimed. New balance: ${updatedBalance}`);});// Listen for new depositswallet.on("deposit:received", (depositId, amount) => { console.log(`Deposit received: ${amount} sats`);});
Monitor your wallet activity using the Sparkscan block explorer for a visual interface.
Sparkscan provides a web interface to view your wallet’s transaction history, balance, and activity without needing to implement the API calls yourself.