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
Parameter | Type | Required | Description |
---|---|---|---|
keyPrefix | string | Yes | Hex-encoded storage key prefix to match. |
count | number | Yes | Max keys to return in this page. |
startKey | string | No | Resume pagination from this key (exclusive). Use the last key from the previous page. |
at | string | No | Optional block hash for historical queries. |
Returns
Field | Type | Description |
---|---|---|
result | array | Hex-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.