getBalance method

Future<EtherAmount> getBalance(
  1. EthereumAddress 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<EtherAmount> getBalance(EthereumAddress address, {BlockNum? atBlock}) {
  final blockParam = _getBlockParam(atBlock);

  return _makeRPCCall<String>('eth_getBalance', [address.hex, blockParam])
      .then((data) {
    return EtherAmount.fromUnitAndValue(EtherUnit.wei, hexToInt(data));
  });
}