swap_coldkey

Call v156 → v160, v161 → v165, v195 → v219, v233 → v298, v301 → v385, v391 → 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

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

v160 v161 Breaking

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.

v165 v195 Breaking

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.

v219 v233 Breaking

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

#NameTypeDescription
0
old_coldkey
AccountId old_coldkey: Account address (32 bytes, SS58-encoded) (hex -> SS58)
1
new_coldkey
AccountId new_coldkey: Account address (32 bytes, SS58-encoded) (hex -> SS58)
2
swap_cost
u64 TaoBalanceswap_cost: TAO amount in RAO (÷10⁹ for TAO) (RAO -> TAO (/ 10^9))

Permissions

Origin
Unknown
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 { 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

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
v301 block 6,205,194 3 args
v391 block 7,782,857 3 args Current

Runtime Info

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