The following sections provide examples of how to retrieve account balances in different formats using hooks. These functionalities allow you to access the current balance of an account in both the native currency (XAH) and in issued tokens (IOUs). By utilizing the provided code snippets, you can easily integrate balance retrieval into your hooks, enabling you to perform various operations based on the account's financial status.

BALANCESxah

XAH Balance

import { balance } from 'jshooks-api'
...
const hook_accid = hook_account()
const balance = balance(hook_accid); // <- amount in xah
// ... Do Stuff

BALANCESiou

IOU Balance

import { iouBalance } from 'jshooks-api'
...
const hook_accid = hook_account()
const currency = [...]
const issuer = [...]
const balance = iouBalance(hook_accid, currency, issuer); // <- amount in token
// ... Do Stuff

Was this page helpful?