getStorageAt method Null safety

Future<EtherScanRpcResponseModel> getStorageAt (
  1. {required String address,
  2. required String position,
  3. String? tag}
)

Returns the value from a storage position at a given address.

address - Address to get code from

position - Storage position

tag - ??

Example

var res = eth.getStorageAt(
    address: '0x6e03d9cce9d60f3e9f2597e13cd4c54c55330cfd',
    position:'0x0',
    tag: 'latest'
);

Implementation

Future<EtherScanRpcResponseModel> getStorageAt({
  required String address,
  required String position,
  String? tag,
}) async {
  const module = 'proxy';
  const action = 'eth_getStorageAt';

  Map<String, dynamic>? query = {
    'apiKey': apiKey,
    'module': module,
    'action': action,
    'address': address,
    'position': position,
  };

  if (tag != null) {
    query.putIfAbsent('tag', () => tag);
  }

  return (await get(query)).fold(
    (l) => EtherScanRpcResponseModel.empty(),
    (r) => EtherScanRpcResponseModel.fromJson(r),
  );
}