bittensor.core.extrinsics.serving#

Functions#

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

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.

get_metadata(self, netuid, hotkey[, block])

publish_metadata(self, wallet, netuid, data_type, data)

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#

bittensor.core.extrinsics.serving.do_serve_axon(self, 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:
  • self (bittensor.core.subtensor.Subtensor) – Subtensor instance object.

  • wallet (bittensor_wallet.Wallet) – The wallet associated with the neuron.

  • call_params (bittensor.core.types.AxonServeCallParams) – Parameters required for the serve axon call.

  • wait_for_inclusion (bool) – Waits for the transaction to be included in a block.

  • wait_for_finalization (bool) – Waits for the transaction to be finalized on the blockchain.

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.

bittensor.core.extrinsics.serving.get_metadata(self, netuid, hotkey, block=None)#
Parameters:
  • netuid (int)

  • hotkey (str)

  • block (Optional[int])

Return type:

str

bittensor.core.extrinsics.serving.publish_metadata(self, 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:
  • self (bittensor.core.subtensor.Subtensor) – The subtensor instance representing the Bittensor blockchain connection.

  • wallet (bittensor_wallet.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) – If True, the function will wait for the extrinsic to be included in a block before returning. Defaults to False.

  • wait_for_finalization (bool) – 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.

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

Serves the axon to the network.

Parameters:
  • subtensor (bittensor.core.subtensor.Subtensor) – 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.

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)

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

Subscribes a Bittensor endpoint to the subtensor chain.

Parameters:
  • subtensor (bittensor.core.subtensor.Subtensor) – 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.

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)