state_getPairs - Bittensor RPC Method
Get storage key-value pairs by prefix on Bittensor. Returns both keys and their SCALE-encoded values.
Returns all storage key-value pairs matching a given prefix. Each entry in the result contains both the full storage key and its SCALE-encoded value. Like state_getKeys, this method loads all matching pairs into memory at once and can be problematic for large storage maps.
Note: For large storage maps, consider using
state_getKeysPagedto enumerate keys and thenstate_getStorageorstate_queryStorageAtto fetch values in batches.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
prefix | string | Yes | Hex-encoded storage key prefix. |
blockHash | string | No | Hex-encoded block hash. Defaults to the best block if omitted. |
Response
| Field | Type | Description |
|---|---|---|
result | array | Array of [key, value] tuples where both are hex-encoded strings. Values are SCALE-encoded. |
Code Examples
Use Cases
- Small map export -- Dump all entries from a storage map that is known to be small for analysis or migration.
- Development and debugging -- Quickly inspect the contents of a storage prefix during development.
- State snapshots -- Export a specific subset of on-chain state for offline analysis of Bittensor subnet data, staking maps, or other pallet storage.
Notes
- Returns all matching pairs in a single response. For large maps this can cause memory exhaustion or timeouts.
- Values are SCALE-encoded. Decode them using the type information from runtime metadata.
- For production use with large maps, prefer paginated approaches: enumerate keys with
state_getKeysPaged, then batch-fetch values withstate_queryStorageAt. - Requires an archive node for historical block hashes.
Related Methods
state_getKeysPaged-- Paginated key enumeration (safer for large maps)state_getStorage-- Read a single storage value by keystate_queryStorageAt-- Batch-read multiple storage values at a blockstate_getKeys-- Get keys only (without values), also deprecated for large maps