getKeysPaged method

Future<List<StorageKey>> getKeysPaged({
  1. required StorageKey key,
  2. required int count,
  3. StorageKey? startKey,
  4. BlockHash? at,
})

Returns the keys with prefix with pagination support. Up to count keys will be returned. If startKey is passed, return next keys in storage in lexicographic order.

Implementation

Future<List<StorageKey>> getKeysPaged(
    {required StorageKey key,
    required int count,
    StorageKey? startKey,
    BlockHash? at}) async {
  final List<dynamic> params = ['0x${hex.encode(key)}', count];
  if (startKey != null) {
    params.add('0x${hex.encode(startKey)}');
  }
  if (at != null) {
    if (startKey == null) {
      params.add(null);
    }
    params.add('0x${hex.encode(at)}');
  }
  final response = await _provider.send('state_getKeysPaged', params);
  return (response.result as List)
      .cast<String>()
      .map((key) => Uint8List.fromList(hex.decode(key.substring(2))))
      .toList();
}