bittensor.subtensor
#
Module Contents#
Classes#
dict() -> new empty dictionary |
|
The Subtensor class in Bittensor serves as a crucial interface for interacting with the Bittensor blockchain, facilitating a range of operations essential for the decentralized machine learning network. |
Attributes#
- class bittensor.subtensor.ParamWithTypes#
Bases:
TypedDict
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s
(key, value) pairs
- dict(iterable) -> new dictionary initialized as if via:
d = {} for k, v in iterable:
d[k] = v
- dict(**kwargs) -> new dictionary initialized with the name=value pairs
in the keyword argument list. For example: dict(one=1, two=2)
- bittensor.subtensor.logger#
- class bittensor.subtensor.subtensor(network=None, config=None, _mock=False, log_verbose=True)#
The Subtensor class in Bittensor serves as a crucial interface for interacting with the Bittensor blockchain, facilitating a range of operations essential for the decentralized machine learning network.
This class enables neurons (network participants) to engage in activities such as registering on the network, managing staked weights, setting inter-neuronal weights, and participating in consensus mechanisms.
The Bittensor network operates on a digital ledger where each neuron holds stakes (S) and learns a set of inter-peer weights (W). These weights, set by the neurons themselves, play a critical role in determining the ranking and incentive mechanisms within the network. Higher-ranked neurons, as determined by their contributions and trust within the network, receive more incentives.
The Subtensor class connects to various Bittensor networks like the main
finney
network or local test networks, providing a gateway to the blockchain layer of Bittensor. It leverages a staked weighted trust system and consensus to ensure fair and distributed incentive mechanisms, where incentives (I) are primarily allocated to neurons that are trusted by the majority of the network.Additionally, Bittensor introduces a speculation-based reward mechanism in the form of bonds (B), allowing neurons to accumulate bonds in other neurons, speculating on their future value. This mechanism aligns with market-based speculation, incentivizing neurons to make judicious decisions in their inter-neuronal investments.
- Parameters:
network (str) – The name of the Bittensor network (e.g., ‘finney’, ‘test’, ‘archive’, ‘local’) the instance is connected to, determining the blockchain interaction context.
chain_endpoint (str) – The blockchain node endpoint URL, enabling direct communication with the Bittensor blockchain for transaction processing and data retrieval.
config (bittensor.config) –
_mock (bool) –
log_verbose (bool) –
Example Usage:
# Connect to the main Bittensor network (Finney). finney_subtensor = subtensor(network='finney') # Close websocket connection with the Bittensor network. finney_subtensor.close() # (Re)creates the websocket connection with the Bittensor network. finney_subtensor.connect_websocket() # Register a new neuron on the network. wallet = bittensor.wallet(...) # Assuming a wallet instance is created. success = finney_subtensor.register(wallet=wallet, netuid=netuid) # Set inter-neuronal weights for collaborative learning. success = finney_subtensor.set_weights(wallet=wallet, netuid=netuid, uids=[...], weights=[...]) # Speculate by accumulating bonds in other promising neurons. success = finney_subtensor.delegate(wallet=wallet, delegate_ss58=other_neuron_ss58, amount=bond_amount) # Get the metagraph for a specific subnet using given subtensor connection metagraph = subtensor.metagraph(netuid=netuid)
By facilitating these operations, the Subtensor class is instrumental in maintaining the decentralized intelligence and dynamic learning environment of the Bittensor network, as envisioned in its foundational principles and mechanisms described in the NeurIPS paper. paper.
- property block: int#
Returns current chain block. :returns: Current chain block. :rtype: block (int)
- Return type:
- get_proposal_vote_data#
- _do_associate_ips(wallet, ip_info_list, netuid, wait_for_inclusion=False, wait_for_finalization=True)#
Sends an associate IPs extrinsic to the chain.
- Parameters:
wallet (
bittensor.wallet()
) – Wallet object.ip_info_list (
List[IPInfo]()
) – List of IPInfo objects.netuid (int) – Netuid to associate IPs to.
wait_for_inclusion (bool) – If
true
, waits for inclusion.wait_for_finalization (bool) – If
true
, waits for finalization.
- Returns:
True
if associate IPs was successful. error (Optional[str]()
): Error message if associate IPs failed, None otherwise.- Return type:
success (bool)
- _do_burned_register(netuid, wallet, wait_for_inclusion=False, wait_for_finalization=True)#
- _do_delegation(wallet, delegate_ss58, amount, wait_for_inclusion=True, wait_for_finalization=False)#
- _do_nominate(wallet, wait_for_inclusion=True, wait_for_finalization=False)#
- _do_pow_register(netuid, wallet, pow_result, wait_for_inclusion=False, wait_for_finalization=True)#
Sends a (POW) register extrinsic to the chain.
- Parameters:
netuid (int) – The subnet to register on.
wallet (bittensor.wallet) – The wallet to register.
pow_result (POWSolution) – The PoW result to register.
wait_for_inclusion (bool) – If
true
, waits for the extrinsic to be included in a block.wait_for_finalization (bool) – If
true
, waits for the extrinsic to be finalized.
- Returns:
True
if the extrinsic was included in a block. error (Optional[str]):None
on success or not waiting for inclusion/finalization, otherwise the error message.- Return type:
success (bool)
- _do_root_register(wallet, wait_for_inclusion=False, wait_for_finalization=True)#
- _do_serve_axon(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:
wallet (bittensor.wallet) – The wallet associated with the neuron.
call_params (AxonServeCallParams) – Parameters required for the serve axon call.
wait_for_inclusion (bool, optional) – Waits for the transaction to be included in a block.
wait_for_finalization (bool, optional) – Waits for the transaction to be finalized on the blockchain.
- Returns:
A tuple containing a success flag and an optional error message.
- Return type:
This function is crucial for initializing and announcing a neuron’s Axon service on the network, enhancing the decentralized computation capabilities of Bittensor.
- _do_serve_prometheus(wallet, call_params, wait_for_inclusion=False, wait_for_finalization=True)#
Sends a serve prometheus extrinsic to the chain. :param wallet: Wallet object. :type wallet:
bittensor.wallet()
:param call_params: Prometheus serve call parameters. :type call_params:PrometheusServeCallParams()
:param wait_for_inclusion: Iftrue
, waits for inclusion. :type wait_for_inclusion: bool :param wait_for_finalization: Iftrue
, waits for finalization. :type wait_for_finalization: bool- Returns:
True
if serve prometheus was successful. error (Optional[str]()
): Error message if serve prometheus failed,None
otherwise.- Return type:
success (bool)
- Parameters:
wallet (bittensor.wallet) –
call_params (bittensor.types.PrometheusServeCallParams) –
wait_for_inclusion (bool) –
wait_for_finalization (bool) –
- _do_set_weights(wallet, uids, vals, netuid, version_key=bittensor.__version_as_int__, wait_for_inclusion=False, wait_for_finalization=True)#
Internal method to send a transaction to the Bittensor blockchain, setting weights for specified neurons. This method constructs and submits the transaction, handling retries and blockchain communication.
- Parameters:
wallet (bittensor.wallet) – The wallet associated with the neuron setting the weights.
uids (List[int]) – List of neuron UIDs for which weights are being set.
vals (List[int]) – List of weight values corresponding to each UID.
netuid (int) – Unique identifier for the network.
version_key (int, optional) – Version key for compatibility with the network.
wait_for_inclusion (bool, optional) – Waits for the transaction to be included in a block.
wait_for_finalization (bool, optional) – Waits for the transaction to be finalized on the blockchain.
- Returns:
A tuple containing a success flag and an optional error message.
- Return type:
This method is vital for the dynamic weighting mechanism in Bittensor, where neurons adjust their trust in other neurons based on observed performance and contributions.
- _do_stake(wallet, hotkey_ss58, amount, wait_for_inclusion=True, wait_for_finalization=False)#
Sends a stake extrinsic to the chain.
- Parameters:
wallet (
bittensor.wallet()
) – Wallet object that can sign the extrinsic.hotkey_ss58 (str) – Hotkey
ss58
address to stake to.amount (
Balance()
) – Amount to stake.wait_for_inclusion (bool) – If
true
, waits for inclusion before returning.wait_for_finalization (bool) – If
true
, waits for finalization before returning.
- Returns:
True
if the extrinsic was successful.- Return type:
success (bool)
- Raises:
StakeError – If the extrinsic failed.
- _do_swap_hotkey(wallet, new_wallet, wait_for_inclusion=False, wait_for_finalization=True)#
- _do_transfer(wallet, dest, transfer_balance, wait_for_inclusion=True, wait_for_finalization=False)#
Sends a transfer extrinsic to the chain.
- Parameters:
wallet (
bittensor.wallet()
) – Wallet object.dest (str) – Destination public key address.
transfer_balance (
Balance()
) – Amount to transfer.wait_for_inclusion (bool) – If
true
, waits for inclusion.wait_for_finalization (bool) – If
true
, waits for finalization.
- Returns:
True
if transfer was successful. block_hash (str): Block hash of the transfer. On success and if wait_for_ finalization/inclusion isTrue
. error (str): Error message if transfer failed.- Return type:
success (bool)
- _do_undelegation(wallet, delegate_ss58, amount, wait_for_inclusion=True, wait_for_finalization=False)#
- _do_unstake(wallet, hotkey_ss58, amount, wait_for_inclusion=True, wait_for_finalization=False)#
Sends an unstake extrinsic to the chain.
- Parameters:
wallet (
bittensor.wallet()
) – Wallet object that can sign the extrinsic.hotkey_ss58 (str) – Hotkey
ss58
address to unstake from.amount (
Balance()
) – Amount to unstake.wait_for_inclusion (bool) – If
true
, waits for inclusion before returning.wait_for_finalization (bool) – If
true
, waits for finalization before returning.
- Returns:
True
if the extrinsic was successful.- Return type:
success (bool)
- Raises:
StakeError – If the extrinsic failed.
- _encode_params(call_definition, params)#
Returns a hex encoded string of the params using their types.
- Parameters:
call_definition (List[ParamWithTypes]) –
- Return type:
- static _null_neuron()#
- Return type:
- classmethod add_args(parser, prefix=None)#
- Parameters:
parser (argparse.ArgumentParser) –
prefix (str) –
- add_stake(wallet, hotkey_ss58=None, amount=None, wait_for_inclusion=True, wait_for_finalization=False, prompt=False)#
Adds the specified amount of stake to a neuron identified by the hotkey
SS58
address. Staking is a fundamental process in the Bittensor network that enables neurons to participate actively and earn incentives.- Parameters:
wallet (bittensor.wallet) – The wallet to be used for staking.
hotkey_ss58 (Optional[str]) – The
SS58
address of the hotkey associated with the neuron.amount (Union[Balance, float]) – The amount of TAO to stake.
wait_for_inclusion (bool, optional) – Waits for the transaction to be included in a block.
wait_for_finalization (bool, optional) – Waits for the transaction to be finalized on the blockchain.
prompt (bool, optional) – If
True
, prompts for user confirmation before proceeding.
- Returns:
True
if the staking is successful, False otherwise.- Return type:
This function enables neurons to increase their stake in the network, enhancing their influence and potential rewards in line with Bittensor’s consensus and reward mechanisms.
- add_stake_multiple(wallet, hotkey_ss58s, amounts=None, wait_for_inclusion=True, wait_for_finalization=False, prompt=False)#
Adds stakes to multiple neurons identified by their hotkey SS58 addresses. This bulk operation allows for efficient staking across different neurons from a single wallet.
- Parameters:
wallet (bittensor.wallet) – The wallet used for staking.
hotkey_ss58s (List[str]) – List of
SS58
addresses of hotkeys to stake to.amounts (List[Union[Balance, float]], optional) – Corresponding amounts of TAO to stake for each hotkey.
wait_for_inclusion (bool, optional) – Waits for the transaction to be included in a block.
wait_for_finalization (bool, optional) – Waits for the transaction to be finalized on the blockchain.
prompt (bool, optional) – If
True
, prompts for user confirmation before proceeding.
- Returns:
True
if the staking is successful for all specified neurons, False otherwise.- Return type:
This function is essential for managing stakes across multiple neurons, reflecting the dynamic and collaborative nature of the Bittensor network.
- associated_validator_ip_info(netuid, block=None)#
Retrieves the list of all validator IP addresses associated with a specific subnet in the Bittensor network. This information is crucial for network communication and the identification of validator nodes.
- Parameters:
- Returns:
A list of IPInfo objects for validator nodes in the subnet, or
None
if no validators are associated.- Return type:
Optional[List[IPInfo]]
Validator IP information is key for establishing secure and reliable connections within the network, facilitating consensus and validation processes critical for the network’s integrity and performance.
- blocks_since_epoch(netuid, block=None)#
Returns network BlocksSinceLastStep hyper parameter
- bonds(netuid, block=None)#
Retrieves the bond distribution set by neurons within a specific subnet of the Bittensor network. Bonds represent the investments or commitments made by neurons in one another, indicating a level of trust and perceived value. This bonding mechanism is integral to the network’s market-based approach to measuring and rewarding machine intelligence.
- Parameters:
- Returns:
A list of tuples mapping each neuron’s UID to its bonds with other neurons.
- Return type:
Understanding bond distributions is crucial for analyzing the trust dynamics and market behavior within the subnet. It reflects how neurons recognize and invest in each other’s intelligence and contributions, supporting diverse and niche systems within the Bittensor ecosystem.
- burn(netuid, block=None)#
Retrieves the ‘Burn’ hyperparameter for a specified subnet. The ‘Burn’ parameter represents the amount of Tao that is effectively removed from circulation within the Bittensor network.
- Parameters:
- Returns:
The value of the ‘Burn’ hyperparameter if the subnet exists, None otherwise.
- Return type:
Optional[Balance]
Understanding the ‘Burn’ rate is essential for analyzing the network’s economic model, particularly how it manages inflation and the overall supply of its native token Tao.
- burned_register(wallet, netuid, wait_for_inclusion=False, wait_for_finalization=True, prompt=False)#
Registers a neuron on the Bittensor network by burning TAO. This method of registration involves recycling TAO tokens, contributing to the network’s deflationary mechanism.
- Parameters:
wallet (bittensor.wallet) – The wallet associated with the neuron to be registered.
netuid (int) – The unique identifier of the subnet.
wait_for_inclusion (bool, optional) – Waits for the transaction to be included in a block.
wait_for_finalization (bool, optional) – Waits for the transaction to be finalized on the blockchain.
prompt (bool, optional) – If
True
, prompts for user confirmation before proceeding.
- Returns:
True
if the registration is successful, False otherwise.- Return type:
This function offers an alternative registration path, aligning with the network’s principles of token circulation and value conservation.
- close()#
Cleans up resources for this subtensor instance like active websocket connection and active extensions
- static config()#
- Return type:
- connect_websocket()#
(Re)creates the websocket connection, if the URL contains a ‘ws’ or ‘wss’ scheme
- delegate(wallet, delegate_ss58=None, amount=None, wait_for_inclusion=True, wait_for_finalization=False, prompt=False)#
Becomes a delegate for the hotkey associated with the given wallet. This method is used to nominate a neuron (identified by the hotkey in the wallet) as a delegate on the Bittensor network, allowing it to participate in consensus and validation processes.
- Parameters:
wallet (bittensor.wallet) – The wallet containing the hotkey to be nominated.
wait_for_finalization (bool, optional) – If
True
, waits until the transaction is finalized on the blockchain.wait_for_inclusion (bool, optional) – If
True
, waits until the transaction is included in a block.delegate_ss58 (Optional[str]) –
amount (Union[bittensor.utils.balance.Balance, float]) –
prompt (bool) –
- Returns:
True
if the nomination process is successful, False otherwise.- Return type:
This function is a key part of the decentralized governance mechanism of Bittensor, allowing for the dynamic selection and participation of validators in the network’s consensus process.
- static determine_chain_endpoint_and_network(network)#
Determines the chain endpoint and network from the passed network or chain_endpoint.
- Parameters:
- Returns:
The network flag. chain_endpoint (str): The chain endpoint flag. If set, overrides the
network
argument.- Return type:
network (str)
- difficulty(netuid, block=None)#
Retrieves the ‘Difficulty’ hyperparameter for a specified subnet in the Bittensor network. This parameter is instrumental in determining the computational challenge required for neurons to participate in consensus and validation processes.
- Parameters:
- Returns:
The value of the ‘Difficulty’ hyperparameter if the subnet exists,
None
otherwise.- Return type:
Optional[int]
The ‘Difficulty’ parameter directly impacts the network’s security and integrity by setting the computational effort required for validating transactions and participating in the network’s consensus mechanism.
- does_hotkey_exist(hotkey_ss58, block=None)#
Returns true if the hotkey is known by the chain and there are accounts.
- get_all_neurons_for_pubkey(hotkey_ss58, block=None)#
Retrieves information about all neuron instances associated with a given public key (hotkey
SS58
address) across different subnets of the Bittensor network. This function aggregates neuron data from various subnets to provide a comprehensive view of a neuron’s presence and status within the network.- Parameters:
- Returns:
A list of NeuronInfo objects detailing the neuron’s presence across various subnets.
- Return type:
List[NeuronInfo]
This function is valuable for analyzing a neuron’s overall participation, influence, and contributions across the Bittensor network.
- get_all_subnet_netuids(block=None)#
Retrieves the list of all subnet unique identifiers (netuids) currently present in the Bittensor network.
- Parameters:
block (Optional[int], optional) – The blockchain block number at which to retrieve the subnet netuids.
- Returns:
A list of subnet netuids.
- Return type:
List[int]
This function provides a comprehensive view of the subnets within the Bittensor network, offering insights into its diversity and scale.
- get_all_subnets_info(block=None)#
Retrieves detailed information about all subnets within the Bittensor network. This function provides comprehensive data on each subnet, including its characteristics and operational parameters.
- Parameters:
block (Optional[int], optional) – The blockchain block number for the query.
- Returns:
A list of SubnetInfo objects, each containing detailed information about a subnet.
- Return type:
List[SubnetInfo]
Gaining insights into the subnets’ details assists in understanding the network’s composition, the roles of different subnets, and their unique features.
- get_all_uids_for_hotkey(hotkey_ss58, block=None)#
Retrieves all unique identifiers (UIDs) associated with a given hotkey across different subnets within the Bittensor network. This function helps in identifying all the neuron instances that are linked to a specific hotkey.
- Parameters:
- Returns:
A list of UIDs associated with the given hotkey across various subnets.
- Return type:
List[int]
This function is important for tracking a neuron’s presence and activities across different subnets within the Bittensor ecosystem.
- get_axon_info(netuid, hotkey_ss58, block=None)#
Returns the axon information for this hotkey account
- Parameters:
- Return type:
Optional[bittensor.chain_data.AxonInfo]
- get_balance(address, block=None)#
Retrieves the token balance of a specific address within the Bittensor network. This function queries the blockchain to determine the amount of Tao held by a given account.
- Parameters:
- Returns:
The account balance at the specified block, represented as a Balance object.
- Return type:
Balance
This function is important for monitoring account holdings and managing financial transactions within the Bittensor ecosystem. It helps in assessing the economic status and capacity of network participants.
- get_balances(block=None)#
Retrieves the token balances of all accounts within the Bittensor network as of a specific blockchain block. This function provides a comprehensive view of the token distribution among different accounts.
- Parameters:
block (int, optional) – The blockchain block number at which to perform the query.
- Returns:
A dictionary mapping each account’s
ss58
address to its balance.- Return type:
Dict[str, Balance]
This function is valuable for analyzing the overall economic landscape of the Bittensor network, including the distribution of financial resources and the financial status of network participants.
- get_block_hash(block_id)#
Retrieves the hash of a specific block on the Bittensor blockchain. The block hash is a unique identifier representing the cryptographic hash of the block’s content, ensuring its integrity and immutability.
- Parameters:
block_id (int) – The block number for which the hash is to be retrieved.
- Returns:
The cryptographic hash of the specified block.
- Return type:
The block hash is a fundamental aspect of blockchain technology, providing a secure reference to each block’s data. It is crucial for verifying transactions, ensuring data consistency, and maintaining the trustworthiness of the blockchain.
- get_commitment(netuid, uid, block=None)#
- get_current_block()#
Returns the current block number on the Bittensor blockchain. This function provides the latest block number, indicating the most recent state of the blockchain.
- Returns:
The current chain block number.
- Return type:
Knowing the current block number is essential for querying real-time data and performing time-sensitive operations on the blockchain. It serves as a reference point for network activities and data synchronization.
- get_delegate_by_hotkey(hotkey_ss58, block=None)#
Retrieves detailed information about a delegate neuron based on its hotkey. This function provides a comprehensive view of the delegate’s status, including its stakes, nominators, and reward distribution.
- Parameters:
- Returns:
Detailed information about the delegate neuron,
None
if not found.- Return type:
Optional[DelegateInfo]
This function is essential for understanding the roles and influence of delegate neurons within the Bittensor network’s consensus and governance structures.
- get_delegate_take(hotkey_ss58, block=None)#
Retrieves the delegate ‘take’ percentage for a neuron identified by its hotkey. The ‘take’ represents the percentage of rewards that the delegate claims from its nominators’ stakes.
- Parameters:
- Returns:
The delegate take percentage, None if not available.
- Return type:
Optional[float]
The delegate take is a critical parameter in the network’s incentive structure, influencing the distribution of rewards among neurons and their nominators.
- get_delegated(coldkey_ss58, block=None)#
Retrieves a list of delegates and their associated stakes for a given coldkey. This function identifies the delegates that a specific account has staked tokens on.
- Parameters:
- Returns:
A list of tuples, each containing a delegate’s information and staked amount.
- Return type:
List[Tuple[DelegateInfo, Balance]]
This function is important for account holders to understand their stake allocations and their involvement in the network’s delegation and consensus mechanisms.
- get_delegates(block=None)#
Retrieves a list of all delegate neurons within the Bittensor network. This function provides an overview of the neurons that are actively involved in the network’s delegation system.
- Parameters:
block (Optional[int], optional) – The blockchain block number for the query.
- Returns:
A list of DelegateInfo objects detailing each delegate’s characteristics.
- Return type:
List[DelegateInfo]
Analyzing the delegate population offers insights into the network’s governance dynamics and the distribution of trust and responsibility among participating neurons.
- get_emission_value_by_subnet(netuid, block=None)#
Retrieves the emission value of a specific subnet within the Bittensor network. The emission value represents the rate at which the subnet emits or distributes the network’s native token (Tao).
- Parameters:
- Returns:
The emission value of the subnet, None if not available.
- Return type:
Optional[float]
The emission value is a critical economic parameter, influencing the incentive distribution and reward mechanisms within the subnet.
- get_existential_deposit(block=None)#
Retrieves the existential deposit amount for the Bittensor blockchain. The existential deposit is the minimum amount of TAO required for an account to exist on the blockchain. Accounts with balances below this threshold can be reaped to conserve network resources.
- Parameters:
block (Optional[int], optional) – Block number at which to query the deposit amount. If
None
, the current block is used.- Returns:
The existential deposit amount, or
None
if the query fails.- Return type:
Optional[Balance]
The existential deposit is a fundamental economic parameter in the Bittensor network, ensuring efficient use of storage and preventing the proliferation of dust accounts.
- get_hotkey_owner(hotkey_ss58, block=None)#
Returns the coldkey owner of the passed hotkey
- get_netuids_for_hotkey(hotkey_ss58, block=None)#
Retrieves a list of subnet UIDs (netuids) for which a given hotkey is a member. This function identifies the specific subnets within the Bittensor network where the neuron associated with the hotkey is active.
- get_neuron_for_pubkey_and_subnet(hotkey_ss58, netuid, block=None)#
Retrieves information about a neuron based on its public key (hotkey SS58 address) and the specific subnet UID (netuid). This function provides detailed neuron information for a particular subnet within the Bittensor network.
- Parameters:
- Returns:
Detailed information about the neuron if found,
None
otherwise.- Return type:
Optional[NeuronInfo]
This function is crucial for accessing specific neuron data and understanding its status, stake, and other attributes within a particular subnet of the Bittensor ecosystem.
- get_nominators_for_hotkey(hotkey_ss58, block=None)#
Retrieves a list of nominators and their stakes for a neuron identified by its hotkey. Nominators are neurons that stake their tokens on a delegate to support its operations.
- Parameters:
- Returns:
A list of tuples containing each nominator’s address and staked amount.
- Return type:
List[Tuple[str, Balance]]
This function provides insights into the neuron’s support network within the Bittensor ecosystem, indicating its trust and collaboration relationships.
- get_prometheus_info(netuid, hotkey_ss58, block=None)#
Returns the prometheus information for this hotkey account
- Parameters:
- Return type:
Optional[bittensor.chain_data.AxonInfo]
- get_proposal_call_data(proposal_hash, block=None)#
Retrieves the call data of a specific proposal on the Bittensor blockchain. This data provides detailed information about the proposal, including its purpose and specifications.
- Parameters:
- Returns:
An object containing the proposal’s call data, or
None
if not found.- Return type:
Optional[bittensor.ProposalCallData]
This function is crucial for analyzing the types of proposals made within the network and the specific changes or actions they intend to implement or address.
- get_proposal_hashes(block=None)#
Retrieves the list of proposal hashes currently present on the Bittensor blockchain. Each hash uniquely identifies a proposal made within the network.
- Parameters:
block (Optional[int], optional) – The blockchain block number to query the proposal hashes.
- Returns:
A list of proposal hashes, or
None
if not available.- Return type:
Optional[List[str]]
This function enables tracking and reviewing the proposals made in the network, offering insights into the active governance and decision-making processes.
- get_proposals(block=None)#
Retrieves all active proposals on the Bittensor blockchain, along with their call and voting data. This comprehensive view allows for a thorough understanding of the proposals and their reception by the senate.
- Parameters:
block (Optional[int], optional) – The blockchain block number to query the proposals.
- Returns:
A dictionary mapping proposal hashes to their corresponding call and vote data, or
None
if not available.- Return type:
Optional[Dict[str, Tuple[bittensor.ProposalCallData, bittensor.ProposalVoteData]]]
This function is integral for analyzing the governance activity on the Bittensor network, providing a holistic view of the proposals and their impact or potential changes within the network.
- get_senate_members(block=None)#
Retrieves the list of current senate members from the Bittensor blockchain. Senate members are responsible for governance and decision-making within the network.
- Parameters:
block (Optional[int], optional) – The blockchain block number at which to retrieve the senate members.
- Returns:
A list of
SS58
addresses of current senate members, orNone
if not available.- Return type:
Optional[List[str]]
Understanding the composition of the senate is key to grasping the governance structure and decision-making authority within the Bittensor network.
- get_stake(hotkey_ss58, block=None)#
Returns a list of stake tuples (coldkey, balance) for each delegating coldkey including the owner
- get_stake_for_coldkey_and_hotkey(hotkey_ss58, coldkey_ss58, block=None)#
Returns the stake under a coldkey - hotkey pairing
- get_stake_info_for_coldkey(coldkey_ss58, block=None)#
Retrieves stake information associated with a specific coldkey. This function provides details about the stakes held by an account, including the staked amounts and associated delegates.
- Parameters:
- Returns:
A list of StakeInfo objects detailing the stake allocations for the account.
- Return type:
List[StakeInfo]
Stake information is vital for account holders to assess their investment and participation in the network’s delegation and consensus processes.
- get_stake_info_for_coldkeys(coldkey_ss58_list, block=None)#
Retrieves stake information for a list of coldkeys. This function aggregates stake data for multiple accounts, providing a collective view of their stakes and delegations.
- Parameters:
- Returns:
A dictionary mapping each coldkey to a list of its StakeInfo objects.
- Return type:
This function is useful for analyzing the stake distribution and delegation patterns of multiple accounts simultaneously, offering a broader perspective on network participation and investment strategies.
- get_subnet_burn_cost(block=None)#
Retrieves the burn cost for registering a new subnet within the Bittensor network. This cost represents the amount of Tao that needs to be locked or burned to establish a new subnet.
- Parameters:
block (Optional[int]) – The blockchain block number for the query.
- Returns:
The burn cost for subnet registration.
- Return type:
The subnet burn cost is an important economic parameter, reflecting the network’s mechanisms for controlling the proliferation of subnets and ensuring their commitment to the network’s long-term viability.
- get_subnet_connection_requirement(netuid_0, netuid_1, block=None)#
- get_subnet_connection_requirements(netuid, block=None)#
Retrieves the connection requirements for a specific subnet within the Bittensor network. This function provides details on the criteria that must be met for neurons to connect to the subnet.
- Parameters:
- Returns:
A dictionary detailing the connection requirements for the subnet.
- Return type:
Understanding these requirements is crucial for neurons looking to participate in or interact with specific subnets, ensuring compliance with their connection standards.
- get_subnet_hyperparameters(netuid, block=None)#
Retrieves the hyperparameters for a specific subnet within the Bittensor network. These hyperparameters define the operational settings and rules governing the subnet’s behavior.
- Parameters:
- Returns:
The subnet’s hyperparameters, or
None
if not available.- Return type:
Optional[SubnetHyperparameters]
Understanding the hyperparameters is crucial for comprehending how subnets are configured and managed, and how they interact with the network’s consensus and incentive mechanisms.
- get_subnet_info(netuid, block=None)#
Retrieves detailed information about a specific subnet within the Bittensor network. This function provides key data on the subnet, including its operational parameters and network status.
- Parameters:
- Returns:
Detailed information about the subnet, or
None
if not found.- Return type:
Optional[SubnetInfo]
This function is essential for neurons and stakeholders interested in the specifics of a particular subnet, including its governance, performance, and role within the broader network.
- get_subnet_modality(netuid, block=None)#
- get_subnet_owner(netuid, block=None)#
Retrieves the owner’s address of a specific subnet within the Bittensor network. The owner is typically the entity responsible for the creation and maintenance of the subnet.
- Parameters:
- Returns:
The SS58 address of the subnet’s owner, or
None
if not available.- Return type:
Optional[str]
Knowing the subnet owner provides insights into the governance and operational control of the subnet, which can be important for decision-making and collaboration within the network.
- get_subnets(block=None)#
Retrieves a list of all subnets currently active within the Bittensor network. This function provides an overview of the various subnets and their identifiers.
- Parameters:
block (Optional[int], optional) – The blockchain block number for the query.
- Returns:
A list of network UIDs representing each active subnet.
- Return type:
List[int]
This function is valuable for understanding the network’s structure and the diversity of subnets available for neuron participation and collaboration.
- get_total_stake_for_coldkey(ss58_address, block=None)#
Returns the total stake held on a coldkey across all hotkeys including delegates
- get_total_stake_for_hotkey(ss58_address, block=None)#
Returns the total stake held on a hotkey including delegative
- get_total_subnets(block=None)#
Retrieves the total number of subnets within the Bittensor network as of a specific blockchain block.
- Parameters:
block (Optional[int], optional) – The blockchain block number for the query.
- Returns:
The total number of subnets in the network.
- Return type:
Understanding the total number of subnets is essential for assessing the network’s growth and the extent of its decentralized infrastructure.
- get_transfer_fee(wallet, dest, value)#
Calculates the transaction fee for transferring tokens from a wallet to a specified destination address. This function simulates the transfer to estimate the associated cost, taking into account the current network conditions and transaction complexity.
- Parameters:
- Returns:
The estimated transaction fee for the transfer, represented as a Balance object.
- Return type:
Balance
Estimating the transfer fee is essential for planning and executing token transactions, ensuring that the wallet has sufficient funds to cover both the transfer amount and the associated costs. This function provides a crucial tool for managing financial operations within the Bittensor network.
- get_uid_for_hotkey_on_subnet(hotkey_ss58, netuid, block=None)#
Retrieves the unique identifier (UID) for a neuron’s hotkey on a specific subnet.
- Parameters:
- Returns:
The UID of the neuron if it is registered on the subnet,
None
otherwise.- Return type:
Optional[int]
The UID is a critical identifier within the network, linking the neuron’s hotkey to its operational and governance activities on a particular subnet.
- get_vote_data(proposal_hash, block=None)#
Retrieves the voting data for a specific proposal on the Bittensor blockchain. This data includes information about how senate members have voted on the proposal.
- Parameters:
- Returns:
An object containing the proposal’s voting data, or
None
if not found.- Return type:
Optional[ProposalVoteData]
This function is important for tracking and understanding the decision-making processes within the Bittensor network, particularly how proposals are received and acted upon by the governing body.
- classmethod help()#
Print help to stdout
- immunity_period(netuid, block=None)#
Retrieves the ‘ImmunityPeriod’ hyperparameter for a specific subnet. This parameter defines the duration during which new neurons are protected from certain network penalties or restrictions.
- Parameters:
- Returns:
The value of the ‘ImmunityPeriod’ hyperparameter if the subnet exists,
None
otherwise.- Return type:
Optional[int]
The ‘ImmunityPeriod’ is a critical aspect of the network’s governance system, ensuring that new participants have a grace period to establish themselves and contribute to the network without facing immediate punitive actions.
- incentive(netuid, block=None)#
Retrieves the list of incentives for neurons within a specific subnet of the Bittensor network. This function provides insights into the reward distribution mechanisms and the incentives allocated to each neuron based on their contributions and activities.
- Parameters:
- Returns:
The list of incentives for neurons within the subnet, indexed by UID.
- Return type:
List[int]
Understanding the incentive structure is crucial for analyzing the network’s economic model and the motivational drivers for neuron participation and collaboration.
- is_hotkey_delegate(hotkey_ss58, block=None)#
Determines whether a given hotkey (public key) is a delegate on the Bittensor network. This function checks if the neuron associated with the hotkey is part of the network’s delegation system.
- Parameters:
- Returns:
True
if the hotkey is a delegate,False
otherwise.- Return type:
Being a delegate is a significant status within the Bittensor network, indicating a neuron’s involvement in consensus and governance processes.
- is_hotkey_registered(hotkey_ss58, netuid=None, block=None)#
Determines whether a given hotkey (public key) is registered in the Bittensor network, either globally across any subnet or specifically on a specified subnet. This function checks the registration status of a neuron identified by its hotkey, which is crucial for validating its participation and activities within the network.
- Parameters:
hotkey_ss58 (str) – The SS58 address of the neuron’s hotkey.
netuid (Optional[int], optional) – The unique identifier of the subnet to check the registration. If
None
, the registration is checked across all subnets.block (Optional[int], optional) – The blockchain block number at which to perform the query.
- Returns:
True
if the hotkey is registered in the specified context (either any subnet or a specific subnet),False
otherwise.- Return type:
This function is important for verifying the active status of neurons in the Bittensor network. It aids in understanding whether a neuron is eligible to participate in network processes such as consensus, validation, and incentive distribution based on its registration status.
- is_hotkey_registered_any(hotkey_ss58, block=None)#
Checks if a neuron’s hotkey is registered on any subnet within the Bittensor network.
- Parameters:
- Returns:
True
if the hotkey is registered on any subnet, False otherwise.- Return type:
This function is essential for determining the network-wide presence and participation of a neuron.
- is_hotkey_registered_on_subnet(hotkey_ss58, netuid, block=None)#
Checks if a neuron’s hotkey is registered on a specific subnet within the Bittensor network.
- Parameters:
- Returns:
True
if the hotkey is registered on the specified subnet, False otherwise.- Return type:
This function helps in assessing the participation of a neuron in a particular subnet, indicating its specific area of operation or influence within the network.
- is_senate_member(hotkey_ss58, block=None)#
Checks if a given neuron (identified by its hotkey SS58 address) is a member of the Bittensor senate. The senate is a key governance body within the Bittensor network, responsible for overseeing and approving various network operations and proposals.
- Parameters:
- Returns:
True
if the neuron is a senate member at the given block, False otherwise.- Return type:
This function is crucial for understanding the governance dynamics of the Bittensor network and for identifying the neurons that hold decision-making power within the network.
- kappa(netuid, block=None)#
Retrieves the ‘Kappa’ hyperparameter for a specified subnet. ‘Kappa’ is a critical parameter in the Bittensor network that controls the distribution of stake weights among neurons, impacting their rankings and incentive allocations.
- Parameters:
- Returns:
The value of the ‘Kappa’ hyperparameter if the subnet exists, None otherwise.
- Return type:
Optional[float]
- Mathematical Context:
Kappa (κ) is used in the calculation of neuron ranks, which determine their share of network incentives. It is derived from the softmax function applied to the inter-neuronal weights set by each neuron. The formula for Kappa is: κ_i = exp(w_i) / Σ(exp(w_j)), where w_i represents the weight set by neuron i, and the denominator is the sum of exponential weights set by all neurons. This mechanism ensures a normalized and probabilistic distribution of ranks based on relative weights.
Understanding ‘Kappa’ is crucial for analyzing stake dynamics and the consensus mechanism within the network, as it plays a significant role in neuron ranking and incentive allocation processes.
- leave_senate(wallet, wait_for_inclusion=True, wait_for_finalization=False, prompt=False)#
Removes a specified amount of stake from a single hotkey account. This function is critical for adjusting individual neuron stakes within the Bittensor network.
- Parameters:
wallet (bittensor.wallet) – The wallet associated with the neuron from which the stake is being removed.
hotkey_ss58 (Optional[str]) – The
SS58
address of the hotkey account to unstake from.amount (Union[Balance, float], optional) – The amount of TAO to unstake. If not specified, unstakes all.
wait_for_inclusion (bool, optional) – Waits for the transaction to be included in a block.
wait_for_finalization (bool, optional) – Waits for the transaction to be finalized on the blockchain.
prompt (bool, optional) – If
True
, prompts for user confirmation before proceeding.
- Returns:
True
if the unstaking process is successful, False otherwise.- Return type:
This function supports flexible stake management, allowing neurons to adjust their network participation and potential reward accruals.
- max_allowed_validators(netuid, block=None)#
Returns network MaxAllowedValidators hyper parameter
- max_n(netuid, block=None)#
Returns network MaxAllowedUids hyper parameter
- max_weight_limit(netuid, block=None)#
Returns network MaxWeightsLimit hyper parameter
- metagraph(netuid, lite=True, block=None)#
Returns a synced metagraph for a specified subnet within the Bittensor network. The metagraph represents the network’s structure, including neuron connections and interactions.
- Parameters:
- Returns:
The metagraph representing the subnet’s structure and neuron relationships.
- Return type:
bittensor.Metagraph
The metagraph is an essential tool for understanding the topology and dynamics of the Bittensor network’s decentralized architecture, particularly in relation to neuron interconnectivity and consensus processes.
- min_allowed_weights(netuid, block=None)#
Returns network MinAllowedWeights hyper parameter
- neuron_for_uid(uid, netuid, block=None)#
Retrieves detailed information about a specific neuron identified by its unique identifier (UID) within a specified subnet (netuid) of the Bittensor network. This function provides a comprehensive view of a neuron’s attributes, including its stake, rank, and operational status.
- Parameters:
- Returns:
Detailed information about the neuron if found,
None
otherwise.- Return type:
Optional[NeuronInfo]
This function is crucial for analyzing individual neurons’ contributions and status within a specific subnet, offering insights into their roles in the network’s consensus and validation mechanisms.
- neuron_for_uid_lite(uid, netuid, block=None)#
Retrieves a lightweight version of information about a neuron in a specific subnet, identified by its UID. The ‘lite’ version focuses on essential attributes such as stake and network activity.
- Parameters:
- Returns:
A simplified version of neuron information if found,
None
otherwise.- Return type:
Optional[NeuronInfoLite]
This function is useful for quick and efficient analyses of neuron status and activities within a subnet without the need for comprehensive data retrieval.
- neuron_for_wallet(wallet, netuid, block=None)#
Retrieves information about a neuron associated with a given wallet on a specific subnet. This function provides detailed data about the neuron’s status, stake, and activities based on the wallet’s hotkey address.
- Parameters:
- Returns:
Detailed information about the neuron if found,
None
otherwise.- Return type:
Optional[NeuronInfo]
This function is important for wallet owners to understand and manage their neuron’s presence and activities within a particular subnet of the Bittensor network.
- neuron_has_validator_permit(uid, netuid, block=None)#
Checks if a neuron, identified by its unique identifier (UID), has a validator permit on a specific subnet within the Bittensor network. This function determines whether the neuron is authorized to participate in validation processes on the subnet.
- Parameters:
- Returns:
True
if the neuron has a validator permit, False otherwise.- Return type:
Optional[bool]
This function is essential for understanding a neuron’s role and capabilities within a specific subnet, particularly regarding its involvement in network validation and governance.
- neurons(netuid, block=None)#
Retrieves a list of all neurons within a specified subnet of the Bittensor network. This function provides a snapshot of the subnet’s neuron population, including each neuron’s attributes and network interactions.
- Parameters:
- Returns:
A list of NeuronInfo objects detailing each neuron’s characteristics in the subnet.
- Return type:
List[NeuronInfo]
Understanding the distribution and status of neurons within a subnet is key to comprehending the network’s decentralized structure and the dynamics of its consensus and governance processes.
- neurons_lite(netuid, block=None)#
Retrieves a list of neurons in a ‘lite’ format from a specific subnet of the Bittensor network. This function provides a streamlined view of the neurons, focusing on key attributes such as stake and network participation.
- Parameters:
- Returns:
A list of simplified neuron information for the subnet.
- Return type:
List[NeuronInfoLite]
This function offers a quick overview of the neuron population within a subnet, facilitating efficient analysis of the network’s decentralized structure and neuron dynamics.
- nominate(wallet, wait_for_finalization=False, wait_for_inclusion=True)#
Becomes a delegate for the hotkey associated with the given wallet. This method is used to nominate a neuron (identified by the hotkey in the wallet) as a delegate on the Bittensor network, allowing it to participate in consensus and validation processes.
- Parameters:
- Returns:
True
if the nomination process is successful,False
otherwise.- Return type:
This function is a key part of the decentralized governance mechanism of Bittensor, allowing for the dynamic selection and participation of validators in the network’s consensus process.
- query_constant(module_name, constant_name, block=None)#
Retrieves a constant from the specified module on the Bittensor blockchain. This function is used to access fixed parameters or values defined within the blockchain’s modules, which are essential for understanding the network’s configuration and rules.
- Parameters:
- Returns:
The value of the constant if found,
None
otherwise.- Return type:
Optional[object]
Constants queried through this function can include critical network parameters such as inflation rates, consensus rules, or validation thresholds, providing a deeper understanding of the Bittensor network’s operational parameters.
- query_identity(key, block=None)#
Queries the identity of a neuron on the Bittensor blockchain using the given key. This function retrieves detailed identity information about a specific neuron, which is a crucial aspect of the network’s decentralized identity and governance system.
Note
See the Bittensor CLI documentation for supported identity parameters.
- Parameters:
- Returns:
An object containing the identity information of the neuron if found,
None
otherwise.- Return type:
Optional[object]
The identity information can include various attributes such as the neuron’s stake, rank, and other network-specific details, providing insights into the neuron’s role and status within the Bittensor network.
- query_map(module, name, block=None, params=[])#
Queries map storage from any module on the Bittensor blockchain. This function retrieves data structures that represent key-value mappings, essential for accessing complex and structured data within the blockchain modules.
- Parameters:
module (str) – The name of the module from which to query the map storage.
name (str) – The specific storage function within the module to query.
block (Optional[int], optional) – The blockchain block number at which to perform the query.
params (Optional[List[object]], optional) – Parameters to be passed to the query.
- Returns:
A data structure representing the map storage if found,
None
otherwise.- Return type:
Optional[object]
This function is particularly useful for retrieving detailed and structured data from various blockchain modules, offering insights into the network’s state and the relationships between its different components.
- query_map_subtensor(name, block=None, params=[])#
Queries map storage from the Subtensor module on the Bittensor blockchain. This function is designed to retrieve a map-like data structure, which can include various neuron-specific details or network-wide attributes.
- Parameters:
- Returns:
An object containing the map-like data structure, or
None
if not found.- Return type:
QueryMapResult
This function is particularly useful for analyzing and understanding complex network structures and relationships within the Bittensor ecosystem, such as inter-neuronal connections and stake distributions.
- query_module(module, name, block=None, params=[])#
Queries any module storage on the Bittensor blockchain with the specified parameters and block number. This function is a generic query interface that allows for flexible and diverse data retrieval from various blockchain modules.
- Parameters:
module (str) – The name of the module from which to query data.
name (str) – The name of the storage function within the module.
block (Optional[int], optional) – The blockchain block number at which to perform the query.
params (Optional[List[object]], optional) – A list of parameters to pass to the query function.
- Returns:
An object containing the requested data if found,
None
otherwise.- Return type:
Optional[object]
This versatile query function is key to accessing a wide range of data and insights from different parts of the Bittensor blockchain, enhancing the understanding and analysis of the network’s state and dynamics.
- query_runtime_api(runtime_api, method, params, block=None)#
Queries the runtime API of the Bittensor blockchain, providing a way to interact with the underlying runtime and retrieve data encoded in Scale Bytes format. This function is essential for advanced users who need to interact with specific runtime methods and decode complex data types.
- Parameters:
runtime_api (str) – The name of the runtime API to query.
method (str) – The specific method within the runtime API to call.
params (Optional[List[ParamWithTypes]], optional) – The parameters to pass to the method call.
block (Optional[int], optional) – The blockchain block number at which to perform the query.
- Returns:
The Scale Bytes encoded result from the runtime API call, or
None
if the call fails.- Return type:
Optional[bytes]
This function enables access to the deeper layers of the Bittensor blockchain, allowing for detailed and specific interactions with the network’s runtime environment.
- query_subtensor(name, block=None, params=[])#
Queries named storage from the Subtensor module on the Bittensor blockchain. This function is used to retrieve specific data or parameters from the blockchain, such as stake, rank, or other neuron-specific attributes.
- Parameters:
- Returns:
An object containing the requested data if found,
None
otherwise.- Return type:
Optional[object]
This query function is essential for accessing detailed information about the network and its neurons, providing valuable insights into the state and dynamics of the Bittensor ecosystem.
- register(wallet, netuid, wait_for_inclusion=False, wait_for_finalization=True, prompt=False, max_allowed_attempts=3, output_in_place=True, cuda=False, dev_id=0, tpb=256, num_processes=None, update_interval=None, log_verbose=False)#
Registers a neuron on the Bittensor network using the provided wallet. Registration is a critical step for a neuron to become an active participant in the network, enabling it to stake, set weights, and receive incentives.
- Parameters:
wallet (bittensor.wallet) – The wallet associated with the neuron to be registered.
netuid (int) – The unique identifier of the subnet.
wait_for_inclusion (bool, optional) – Waits for the transaction to be included in a block.
wait_for_finalization (bool, optional) – Waits for the transaction to be finalized on the blockchain.
arguments (Other) – Various optional parameters to customize the registration process.
prompt (bool) –
max_allowed_attempts (int) –
output_in_place (bool) –
cuda (bool) –
tpb (int) –
num_processes (Optional[int]) –
update_interval (Optional[int]) –
log_verbose (bool) –
- Returns:
True
if the registration is successful, False otherwise.- Return type:
This function facilitates the entry of new neurons into the network, supporting the decentralized growth and scalability of the Bittensor ecosystem.
- register_senate(wallet, wait_for_inclusion=True, wait_for_finalization=False, prompt=False)#
Removes a specified amount of stake from a single hotkey account. This function is critical for adjusting individual neuron stakes within the Bittensor network.
- Parameters:
wallet (bittensor.wallet) – The wallet associated with the neuron from which the stake is being removed.
hotkey_ss58 (Optional[str]) – The
SS58
address of the hotkey account to unstake from.amount (Union[Balance, float], optional) – The amount of TAO to unstake. If not specified, unstakes all.
wait_for_inclusion (bool, optional) – Waits for the transaction to be included in a block.
wait_for_finalization (bool, optional) – Waits for the transaction to be finalized on the blockchain.
prompt (bool, optional) – If
True
, prompts for user confirmation before proceeding.
- Returns:
True
if the unstaking process is successful, False otherwise.- Return type:
This function supports flexible stake management, allowing neurons to adjust their network participation and potential reward accruals.
- register_subnetwork(wallet, wait_for_inclusion=False, wait_for_finalization=True, prompt=False)#
Registers a new subnetwork on the Bittensor network using the provided wallet. This function is used for the creation and registration of subnetworks, which are specialized segments of the overall Bittensor network.
- Parameters:
wallet (bittensor.wallet) – The wallet to be used for registration.
wait_for_inclusion (bool, optional) – Waits for the transaction to be included in a block.
wait_for_finalization (bool, optional) – Waits for the transaction to be finalized on the blockchain.
prompt (bool, optional) – If
True
, prompts for user confirmation before proceeding.
- Returns:
True
if the subnetwork registration is successful, False otherwise.- Return type:
This function allows for the expansion and diversification of the Bittensor network, supporting its decentralized and adaptable architecture.
- rho(netuid, block=None)#
Retrieves the ‘Rho’ hyperparameter for a specified subnet within the Bittensor network. ‘Rho’ represents the global inflation rate, which directly influences the network’s token emission rate and economic model.
Note
This is currently fixed such that the Bittensor blockchain emmits 7200 Tao per day.
- Parameters:
- Returns:
The value of the ‘Rho’ hyperparameter if the subnet exists,
None
otherwise.- Return type:
Optional[int]
- Mathematical Context:
Rho (p) is calculated based on the network’s target inflation and actual neuron staking. It adjusts the emission rate of the TAO token to balance the network’s economy and dynamics. The formula for Rho is defined as: p = (Staking_Target / Staking_Actual) * Inflation_Target. Here, Staking_Target and Staking_Actual represent the desired and actual total stakes in the network, while Inflation_Target is the predefined inflation rate goal.
‘Rho’ is essential for understanding the network’s economic dynamics, affecting the reward distribution and incentive structures across the network’s neurons.
- root_register(wallet, wait_for_inclusion=False, wait_for_finalization=True, prompt=False)#
Registers the neuron associated with the wallet on the root network. This process is integral for participating in the highest layer of decision-making and governance within the Bittensor network.
- Parameters:
wallet (bittensor.wallet) – The wallet associated with the neuron to be registered on the root network.
wait_for_inclusion (bool, optional) – Waits for the transaction to be included in a block.
wait_for_finalization (bool, optional) – Waits for the transaction to be finalized on the blockchain.
prompt (bool, optional) – If
True
, prompts for user confirmation before proceeding.
- Returns:
True
if the registration on the root network is successful, False otherwise.- Return type:
This function enables neurons to engage in the most critical and influential aspects of the network’s governance, signifying a high level of commitment and responsibility in the Bittensor ecosystem.
- root_set_weights(wallet, netuids, weights, version_key=0, wait_for_inclusion=False, wait_for_finalization=False, prompt=False)#
Sets the weights for neurons on the root network. This action is crucial for defining the influence and interactions of neurons at the root level of the Bittensor network.
- Parameters:
wallet (bittensor.wallet) – The wallet associated with the neuron setting the weights.
netuids (Union[torch.LongTensor, list]) – The list of neuron UIDs for which weights are being set.
weights (Union[torch.FloatTensor, list]) – The corresponding weights to be set for each UID.
version_key (int, optional) – Version key for compatibility with the network.
wait_for_inclusion (bool, optional) – Waits for the transaction to be included in a block.
wait_for_finalization (bool, optional) – Waits for the transaction to be finalized on the blockchain.
prompt (bool, optional) – If
True
, prompts for user confirmation before proceeding.
- Returns:
True
if the setting of root-level weights is successful, False otherwise.- Return type:
This function plays a pivotal role in shaping the root network’s collective intelligence and decision-making processes, reflecting the principles of decentralized governance and collaborative learning in Bittensor.
- run_faucet(wallet, wait_for_inclusion=False, wait_for_finalization=True, prompt=False, max_allowed_attempts=3, output_in_place=True, cuda=False, dev_id=0, tpb=256, num_processes=None, update_interval=None, log_verbose=False)#
Facilitates a faucet transaction, allowing new neurons to receive an initial amount of TAO for participating in the network. This function is particularly useful for newcomers to the Bittensor network, enabling them to start with a small stake on testnet only.
- Parameters:
wallet (bittensor.wallet) – The wallet for which the faucet transaction is to be run.
arguments (Other) – Various optional parameters to customize the faucet transaction process.
wait_for_inclusion (bool) –
wait_for_finalization (bool) –
prompt (bool) –
max_allowed_attempts (int) –
output_in_place (bool) –
cuda (bool) –
tpb (int) –
num_processes (Optional[int]) –
update_interval (Optional[int]) –
log_verbose (bool) –
- Returns:
True
if the faucet transaction is successful, False otherwise.- Return type:
This function is part of Bittensor’s onboarding process, ensuring that new neurons have the necessary resources to begin their journey in the decentralized AI network.
Note
This is for testnet ONLY and is disabled currently. You must build your own staging subtensor chain with the
--features pow-faucet
argument to enable this.
- scaling_law_power(netuid, block=None)#
Returns network ScalingLawPower hyper parameter
- serve(wallet, ip, port, protocol, netuid, placeholder1=0, placeholder2=0, wait_for_inclusion=False, wait_for_finalization=True, prompt=False)#
Registers a neuron’s serving endpoint on the Bittensor network. This function announces the IP address and port where the neuron is available to serve requests, facilitating peer-to-peer communication within the network.
- Parameters:
wallet (bittensor.wallet) – The wallet associated with the neuron being served.
ip (str) – The IP address of the serving neuron.
port (int) – The port number on which the neuron is serving.
protocol (int) – The protocol type used by the neuron (e.g., GRPC, HTTP).
netuid (int) – The unique identifier of the subnetwork.
arguments (Other) – Placeholder parameters for future extensions.
wait_for_inclusion (bool, optional) – Waits for the transaction to be included in a block.
wait_for_finalization (bool, optional) – Waits for the transaction to be finalized on the blockchain.
prompt (bool, optional) – If
True
, prompts for user confirmation before proceeding.placeholder1 (int) –
placeholder2 (int) –
- Returns:
True
if the serve registration is successful, False otherwise.- Return type:
This function is essential for establishing the neuron’s presence in the network, enabling it to participate in the decentralized machine learning processes of Bittensor.
- serve_axon(netuid, axon, wait_for_inclusion=False, wait_for_finalization=True, prompt=False)#
Registers an Axon serving endpoint on the Bittensor network for a specific neuron. This function is used to set up the Axon, a key component of a neuron that handles incoming queries and data processing tasks.
- Parameters:
netuid (int) – The unique identifier of the subnetwork.
axon (bittensor.Axon) – The Axon instance to be registered for serving.
wait_for_inclusion (bool, optional) – Waits for the transaction to be included in a block.
wait_for_finalization (bool, optional) – Waits for the transaction to be finalized on the blockchain.
prompt (bool, optional) – If
True
, prompts for user confirmation before proceeding.
- Returns:
True
if the Axon serve registration is successful, False otherwise.- Return type:
By registering an Axon, the neuron becomes an active part of the network’s distributed computing infrastructure, contributing to the collective intelligence of Bittensor.
- serve_prometheus(wallet, port, netuid, wait_for_inclusion=False, wait_for_finalization=True)#
- serving_rate_limit(netuid, block=None)#
Retrieves the serving rate limit for a specific subnet within the Bittensor network. This rate limit determines the maximum number of requests a neuron can serve within a given time frame.
- Parameters:
- Returns:
The serving rate limit of the subnet if it exists,
None
otherwise.- Return type:
Optional[int]
The serving rate limit is a crucial parameter for maintaining network efficiency and preventing overuse of resources by individual neurons. It helps ensure a balanced distribution of service requests across the network.
- set_hyperparameter(wallet, netuid, parameter, value, wait_for_inclusion=False, wait_for_finalization=True, prompt=False)#
Sets a specific hyperparameter for a given subnetwork on the Bittensor blockchain. This action involves adjusting network-level parameters, influencing the behavior and characteristics of the subnetwork.
- Parameters:
wallet (bittensor.wallet) – The wallet used for setting the hyperparameter.
netuid (int) – The unique identifier of the subnetwork.
parameter (str) – The name of the hyperparameter to be set.
value – The new value for the hyperparameter.
wait_for_inclusion (bool, optional) – Waits for the transaction to be included in a block.
wait_for_finalization (bool, optional) – Waits for the transaction to be finalized on the blockchain.
prompt (bool, optional) – If
True
, prompts for user confirmation before proceeding.
- Returns:
True
if the hyperparameter setting is successful, False otherwise.- Return type:
This function plays a critical role in the dynamic governance and adaptability of the Bittensor network, allowing for fine-tuning of network operations and characteristics.
- set_weights(wallet, netuid, uids, weights, version_key=bittensor.__version_as_int__, wait_for_inclusion=False, wait_for_finalization=False, prompt=False)#
Sets the inter-neuronal weights for the specified neuron. This process involves specifying the influence or trust a neuron places on other neurons in the network, which is a fundamental aspect of Bittensor’s decentralized learning architecture.
- Parameters:
wallet (bittensor.wallet) – The wallet associated with the neuron setting the weights.
netuid (int) – The unique identifier of the subnet.
uids (Union[torch.LongTensor, list]) – The list of neuron UIDs that the weights are being set for.
weights (Union[torch.FloatTensor, list]) – The corresponding weights to be set for each UID.
version_key (int, optional) – Version key for compatibility with the network.
wait_for_inclusion (bool, optional) – Waits for the transaction to be included in a block.
wait_for_finalization (bool, optional) – Waits for the transaction to be finalized on the blockchain.
prompt (bool, optional) – If
True
, prompts for user confirmation before proceeding.
- Returns:
True
if the setting of weights is successful, False otherwise.- Return type:
This function is crucial in shaping the network’s collective intelligence, where each neuron’s learning and contribution are influenced by the weights it sets towards others【81†source】.
- static setup_config(network, config)#
- Parameters:
network (str) –
config (bittensor.config) –
- state_call(method, data, block=None)#
Makes a state call to the Bittensor blockchain, allowing for direct queries of the blockchain’s state. This function is typically used for advanced queries that require specific method calls and data inputs.
- Parameters:
- Returns:
The result of the state call if successful,
None
otherwise.- Return type:
Optional[object]
The state call function provides a more direct and flexible way of querying blockchain data, useful for specific use cases where standard queries are insufficient.
- subnet_exists(netuid, block=None)#
Checks if a subnet with the specified unique identifier (netuid) exists within the Bittensor network.
- Parameters:
- Returns:
True
if the subnet exists, False otherwise.- Return type:
This function is critical for verifying the presence of specific subnets in the network, enabling a deeper understanding of the network’s structure and composition.
- subnetwork_n(netuid, block=None)#
Returns network SubnetworkN hyper parameter
- swap_hotkey(wallet, new_wallet, wait_for_inclusion=False, wait_for_finalization=True, prompt=False)#
Swaps an old hotkey to a new hotkey.
- synergy_scaling_law_power(netuid, block=None)#
Returns network SynergyScalingLawPower hyper parameter
- tempo(netuid, block=None)#
Returns network Tempo hyper parameter
- total_issuance(block=None)#
Retrieves the total issuance of the Bittensor network’s native token (Tao) as of a specific blockchain block. This represents the total amount of currency that has been issued or mined on the network.
- Parameters:
block (Optional[int], optional) – The blockchain block number at which to perform the query.
- Returns:
The total issuance of TAO, represented as a Balance object.
- Return type:
Balance
The total issuance is a key economic indicator in the Bittensor network, reflecting the overall supply of the currency and providing insights into the network’s economic health and inflationary trends.
- total_stake(block=None)#
Retrieves the total amount of TAO staked on the Bittensor network as of a specific blockchain block. This represents the cumulative stake across all neurons in the network, indicating the overall level of participation and investment by the network’s participants.
- Parameters:
block (Optional[int], optional) – The blockchain block number at which to perform the query.
- Returns:
The total amount of TAO staked on the network, represented as a Balance object.
- Return type:
Balance
The total stake is an important metric for understanding the network’s security, governance dynamics, and the level of commitment by its participants. It is also a critical factor in the network’s consensus and incentive mechanisms.
- transfer(wallet, dest, amount, wait_for_inclusion=True, wait_for_finalization=False, prompt=False)#
Executes a transfer of funds from the provided wallet to the specified destination address. This function is used to move TAO tokens within the Bittensor network, facilitating transactions between neurons.
- Parameters:
wallet (bittensor.wallet) – The wallet from which funds are being transferred.
dest (str) – The destination public key address.
amount (Union[Balance, float]) – The amount of TAO to be transferred.
wait_for_inclusion (bool, optional) – Waits for the transaction to be included in a block.
wait_for_finalization (bool, optional) – Waits for the transaction to be finalized on the blockchain.
prompt (bool, optional) – If
True
, prompts for user confirmation before proceeding.
- Returns:
True
if the transfer is successful, False otherwise.- Return type:
This function is essential for the fluid movement of tokens in the network, supporting various economic activities such as staking, delegation, and reward distribution.
- tx_rate_limit(block=None)#
Retrieves the transaction rate limit for the Bittensor network as of a specific blockchain block. This rate limit sets the maximum number of transactions that can be processed within a given time frame.
- Parameters:
block (Optional[int], optional) – The blockchain block number at which to perform the query.
- Returns:
The transaction rate limit of the network, None if not available.
- Return type:
Optional[int]
The transaction rate limit is an essential parameter for ensuring the stability and scalability of the Bittensor network. It helps in managing network load and preventing congestion, thereby maintaining efficient and timely transaction processing.
- undelegate(wallet, delegate_ss58=None, amount=None, wait_for_inclusion=True, wait_for_finalization=False, prompt=False)#
Removes a specified amount of stake from a delegate neuron using the provided wallet. This action reduces the staked amount on another neuron, effectively withdrawing support or speculation.
- Parameters:
wallet (bittensor.wallet) – The wallet used for the undelegation process.
delegate_ss58 (Optional[str]) – The
SS58
address of the delegate neuron.amount (Union[Balance, float]) – The amount of TAO to undelegate.
wait_for_inclusion (bool, optional) – Waits for the transaction to be included in a block.
wait_for_finalization (bool, optional) – Waits for the transaction to be finalized on the blockchain.
prompt (bool, optional) – If
True
, prompts for user confirmation before proceeding.
- Returns:
True
if the undelegation is successful, False otherwise.- Return type:
This function reflects the dynamic and speculative nature of the Bittensor network, allowing neurons to adjust their stakes and investments based on changing perceptions and performances within the network.
- unstake(wallet, hotkey_ss58=None, amount=None, wait_for_inclusion=True, wait_for_finalization=False, prompt=False)#
Removes a specified amount of stake from a single hotkey account. This function is critical for adjusting individual neuron stakes within the Bittensor network.
- Parameters:
wallet (bittensor.wallet) – The wallet associated with the neuron from which the stake is being removed.
hotkey_ss58 (Optional[str]) – The
SS58
address of the hotkey account to unstake from.amount (Union[Balance, float], optional) – The amount of TAO to unstake. If not specified, unstakes all.
wait_for_inclusion (bool, optional) – Waits for the transaction to be included in a block.
wait_for_finalization (bool, optional) – Waits for the transaction to be finalized on the blockchain.
prompt (bool, optional) – If
True
, prompts for user confirmation before proceeding.
- Returns:
True
if the unstaking process is successful, False otherwise.- Return type:
This function supports flexible stake management, allowing neurons to adjust their network participation and potential reward accruals.
- unstake_multiple(wallet, hotkey_ss58s, amounts=None, wait_for_inclusion=True, wait_for_finalization=False, prompt=False)#
Performs batch unstaking from multiple hotkey accounts, allowing a neuron to reduce its staked amounts efficiently. This function is useful for managing the distribution of stakes across multiple neurons.
- Parameters:
wallet (bittensor.wallet) – The wallet linked to the coldkey from which the stakes are being withdrawn.
hotkey_ss58s (List[str]) – A list of hotkey
SS58
addresses to unstake from.amounts (List[Union[Balance, float]], optional) – The amounts of TAO to unstake from each hotkey. If not provided, unstakes all available stakes.
wait_for_inclusion (bool, optional) – Waits for the transaction to be included in a block.
wait_for_finalization (bool, optional) – Waits for the transaction to be finalized on the blockchain.
prompt (bool, optional) – If
True
, prompts for user confirmation before proceeding.
- Returns:
True
if the batch unstaking is successful, False otherwise.- Return type:
This function allows for strategic reallocation or withdrawal of stakes, aligning with the dynamic stake management aspect of the Bittensor network.
- update_identity(wallet, identified=None, params={}, wait_for_inclusion=True, wait_for_finalization=False)#
Updates the identity of a neuron on the Bittensor blockchain. This function allows neurons to modify their identity attributes, reflecting changes in their roles, stakes, or other network-specific parameters.
Note
See the Bittensor CLI documentation for supported identity parameters.
- Parameters:
wallet (bittensor.wallet) – The wallet associated with the neuron whose identity is being updated.
identified (str, optional) – The identified
SS58
address of the neuron. Defaults to the wallet’s coldkey address.params (dict, optional) – A dictionary of parameters to update in the neuron’s identity.
wait_for_inclusion (bool, optional) – Waits for the transaction to be included in a block.
wait_for_finalization (bool, optional) – Waits for the transaction to be finalized on the blockchain.
- Returns:
True
if the identity update is successful, False otherwise.- Return type:
This function plays a vital role in maintaining the accuracy and currency of neuron identities in the Bittensor network, ensuring that the network’s governance and consensus mechanisms operate effectively.
- validator_batch_size(netuid, block=None)#
Returns network ValidatorBatchSize hyper parameter
- validator_epoch_length(netuid, block=None)#
Returns network ValidatorEpochLen hyper parameter
- validator_epochs_per_reset(netuid, block=None)#
Returns network ValidatorEpochsPerReset hyper parameter
- validator_exclude_quantile(netuid, block=None)#
Returns network ValidatorEpochLen hyper parameter
- validator_logits_divergence(netuid, block=None)#
Returns network ValidatorLogitsDivergence hyper parameter
- validator_prune_len(netuid, block=None)#
Returns network ValidatorPruneLen hyper parameter
- validator_sequence_length(netuid, block=None)#
Returns network ValidatorSequenceLength hyper parameter
- vote_senate(wallet, proposal_hash, proposal_idx, vote, wait_for_inclusion=True, wait_for_finalization=False, prompt=False)#
Removes a specified amount of stake from a single hotkey account. This function is critical for adjusting individual neuron stakes within the Bittensor network.
- Parameters:
wallet (bittensor.wallet) – The wallet associated with the neuron from which the stake is being removed.
hotkey_ss58 (Optional[str]) – The
SS58
address of the hotkey account to unstake from.amount (Union[Balance, float], optional) – The amount of TAO to unstake. If not specified, unstakes all.
wait_for_inclusion (bool, optional) – Waits for the transaction to be included in a block.
wait_for_finalization (bool, optional) – Waits for the transaction to be finalized on the blockchain.
prompt (bool, optional) – If
True
, prompts for user confirmation before proceeding.proposal_hash (str) –
proposal_idx (int) –
vote (bool) –
- Returns:
True
if the unstaking process is successful, False otherwise.- Return type:
This function supports flexible stake management, allowing neurons to adjust their network participation and potential reward accruals.
- weights(netuid, block=None)#
Retrieves the weight distribution set by neurons within a specific subnet of the Bittensor network. This function maps each neuron’s UID to the weights it assigns to other neurons, reflecting the network’s trust and value assignment mechanisms.
- Parameters:
- Returns:
A list of tuples mapping each neuron’s UID to its assigned weights.
- Return type:
The weight distribution is a key factor in the network’s consensus algorithm and the ranking of neurons, influencing their influence and reward allocation within the subnet.