Transactions

swap-coldkey-announced

Execute a previously announced coldkey swap (after the delay has passed).

View as Markdown

Step two of the two-step migration: reveals the new coldkey and moves everything the signing coldkey owns — balance, stake, and subnet ownership — to it. Irreversible once included. The revealed key must hash to exactly what announce_coldkey_swap committed to, and the call fails if the announcement delay has not elapsed, no announcement exists, or the swap is frozen by a dispute. After it succeeds, the old coldkey is empty; all future operations sign with the new coldkey.

SignerOriginPalletWraps
coldkeysigned account (pallet role may apply)SubtensorModuleSubtensorModule.swap_coldkey_announced

Parameters

ParameterTypeRequiredDescription
new_coldkey_ss58stringyesColdkey receiving everything; must match the previously announced hash exactly.

Address parameters (--hotkey, --coldkey, --dest, ...) accept a raw ss58 address, an address-book or proxy-book name, or a local wallet/hotkey name.

CLI

Preview with --dry-run (shows fee, effects, and policy result without submitting), then submit:

btcli tx swap-coldkey-announced \
  --new-coldkey <ss58|name> --dry-run
btcli tx swap-coldkey-announced \
  --new-coldkey <ss58|name> -w my_coldkey

Python

import bittensor as bt
from bittensor.wallet import Wallet

wallet = Wallet(name="my_coldkey", hotkey="my_hotkey")
intent = bt.SwapColdkeyAnnounced(new_coldkey_ss58="5F...")

sub = bt.Subtensor()
plan = sub.plan(intent, wallet)   # fee, effects, policy — no submission
result = sub.execute(intent, wallet)
if not result.success:
    print(result.error.code, result.error.remediation)

(bt.Subtensor is also the async client — async with bt.Subtensor() as client: — see The client.) Or build the intent by op name, as an agent would:

result = sub.execute_tool("swap_coldkey_announced", {...}, wallet)

On-chain implementation

SubtensorModule.swap_coldkey_announcedpallets/subtensor/src/macros/dispatches.rs#L2025:

#[pallet::call_index(126)]
#[pallet::weight(<T as crate::pallet::Config>::WeightInfo::swap_coldkey_announced())]
pub fn swap_coldkey_announced(
    origin: OriginFor<T>,
    new_coldkey: T::AccountId,
) -> DispatchResult {
    let who = ensure_signed(origin)?;

    let (when, new_coldkey_hash) = ColdkeySwapAnnouncements::<T>::take(who.clone())
        .ok_or(Error::<T>::ColdkeySwapAnnouncementNotFound)?;

    ensure!(
        new_coldkey_hash == T::Hashing::hash_of(&new_coldkey),
        Error::<T>::AnnouncedColdkeyHashDoesNotMatch
    );

    let now = <frame_system::Pallet<T>>::block_number();
    ensure!(now >= when, Error::<T>::ColdkeySwapTooEarly);

    Self::do_swap_coldkey(&who, &new_coldkey)?;

    Ok(())
}

Delegates to do_swap_coldkey.

Every file is browsable under /code exactly as built into the runtime, or as plain text under /code/raw/<path> (index: /code/index.json).