🟠getBalance

You can use the getBalance method to retrieve your user's Bitcoin balance, i.e. the amount of BTC that their connected wallet's Bitcoin payment address owns.

Your app must have first connected to the wallet and obtained account read permissions. No query parameters are required for the method:

import { Wallet } from 'sats-connect';

const response = await Wallet.request('getBalance', undefined);

if (response.status === 'success') {
  console.log(response.result);
} else {
  console.error(response.error);
}

The getBalance method will not trigger any operation or prompt your user to sign any transaction. It will return an object representing the connected wallet's payment address BTC holdings:

balance Description

confirmed

a string representing the connected wallet's confirmed BTC balance, i.e. the amount of confirmed BTC which the payment address holds, in satoshis

unconfirmed

a string representing the connected wallet's unconfirmed BTC balance, i.e. the amount of unconfirmed BTC which the payment address will send/receive as a result of pending mempool transactions, in satoshis ℹī¸Note that this amount can be negative if the net result of pending mempool transaction decreases the address balance.

total

a string representing the sum of confirmed and unconfirmed BTC balances.

Last updated