Transactions
swap-coldkey-announced
Execute a previously announced coldkey swap (after the delay has passed).
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 |
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
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_coldkeyPython
import bittensor as bt
from bittensor.wallet import Wallet
wallet = Wallet(name="my_coldkey", hotkey="my_hotkey")
intent = bt.SwapColdkeyAnnounced(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("swap_coldkey_announced", {...}, wallet)On-chain implementation
SubtensorModule.swap_coldkey_announced — pallets/subtensor/src/macros/dispatches.rs#L2406:
#[pallet::call_index(126)]
#[pallet::weight((Pallet::<T>::swap_coldkey_announced_declared_weight(), DispatchClass::Normal, Pays::Yes))]
pub fn swap_coldkey_announced(
origin: OriginFor<T>,
new_coldkey: T::AccountId,
) -> DispatchResultWithPostInfo {
let who = ensure_signed(origin)?;
// A swap refused by the announcement checks read one row; charge that plus
// the benchmarked base, not the envelope of `MAX_COLDKEY_SWAP_POSITIONS`
// stake transfers.
let base = <T as crate::pallet::Config>::WeightInfo::swap_coldkey_announced();
let precheck = base.saturating_add(T::DbWeight::get().reads(1));
let (when, new_coldkey_hash) = ColdkeySwapAnnouncements::<T>::take(who.clone()).ok_or(
Self::fail_with_weight(Error::<T>::ColdkeySwapAnnouncementNotFound, precheck),
)?;
ensure!(
new_coldkey_hash == T::Hashing::hash_of(&new_coldkey),
Self::fail_with_weight(Error::<T>::AnnouncedColdkeyHashDoesNotMatch, precheck)
);
let now = <frame_system::Pallet<T>>::block_number();
ensure!(
now >= when,
Self::fail_with_weight(Error::<T>::ColdkeySwapTooEarly, precheck)
);
let work =
Self::do_swap_coldkey_tracked(&who, &new_coldkey).map_err(|(done, error)| {
Self::fail_with_weight(error, base.saturating_add(done))
})?;
Ok((
Some(Self::swap_coldkey_announced_actual_weight(work)),
Pays::Yes,
)
.into())
}Delegates to fail_with_weight, do_swap_coldkey_tracked, swap_coldkey_announced_actual_weight.
Every file is browsable under /code exactly as built into the runtime, or as plain text under /code/raw/<path> (index: /code/index.json).