Transactions

announce-coldkey-swap

Announce (commit to) a coldkey swap; executable after the chain's delay.

View as Markdown

Step one of the two-step coldkey migration: publishes new_coldkey_ss58 (validated before any fee — destination must not be a hotkey, must not hold active locks, and the combined swap work must fit one call) and starts the chain's announcement delay. After the delay, run the swap_coldkey_announced intent to move EVERYTHING this coldkey owns (balance, stake, subnets) to the new key, merging with any assets the destination already holds; check timing with the coldkey_swap_announcement read. Every announcement, including a re-announcement after the chain's reannouncement delay, charges the key-swap cost (0.1 TAO, recycled). While an announcement is pending, the chain blocks every other signed extrinsic from this coldkey — only the swap-related calls and shielded (encrypted) submission go through — so the account is operationally locked for the full delay. Before announcing, be certain you control the new coldkey and have its mnemonic backed up. A pending announcement can be cancelled with clear_coldkey_swap_announcement, and the legitimate holder can freeze an unauthorized one with dispute_coldkey_swap.

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

Parameters

ParameterTypeRequiredDescription
new_coldkey_ss58stringyesColdkey that will take over everything this coldkey owns once the swap executes; validated and reserved before the announcement fee is charged.

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 announce-coldkey-swap \
  --new-coldkey <ss58|name> --dry-run
btcli tx announce-coldkey-swap \
  --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.AnnounceColdkeySwap(new_coldkey_ss58="5G...destination")

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("announce_coldkey_swap", {...}, wallet)

On-chain implementation

SubtensorModule.announce_coldkey_swap_v2 — pallets/subtensor/src/macros/dispatches.rs#L2461:

#[pallet::call_index(155)]
#[pallet::weight(
    <T as crate::pallet::Config>::WeightInfo::announce_coldkey_swap_v2()
        .saturating_add(Pallet::<T>::announce_coldkey_swap_v2_admission_weight())
)]
pub fn announce_coldkey_swap_v2(
    origin: OriginFor<T>,
    new_coldkey: T::AccountId,
) -> DispatchResult {
    let who = ensure_signed(origin)?;
    let now = <frame_system::Pallet<T>>::block_number();

    // Refuse destinations that execution would still reject, before the fee.
    let _ = Self::ensure_coldkey_swap_destination(&who, &new_coldkey)
        .map_err(|(_weight, error)| error)?;
    // Also refuse a destination another announcer already reserved —
    // before the fee, so a conflict cannot burn the swap cost.
    Self::ensure_coldkey_swap_destination_reservable(&who, &new_coldkey)?;
    // Snapshot destination presence before the delay. Otherwise anyone
    // can transfer dust to a blank destination after announce and make
    // execution silently discard the source's auto-stake policy.
    let import_source_policies =
        !Self::coldkey_rejects_unsolicited_policy_import(&new_coldkey);

    if let Some((when, _)) = ColdkeySwapAnnouncements::<T>::get(who.clone()) {
        let reannouncement_delay = ColdkeySwapReannouncementDelay::<T>::get();
        let min_when = when.saturating_add(reannouncement_delay);
        ensure!(now >= min_when, Error::<T>::ColdkeySwapReannouncedTooEarly);
    }
    // Each call creates or renews a destination reservation, so a free
    // reannouncement would let anyone hold an account reserved forever.
    Self::charge_swap_cost(&who, Self::get_key_swap_cost())?;

    // Reserve the destination for the delay so a third party cannot
    // register it as a hotkey and force NewColdKeyIsHotkey at execute.
    Self::reserve_coldkey_swap_destination(&who, &new_coldkey)?;

    let new_coldkey_hash =
        Self::coldkey_swap_v2_announcement_hash(&new_coldkey, import_source_policies);
    let delay = ColdkeySwapAnnouncementDelay::<T>::get();
    let when = now.saturating_add(delay);
    ColdkeySwapAnnouncements::<T>::insert(who.clone(), (when, new_coldkey_hash.clone()));
    ColdkeySwapV2PolicySnapshots::<T>::insert(&who, import_source_policies);

    Self::deposit_event(Event::ColdkeySwapAnnounced {
        who,
        new_coldkey_hash,
    });
    Ok(())
}

Delegates to ensure_coldkey_swap_destination, ensure_coldkey_swap_destination_reservable, coldkey_rejects_unsolicited_policy_import.

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