Docs

state_getKeys - Bittensor RPC Method

List storage keys matching a prefix on Bittensor. Deprecated in favor of state_getKeysPaged.

Returns all storage keys matching a given prefix. This method loads all matching keys into memory at once, which can be problematic for large storage maps. It is deprecated in favor of state_getKeysPaged, which supports cursor-based pagination and is safer for production use.

Deprecated: Use state_getKeysPaged instead. This method may cause memory issues or timeouts on large storage maps.

Parameters

ParameterTypeRequiredDescription
prefixstringYesHex-encoded storage key prefix. Use the pallet's key prefix to list all keys in a storage map.
blockHashstringNoHex-encoded block hash. Defaults to the best block if omitted.

Response

FieldTypeDescription
resultarrayArray of all hex-encoded storage keys matching the prefix.

Code Examples

Use Cases

  • Small storage maps -- Enumerate all keys in a storage map that you know to be small (e.g. a map with fewer than 1000 entries).
  • Quick exploration -- Inspect which keys exist under a prefix during development or debugging.

Notes

  • This method returns all matching keys in a single response. For large maps (like System.Account on Bittensor), this can cause memory exhaustion or timeouts.
  • Always prefer state_getKeysPaged for production code. It returns keys in pages and handles large maps safely.
  • Requires an archive node for historical block hashes.