Check Balance

📘

Permission Required

This feature requires the Pay permission.

Check the user's spendable balance

HandCash users have a global spend limit for how much they're willing to spend on apps, hence 'spendable balance'. This limit can be changed or reset by users at any time.

You can fetch the user's spendable balance with the wallet.getSpendableBalance function.

const {HandCashConnect} = require('@handcash/handcash-connect');
const handCashConnect = new HandCashConnect({ 
   appId: '<app-id>', 
   appSecret: '<secret>',
}); 

const account = handCashConnect.getAccountFromAuthToken(token);
var balance = await account.wallet.getSpendableBalance();

console.log(balance);
// balance
{
  spendableSatoshiBalance: 1260000,
  spendableFiatBalance: 2.96,
  currencyCode: 'CAD'
}

If you need to customize the local currency conversion, you can pass any currency code through the function:

var balance = await account.wallet.getSpendableBalance("USD");

console.log(balance);
// balance
{
  spendableSatoshiBalance: 1260000,
  spendableFiatBalance: 2.03,
  currencyCode: 'USD'
}

Did this page help you?