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_getKeysPagedinstead. This method may cause memory issues or timeouts on large storage maps.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
prefix | string | Yes | Hex-encoded storage key prefix. Use the pallet's key prefix to list all keys in a storage map. |
blockHash | string | No | Hex-encoded block hash. Defaults to the best block if omitted. |
Response
| Field | Type | Description |
|---|---|---|
result | array | Array 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.Accounton Bittensor), this can cause memory exhaustion or timeouts. - Always prefer
state_getKeysPagedfor production code. It returns keys in pages and handles large maps safely. - Requires an archive node for historical block hashes.
Related Methods
state_getKeysPaged-- Paginated key enumeration (recommended replacement)state_getStorage-- Read the value for a specific keystate_getPairs-- Get key-value pairs for a prefix (also deprecated)state_getMetadata-- Get runtime metadata to determine storage key prefixes
state_call
Call a runtime API function on Bittensor. Execute on-chain computations like account nonce lookups, fee estimation, and custom runtime logic without submitting a transaction.
state_getKeysPaged
Enumerate storage keys with pagination on Bittensor. Iterate over storage maps like accounts, validators, and assets efficiently with cursor-based pagination.