bittensor.core.extrinsics.asyncex.serving#

Functions#

do_serve_axon(subtensor, wallet, call_params[, ...])

Internal method to submit a serve axon transaction to the Bittensor blockchain. This method creates and submits a

get_metadata(subtensor, netuid, hotkey[, block, ...])

Fetches metadata from the blockchain for a given hotkey and netuid.

publish_metadata(subtensor, wallet, netuid, data_type, ...)

Publishes metadata on the Bittensor network using the specified wallet and network identifier.

serve_axon_extrinsic(subtensor, netuid, axon[, ...])

Serves the axon to the network.

serve_extrinsic(subtensor, wallet, ip, port, protocol, ...)

Subscribes a Bittensor endpoint to the subtensor chain.

Module Contents#

async bittensor.core.extrinsics.asyncex.serving.do_serve_axon(subtensor, wallet, call_params, wait_for_inclusion=False, wait_for_finalization=True)#
Internal method to submit a serve axon transaction to the Bittensor blockchain. This method creates and submits a

transaction, enabling a neuron’s Axon to serve requests on the network.

Parameters:
Returns:

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

Return type:

tuple[bool, Optional[str]]

This function is crucial for initializing and announcing a neuron’s Axon service on the network, enhancing the

decentralized computation capabilities of Bittensor.

async bittensor.core.extrinsics.asyncex.serving.get_metadata(subtensor, netuid, hotkey, block=None, block_hash=None, reuse_block=False)#

Fetches metadata from the blockchain for a given hotkey and netuid.

Parameters:
Return type:

str

async bittensor.core.extrinsics.asyncex.serving.publish_metadata(subtensor, wallet, netuid, data_type, data, wait_for_inclusion=False, wait_for_finalization=True)#

Publishes metadata on the Bittensor network using the specified wallet and network identifier.

Parameters:
  • subtensor (bittensor.subtensor) – The subtensor instance representing the Bittensor blockchain connection.

  • wallet (bittensor.wallet) – The wallet object used for authentication in the transaction.

  • netuid (int) – Network UID on which the metadata is to be published.

  • data_type (str) – The data type of the information being submitted. It should be one of the following: 'Sha256', 'Blake256', 'Keccak256', or 'Raw0-128'. This specifies the format or hashing algorithm used for the data.

  • data (str) – The actual metadata content to be published. This should be formatted or hashed according to the type specified. (Note: max str length is 128 bytes)

  • wait_for_inclusion (bool, optional) – If True, the function will wait for the extrinsic to be included in a block before returning. Defaults to False.

  • wait_for_finalization (bool, optional) – If True, the function will wait for the extrinsic to be finalized on the chain before returning. Defaults to True.

Returns:

True if the metadata was successfully published (and finalized if specified). False otherwise.

Return type:

bool

Raises:

MetadataError – If there is an error in submitting the extrinsic or if the response from the blockchain indicates failure.

async bittensor.core.extrinsics.asyncex.serving.serve_axon_extrinsic(subtensor, netuid, axon, wait_for_inclusion=False, wait_for_finalization=True, certificate=None)#

Serves the axon to the network.

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

  • netuid (int) – The netuid being served on.

  • axon (bittensor.core.axon.Axon) – Axon to serve.

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

  • certificate (bittensor.utils.Certificate) – Certificate to use for TLS. If None, no TLS will be used. Defaults to None.

Returns:

Flag is True if extrinsic was finalized or included in the block. If we did not wait for

finalization / inclusion, the response is True.

Return type:

success (bool)

async bittensor.core.extrinsics.asyncex.serving.serve_extrinsic(subtensor, wallet, ip, port, protocol, netuid, placeholder1=0, placeholder2=0, wait_for_inclusion=False, wait_for_finalization=True, certificate=None)#

Subscribes a Bittensor endpoint to the subtensor chain.

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

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

  • ip (str) – Endpoint host port i.e., 192.122.31.4.

  • port (int) – Endpoint port number i.e., 9221.

  • protocol (int) – An int representation of the protocol.

  • netuid (int) – The network uid to serve on.

  • placeholder1 (int) – A placeholder for future use.

  • placeholder2 (int) – A placeholder for future use.

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

  • certificate (bittensor.utils.Certificate) – Certificate to use for TLS. If None, no TLS will be used. Defaults to None.

Returns:

Flag is True if extrinsic was finalized or included in the block. If we did not wait for

finalization / inclusion, the response is True.

Return type:

success (bool)