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§
- Stake
Info - Stake information returned from runtime API
- Subnet
Hyperparameters - Subnet hyperparameters
- Subnet
Info - 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
- Neuron
Info - NeuronInfo type with AccountId
- Neuron
Info Lite - NeuronInfoLite type with AccountId
- Selective
Metagraph - SelectiveMetagraph type with AccountId