Get Balance

Assuming you are connected, you can retrieve the user's most recently updated wallet balance. The method returns the bsv, sat, and usd amounts.

const wallet = initProvider(); // see "Detecting the Provider"
try {
    const { bsv, satoshis, usdInCents } = await wallet.getBalance();
    console.log(bsv);
    console.log(satoshis);
    console.log(usdInCents);
    // 0.00200000 (number)
    // 200000 (number)
    // 1354 (number) ie $13.54
} catch (err) {
    console.log(err);
}

Last updated