bittensor.core.extrinsics.utils#

Module with helper functions for extrinsics.

Functions#

apply_pure_proxy_data(response, triggered_events, ...)

Apply pure proxy data to the response object.

get_old_stakes(wallet, hotkey_ss58s, netuids, all_stakes)

Retrieve the previous staking balances for a wallet's hotkeys across given netuids.

get_transfer_fn_params(amount, destination_ss58, ...)

Helper function to get the transfer call function and call params, depending on the value and keep_alive flag

sudo_call_extrinsic(subtensor, wallet, call_function, ...)

Execute a sudo call extrinsic.

Module Contents#

bittensor.core.extrinsics.utils.apply_pure_proxy_data(response, triggered_events, block_number, extrinsic_idx, raise_error)#

Apply pure proxy data to the response object.

Parameters:
  • response (bittensor.core.types.ExtrinsicResponse) – The response object to update.

  • triggered_events (list) – The triggered events of the transaction.

  • block_number (int) – The block number of the transaction.

  • extrinsic_idx (int) – The index of the extrinsic in the transaction.

  • raise_error (bool) – Whether to raise an error if the data cannot be applied successfully.

Returns:

True if the data was applied successfully, False otherwise.

Return type:

bittensor.core.types.ExtrinsicResponse

bittensor.core.extrinsics.utils.get_old_stakes(wallet, hotkey_ss58s, netuids, all_stakes)[source]#

Retrieve the previous staking balances for a wallet’s hotkeys across given netuids.

This function searches through the provided staking data to find the stake amounts for the specified hotkeys and netuids associated with the wallet’s coldkey. If no match is found for a particular hotkey and netuid combination, a default balance of zero is returned.

Parameters:
  • wallet (bittensor_wallet.Wallet) – The wallet containing the coldkey to compare with stake data.

  • hotkey_ss58s (list[str]) – List of hotkey SS58 addresses for which stakes are retrieved.

  • netuids (list[int]) – List of network unique identifiers (netuids) corresponding to the hotkeys.

  • all_stakes (list[bittensor.core.chain_data.StakeInfo]) – A collection of all staking information to search through.

Returns:

A list of Balances, each representing the stake for a given hotkey and netuid.

Return type:

list[bittensor.utils.balance.Balance]

bittensor.core.extrinsics.utils.get_transfer_fn_params(amount, destination_ss58, keep_alive)#

Helper function to get the transfer call function and call params, depending on the value and keep_alive flag provided.

Parameters:
  • amount (Optional[bittensor.utils.balance.Balance]) – the amount of Tao to transfer. None if transferring all.

  • destination_ss58 (str) – the destination SS58 of the transfer

  • keep_alive (bool) – whether to enforce a retention of the existential deposit in the account after transfer.

Returns:

tuple[call function, call params]

Return type:

tuple[str, dict[str, Union[str, int, bool]]]

bittensor.core.extrinsics.utils.sudo_call_extrinsic(subtensor, wallet, call_function, call_params, call_module='AdminUtils', sign_with='coldkey', use_nonce=False, nonce_key='hotkey', period=None, raise_error=False, wait_for_inclusion=True, wait_for_finalization=True, root_call=False)#

Execute a sudo call extrinsic.

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

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

  • call_function (str) – The call function to execute.

  • call_params (dict) – The call parameters.

  • call_module (str) – The call module.

  • sign_with (str) – The keypair to sign the extrinsic with.

  • use_nonce (bool) – Whether to use a nonce.

  • nonce_key (str) – The key to use for the nonce.

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

  • root_call (bool) – False, if the subnet owner makes a call.

Returns:

The result object of the extrinsic execution.

Return type:

ExtrinsicResponse