LAST EDIT:Jan 3, 2024
Working with Subnets
Subnets are composed of a discrete number of UIDs. The subnet validators and subnet miners are associated with these UIDs. Each UID in the subnet belongs to a unique hotkey which in turn is connected to a unique coldkey which was used during regisration. The Yuma Consensus runs on these UIDs. This section presents a few examples showing how to work with subnets.
Viewing subnetworks
Show all currently running subnets on Bittensor:
btcli subnets list
Viewing state
To display fine-grained information about each subnetwork use bt.metagraph:
import bittensor as bt
subnet = bt.metagraph( netuid = 1 ) # Get the current state.
assert subnet.netuid == 1
subnet.sync( block = 101010 ) # Sync the state with a particular block.
assert subnet.block == 101010
Verifying UIDs
import bittensor as bt
subnet = bt.metagraph( netuid = 1 )
assert subnet.uids.tolist() == [ 0, 1, 2, ... 1022, 1023 ]
Extracting UID information
import bittensor as bt
subnet = bt.metagraph( netuid = 1 )
uid = 123
print ('uid', uid, ' owned by hotkey:', subnet.hotkeys[ uid ], 'associated with coldkey': subnet.coldkey[ uid ] )
Viewing parameters
The below code prints stake S
on the subnet and the weights W
set by the subnet validators in the subnet.
import bittensor as bt
subnet = bt.metagraph( netuid = 1, lite = False)
print ('subnet 1 validator stake', subnet.S )
print ('subnet 1 validator weights', subnet.W )
Viewing dividends
The below code prints the subnet validator dividends, D
.
import bittensor as bt
subnet = bt.metagraph( netuid = 1 )
print ('subnet 1 validator dividends', subnet.D )