getBalance method

Future<XCBAmount> getBalance(
  1. XCBAddress address, {
  2. BlockNum? atBlock,
})

Gets the balance of the account with the specified address.

This function allows specifying a custom block mined in the past to get historical data. By default, BlockNum.current will be used.

Implementation

Future<XCBAmount> getBalance(XCBAddress address, {BlockNum? atBlock}) {
  final blockParam = _getBlockParam(atBlock);

  return _makeRPCCall<String>('xcb_getBalance', [
    address.hexNo0x,
    blockParam,
  ]).then((data) {
    return XCBAmount.fromUnitAndValue(XCBUnit.ore, hexToInt(data));
  });
}