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 #64

Emitted when a hotkey is swapped to a new address.

View events on chain
Useful for: minersvalidatorsstakersanalytics

The 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

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

#NameTypeDescription
0
coldkey
AccountId Cold wallet address (offline storage) (hex -> SS58)
1
old_hotkey
AccountId old_hotkey (AccountId) (hex -> SS58)
2
new_hotkey
AccountId new_hotkey (AccountId) (hex -> SS58)

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

v136 block 1,756,781 3 args
v142 block 2,543,779 3 args
v149 block 3,014,339 3 args
v195 block 3,791,350 3 args
v233 block 4,920,350 3 args
v252 block 5,163,656 3 args
v273 block 5,659,032 3 args
v290 block 5,947,548 3 args
v320 block 6,523,566 3 args
v334 block 6,811,690 3 args
v372 block 7,430,358 3 args Current

Runtime Info

View Source
Pallet Index
7
Event Index
64
First Version
v136
Current Version
v393