getStorageAt method

Future<EthereumData?> getStorageAt(
  1. EthereumAddress? address,
  2. int? pos,
  3. EthereumDefaultBlock? block
)

Get Storage at, the value from a storage position at a given address. Parameters are the address of the storage, the integer position of the storage and the default block parameter.

Implementation

Future<EthereumData?> getStorageAt(
    EthereumAddress? address, int? pos, EthereumDefaultBlock? block) async {
  if (address == null) {
    throw ArgumentError.notNull('Ethereum::getStorageAt - address');
  }
  if (pos == null) {
    throw ArgumentError.notNull('Ethereum::getStorageAt - pos');
  }
  if (block == null) {
    throw ArgumentError.notNull('Ethereum::getStorageAt - block');
  }
  const method = EthereumRpcMethods.storageAt;
  final blockString = block.getSelection();
  final params = <String?>[
    address.asString,
    EthereumUtilities.intToHex(pos),
    blockString
  ];
  final dynamic res = await _client.rpcClient.request(method, params);
  if (res != null && res.containsKey(EthereumConstants.ethResultKey)) {
    return EthereumData.fromString(res[EthereumConstants.ethResultKey]);
  }
  _client.processError(method, res);
  return null;
}