bittensor.core.extrinsics.staking#

Functions#

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

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

_check_threshold_amount(subtensor, stake_balance)

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

_do_stake(self, wallet, hotkey_ss58, amount[, ...])

Sends a stake extrinsic to the chain.

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.

Module Contents#

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

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

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

  • hotkey_ss58 (str) – Hotkey to stake to.

  • amount (bittensor.utils.balance.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.

  • subtensor (bittensor.core.subtensor.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.core.extrinsics.staking._check_threshold_amount(subtensor, stake_balance)#

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

Parameters:
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.core.extrinsics.staking._do_stake(self, wallet, hotkey_ss58, amount, wait_for_inclusion=True, wait_for_finalization=False)#

Sends a stake extrinsic to the chain.

Parameters:
  • self (subtensor) – Subtensor instance.

  • wallet (bittensor_wallet.Wallet) – Wallet object that can sign the extrinsic.

  • hotkey_ss58 (str) – Hotkey ss58 address to stake to.

  • amount (bittensor.utils.balance.Balance) – Amount to stake.

  • wait_for_inclusion (bool) – If true, waits for inclusion before returning.

  • wait_for_finalization (bool) – If true, waits for finalization before returning.

Returns:

True if the extrinsic was successful.

Return type:

success (bool)

Raises:

bittensor.core.errors.StakeError – If the extrinsic failed.

bittensor.core.extrinsics.staking.add_stake_extrinsic(subtensor, wallet, hotkey_ss58=None, amount=None, wait_for_inclusion=True, wait_for_finalization=False)#

Adds the specified amount of stake to passed hotkey uid.

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

  • wallet (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.

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.core.extrinsics.staking.add_stake_multiple_extrinsic(subtensor, wallet, hotkey_ss58s, amounts=None, wait_for_inclusion=True, wait_for_finalization=False)#

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

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

  • wallet (bittensor_wallet.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.

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)