WDK logoWDK documentation

Check Balances

Query native BTC balances for owned and read-only accounts.

This guide explains how to check native BTC balances, maximum spendable amounts, and read-only account balances.

Native BTC Balance

You can retrieve the confirmed balance in satoshis using account.getBalance():

Get Native BTC Balance
const balance = await account.getBalance()
console.log('Total balance:', balance, 'satoshis')

On Bitcoin, balances are expressed in satoshis (1 BTC = 100,000,000 satoshis). The getBalance() method returns the total balance, including unconfirmed funds when present.

Maximum Spendable Amount

You can check the maximum amount available to send in a single transaction using account.getMaxSpendable():

Get Maximum Spendable
const { amount, fee } = await account.getMaxSpendable()
console.log('Max spendable:', amount, 'satoshis')
console.log('Estimated fee:', fee, 'satoshis')

The maximum spendable amount can differ from the total balance due to transaction fees, uneconomic UTXOs, the 200-input limit per transaction, and the dust threshold (294 satoshis for SegWit, 546 for legacy).

Read-Only Account Balances

You can check balances for any Bitcoin address without a seed phrase using WalletAccountReadOnlyBtc:

Create Read-Only Account
import { WalletAccountReadOnlyBtc, ElectrumTcp } from '@tetherto/wdk-wallet-btc'

const client = new ElectrumTcp({
  host: 'electrum.blockstream.info',
  port: 50001
})

const readOnlyAccount = new WalletAccountReadOnlyBtc('bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh', {
  client,
  network: 'bitcoin'
})

You can retrieve the balance from a read-only account using readOnlyAccount.getBalance():

Read-Only Balance
const balance = await readOnlyAccount.getBalance()
console.log('Read-only account balance:', balance, 'satoshis')

Read-only accounts follow the same balance behavior as owned accounts: getBalance() includes unconfirmed funds when present.

You can also create a read-only account from an existing owned account using account.toReadOnlyAccount().

Next Steps

With balance checks in place, learn how to send BTC.

On this page