queryStorage method

Future<List<StorageChangeSet>> queryStorage(
  1. List<StorageKey> keys,
  2. BlockHash fromBlock, {
  3. BlockHash? toBlock,
})

Query historical storage entries (by key) starting from a block given as the second parameter.

NOTE This first returned result contains the initial state of storage for all keys. Subsequent values in the vector represent changes to the previous state (diffs).

Implementation

Future<List<StorageChangeSet>> queryStorage(
    List<StorageKey> keys, BlockHash fromBlock,
    {BlockHash? toBlock}) async {
  final List<dynamic> params = [
    keys.map((key) => '0x${hex.encode(key)}').toList(),
    '0x${hex.encode(fromBlock)}'
  ];
  if (toBlock != null) {
    params.add('0x${hex.encode(toBlock)}');
  }
  final response = await _provider.send('state_queryStorage', params);
  return (response.result as List)
      .cast<Map<String, dynamic>>()
      .map((changeSet) => StorageChangeSet.fromJson(changeSet))
      .toList();
}