swap_coldkey
Call v156 → v160, v161 → v165, v195 → v219, v233 → v298, v301 → v385, v391 → current #71Swaps coldkey to a new address (immediate).
View calls on chainCall Workflow
Click items to navigate. Pan and zoom to explore.
The Big Picture
Your coldkey controls everything - stake, registrations, earnings. If it's compromised or you need to migrate urgently, swap_coldkey moves all ownership to a new address immediately. This is the emergency option - faster but with less protection than schedule_swap_coldkey. Use when speed matters more than arbitration safety.
Why This Matters
If an attacker has your coldkey, every second counts. swap_coldkey executes immediately - no waiting period. The tradeoff: no arbitration window means you can't dispute a malicious swap. Only use if you're confident you're the rightful owner.
Example Scenario
Your coldkey's mnemonic may have been exposed. You generate a new coldkey on a hardware wallet. Call swap_coldkey(old_coldkey, new_coldkey) immediately. All your stake, registrations, and associations transfer to the new key in one block. The compromised key now controls nothing.
Common Questions
- What's the difference between swap and schedule_swap?
- swap_coldkey is immediate. schedule_swap_coldkey has a waiting period where disputes can be raised. Use swap for emergencies, schedule_swap for planned migrations.
- What exactly transfers?
- Everything: all stake positions, all hotkey associations, delegate ownership, subnet ownership, pending emissions - the new coldkey becomes you.
- Can I reverse a coldkey swap?
- No. Once executed, it's permanent. The old coldkey has no special recovery rights. Triple-check the destination address before submitting.
- Is there a fee for immediate swap?
- Yes - higher than scheduled swap. The fee discourages casual use and helps prevent abuse. Emergency security is worth paying for.
Use Cases
- Emergency key rotation after suspected compromise
- Migrate to a hardware wallet immediately
- Transfer all assets to a new address in one operation
- Security upgrade when time is critical
From Chain Metadata
Performs an arbitrary coldkey swap for any coldkey. Only callable by root as it doesn't require an announcement and can be used to swap any coldkey.
Migration Notes
removed field old_coldkey (was AccountId)
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.
added field old_coldkey (AccountId)
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.
added field swap_cost (u64)
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.
Input Parameters
Permissions
- Signer is the current coldkey being swapped away from
Requirements
- Caller is current coldkey owner
- Swap conditions met
- Required fee paid
Effects
Events Emitted
Storage Modified
Postconditions
- All stake/associations transferred
- Old coldkey loses control
- New coldkey gains all ownership
Side Effects
- Immediate transfer of all ownership
- Cannot be reversed after execution
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);
// Build swap_coldkey call (typed, named args)
const old_coldkey = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
const new_coldkey = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
const swap_cost = 1_000_000_000n;
const tx = api.tx.SubtensorModule.swap_coldkey({
old_coldkey,
new_coldkey,
swap_cost,
});On-Chain Activity
Infrequent
#48 most used call
Under 5% succeed — vast majority fail due to competition
As of block 7,429,232
Version History
Runtime Info
View Source- Pallet Index
- 7
- Call Index
- 71
- First Version
- v156
- Current Version
- v411