⚠️Blast API (blastapi.io) ends Oct 31. Migrate to Dwellir and skip Alchemy's expensive compute units.
Switch Today →
Skip to main content

state_getKeysPaged

Retrieves storage keys in a paginated fashion. Use this when enumerating large data sets such as zkSBT issuance records or identity credential registries.

Parameters

ParameterTypeRequiredDescription
keyPrefixstringYesHex-encoded storage key prefix to match.
countnumberYesMax keys to return in this page.
startKeystringNoResume pagination from this key (exclusive). Use the last key from the previous page.
atstringNoOptional block hash for historical queries.

Returns

FieldTypeDescription
resultarrayHex-encoded keys for the current page.

Paginated Scan Example

import { ApiPromise, WsProvider } from '@polkadot/api';

const provider = new WsProvider('wss://api-manta-atlantic-mainnet.n.dwellir.com/YOUR_API_KEY');
const api = await ApiPromise.create({ provider });

const prefix = api.query.zksbt.issuances.keyPrefix();
let startKey: string | null = null;
const pageSize = 100;

while (true) {
const keys = await api.rpc.state.getKeysPaged(prefix.toHex(), pageSize, startKey);
if (!keys.length) break;

console.log('Fetched', keys.length, 'keys');
startKey = keys[keys.length - 1];
}

Raw JSON-RPC

{
"jsonrpc": "2.0",
"method": "state_getKeysPaged",
"params": [
"0x3a636f6465",
256,
null
],
"id": 1
}

Operational Tips

  • Tune count to stay below your endpoint's payload limit (128–256 entries per page works well for Atlantic).
  • Always persist startKey so you can resume scans after interruptions.
  • Use finalized block hashes when exporting snapshots for compliance or analytics.