swap_coldkey

Call Re-added v156 → v160, v161 → v165, v195 → v219, v233 → current #71

Swaps coldkey to a new address (immediate).

View calls on chain

Click items to navigate. Pan and zoom to explore.

Used by: validatorsstakerswalletsdevelopers

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

#NameTypeDescription
0
old_coldkey
AccountId old_coldkey (AccountId) (hex -> SS58)
1
new_coldkey
AccountId new_coldkey (AccountId) (hex -> SS58)
2
swap_cost
u64 swap_cost (u64) (RAO -> TAO (/ 10^9))

Permissions

Origin
Signed
Required Role
Authorization Checks
  • Signer is the current coldkey being swapped away from

Requirements

  • Caller is current coldkey owner
  • Swap conditions met
  • Required fee paid

Effects

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

Usage Frequency
●●○○○○ Low 1K–10K extrinsics

Infrequent

#48 most used call

Success Rate Highly competitive

Under 5% succeed — vast majority fail due to competition

As of block 7,429,232

Version History

v156 block 3,321,841 2 args
v161 block 3,351,936 1 args
v195 block 3,791,350 2 args
v233 block 4,920,350 3 args Current

Runtime Info

View Source
Pallet Index
7
Call Index
71
First Version
v156
Current Version
v393