Docs

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_getKeysPaged to enumerate keys and then state_getStorage or state_queryStorageAt to fetch values in batches.

Parameters

ParameterTypeRequiredDescription
prefixstringYesHex-encoded storage key prefix.
blockHashstringNoHex-encoded block hash. Defaults to the best block if omitted.

Response

FieldTypeDescription
resultarrayArray 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 with state_queryStorageAt.
  • Requires an archive node for historical block hashes.