HotkeySwapped
Event Re-added v136 → v141, v142 → v148, v149 → v165, v195 → v219, v233 → v247, v252 → v265, v273 → v277, v290 → v315, v320 → v326, v334 → v367, v372 → current #64Emitted when a hotkey is swapped to a new address.
View events on chainThe Big Picture
Your hotkey is your operational identity - it holds UIDs, receives stake, and runs your miner/validator. Hotkey swap lets you change this identity without losing everything. All registrations, all stakers, all UIDs move to the new hotkey. Essential for key rotation or if you suspect compromise.
Why This Matters
Your hotkey is exposed to the network (validators query it, it's on-chain). If it's compromised, a swap lets you move everything to a fresh key without re-registering on every subnet and asking all your stakers to restake.
Example Scenario
Your validator hotkey might be compromised. You generate new_hotkey and call swap_hotkey. HotkeySwapped fires showing old→new. Your 5 subnet registrations, 10,000 TAO delegated stake, and served axon all move to new_hotkey automatically.
Common Questions
- Do my stakers need to do anything?
- No, their stake follows the hotkey automatically. From their perspective, nothing changes - they're still staked to 'you', just at a new address.
- What happens to my UIDs?
- They're preserved. UID 47 on subnet 1 is still your UID 47, just associated with the new hotkey now.
Use Cases
- Migrate to a new hotkey without losing registrations
- Rotate hotkey for security
- Track hotkey changes for stake monitoring
- Detect when validators change operational keys
How to Use This Event
- → Monitor validators you're staked to for hotkey changes
- → Track your own hotkey swaps for confirmation
- → Build hotkey history tracking tools
From Chain Metadata
the hotkey is swapped
Triggers
Emitted by
Preconditions
- Caller owns the original hotkey
- New hotkey is not already in use
Effects
Storage Modified
Postconditions
- All registrations transferred to new hotkey
- All stake associations updated
- Old hotkey becomes unused
Side Effects
- Updates Keys storage on all subnets
- Updates Axons/Prometheus if served
Event Data
Code Examples
import { ApiPromise, WsProvider } from "@polkadot/api";
import { stringCamelCase } from "@polkadot/util";
const provider = new WsProvider("wss://entrypoint-finney.opentensor.ai:443");
const api = await ApiPromise.create({ provider });
// Subscribe to HotkeySwapped events
api.query.system.events((events) => {
events
.filter(({ event }) =>
event.section === stringCamelCase("SubtensorModule") &&
event.method === "HotkeySwapped"
)
.forEach(({ event }) => {
console.log("HotkeySwapped:", event.data.toHuman());
});
});Version History
Runtime Info
View Source- Pallet Index
- 7
- Event Index
- 64
- First Version
- v136
- Current Version
- v393