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

Destroys `amount_gamma` of the deposit and adds it to what the hotkey has
spent at the service at `service_hotkey_ss58`, which credits it. The
amount is at least 0.1 gamma unless it empties the deposit, and within its
balance and what its daily spend cap allows. Signed by the hotkey, which
pays no fee: the chain refuses an invalid spend before it enters a block.

| Signer   | Origin                                 | Pallet          | Wraps                                                                                         |
| -------- | -------------------------------------- | --------------- | --------------------------------------------------------------------------------------------- |
| `hotkey` | signed account (pallet role may apply) | SubtensorModule | [`SubtensorModule.spend_gamma`](/code/pallets/subtensor/src/macros/dispatches.rs#L3280-L3289) |

## Parameters [#parameters]

| Parameter             | Type    | Required | Description                            |
| --------------------- | ------- | -------- | -------------------------------------- |
| `netuid`              | integer | yes      | Subnet of the deposit and the service. |
| `service_hotkey_ss58` | string  | yes      | Hotkey of the service spent at.        |
| `amount_gamma`        | number  | yes      | Gamma spent.                           |

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 spend-gamma \
  --netuid <int> \
  --service-hotkey <ss58|name> \
  --amount-gamma <amount> --dry-run
btcli tx spend-gamma \
  --netuid <int> \
  --service-hotkey <ss58|name> \
  --amount-gamma <amount> -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.SpendGamma(netuid=1, service_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("spend_gamma", {...}, wallet)
```

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

`SubtensorModule.spend_gamma` — [`pallets/subtensor/src/macros/dispatches.rs#L3282`](/code/pallets/subtensor/src/macros/dispatches.rs#L3280-L3289):

```rust
#[pallet::call_index(168)]
#[pallet::weight((<T as Config>::WeightInfo::spend_gamma(), DispatchClass::Normal, Pays::No))]
pub fn spend_gamma(
    origin: OriginFor<T>,
    service: T::AccountId,
    netuid: NetUid,
    amount: GammaBalance,
) -> DispatchResult {
    Self::do_spend_gamma(origin, service, netuid, amount)
}
```

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

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