Subnet Metagraph
This page documents the Bittensor subnet metagraph.
The metagraph is a core data structure in Bittensor that represents the complete state of a subnet at any given block. It contains comprehensive information about all neurons (miners and validators) participating in a subnet, their emissions, bonds, and trust, as well as subnet metrics.
The metagraph is implemented in the Bittensor blockchain (Subtensor) as a Rust data structure. The source code is located in the Subtensor repository.
Related reading:
Accessing the Metagraph
You can access metagraph data through multiple interfaces:
Bittensor CLI (btcli)
The btcli
command-line interface provides access to a subset of metagraph information (corresponding to "lite" mode in the SDK). For full metagraph data including weights and bonds, use the Python SDK with lite=False
.
# Dump metagraph subset to file (lite mode)
btcli subnets metagraph --netuid 14 --network finney \
--json-output > sn14_metagraph.json
# View abridged metagraph
btcli subnets metagraph --netuid 14 --network finney
Subnet 14: TAOHash
Network: finney
UID ┃ Stake (ξ) ┃ Alpha (ξ) ┃ Tao (τ) ┃ Dividends ┃ Incentive ┃ Emissions (ξ) ┃ Hotk… ┃ Coldkey ┃ Identity
━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━
29 │ 271.67k ξ │ 254.83k ξ │ τ 16.84k │ 0.129183 │ 0.000000 │ 19.122456 ξ │ 5Cf4… │ 5CKhH8 │ Owner14 (*Owner)
3 │ 387.08k ξ │ 61.46k ξ │ τ 325.62k │ 0.184314 │ 0.000000 │ 27.280861 ξ │ 5C59… │ 5GZSAg │
...
The btcli output shows a subset of metagraph data (lite mode). For complete data including ranks, trust scores, weights, and bonds, use the Python SDK with lite=False
.
Python SDK
The Bittensor Python SDK Metagraph module provides programmatic access to metagraph data:
from bittensor.core.metagraph import Metagraph
# Initialize metagraph for subnet 14 (lite mode - excludes weights/bonds)
m = Metagraph(netuid=14, network="finney", sync=True)
# Initialize metagraph with full data including weights and bonds
m = Metagraph(netuid=14, network="finney", lite=False, sync=True)
Smart Contract Access (Metagraph Precompile)
For smart contract integration, you can access metagraph data through the Metagraph Precompile at address 0x0000000000000000000000000000000000000802
. This provides read-only access to individual neuron metrics and network information.
For detailed smart contract examples and complete ABI, see the Metagraph Precompile documentation.
RPC Functions
The blockchain provides several RPC functions for accessing metagraph data:
get_metagraph(netuid)
- Returns complete metagraph for a subnetget_all_metagraphs()
- Returns metagraphs for all subnetsget_selective_metagraph(netuid, indexes)
- Returns partial metagraph data
See Subtensor:Metagraph RPC source code