Keys

Storage Map v101 → v490 · 1 shape change

Hotkey at a specific UID on a subnet .

Explore chain
Queried by: minersvalidatorssubnet ownersdevelopersanalytics

The Big Picture

UIDs are the internal identifiers for neurons on a subnet. Keys maps UID→hotkey, while Uids maps hotkey→UID. Together they let you look up neurons in either direction.

Why This Matters

When you see 'UID 47 on subnet 1', this tells you which hotkey that is. Essential for understanding who's who on a subnet.

Example Scenario

Query Keys(netuid=1, uid=47) returns the hotkey address for UID 47 on subnet 1. Now you know which validator or miner that UID represents.

Common Questions

What if the UID doesn't exist?
Returns a default value (zero address). Check SubnetworkN to see valid UID range.

Use Cases

  • Find which hotkey holds a specific UID
  • List all registered neurons on a subnet
  • Map UIDs to addresses for indexing

From Chain Metadata

DMAP ( netuid, uid ) --> hotkey

Purpose & Usage

Purpose

Reverse lookup from UID to hotkey address.

Common Query Patterns

  • Get hotkey for a UID on a subnet
  • Iterate all registered hotkeys on a subnet
Part of: Neuron RegistrationNeuron Pruning

Migration Notes

v424 v432 Breaking

key type changed from (u16, u16) to (NetUid, u16)

Update decoders: SCALE encoding is positional, so any signature change (added, removed, or type-changed fields, or storage shape changes) shifts byte offsets and existing decoders will misparse this item. Re-derive types from the new metadata.

Query Keys

#NameTypeDescription
1
netuid
NetUid Subnet ID (NetUid; unlike Weights and LastUpdate, Keys is not on the NetUidStorageIndex remap)
2
uid
u16 Neuron UID

Stored Value

Hotkey address registered at this UID

Default Value

0x0000000000000000000000000000000000000000000000000000000000000000 (raw SCALE bytes)

Absent keys read as this value — querying a key that has never been written returns this default, not an error or empty result.

Decoding the value

AccountId (32-byte hex)

Bittensor uses SS58 prefix 42 for both hotkeys and coldkeys. The 32 bytes are sr25519 public keys.

value as `0x${string}` // 32-byte AccountId

Relationships

Code Examples

import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Query Keys storage
const netuid = 1;
const uid = 0;

const result = await api.query.SubtensorModule.Keys.getValue(netuid, uid);
console.log("Keys:", result);

On-Chain Activity

Write Frequency
●●●●●○ High 1M–10M est. writes

1M to 10M writes

#130 most written storage item

Write Source Calls + Hooks

Modified by both user extrinsics and runtime hooks

As of block 9,385,000

Version History

v101 block 1 Added
v425–v431 · runtime versions skipped on chain (never deployed)
v432 block 8,636,190 Shape changed Current
  • key : (u16, u16) → (NetUid, u16)

Runtime Info

View Source
Pallet
SubtensorModule
Storage Kind
Map
First Version
v101
Current Version
v490