--- title: "announce-coldkey-swap" description: "Announce (commit to) a coldkey swap; executable after the chain's delay." --- {/* GENERATED by scripts/generate.py from the SDK registries — do not edit. */} 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`. | Signer | Origin | Pallet | Wraps | | --- | --- | --- | --- | | `coldkey` | signed account (pallet role may apply) | SubtensorModule | [`SubtensorModule.announce_coldkey_swap_v2`](/code/pallets/subtensor/src/macros/dispatches.rs#L2499-L2547) | ## Parameters | Parameter | Type | Required | Description | | --- | --- | --- | --- | | `new_coldkey_ss58` | string | yes | Coldkey that will take over everything this coldkey owns once the swap executes; validated and reserved before the announcement fee is charged. | | `hashed_descriptor` | string | no | Public descriptor hex for a remote hashed destination's registration. | 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: ```bash btcli tx announce-coldkey-swap \ --new-coldkey --dry-run btcli tx announce-coldkey-swap \ --new-coldkey -w my_coldkey ``` ## Python ```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](/docs/concepts/client).) Or build the intent by op name, as an agent would: ```python result = sub.execute_tool("announce_coldkey_swap", {...}, wallet) ``` ## On-chain implementation `SubtensorModule.announce_coldkey_swap_v2` — [`pallets/subtensor/src/macros/dispatches.rs#L2504`](/code/pallets/subtensor/src/macros/dispatches.rs#L2499-L2547): ```rust #[pallet::call_index(155)] #[pallet::weight( ::WeightInfo::announce_coldkey_swap_v2() .saturating_add(Pallet::::announce_coldkey_swap_v2_admission_weight()) )] pub fn announce_coldkey_swap_v2( origin: OriginFor, new_coldkey: T::AccountId, ) -> DispatchResult { let who = ensure_signed(origin)?; let now = >::block_number(); // Refuse destinations that execution would still reject, before the fee. let work = 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)?; // Bind the balance-sensitive swap decisions before funds can change. let policy = Self::coldkey_swap_announcement_policy(&new_coldkey, &work); if let Some((when, _)) = ColdkeySwapAnnouncements::::get(who.clone()) { let reannouncement_delay = ColdkeySwapReannouncementDelay::::get(); let min_when = when.saturating_add(reannouncement_delay); ensure!(now >= min_when, Error::::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, policy.import_source_policies, ); let delay = ColdkeySwapAnnouncementDelay::::get(); let when = now.saturating_add(delay); ColdkeySwapAnnouncements::::insert(who.clone(), (when, new_coldkey_hash.clone())); Self::set_coldkey_swap_v2_policy_snapshot(&who, Some(policy)); Self::deposit_event(Event::ColdkeySwapAnnounced { who, new_coldkey_hash, }); Ok(()) } ``` Delegates to [`ensure_coldkey_swap_destination`](/code/pallets/subtensor/src/swap/swap_coldkey.rs#L719), [`ensure_coldkey_swap_destination_reservable`](/code/pallets/subtensor/src/swap/swap_coldkey.rs#L281), [`coldkey_swap_announcement_policy`](/code/pallets/subtensor/src/swap/swap_coldkey.rs#L564). Every file is browsable under [/code](/code) exactly as built into the runtime, or as plain text under `/code/raw/` (index: [`/code/index.json`](/code/index.json)).