bittensor.utils#
Submodules#
- bittensor.utils.axon_utils
- bittensor.utils.balance
- bittensor.utils.btlogging
- bittensor.utils.delegates_details
- bittensor.utils.easy_imports
- bittensor.utils.formatting
- bittensor.utils.mock
- bittensor.utils.networking
- bittensor.utils.registration
- bittensor.utils.subnets
- bittensor.utils.substrate_utils
- bittensor.utils.version
- bittensor.utils.weight_utils
Attributes#
Classes#
str(object='') -> str |
|
Functions#
|
Decodes hex-encoded strings in a dictionary. |
|
Determines the chain endpoint and network from the passed network or chain_endpoint. |
|
Formats an error message from the Subtensor error information for use in extrinsics. |
|
Returns the explorer url for the given block hash and network. |
|
|
Checks if the given address is a valid destination address. |
|
|
Checks if the given address is a valid ss58 address. |
|
Converts a ss58 address to a bytes object. |
|
|
|
Converts a string to a boolean value. |
|
Attempts to decrypt a wallet's coldkey or hotkey |
|
Validates if the provided endpoint URL is a valid WebSocket URL. |
Package Contents#
- class bittensor.utils.Certificate#
Bases:
str
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
Initialize self. See help(type(self)) for accurate signature.
- bittensor.utils.RAOPERTAO = 1000000000.0#
- bittensor.utils.U16_MAX = 65535#
- bittensor.utils.U64_MAX = 18446744073709551615#
- bittensor.utils.VersionCheckError#
- bittensor.utils.check_version#
- bittensor.utils.decode_hex_identity_dict(info_dictionary)#
Decodes hex-encoded strings in a dictionary.
- This function traverses the given dictionary, identifies hex-encoded strings, and decodes them into readable
strings. It handles nested dictionaries and lists within the dictionary.
- Parameters:
info_dictionary (dict) – The dictionary containing hex-encoded strings to decode.
- Returns:
The dictionary with decoded strings.
- Return type:
Examples
input_dict = { … “name”: {“value”: “0x6a6f686e”}, … “additional”: [ … [{“data”: “0x64617461”}] … ] … } decode_hex_identity_dict(input_dict) {‘name’: ‘john’, ‘additional’: [(‘data’, ‘data’)]}
- bittensor.utils.determine_chain_endpoint_and_network(network)#
Determines the chain endpoint and network from the passed network or chain_endpoint.
- Parameters:
network (str) – The network flag. The choices are:
finney
(main network),archive
(archive network +300 blocks),local
(local running network),test
(test network).- Returns:
- The network and chain endpoint flag. If passed, overrides the
network
argument.
- Return type:
- bittensor.utils.format_error_message(error_message)#
Formats an error message from the Subtensor error information for use in extrinsics.
- bittensor.utils.get_explorer_url_for_network(network, block_hash, network_map)#
Returns the explorer url for the given block hash and network.
- Parameters:
- Returns:
The explorer url for the given block hash and network. Or None if the network is not known.
- Return type:
- bittensor.utils.get_hash(content, encoding='utf-8')#
- bittensor.utils.hex_to_bytes#
- bittensor.utils.is_valid_bittensor_address_or_public_key(address)#
Checks if the given address is a valid destination address.
- bittensor.utils.is_valid_ss58_address(address)#
Checks if the given address is a valid ss58 address.
- bittensor.utils.logging#
- bittensor.utils.ss58_address_to_bytes(ss58_address)#
Converts a ss58 address to a bytes object.
- bittensor.utils.ss58_decode#
- bittensor.utils.strtobool(val)#
Converts a string to a boolean value.
truth-y values are ‘y’, ‘yes’, ‘t’, ‘true’, ‘on’, and ‘1’; false-y values are ‘n’, ‘no’, ‘f’, ‘false’, ‘off’, and ‘0’.
Raises ValueError if ‘val’ is anything else.
- bittensor.utils.torch#
- bittensor.utils.unlock_key(wallet, unlock_type='coldkey')#
Attempts to decrypt a wallet’s coldkey or hotkey :param wallet: a Wallet object :param unlock_type: the key type, ‘coldkey’ or ‘hotkey’
Returns: UnlockStatus for success status of unlock, with error message if unsuccessful
- Parameters:
wallet (bittensor_wallet.Wallet)
- Return type:
- bittensor.utils.use_torch#
- bittensor.utils.validate_chain_endpoint(endpoint_url)#
Validates if the provided endpoint URL is a valid WebSocket URL.
- bittensor.utils.version_checking#