bittensor.core.extrinsics.staking#

Functions#

add_stake_extrinsic(subtensor, wallet, netuid, ...[, ...])

Adds a stake from the specified wallet to the neuron identified by the SS58 address of its hotkey in specified subnet.

add_stake_multiple_extrinsic(subtensor, wallet, ...[, ...])

Adds stake to each hotkey_ss58 in the list, using each amount, from a common coldkey on subnet with

set_auto_stake_extrinsic(subtensor, wallet, netuid, ...)

Sets the coldkey to automatically stake to the hotkey within specific subnet mechanism.

Module Contents#

bittensor.core.extrinsics.staking.add_stake_extrinsic(subtensor, wallet, netuid, hotkey_ss58, amount, safe_staking=False, allow_partial_stake=False, rate_tolerance=0.005, period=None, raise_error=False, wait_for_inclusion=True, wait_for_finalization=True)[source]#

Adds a stake from the specified wallet to the neuron identified by the SS58 address of its hotkey in specified subnet. Staking is a fundamental process in the Bittensor network that enables neurons to participate actively and earn incentives.

Parameters:
  • subtensor (bittensor.core.subtensor.Subtensor) – Subtensor instance with the connection to the chain.

  • wallet (bittensor_wallet.Wallet) – Bittensor wallet object.

  • netuid (int) – The unique identifier of the subnet to which the neuron belongs.

  • hotkey_ss58 (str) – The ss58 address of the hotkey account to stake to default to the wallet’s hotkey.

  • amount (bittensor.utils.balance.Balance) – Amount to stake as Bittensor balance in TAO always.

  • safe_staking (bool) – If True, enables price safety checks.

  • allow_partial_stake (bool) – If True, allows partial unstaking if price tolerance exceeded.

  • rate_tolerance (float) – Maximum allowed price increase percentage (0.005 = 0.5%).

  • period (Optional[int]) – The number of blocks during which the transaction will remain valid after it’s submitted. If the transaction is not included in a block within that number of blocks, it will expire and be rejected. You can think of it as an expiration date for the transaction.

  • raise_error (bool) – Raises a relevant exception rather than returning False if unsuccessful.

  • wait_for_inclusion (bool) – Whether to wait for the inclusion of the transaction.

  • wait_for_finalization (bool) – Whether to wait for the finalization of the transaction.

Returns:

The result object of the extrinsic execution.

Return type:

ExtrinsicResponse

Raises:

SubstrateRequestException – Raised if the extrinsic fails to be included in the block within the timeout.

Notes

The data field in the returned ExtrinsicResponse contains extra information about the extrinsic execution.

bittensor.core.extrinsics.staking.add_stake_multiple_extrinsic(subtensor, wallet, netuids, hotkey_ss58s, amounts, period=None, raise_error=False, wait_for_inclusion=True, wait_for_finalization=True)[source]#

Adds stake to each hotkey_ss58 in the list, using each amount, from a common coldkey on subnet with corresponding netuid.

Parameters:
  • subtensor (bittensor.core.subtensor.Subtensor) – Subtensor instance with the connection to the chain.

  • wallet (bittensor_wallet.Wallet) – Bittensor wallet object for the coldkey.

  • netuids (bittensor.core.types.UIDs) – List of netuids to stake to.

  • hotkey_ss58s (list[str]) – List of hotkeys to stake to.

  • amounts (list[bittensor.utils.balance.Balance]) – List of corresponding TAO amounts to bet for each netuid and hotkey.

  • period (Optional[int]) – The number of blocks during which the transaction will remain valid after it’s submitted. If the transaction is not included in a block within that number of blocks, it will expire and be rejected. You can think of it as an expiration date for the transaction.

  • raise_error (bool) – Raises a relevant exception rather than returning False if unsuccessful.

  • wait_for_inclusion (bool) – Whether to wait for the inclusion of the transaction.

  • wait_for_finalization (bool) – Whether to wait for the finalization of the transaction.

Returns:

The result object of the extrinsic execution.

Return type:

ExtrinsicResponse

Note

The data field in the returned ExtrinsicResponse contains the results of each individual internal add_stake_extrinsic call. Each entry maps a tuple key (idx, hotkey_ss58, netuid) to either:

  • the corresponding ExtrinsicResponse object if the staking attempt was executed, or

  • None if the staking was skipped due to failing validation (e.g., wrong balance, zero amount, etc.).

In the key, idx is the index the stake attempt. This allows the caller to inspect which specific operations were attempted and which were not.

bittensor.core.extrinsics.staking.set_auto_stake_extrinsic(subtensor, wallet, netuid, hotkey_ss58, period=None, raise_error=False, wait_for_inclusion=True, wait_for_finalization=True)#

Sets the coldkey to automatically stake to the hotkey within specific subnet mechanism.

Parameters:
  • subtensor (bittensor.core.subtensor.Subtensor) – AsyncSubtensor instance.

  • wallet (bittensor_wallet.Wallet) – Bittensor Wallet instance.

  • netuid (int) – The subnet unique identifier.

  • hotkey_ss58 (str) – The SS58 address of the validator’s hotkey to which the miner automatically stakes all rewards received from the specified subnet immediately upon receipt.

  • period (Optional[int]) – The number of blocks during which the transaction will remain valid after it’s submitted. If the transaction is not included in a block within that number of blocks, it will expire and be rejected. You can think of it as an expiration date for the transaction.

  • raise_error (bool) – Raises a relevant exception rather than returning False if unsuccessful.

  • wait_for_inclusion (bool) – Whether to wait for the inclusion of the transaction.

  • wait_for_finalization (bool) – Whether to wait for the finalization of the transaction.

Returns:

The result object of the extrinsic execution.

Return type:

ExtrinsicResponse