bittensor.core.types#

Attributes#

Classes#

AxonServeCallParams

BlockInfo

Class that holds information about a blockchain block.

ExtrinsicResponse

A standardized response container for handling the extrinsic results submissions and related operations in the SDK.

PrometheusServeCallParams

Prometheus serve chain call parameters.

SubtensorMixin

Helper class that provides a standard way to create an ABC using

Module Contents#

class bittensor.core.types.AxonServeCallParams(version, ip, port, ip_type, netuid, hotkey, coldkey, protocol, placeholder1, placeholder2, certificate)[source]#
Parameters:
as_dict()#

Returns a dict representation of this object. If self.certificate is None, it is not included in this.

Return type:

dict

certificate#
coldkey#
copy()[source]#
Return type:

AxonServeCallParams

hotkey#
ip#
ip_type#
netuid#
placeholder1#
placeholder2#
port#
protocol#
version#
class bittensor.core.types.BlockInfo#

Class that holds information about a blockchain block.

This class encapsulates all relevant information about a block in the blockchain, including its number, hash, timestamp, and contents.

Variables:
  • number – The block number.

  • hash – The corresponding block hash.

  • timestamp – The timestamp of the block (based on the Timestamp.Now extrinsic).

  • header – The raw block header returned by the node RPC.

  • extrinsics – The list of extrinsics included in the block.

  • explorer – The link to block explorer service.

explorer: str#
extrinsics: list#
hash: str#
header: dict#
number: int#
timestamp: int | None#
class bittensor.core.types.ExtrinsicResponse#

A standardized response container for handling the extrinsic results submissions and related operations in the SDK.

This class is designed to give developers a consistent way to represent the outcome of an extrinsic call — whether it succeeded or failed — along with useful metadata for debugging, logging, or higher-level business logic.

The object also implements tuple-like behavior:
  • Iteration yields (success, message).

  • Indexing is supported: response[0] -> success, response[1] -> message.

  • len(response) returns 2.

Variables:
  • success – Indicates if the extrinsic execution was successful.

  • message – A status or informational message returned from the execution (e.g., “Successfully registered subnet”).

  • extrinsic_function – The SDK extrinsic or external function name that was executed (e.g., “add_stake_extrinsic”).

  • extrinsic – The raw extrinsic object used in the call, if available. This is a GenericExtrinsic instance containing the full payload and metadata of the submitted extrinsic, including call section, method, signer, signature, parameters, and encoded bytes. Useful for inspecting or reconstructing the exact transaction submitted to the chain.

  • extrinsic_fee – The fee charged by the extrinsic, if available.

  • extrinsic_receipt – The receipt object of the submitted extrinsic. This is an ExtrinsicReceipt instance that contains the most detailed execution data available, including the block number and hash, triggered events, extrinsic index, execution phase, and other low-level details. This allows deep debugging or post-analysis of on-chain execution.

  • mev_extrinsic – The extrinsic object of the revealed (decrypted and executed) MEV Shield extrinsic. This is populated when using MEV Shield protection (with_mev_protection=True) and contains the execution details of the second extrinsic that decrypts and executes the originally encrypted call. Contains triggered events, block information, and other execution metadata. Set to None for non-MEV Shield transactions or when the revealed extrinsic receipt is not available.

  • transaction_tao_fee – TAO fee charged by the transaction in TAO (e.g., fee for add_stake), if available.

  • transaction_alpha_fee – Alpha fee charged by the transaction (e.g., fee for transfer_stake), if available.

  • error – Captures the underlying exception if the extrinsic failed, otherwise None.

  • data – Arbitrary data returned from the extrinsic, such as decoded events, balance or another extra context.

Instance methods:

as_dict: Returns a dictionary representation of this object. with_log: Returns itself but with logging message.

Class methods:

from_exception: Checks if error is raised or return ExtrinsicResponse accordingly. unlock_wallet: Checks if keypair is unlocked and can be used for signing the extrinsic.

Example

import bittensor as bt

subtensor = bt.SubtensorApi(“local”) wallet = bt.Wallet(“alice”)

response = subtensor.subnets.register_subnet(alice_wallet) print(response)

ExtrinsicResponse:

