Skip to content

Instantly share code, notes, and snippets.

@salmanshah1d
Created March 25, 2024 23:53
Show Gist options
  • Save salmanshah1d/d4643c733f31edbb5f1d5c9080cfad1e to your computer and use it in GitHub Desktop.
Save salmanshah1d/d4643c733f31edbb5f1d5c9080cfad1e to your computer and use it in GitHub Desktop.
Query the top miner on SN24
# Usage: python top_miner.py --wallet.name <name> --wallet.hotkey <hotkey>
import bittensor
subtensor = bittensor.subtensor(log_verbose=False)
root_validators = subtensor.neurons_lite(netuid=0)
netuid = 24
metagraph = subtensor.metagraph(netuid)
miner_ranks = [(uid, metagraph.ranks[uid]) for uid in metagraph.uids]
# sort miners by ascending rank, take the top one (i.e. last one) and print its uid
print(f"The top miner on SN{netuid} is {sorted(miner_ranks, key=lambda x: x[1])[-1][0]}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment