bittensor.core.extrinsics.utils#

Module with helper functions for extrinsics.

Exceptions#

_ThreadingTimeoutException

Exception raised for timeout. Different from TimeoutException because this also triggers

Functions#

submit_extrinsic(substrate, extrinsic, ...)

Submits an extrinsic to the substrate blockchain and handles potential exceptions.

Module Contents#

exception bittensor.core.extrinsics.utils._ThreadingTimeoutException#

Bases: Exception

Exception raised for timeout. Different from TimeoutException because this also triggers a websocket failure. This exception should only be used with threading timer..

Initialize self. See help(type(self)) for accurate signature.

bittensor.core.extrinsics.utils.submit_extrinsic(substrate, extrinsic, wait_for_inclusion, wait_for_finalization)#

Submits an extrinsic to the substrate blockchain and handles potential exceptions.

This function attempts to submit an extrinsic to the substrate blockchain with specified options for waiting for inclusion in a block and/or finalization. If an exception occurs during submission, it logs the error and re-raises the exception.

Parameters:
  • substrate (substrateinterface.SubstrateInterface) – The substrate interface instance used to interact with the blockchain.

  • extrinsic (scalecodec.types.GenericExtrinsic) – The extrinsic to be submitted to the blockchain.

  • wait_for_inclusion (bool) – Whether to wait for the extrinsic to be included in a block.

  • wait_for_finalization (bool) – Whether to wait for the extrinsic to be finalized on the blockchain.

Returns:

The response from the substrate after submitting the extrinsic.

Return type:

response

Raises:

SubstrateRequestException – If the submission of the extrinsic fails, the error is logged and re-raised.