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

Burns up to `amount_alpha` (`all` for the whole stake) of your stake
on `origin_hotkey_ss58` and credits its value in gamma to the deposit at
`hotkey_ss58`, valued as `mint_gamma` values bought alpha. The stake is
destroyed, not moved. `spender_ss58`, `service_hotkey_ss58` and
`daily_spend_cap_gamma` name the deposit's spender and cap as for
`mint_gamma`. Fails rather than minting less than the current quote
less `rate_tolerance`. Its plan's `preview` and result's
`data["minted"]` are as for `mint_gamma`.

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

## Parameters [#parameters]

| Parameter               | Type              | Required | Description                                                                                                                                                                                                                                                                                                 |
| ----------------------- | ----------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `netuid`                | integer           | yes      | Subnet of the stake burned.                                                                                                                                                                                                                                                                                 |
| `hotkey_ss58`           | string            | yes      | Hotkey of the deposit credited: an API key, not a staking hotkey.                                                                                                                                                                                                                                           |
| `amount_alpha`          | number \| `"all"` | yes      | Alpha of stake burned.                                                                                                                                                                                                                                                                                      |
| `origin_hotkey_ss58`    | string            | yes      | Hotkey the stake is held on (the validator backing the position).                                                                                                                                                                                                                                           |
| `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-with-stake \
  --netuid <int> \
  --hotkey <ss58|name> \
  --amount-alpha <amount|all> \
  --origin-hotkey <ss58|name> --dry-run
btcli tx mint-gamma-with-stake \
  --netuid <int> \
  --hotkey <ss58|name> \
  --amount-alpha <amount|all> \
  --origin-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.MintGammaWithStake(netuid=1, hotkey_ss58="5F...", amount_alpha=1.0, origin_hotkey_ss58="5F...origin")

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

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

`SubtensorModule.mint_gamma_with_stake` — [`pallets/subtensor/src/macros/dispatches.rs#L3247`](/code/pallets/subtensor/src/macros/dispatches.rs#L3245-L3267):

```rust
#[pallet::call_index(159)]
#[pallet::weight((<T as Config>::WeightInfo::mint_gamma_with_stake(), DispatchClass::Normal, Pays::Yes))]
pub fn mint_gamma_with_stake(
    origin: OriginFor<T>,
    origin_hotkey: T::AccountId,
    destination_hotkey: T::AccountId,
    netuid: NetUid,
    alpha_amount: AlphaBalance,
    min_amount_out: GammaBalance,
    spender: Option<T::AccountId>,
    daily_spend_cap: Option<GammaBalance>,
) -> DispatchResult {
    Self::do_mint_gamma_with_stake(
        origin,
        origin_hotkey,
        destination_hotkey,
        netuid,
        alpha_amount,
        min_amount_out,
        spender,
        daily_spend_cap,
    )
}
```

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

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