# withdraw-gamma (/docs/tx/withdraw-gamma)

Moves up to `amount_gamma` (`all` for the whole deposit) from the
deposit at `hotkey_ss58` to your coldkey's gamma balance: the whole
deposit, or at least 0.1 gamma leaving at least as much. A withdrawal that
empties the deposit closes it.

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

## Parameters [#parameters]

| Parameter      | Type              | Required | Description                            |
| -------------- | ----------------- | -------- | -------------------------------------- |
| `netuid`       | integer           | yes      | Subnet of the deposit and the balance. |
| `hotkey_ss58`  | string            | yes      | Hotkey of the deposit withdrawn from.  |
| `amount_gamma` | number \| `"all"` | yes      | Gamma withdrawn.                       |

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 withdraw-gamma \
  --netuid <int> \
  --hotkey <ss58|name> \
  --amount-gamma <amount|all> --dry-run
btcli tx withdraw-gamma \
  --netuid <int> \
  --hotkey <ss58|name> \
  --amount-gamma <amount|all> -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.WithdrawGamma(netuid=1, hotkey_ss58="5F...", amount_gamma=1.0)

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

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

`SubtensorModule.withdraw_gamma` — [`pallets/subtensor/src/macros/dispatches.rs#L3313`](/code/pallets/subtensor/src/macros/dispatches.rs#L3311-L3320):

```rust
#[pallet::call_index(176)]
#[pallet::weight((<T as Config>::WeightInfo::withdraw_gamma(), DispatchClass::Normal, Pays::Yes))]
pub fn withdraw_gamma(
    origin: OriginFor<T>,
    hotkey: T::AccountId,
    netuid: NetUid,
    amount: GammaBalance,
) -> DispatchResult {
    Self::do_withdraw_gamma(origin, hotkey, netuid, amount)
}
```

Delegates to [`do_withdraw_gamma`](/code/pallets/subtensor/src/subnets/gamma.rs#L731).

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