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

Buys the subnet's alpha with `amount_tao`, burns it, and credits its value
in gamma, one per US dollar, to the deposit at `hotkey_ss58`, opening it
when absent. The alpha is valued at the lower of the subnet's gamma price
and its spot price before the buy. The hotkey spends the deposit with
`spend_gamma`. A new deposit has no daily spend cap unless
`daily_spend_cap_gamma` sets one, and a mint naming a cap fails on a
deposit with another.
Fails rather than minting less than the current quote less
`rate_tolerance`. A plan's `preview` holds the quote's `gamma`,
`minimum_gamma`, `alpha_burned` and `tao_value`, and the deposit's
balance and cap as `deposit_balance_gamma` (None when the mint opens it)
and `daily_spend_cap_gamma`. The result's `data["minted"]` holds the
deposit's `hotkey_ss58` and `daily_spend_cap_gamma`, and the
`alpha_burned`, `tao_value` and `gamma` minted.

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

## Parameters [#parameters]

| Parameter               | Type    | Required | Description                                                                                                                                                                                                                      |
| ----------------------- | ------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `netuid`                | integer | yes      | Subnet whose alpha is bought and burned.                                                                                                                                                                                         |
| `hotkey_ss58`           | string  | yes      | Hotkey of the deposit credited: an API key, not a staking hotkey.                                                                                                                                                                |
| `amount_tao`            | number  | yes      | TAO spent buying the alpha that is burned.                                                                                                                                                                                       |
| `rate_tolerance`        | number  | no       | Maximum fall of the minted gamma below the quote, as a fraction (0.05 = 5%).                                                                                                                                                     |
| `daily_spend_cap_gamma` | number  | no       | The deposit's daily spend cap, in gamma: 0 pauses it, and any other cap is at least 0.1. A new deposit opens with it, and an existing one must already have it. Omit to keep the deposit's cap, which for a new deposit is none. |

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 mint-gamma \
  --netuid <int> \
  --hotkey <ss58|name> \
  --amount-tao <amount> --dry-run
btcli tx mint-gamma \
  --netuid <int> \
  --hotkey <ss58|name> \
  --amount-tao <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.MintGamma(netuid=1, hotkey_ss58="5F...", amount_tao=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("mint_gamma", {...}, wallet)
```

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

`SubtensorModule.mint_gamma` — [`pallets/subtensor/src/macros/dispatches.rs#L3188`](/code/pallets/subtensor/src/macros/dispatches.rs#L3186-L3204):

```rust
#[pallet::call_index(166)]
#[pallet::weight((<T as Config>::WeightInfo::mint_gamma(), DispatchClass::Normal, Pays::Yes))]
pub fn mint_gamma(
    origin: OriginFor<T>,
    hotkey: T::AccountId,
    netuid: NetUid,
    amount: TaoBalance,
    min_amount_out: GammaBalance,
    daily_spend_cap: Option<GammaBalance>,
) -> DispatchResult {
    Self::do_mint_gamma(
        origin,
        hotkey,
        netuid,
        amount,
        min_amount_out,
        daily_spend_cap,
    )
}
```

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

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