# unstake-all (/docs/tx/unstake-all)

Sweeps the signing coldkey's entire stake held on this hotkey across every
subnet (root included) back to TAO in the coldkey's free balance. Subnets
where subtoken trading is disabled or where the position fails validation
(e.g. dust below the chain minimum) are silently skipped, so the call can
succeed while leaving some positions untouched. Alpha positions are sold
at each pool's current price with no limit protection, so large positions
can incur significant slippage. Use `remove_stake` to exit a single
subnet, or `unstake_all_alpha` to consolidate onto root while staying
staked.

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

## Parameters [#parameters]

| Parameter     | Type   | Required | Description                           |
| ------------- | ------ | -------- | ------------------------------------- |
| `hotkey_ss58` | string | yes      | Hotkey whose entire stake is removed. |

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 unstake-all \
  --hotkey <ss58|name> --dry-run
btcli tx unstake-all \
  --hotkey <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.UnstakeAll(hotkey_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("unstake_all", {...}, wallet)
```

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

`SubtensorModule.unstake_all` — [`pallets/subtensor/src/macros/dispatches.rs#L1212`](/code/pallets/subtensor/src/macros/dispatches.rs#L1210-L1214):

```rust
#[pallet::call_index(83)]
#[pallet::weight(<T as crate::pallet::Config>::WeightInfo::unstake_all())]
pub fn unstake_all(origin: OriginFor<T>, hotkey: T::AccountId) -> DispatchResult {
    Self::do_unstake_all(origin, hotkey)
}
```

Delegates to [`do_unstake_all`](/code/pallets/subtensor/src/staking/remove_stake.rs#L110).

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