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

The recovery path for a compromised coldkey: if a swap was announced on
your coldkey that you did not initiate, disputing freezes the account
entirely — the chain rejects ALL signed extrinsics from it, including
executing the swap, clearing the announcement, or disputing again — until
root clears the state via `reset_coldkey_swap`. Sign it from the
affected coldkey itself. It does not cancel the announcement or move
anything — it locks the situation so an attacker cannot complete the
takeover while governance investigates; only root can unfreeze. Use
`clear_coldkey_swap_announcement` instead to withdraw an announcement
you made yourself.

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

## Parameters [#parameters]

This operation takes no parameters.

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 dispute-coldkey-swap --dry-run
btcli tx dispute-coldkey-swap -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.DisputeColdkeySwap()

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

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

`SubtensorModule.dispute_coldkey_swap` — [`pallets/subtensor/src/macros/dispatches.rs#L2056`](/code/pallets/subtensor/src/macros/dispatches.rs#L2054-L2073):

```rust
#[pallet::call_index(127)]
#[pallet::weight(<T as crate::pallet::Config>::WeightInfo::dispute_coldkey_swap())]
pub fn dispute_coldkey_swap(origin: OriginFor<T>) -> DispatchResult {
    let coldkey = ensure_signed(origin)?;

    ensure!(
        ColdkeySwapAnnouncements::<T>::contains_key(&coldkey),
        Error::<T>::ColdkeySwapAnnouncementNotFound
    );
    ensure!(
        !ColdkeySwapDisputes::<T>::contains_key(&coldkey),
        Error::<T>::ColdkeySwapAlreadyDisputed
    );

    let now = <frame_system::Pallet<T>>::block_number();
    ColdkeySwapDisputes::<T>::insert(&coldkey, now);

    Self::deposit_event(Event::ColdkeySwapDisputed { coldkey });
    Ok(())
}
```

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)).
