# 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.
A new deposit's spender is the spender of the subnet owner's service,
otherwise the subnet owner, or a leased subnet's beneficiary, unless
`spender_ss58` names another or `service_hotkey_ss58` names a service
published on the subnet, whose spender it takes. It has
no daily spend cap unless `daily_spend_cap_gamma` sets one. A mint
naming either 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, spender and cap as `deposit_balance_gamma` (None when the mint
opens it), `spender_ss58` (None for the default spender) and
`daily_spend_cap_gamma`. The result's `data["minted"]` holds the
deposit's `hotkey_ss58`, `spender_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#L3218-L3238) |

## 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%).                                                                                                                                                                                                                                |
| `spender_ss58`          | string  | no       | The account that spends the deposit. A new deposit opens with it, and an existing one must already name it. Omit to keep the deposit's spender, which for a new deposit is the spender of the subnet owner's service, otherwise the subnet owner, or its lease's beneficiary while a lease owns the subnet. |
| `service_hotkey_ss58`   | string  | no       | Hotkey of a service published on the subnet, instead of a spender. The deposit names the spender the service publishes.                                                                                                                                                                                     |
| `daily_spend_cap_gamma` | number  | no       | The deposit's daily spend cap, in gamma; 0 pauses it. 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#L3220`](/code/pallets/subtensor/src/macros/dispatches.rs#L3218-L3238):

```rust
#[pallet::call_index(158)]
#[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,
    spender: Option<T::AccountId>,
    daily_spend_cap: Option<GammaBalance>,
) -> DispatchResult {
    Self::do_mint_gamma(
        origin,
        hotkey,
        netuid,
        amount,
        min_amount_out,
        spender,
        daily_spend_cap,
    )
}
```

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

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