Skip to content

Checking balances

To check the balance of a specific asset, you can use getBalance method. This function aggregates the amounts of all unspent coins of the given asset in your wallet.

ts
const myWallet = Wallet.fromPrivateKey(privateKey, provider);

// The returned amount is a BigNumber
const balance: BN = await myWallet.getBalance(provider.getBaseAssetId());
See code in context

To retrieve the balances of all assets in your wallet, use the getBalances method, it returns an array of CoinQuantity. This is useful for getting a comprehensive view of your holdings.

ts
const myWallet = Wallet.fromPrivateKey(privateKey, provider);

const { balances } = await myWallet.getBalances();
See code in context