Module queries

Module queries 

Source
Expand description

§Chain Queries

Read-only queries against Bittensor blockchain state.

This module provides functions for querying:

  • Account: Balances, stake amounts, and stake info
  • Metagraph: Full or selective metagraph data for subnets
  • Neurons: Individual neuron info and UID lookups
  • Subnets: Subnet existence, hyperparameters, and metadata

§Example

use bittensor_rs::queries::{get_metagraph, get_balance, get_neuron};

async fn example(client: &subxt::OnlineClient<subxt::PolkadotConfig>, account_id: &subxt::config::polkadot::AccountId32) -> Result<(), Box<dyn std::error::Error>> {
    // Get metagraph for subnet 1
    let metagraph = get_metagraph(client, 1).await?;

    // Check account balance
    let balance = get_balance(client, account_id).await?;

    // Get specific neuron by UID
    let neuron = get_neuron(client, 1, 0).await?;
    Ok(())
}

All query functions accept a subxt OnlineClient and return typed results.

Modules§

fields
Field bitmask constants for selective metagraph queries

Structs§

StakeInfo
Stake information returned from runtime API
SubnetHyperparameters
Subnet hyperparameters
SubnetInfo
Subnet information

Functions§

get_balance
Get the free balance of an account
get_metagraph
Get the full metagraph for a subnet
get_neuron
Get full neuron information by UID
get_neuron_lite
Get lite neuron information by UID
get_stake
Get the stake of a hotkey on a specific coldkey for a subnet
get_stake_info_for_coldkey
Get stake information for a coldkey using runtime API
get_subnet_hyperparameters
Get hyperparameters for a subnet
get_subnet_info
Get information about a subnet
get_total_network_stake
Get the global total stake on the network
get_total_subnets
Get the number of active subnets
get_uid_for_hotkey
Get the UID for a hotkey on a subnet
subnet_exists
Check if a subnet exists

Type Aliases§

Metagraph
Metagraph type with AccountId
NeuronInfo
NeuronInfo type with AccountId
NeuronInfoLite
NeuronInfoLite type with AccountId
SelectiveMetagraph
SelectiveMetagraph type with AccountId