getBlockTransactionCountByHash method

Future<int?> getBlockTransactionCountByHash(
  1. EthereumData? blockHash
)

Block Transaction Count By Hash The number of transactions in a block from a block matching the given block hash. If the method returns null a count of 0 is returned, this is to distinguish between this and an error.

Implementation

Future<int?> getBlockTransactionCountByHash(EthereumData? blockHash) async {
  if (blockHash == null) {
    throw ArgumentError.notNull(
        'Ethereum::getBlockTransactionCountByHash - blockHash');
  }
  const method = EthereumRpcMethods.blockTransactionCountByHash;
  final params = <String?>[blockHash.asString];
  final dynamic res = await _client.rpcClient.request(method, params);
  if (res != null && res.containsKey(EthereumConstants.ethResultKey)) {
    if (res[EthereumConstants.ethResultKey] != null) {
      return EthereumUtilities.hexToInt(res[EthereumConstants.ethResultKey]);
    } else {
      return 0;
    }
  }
  _client.processError(method, res);
  return null;
}