getBalance method

Future<BigInt?> getBalance(
  1. EthereumAddress? address,
  2. EthereumDefaultBlock? block
)

Get balance, the balance of the account of the given address.

Implementation

Future<BigInt?> getBalance(
    EthereumAddress? address, EthereumDefaultBlock? block) async {
  if (address == null) {
    throw ArgumentError.notNull('Ethereum::getBalance - address');
  }
  if (block == null) {
    throw ArgumentError.notNull('Ethereum::getBalance - block');
  }
  const method = EthereumRpcMethods.balance;
  final blockString = block.getSelection();
  final params = <String?>[address.asString, blockString];
  final dynamic res = await _client.rpcClient.request(method, params);
  if (res != null && res.containsKey(EthereumConstants.ethResultKey)) {
    return EthereumUtilities.safeParse(res[EthereumConstants.ethResultKey]);
  }
  _client.processError(method, res);
  return null;
}