success: True message: Successfully registered subnet extrinsic_function: register_subnet_extrinsic extrinsic: {‘account_id’: ‘0xd43593c715fdd31c… transaction_fee: τ1.0 extrinsic_receipt: Extrinsic Receipt data of of the submitted extrinsic mev_extrinsic: None transaction_tao_fee: τ1.0 transaction_alpha_fee: 1.0β error: None data: None

success, message = response print(success, message)

True Successfully registered subnet

print(response[0]) True print(response[1]) ‘Successfully registered subnet’

as_dict()#

Represents this object as a dictionary.

Return type:

dict

data: Any | None = None#
error: Exception | None = None#
extrinsic: scalecodec.types.GenericExtrinsic | None = None#
extrinsic_fee: bittensor.utils.balance.Balance | None = None#
extrinsic_function: str | None = None#
extrinsic_receipt: AsyncExtrinsicReceipt | ExtrinsicReceipt | None = None#
classmethod from_exception(raise_error, error)#

Check if error is raised and return ExtrinsicResponse accordingly. :param raise_error: Raises a relevant exception rather than returning False if unsuccessful. :param error: Exception raised during extrinsic execution.

Returns:

Extrinsic Response with False checks whether to raise an error or simply return the instance.

Parameters:
Return type:

ExtrinsicResponse

message: str | None = None#
mev_extrinsic: AsyncExtrinsicReceipt | ExtrinsicReceipt | None = None#
success: bool = True#
transaction_alpha_fee: bittensor.utils.balance.Balance | None = None#
transaction_tao_fee: bittensor.utils.balance.Balance | None = None#
classmethod unlock_wallet(wallet, raise_error=False, unlock_type='coldkey', nonce_key=None)#

Check if keypair is unlocked and return ExtrinsicResponse accordingly.

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

  • raise_error (bool) – Raises a relevant exception rather than returning False if unsuccessful.

  • unlock_type (str) – The key type, ‘coldkey’ or ‘hotkey’. Or ‘both’ to check both.

  • nonce_key (Optional[str]) – Key used for generating nonce in extrinsic function.

Returns:

Extrinsic Response is used to check if the key is unlocked.

Return type:

ExtrinsicResponse

Note

When an extrinsic is signed with the coldkey but internally references or uses the hotkey, both keypairs must be validated. Passing unlock_type=’both’ ensures that authentication is performed against both the coldkey and hotkey.

with_log(level='error')#

Logs provided message with provided level.

Parameters:

level (Literal['trace', 'debug', 'info', 'warning', 'error', 'success']) – Logging level represented as “trace”, “debug”, “info”, “warning”, “error”, “success” uses to logging message.

Returns:

ExtrinsicResponse instance.

Return type:

ExtrinsicResponse

class bittensor.core.types.PrometheusServeCallParams[source]#

Bases: TypedDict

Prometheus serve chain call parameters.

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

ip: int#
ip_type: int#
netuid: int#
port: int#
version: int#
bittensor.core.types.Salt#
class bittensor.core.types.SubtensorMixin[source]#

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

classmethod add_args(parser, prefix=None)[source]#

Adds command-line arguments to the provided ArgumentParser for configuring the Subtensor settings.

Parameters:
  • parser (argparse.ArgumentParser) – The ArgumentParser object to which the Subtensor arguments will be added.

  • prefix (Optional[str]) – An optional prefix for the argument names. If provided, the prefix is prepended to each argument name.

Arguments added:
–subtensor.network: The Subtensor network flag. Possible values are ‘finney’, ‘test’, ‘archive’, and

‘local’. Overrides the chain endpoint if set.

–subtensor.chain_endpoint: The Subtensor chain endpoint flag. If set, it overrides the network flag. –subtensor._mock: If true, uses a mocked connection to the chain.

Example

parser = argparse.ArgumentParser() Subtensor.add_args(parser)

chain_endpoint: str#
static config()[source]#

Creates and returns a Bittensor configuration object.

Returns:

A Bittensor configuration object configured with arguments added by the subtensor.add_args method.

Return type:

bittensor.core.config.Config

classmethod help()[source]#

Print help to stdout.

log_verbose: bool#
network: str#
static setup_config(network, config)[source]#

Sets up and returns the configuration for the Subtensor network and endpoint.

This method determines the appropriate network and chain endpoint based on the provided network string or

configuration object. It evaluates the network and endpoint in the following order of precedence: 1. Provided network string. 2. Configured chain endpoint in the config object. 3. Configured network in the config object. 4. Default chain endpoint. 5. Default network.

Parameters:
  • network (Optional[str]) – The name of the Subtensor network. If None, the network and endpoint will be determined from the config object.

  • config (bittensor.core.config.Config) – The configuration object containing the network and chain endpoint settings.

Returns:

A tuple containing the formatted WebSocket endpoint URL and the evaluated network name.

Return type:

tuple

bittensor.core.types.UIDs#
bittensor.core.types.Weights#