# swap-coldkey-announced (/docs/tx/swap-coldkey-announced)

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.

| Signer    | Origin                                 | Pallet          | Wraps                                                                                                    |
| --------- | -------------------------------------- | --------------- | -------------------------------------------------------------------------------------------------------- |
| `coldkey` | signed account (pallet role may apply) | SubtensorModule | [`SubtensorModule.swap_coldkey_announced`](/code/pallets/subtensor/src/macros/dispatches.rs#L2023-L2045) |

## Parameters [#parameters]

| Parameter          | Type   | Required | Description                                                                     |
| ------------------ | ------ | -------- | ------------------------------------------------------------------------------- |
| `new_coldkey_ss58` | string | yes      | Coldkey 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 [#cli]

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

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

## Python [#python]

```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](/docs/concepts/client).) Or build the intent by op name, as
an agent would:

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

## On-chain implementation [#on-chain-implementation]

`SubtensorModule.swap_coldkey_announced` — [`pallets/subtensor/src/macros/dispatches.rs#L2025`](/code/pallets/subtensor/src/macros/dispatches.rs#L2023-L2045):

```rust
#[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`](/code/pallets/subtensor/src/swap/swap_coldkey.rs#L8).

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