WDK logoWDK documentation
BitcoinGuides

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 provider-adjusted 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). Pending transactions are handled differently by the selected client:

  • The built-in Blockbook client starts with confirmed funds and subtracts address-owned confirmed inputs spent by pending transactions. It credits pending change only when every input is address-owned and confirmed or descends from a trusted pending transaction. Other unconfirmed incoming funds are not added. An untrusted mixed-input transaction can therefore reduce the displayed balance without crediting its pending change.
  • The built-in Electrum clients do not calculate unconfirmedOutgoing. They return the confirmed balance plus the Electrum server's raw net unconfirmed delta, which can include pending incoming funds.
  • A custom client can return optional BtcBalance.unconfirmedOutgoing to select the Blockbook-style calculation. When that field is present, getBalance() ignores the raw unconfirmed value.

Balances from Blockbook and Electrum can differ while transactions are unconfirmed. Choose one provider policy for user-visible balances, and wait for confirmation before treating incoming funds as final.

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 use the same provider-specific pending-transaction policy as owned accounts.

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