bittensor.extras.subtensor_api#

Submodules#

Classes#

SubtensorApi

Subtensor API class.

Package Contents#

class bittensor.extras.subtensor_api.SubtensorApi(network=None, config=None, async_subtensor=False, legacy_methods=False, fallback_endpoints=None, retry_forever=False, log_verbose=False, mock=False, archive_endpoints=None, websocket_shutdown_timer=5.0)#

Subtensor API class.

Parameters:
  • network (Optional[str]) – The network to connect to.

  • config (Optional[bittensor.core.config.Config]) – Bittensor configuration object.

  • legacy_methods (bool) – If True, all methods from the Subtensor class will be added to the root level of this class.

  • fallback_endpoints (Optional[list[str]]) – List of fallback endpoints to use if default or provided network is not available.

  • retry_forever (bool) – Whether to retry forever on connection errors.

  • log_verbose (bool) – Enables or disables verbose logging.

  • mock (bool) – Whether this is a mock instance. Mainly just for use in testing.

  • archive_endpoints (Optional[list[str]]) – Similar to fallback_endpoints, but specifically only archive nodes. Will be used in cases where you are requesting a block that is too old for your current (presumably lite) node.

  • websocket_shutdown_timer (Optional[float]) – Amount of time, in seconds, to wait after the last response from the chain to close the connection. Only applicable to AsyncSubtensor. If None is passed to this, the automatic shutdown process is disabled.

  • async_subtensor (bool)

Example

# sync version import bittensor as bt

subtensor = bt.SubtensorApi() print(subtensor.block) print(subtensor.delegates.get_delegate_identities()) subtensor.chain.tx_rate_limit()

# async version import bittensor as bt

subtensor = bt.SubtensorApi(async_subtensor=True) async with subtensor:

print(await subtensor.block) print(await subtensor.delegates.get_delegate_identities()) print(await subtensor.chain.tx_rate_limit())

# using legacy_methods import bittensor as bt

subtensor = bt.SubtensorApi(legacy_methods=True) print(subtensor.bonds(0))

# using fallback_endpoints or retry_forever import bittensor as bt

subtensor = bt.SubtensorApi(

network=”finney”, fallback_endpoints=[“wss://localhost:9945”, “wss://some-other-endpoint:9945”], retry_forever=True,

) print(subtensor.block)

classmethod add_args(parser)#
property block#

Returns current chain block number.

property chain#

Property of interaction with chain methods.

chain_endpoint = None#
close#
property commitments#

Property to access commitments methods.

compose_call#
config#
property delegates#

Property to access delegates methods.

determine_block_hash#
encode_params#
property extrinsics#

Property to access extrinsics methods.

help#
initialize = None#
inner_subtensor#
is_async = False#
log_verbose = False#
property metagraphs#

Property to access metagraphs methods.

network = None#
property neurons#

Property to access neurons methods.

property queries#

Property to access subtensor queries methods.

setup_config#
sign_and_send_extrinsic#
property staking#

Property to access staking methods.

start_call#
property subnets#

Property of interaction with subnets methods.

substrate#
wait_for_block#
property wallets#

Property of interaction methods with cold/hotkeys, and balances, etc.