getBlockByHash method

Future<EthereumBlock?> getBlockByHash(
  1. EthereumData? blockHash, {
  2. bool full = true,
})

Get block by hash Returns information about a block by hash Hash of a block and a boolean, if true it returns the full transaction objects, if false only the hashes of the transactions, defaults to true. Returns A block object, or null when no block was found :

Implementation

Future<EthereumBlock?> getBlockByHash(EthereumData? blockHash,
    {bool full = true}) async {
  if (blockHash == null) {
    throw ArgumentError.notNull('Ethereum::getBlockByHash - blockHash');
  }
  final dynamic params = <dynamic>[blockHash.asString, full];
  const method = EthereumRpcMethods.getBlockByHash;
  final dynamic res = await _client.rpcClient.request(method, params);
  if (res != null && res.containsKey(EthereumConstants.ethResultKey)) {
    return EthereumBlock.fromMap(res[EthereumConstants.ethResultKey]);
  }
  _client.processError(method, res);
  return null;
}