Transactions

lock-stake

Lock alpha stake on a subnet, building conviction toward a hotkey.

View as Markdown

Commits part of the signing coldkey's alpha on the subnet as locked stake: the locked amount builds conviction the longer it stays locked. The lock acts as a subnet-wide floor on unstaking, not a hold on a specific position — the coldkey can freely unstake anything above the locked mass, and the locked amount itself keeps earning normally. The coldkey's total alpha on the subnet, summed across all hotkeys, must cover the locked amount; conviction can be pointed at one hotkey while the stake sits on another. If a lock already exists on the subnet, the hotkey must match the existing lock's hotkey or the call fails with LockHotkeyMismatch — repeat calls only top up the lock; use move_lock to change hotkeys. Whether the lock decays over time or persists is controlled per coldkey per subnet with set_perpetual_lock.

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

Parameters

ParameterTypeRequiredDescription
netuidintegeryesSubnet the locked stake lives on.
amount_alphanumber | "all"yesHow much of the existing stake to lock.
hotkey_ss58stringnoHotkey the lock's conviction is credited to. Defaults to the wallet hotkey.

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 lock-stake \
  --netuid <int> \
  --amount-alpha <amount|all> --dry-run
btcli tx lock-stake \
  --netuid <int> \
  --amount-alpha <amount|all> -w my_coldkey

Python

import bittensor as bt
from bittensor.wallet import Wallet

wallet = Wallet(name="my_coldkey", hotkey="my_hotkey")
intent = bt.LockStake(netuid=1, amount_alpha=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.) Or build the intent by op name, as an agent would:

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

On-chain implementation

SubtensorModule.lock_stakepallets/subtensor/src/macros/dispatches.rs#L2258:

#[pallet::call_index(136)]
#[pallet::weight(<T as crate::pallet::Config>::WeightInfo::lock_stake())]
pub fn lock_stake(
    origin: OriginFor<T>,
    hotkey: T::AccountId,
    netuid: NetUid,
    amount: AlphaBalance,
) -> DispatchResult {
    let coldkey = ensure_signed(origin)?;
    Self::do_lock_stake(&coldkey, netuid, &hotkey, amount)
}

Delegates to do_lock_stake.

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