bittensor.extrinsics.staking#

Attributes#

Functions#

_check_threshold_amount(subtensor, stake_balance)

Checks if the new stake balance will be above the minimum required stake threshold.

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

Adds the specified amount of stake to passed hotkey uid.

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

Adds stake to each hotkey_ss58 in the list, using each amount, from a common coldkey.

__do_add_stake_single(subtensor, wallet, hotkey_ss58, ...)

Executes a stake call to the chain using the wallet and the amount specified.

set_childkey_take_extrinsic(subtensor, wallet, hotkey, ...)

Sets childkey take.

set_children_extrinsic(subtensor, wallet, hotkey, ...)

Sets children hotkeys with proportions assigned from the parent.

prepare_child_proportions(children_with_proportions)

Convert proportions to u64 and normalize, ensuring total does not exceed u64 max.

Module Contents#

bittensor.extrinsics.staking.console#
bittensor.extrinsics.staking._check_threshold_amount(subtensor, stake_balance)[source]#

Checks if the new stake balance will be above the minimum required stake threshold.

Parameters:
  • stake_balance (Balance) – the balance to check for threshold limits.

  • subtensor (bittensor.subtensor)

Returns:

true if the staking balance is above the threshold, or false if the

staking balance is below the threshold.

The threshold balance required to stake.

Return type:

success, threshold (bool, Balance)

bittensor.extrinsics.staking.add_stake_extrinsic(subtensor, wallet, hotkey_ss58=None, amount=None, wait_for_inclusion=True, wait_for_finalization=False, prompt=False)[source]#

Adds the specified amount of stake to passed hotkey uid.

Parameters:
  • wallet (bittensor.wallet) – Bittensor wallet object.

  • hotkey_ss58 (Optional[str]) – The ss58 address of the hotkey account to stake to defaults to the wallet’s hotkey.

  • amount (Union[Balance, float]) – Amount to stake as Bittensor balance, or float interpreted as Tao.

  • wait_for_inclusion (bool) – If set, waits for the extrinsic to enter a block before returning true, or returns false if the extrinsic fails to enter the block within the timeout.

  • wait_for_finalization (bool) – If set, waits for the extrinsic to be finalized on the chain before returning true, or returns false if the extrinsic fails to be finalized within the timeout.

  • prompt (bool) – If true, the call waits for confirmation from the user before proceeding.

  • subtensor (bittensor.subtensor)

Returns:

Flag is true if extrinsic was finalized or uncluded in the block. If we did not wait for finalization / inclusion, the response is true.

Return type:

success (bool)

Raises:
bittensor.extrinsics.staking.add_stake_multiple_extrinsic(subtensor, wallet, hotkey_ss58s, amounts=None, wait_for_inclusion=True, wait_for_finalization=False, prompt=False)[source]#

Adds stake to each hotkey_ss58 in the list, using each amount, from a common coldkey.

Parameters:
  • wallet (bittensor.wallet) – Bittensor wallet object for the coldkey.

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

  • amounts (List[Union[Balance, float]]) – List of amounts to stake. If None, stake all to the first hotkey.

  • wait_for_inclusion (bool) – If set, waits for the extrinsic to enter a block before returning true, or returns false if the extrinsic fails to enter the block within the timeout.

  • wait_for_finalization (bool) – If set, waits for the extrinsic to be finalized on the chain before returning true, or returns false if the extrinsic fails to be finalized within the timeout.

  • prompt (bool) – If true, the call waits for confirmation from the user before proceeding.

  • subtensor (bittensor.subtensor)

Returns:

Flag is true if extrinsic was finalized or included in the block. Flag is true if any wallet was staked. If we did not wait for finalization / inclusion, the response is true.

Return type:

success (bool)

bittensor.extrinsics.staking.__do_add_stake_single(subtensor, wallet, hotkey_ss58, amount, wait_for_inclusion=True, wait_for_finalization=False)[source]#

Executes a stake call to the chain using the wallet and the amount specified.

Parameters:
  • wallet (bittensor.wallet) – Bittensor wallet object.

  • hotkey_ss58 (str) – Hotkey to stake to.

  • amount (bittensor.Balance) – Amount to stake as Bittensor balance object.

  • wait_for_inclusion (bool) – If set, waits for the extrinsic to enter a block before returning true, or returns false if the extrinsic fails to enter the block within the timeout.

  • wait_for_finalization (bool) – If set, waits for the extrinsic to be finalized on the chain before returning true, or returns false if the extrinsic fails to be finalized within the timeout.

  • prompt (bool) – If true, the call waits for confirmation from the user before proceeding.

  • subtensor (bittensor.subtensor)

Returns:

Flag is true if extrinsic was finalized or uncluded in the block. If we did not wait for finalization / inclusion, the response is true.

Return type:

success (bool)

Raises:
bittensor.extrinsics.staking.set_childkey_take_extrinsic(subtensor, wallet, hotkey, netuid, take, wait_for_inclusion=True, wait_for_finalization=False, prompt=False)[source]#

Sets childkey take.

Parameters:
  • subtensor (bittensor.subtensor) – Subtensor endpoint to use.

  • wallet (bittensor.wallet) – Bittensor wallet object.

  • hotkey (str) – Childkey hotkey.

  • take (float) – Childkey take value.

  • netuid (int) – Unique identifier of for the subnet.

  • wait_for_inclusion (bool) – If set, waits for the extrinsic to enter a block before returning true, or returns false if the extrinsic fails to enter the block within the timeout.

  • wait_for_finalization (bool) – If set, waits for the extrinsic to be finalized on the chain before returning true, or returns false if the extrinsic fails to be finalized within the timeout.

  • prompt (bool) – If true, the call waits for confirmation from the user before proceeding.

Returns:

A tuple containing a success flag and an optional error message.

Return type:

Tuple[bool, Optional[str]]

Raises:
  • bittensor.errors.ChildHotkeyError – If the extrinsic fails to be finalized or included in the block.

  • bittensor.errors.NotRegisteredError – If the hotkey is not registered in any subnets.

bittensor.extrinsics.staking.set_children_extrinsic(subtensor, wallet, hotkey, netuid, children_with_proportions, wait_for_inclusion=True, wait_for_finalization=False, prompt=False)[source]#

Sets children hotkeys with proportions assigned from the parent.

Parameters:
  • subtensor (bittensor.subtensor) – Subtensor endpoint to use.

  • wallet (bittensor.wallet) – Bittensor wallet object.

  • hotkey (str) – Parent hotkey.

  • children_with_proportions (List[str]) – Children hotkeys.

  • netuid (int) – Unique identifier of for the subnet.

  • wait_for_inclusion (bool) – If set, waits for the extrinsic to enter a block before returning true, or returns false if the extrinsic fails to enter the block within the timeout.

  • wait_for_finalization (bool) – If set, waits for the extrinsic to be finalized on the chain before returning true, or returns false if the extrinsic fails to be finalized within the timeout.

  • prompt (bool) – If true, the call waits for confirmation from the user before proceeding.

Returns:

A tuple containing a success flag and an optional error message.

Return type:

Tuple[bool, Optional[str]]

Raises:
  • bittensor.errors.ChildHotkeyError – If the extrinsic fails to be finalized or included in the block.

  • bittensor.errors.NotRegisteredError – If the hotkey is not registered in any subnets.

bittensor.extrinsics.staking.prepare_child_proportions(children_with_proportions)[source]#

Convert proportions to u64 and normalize, ensuring total does not exceed u64 max.