getTransactionCount method

Future<int?> getTransactionCount(
  1. EthereumAddress? address,
  2. EthereumDefaultBlock? block
)

Transaction count, returns the number of transactions sent from an address.

Implementation

Future<int?> getTransactionCount(
    EthereumAddress? address, EthereumDefaultBlock? block) async {
  if (address == null) {
    throw ArgumentError.notNull('Ethereum::getTransactionCount - address');
  }
  if (block == null) {
    throw ArgumentError.notNull('Ethereum::getTransactionCount - block');
  }
  const method = EthereumRpcMethods.transactionCount;
  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.hexToInt(res[EthereumConstants.ethResultKey]);
  }
  _client.processError(method, res);
  return null;
}