getBlockByNumber method

Future<EthereumBlock?> getBlockByNumber(
  1. EthereumDefaultBlock? blockNumber, {
  2. bool full = true,
})

Get block by number Returns information about a block by block number. blockNumber - defualt block parameter as in the default block parameter. A boolean, if true it returns the full transaction objects, if false only the hashes of the transactions, defaults to true. Returns See getBlockByHash

Implementation

Future<EthereumBlock?> getBlockByNumber(EthereumDefaultBlock? blockNumber,
    {bool full = true}) async {
  if (blockNumber == null) {
    throw ArgumentError.notNull('Ethereum::getBlockByNumber - blockNumber');
  }
  final blockString = blockNumber.getSelection();
  final dynamic params = <dynamic>[blockString, full];
  const method = EthereumRpcMethods.getBlockByNumber;
  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;
}