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
Migration Notes
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
Stored Value
Hotkey address registered at this UID
Default Value
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 AccountIdRelationships
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
1M to 10M writes
#130 most written storage item
Modified by both user extrinsics and runtime hooks
As of block 9,385,000
Version History
- key :
(u16, u16)→(NetUid, u16)
Runtime Info
View Source- Pallet
- SubtensorModule
- Storage Kind
- Map
- First Version
- v101
- Current Version
- v490