Module: bittensor_chain::queries::subnet
Subnet metadata, hyperparameters, existence checks, and per-subnet parameters.
use bittensor_chain::queries::subnet;
use bittensor_chain::prelude::*;
use bittensor_core::types::{SubnetInfo, SubnetHyperparameters};All functions take &OnlineClient<SubtensorConfig> as the first argument and return Result<T, BittensorError>.
pub async fn get_subnet_info(
client: &OnlineClient<SubtensorConfig>,
netuid: u16,
) -> Result<Option<SubnetInfo>>Fetches subnet metadata including owner, tempo, identity, and UID count. Returns None if the subnet does not exist.
Parameters
| Name | Type | Description |
|---|---|---|
client |
&OnlineClient<SubtensorConfig> |
Connected subxt client |
netuid |
u16 |
Subnet ID |
Returns
Option<SubnetInfo> -- Subnet metadata, or None if subnet does not exist.
Example
// Requires live node
if let Some(info) = subnet::get_subnet_info(client.rpc(), 1).await? {
println!("Subnet 1: {} (tempo={})", info.name, info.tempo);
}pub async fn get_subnet_hyperparameters(
client: &OnlineClient<SubtensorConfig>,
netuid: u16,
) -> Result<Option<SubnetHyperparameters>>Fetches the full hyperparameter set for a subnet. Returns None if the subnet does not exist.
Returns
Option<SubnetHyperparameters> -- All hyperparameters including rho, kappa, difficulty, burn, immunity ratio, alpha values, and more.
pub async fn get_total_subnets(client: &OnlineClient<SubtensorConfig>) -> Result<u16>Fetches the total number of subnets on chain.
pub async fn subnet_exists(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<bool>Checks whether a subnet exists on chain.
pub async fn get_subnet_owner(
client: &OnlineClient<SubtensorConfig>,
netuid: u16,
) -> Result<Option<String>>Fetches the owner coldkey of a subnet as an SS58 string. Returns None if no owner is set.
pub async fn get_subnet_name(
client: &OnlineClient<SubtensorConfig>,
netuid: u16,
) -> Result<Option<String>>Fetches the display name of a subnet from its on-chain identity. Returns None if no identity is set.
pub async fn get_subnet_owner_hotkey(
client: &OnlineClient<SubtensorConfig>,
netuid: u16,
) -> Result<Option<subxt::utils::AccountId32>>Fetches the hotkey that owns the subnet. Returns None if no owner hotkey is set.
pub async fn get_tempo(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u16>Blocks per epoch for a subnet.
pub async fn get_subnetwork_n(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u16>Current number of UIDs in a subnet.
pub async fn get_subnet_mechanism(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u16>Subnet mechanism type (Yuma variant identifier).
pub async fn get_is_network_member(
client: &OnlineClient<SubtensorConfig>,
hotkey: &subxt::utils::AccountId32,
netuid: u16,
) -> Result<bool>Checks if a hotkey is a member of a subnet.
pub async fn get_network_registration_allowed(
client: &OnlineClient<SubtensorConfig>,
netuid: u16,
) -> Result<bool>Whether burn-based registration is allowed for the subnet.
pub async fn get_network_pow_registration_allowed(
client: &OnlineClient<SubtensorConfig>,
netuid: u16,
) -> Result<bool>Whether PoW registration is allowed for the subnet.
pub async fn get_network_registered_at(
client: &OnlineClient<SubtensorConfig>,
netuid: u16,
) -> Result<u64>Block at which the subnet was registered.
pub async fn get_min_allowed_uids(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u16>Minimum allowed UIDs.
pub async fn get_max_allowed_uids(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u16>Maximum allowed UIDs (default 256).
pub async fn get_max_allowed_validators(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u16>Maximum allowed validators (default 128).
pub async fn get_immunity_period(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u16>Immunity period in blocks (default 4096).
pub async fn get_activity_cutoff(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u16>Activity cutoff in blocks (default 5000).
pub async fn get_max_weights_limit(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u16>Maximum total weight a neuron can distribute (u16 scale, default 65535).
pub async fn get_min_allowed_weights(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u16>Minimum allowed weight value (default 1024).
pub async fn get_adjustment_interval(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u16>Blocks between difficulty/burn adjustments (default 100).
pub async fn get_bonds_moving_average(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u64>Bonds moving average denominator (default 900000).
pub async fn get_bonds_penalty(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u16>Bonds penalty value.
pub async fn get_bonds_reset_on(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<bool>Whether bonds reset on registration.
pub async fn get_scaling_law_power(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u16>Scaling law exponent (default 50 = 0.5).
pub async fn get_target_registrations_per_interval(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u16>Target registrations per adjustment interval (default 2).
pub async fn get_adjustment_alpha(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u64>EMA adjustment alpha for difficulty/burn.
pub async fn get_liquid_alpha_on(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<bool>Whether liquid alpha is enabled.
pub async fn get_yuma3_on(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<bool>Whether Yuma3 consensus is enabled.
pub async fn get_alpha_values(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<(u16, u16)>Alpha values as (alpha_high, alpha_low).
pub async fn get_subtoken_enabled(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<bool>Whether the subtoken economy is enabled.
pub async fn get_serving_rate_limit(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u64>Blocks between serve operations (default 50).
pub async fn get_burn(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u64>Current burn cost for registration in rao.
pub async fn get_difficulty(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u64>PoW difficulty for registration.
pub async fn get_min_burn(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u64>Minimum registration burn in rao.
pub async fn get_max_burn(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u64>Maximum registration burn in rao.
pub async fn get_min_difficulty(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u64>Minimum PoW difficulty.
pub async fn get_max_difficulty(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u64>Maximum PoW difficulty.
pub async fn get_last_adjustment_block(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u64>Last block at which difficulty/burn was adjusted.
pub async fn get_registrations_this_interval(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u16>Registrations in the current adjustment interval.
pub async fn get_registrations_this_block(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u16>Registrations in the current block.
pub async fn get_rao_recycled_for_registration(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u64>Rao recycled (burned) for registrations in the current interval.
pub async fn get_tx_rate_limit(client: &OnlineClient<SubtensorConfig>) -> Result<u64>Global transaction rate limit in blocks (default 1000).
pub async fn get_ema_price_halving_blocks(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u64>Blocks for EMA price halving (default 201600).
pub async fn get_rho(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u16>Rho: overall incentive power (default 10).
pub async fn get_kappa(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u16>Kappa: temperature for sigmoid trust (default 32767).
pub async fn get_alpha_sigmoid_steepness(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<i16>Signed steepness of the alpha sigmoid function (default 1000).
pub async fn get_voting_power(client: &OnlineClient<SubtensorConfig>, netuid: u16, hotkey: &subxt::utils::AccountId32) -> Result<u64>Voting power for a hotkey in a subnet.
pub async fn get_voting_power_tracking_enabled(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<bool>Whether voting power tracking is enabled.
pub async fn get_max_registrations_per_block(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u16>Max registrations per block (default 1).
pub async fn get_validator_prune_len(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u64>Validator prune length (default 1).
pub async fn get_subnet_locked(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u64>Amount locked in the subnet in rao.
pub async fn get_largest_locked(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<u64>Largest single lock in the subnet in rao.
pub async fn get_transfer_toggle(client: &OnlineClient<SubtensorConfig>, netuid: u16) -> Result<bool>Whether transfers are enabled for the subnet.
// Requires live node
use bittensor_chain::prelude::*;
use bittensor_chain::queries::subnet;
use bittensor_core::config::NetworkConfig;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = SubtensorClient::from_config(NetworkConfig::finney()).await?;
let rpc = client.rpc();
let total = subnet::get_total_subnets(rpc).await?;
println!("Total subnets: {total}");
for netuid in 0..total {
if subnet::subnet_exists(rpc, netuid).await? {
let tempo = subnet::get_tempo(rpc, netuid).await?;
let n = subnet::get_subnetwork_n(rpc, netuid).await?;
println!("Subnet {netuid}: tempo={tempo}, neurons={n}");
}
}
if let Some(hp) = subnet::get_subnet_hyperparameters(rpc, 1).await? {
println!("Subnet 1 rho={} kappa={}", hp.rho, hp.kappa);
println!(" liquid_alpha={}", hp.liquid_alpha_enabled);
}
Ok(())
}