getUncleCountByNumber method

Future<int?> getUncleCountByNumber(
  1. EthereumDefaultBlock? blockNumber
)

Block Uncle Count By Number The number of uncles in a block matching the given block number. If the method returns null a count of 0 is returned, this is to distinguish between this and an error.

Implementation

Future<int?> getUncleCountByNumber(EthereumDefaultBlock? blockNumber) async {
  if (blockNumber == null) {
    throw ArgumentError.notNull(
        'Ethereum::getUncleCountByNumber - blockNumber');
  }
  const method = EthereumRpcMethods.blockUncleCountByBlockNumber;
  final blockString = blockNumber.getSelection();
  final params = <String?>[blockString];
  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;
}