swap_coldkey
Call Re-added v156 → v160, v161 → v165, v195 → v219, v233 → 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
The extrinsic for user to change the coldkey associated with their account.
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 { 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 });
// Build swap_coldkey call
const old_coldkey = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
const new_coldkey = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
const swap_cost = 1_000_000_000n;
const call = api.tx[stringCamelCase("SubtensorModule")][stringCamelCase("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
- v393