getBalance method

  1. @override
Future<BigInt> getBalance(
  1. String address, {
  2. BlockTag? blockTag,
})
override

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, BlockTag.latest will be used.

Implementation

@override
Future<BigInt> getBalance(
  String address, {
  BlockTag? blockTag,
}) {
  final bt = blockTag?.toParam() ?? const BlockTag.latest().toParam();

  return _makeRPCCall<String>('eth_getBalance', [address.toLowerCase(), bt])
      .then((data) {
    return hexToInt(data);
  });
}