Transactions

spend-gamma

Spend gamma from the deposits you are the spender of.

View as Markdown

Spends, in order, each entry's amount_gamma from the deposit at its hotkey_ss58. Entries whose hotkey has no deposit, whose deposit you are not the spender of, or whose amount is zero or above the deposit's balance or what its daily spend cap allows, are skipped. Spent gamma is destroyed. Each entry's optional reference, 32 bytes as hex, is repeated in its GammaSpent or GammaSpendSkipped event; by convention it is the service's own id for the request it pays for, returned with its response. Sign as the spender, or as its GammaSpend proxy. The result's data["spent"] lists, in order, each entry that spent, with its hotkey_ss58, amount_gamma and reference, and data["skipped"] each entry that was skipped, with the chain error that skipped it as reason.

SignerOriginPalletWraps
coldkeysigned account (pallet role may apply)SubtensorModuleSubtensorModule.spend_gamma

Parameters

ParameterTypeRequiredDescription
netuidintegeryesSubnet of the deposits.
spendsarray of objectyesOne to 512 objects of hotkey_ss58, amount_gamma and an optional 32-byte hex reference, spent in order.

Address parameters (--hotkey, --coldkey, --dest, ...) accept a raw ss58 address, an address-book or proxy-book name, or a local wallet/hotkey name.

CLI

Preview with --dry-run (shows fee, effects, and policy result without submitting), then submit:

btcli tx spend-gamma \
  --netuid <int> \
  --spends '<json>' --dry-run
btcli tx spend-gamma \
  --netuid <int> \
  --spends '<json>' -w my_coldkey

Python

import bittensor as bt
from bittensor.wallet import Wallet

wallet = Wallet(name="my_coldkey", hotkey="my_hotkey")
intent = bt.SpendGamma(netuid=1, spends=[...])

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.) Or build the intent by op name, as an agent would:

result = sub.execute_tool("spend_gamma", {...}, wallet)

On-chain implementation

SubtensorModule.spend_gamma — pallets/subtensor/src/macros/dispatches.rs#L3330:

#[pallet::call_index(164)]
#[pallet::weight((<T as Config>::WeightInfo::spend_gamma(spends.len() as u32), DispatchClass::Normal, Pays::Yes))]
pub fn spend_gamma(
    origin: OriginFor<T>,
    netuid: NetUid,
    spends: BoundedVec<(T::AccountId, GammaBalance, [u8; 32]), ConstU32<MAX_GAMMA_SPENDS>>,
) -> DispatchResultWithPostInfo {
    let spent = Self::do_spend_gamma(origin, netuid, &spends)?;
    let skipped = (spends.len() as u32).saturating_sub(spent);
    Ok((
        Some(
            <T as Config>::WeightInfo::spend_gamma(spends.len() as u32)
                .saturating_sub(T::DbWeight::get().writes(skipped.into())),
        ),
        Pays::Yes,
    )
        .into())
}

Delegates to do_spend_gamma.

Every file is browsable under /code exactly as built into the runtime, or as plain text under /code/raw/<path> (index: /code/index.json).