Bittensor - Decentralized Machine Learning Network
Description#
Interact with Substrate JSON‑RPC. This method is commonly used to build reliable indexers, developer tooling, and responsive UIs.
Bittensor RPC
Reliable, high-availability Bittensor RPC on Dwellir. Your requests are served by resilient infrastructure with automatic failover and attentive monitoring for consistent performance.
Why Build on Bittensor?#
Bittensor is a revolutionary blockchain that creates a decentralized marketplace for machine learning models and computational intelligence. Built on Substrate, Bittensor enables:
🤖 AI-Native Blockchain#
- Decentralized ML - Train and serve models in a trustless environment
- Incentivized Intelligence - Earn TAO tokens for contributing compute and models
- Collaborative Learning - Models improve through network-wide collaboration
🔬 Advanced Capabilities#
- Neural Mining - Mine TAO tokens by running AI models
- 36+ Subnets - Specialized networks for different AI tasks (expanding to 1024)
- Yuma Consensus - Novel consensus mechanism for ML validation
💡 Innovation Platform#
- Open AI Marketplace - Access diverse AI models and services
- Composable Intelligence - Build complex AI systems from network primitives
- Research Network - Contribute to cutting-edge ML research
Quick Start with Bittensor#
Connect to Bittensor in seconds with Dwellir's optimized endpoints:
🔗 RPC Endpoints
Quick Connect:
curl -X POST ${S.rpcBase} \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
Installation & Setup#
- Ethers.js v6
- Web3.js
- Python
import { JsonRpcProvider } from 'ethers';
// Connect to Bittensor mainnet
const provider = new JsonRpcProvider(
'${S.rpcBase}'
);
// Get the latest block
const block = await provider.getBlock('latest');
console.log('Latest block:', block.number);
// Query account balance
const balance = await provider.getBalance('0x...');
console.log('Balance:', balance.toString());
const Web3 = require('web3');
// Connect to Bittensor mainnet
const web3 = new Web3(
'${S.rpcBase}'
);
// Get chain ID to verify connection
const chainId = await web3.eth.getChainId();
console.log('Connected to Bittensor:', chainId);
// Get gas price for optimal transaction pricing
const gasPrice = await web3.eth.getGasPrice();
console.log('Current gas price:', gasPrice);
from web3 import Web3
# Connect to Bittensor mainnet
w3 = Web3(Web3.HTTPProvider(
'${S.rpcBase}'
))
# Check connection
if w3.is_connected():
print("Connected to Bittensor")
# Get latest block
latest_block = w3.eth.block_number
print(f"Latest block: {latest_block}")
# Get account balance
balance = w3.eth.get_balance('0x...')
print(f"Balance: {balance} TAO")
Network Information#
Chain ID
N/A
Substrate-basedBlock Time
12 seconds
AverageNative Token
TAO
21M max supplyConsensus
Yuma
ML ValidationJSON-RPC API Reference#
Bittensor exposes both an Ethereum-compatible JSON-RPC (via Frontier) and native Substrate RPC. Use either or both depending on your integration.
Substrate API#
Available JSON-RPC Methods
System & Runtime
Identify the chain, runtime versions, and node health.
Chain Data & Finality
Inspect blocks, headers, and finality streams.
State Access & Storage
Query storage, metadata, and runtime entry points.
Authoring & Sessions
Submit extrinsics and manage session keys.
Fees & Payment
Estimate fees for signed extrinsics (pre-broadcast).
RPC Introspection
Discover supported RPC namespaces and versions.
Chain Spec
Network name, properties and genesis via chainSpec v1.
Additional Chain Methods
Chain helpers and runtime info.
Extended State
Advanced storage queries and proofs.
Account Nonce
Retrieve next transaction index for accounts.
Node Admin & Network
Peer info and node-level admin operations.
Custom: Subnet Info
Bittensor subnet configuration, metrics and hyperparameters.
Custom: Neurons & Delegates
Neuron data and delegate relationships.
Subscriptions
Real-time updates via WebSocket.
Unsubscribe Methods
Cancel active subscriptions (WebSocket).
Child Storage
Child trie queries and pagination.
Archive API
Historical blocks and storage via archive service.
ChainHead API
Follow operations for headers/body/storage (experimental).
Debug & Diagnostics
Raw data and debug helpers (may require flags).
Transaction Watch & Broadcast
Admin-only helpers to submit and watch extrinsics.
Offchain (Admin)
Local node offchain storage access.
EVM API#
Available JSON-RPC Methods
Reading Blockchain Data
Query blocks, transactions, and account states
Sending Transactions
Submit and manage transactions
Smart Contract Interaction
Call and interact with smart contracts
Node & Network Info
Query node status and network information
Ready to build on Bittensor?
Get your API key →Custom RPC Extensions#
Bittensor nodes also expose custom RPC namespaces for chain‑specific AI/ML data:
subnetInfo_*— subnet configuration, hyperparameters, metagraphsneuronInfo_*— neuron and mechagraph datadelegateInfo_*— delegation and delegate detailsswap_*— TAO/ALPHA swap simulation helpers
These are implemented by the chain and surfaced over JSON‑RPC; see the runtime and node RPC code for details. Refer to the links in the Resources section below.
Common Integration Patterns#
🧠 Subnet Interaction#
Connect to Bittensor subnets for specialized AI tasks:
// Query subnet information
async function getSubnetInfo(subnetId) {
const result = await provider.call({
to: SUBNET_REGISTRY_ADDRESS,
data: encodeSubnetQuery(subnetId)
});
return decodeSubnetInfo(result);
}
// Register as miner
async function registerMiner(subnetId, modelEndpoint) {
const tx = {
to: SUBNET_REGISTRY_ADDRESS,
data: encodeMinerRegistration(subnetId, modelEndpoint),
value: REGISTRATION_FEE
};
const receipt = await signer.sendTransaction(tx);
return receipt;
}
💰 TAO Token Operations#
Manage TAO tokens and staking:
// Stake TAO tokens
async function stakeTAO(amount, validatorAddress) {
const stakingContract = new Contract(
STAKING_CONTRACT_ADDRESS,
STAKING_ABI,
signer
);
const tx = await stakingContract.stake(
validatorAddress,
{ value: parseEther(amount) }
);
return tx.wait();
}
// Query staking rewards
async function getStakingRewards(address) {
const rewards = await stakingContract.pendingRewards(address);
return formatUnits(rewards, 9); // TAO has 9 decimals
}
🔍 Model Validation#
Validate AI model outputs on-chain:
// Submit model output for validation
async function submitModelOutput(subnetId, taskId, output) {
const validationContract = new Contract(
VALIDATION_CONTRACT_ADDRESS,
VALIDATION_ABI,
signer
);
const proof = generateProof(output);
const tx = await validationContract.submitOutput(
subnetId,
taskId,
output,
proof
);
return tx.wait();
}
Performance Best Practices#
1. Efficient Querying#
Optimize queries for Bittensor's unique architecture:
// Batch subnet queries
async function batchSubnetQueries(subnetIds) {
const queries = subnetIds.map(id => ({
to: SUBNET_REGISTRY_ADDRESS,
data: encodeSubnetQuery(id)
}));
const results = await Promise.all(
queries.map(q => provider.call(q))
);
return results.map(decodeSubnetInfo);
}
2. Caching Strategy#
Cache frequently accessed subnet and model data:
class SubnetCache {
constructor(ttl = 60000) { // 1 minute TTL
this.cache = new Map();
this.ttl = ttl;
}
async get(subnetId, fetcher) {
const key = `subnet_${subnetId}`;
const cached = this.cache.get(key);
if (cached && Date.now() - cached.timestamp < this.ttl) {
return cached.data;
}
const data = await fetcher(subnetId);
this.cache.set(key, { data, timestamp: Date.now() });
return data;
}
}
3. Connection Management#
Maintain persistent connections for real-time updates:
// WebSocket connection for real-time updates
const wsProvider = new WebSocketProvider(
'${S.wsBase}'
);
// Subscribe to subnet events
wsProvider.on('subnet_update', (event) => {
console.log('Subnet updated:', event);
});
Troubleshooting Common Issues#
Error: "Invalid subnet ID"#
Ensure you're using valid subnet identifiers:
// Validate subnet ID before operations
async function validateSubnet(subnetId) {
const exists = await provider.call({
to: SUBNET_REGISTRY_ADDRESS,
data: encodeSubnetExists(subnetId)
});
if (!exists) {
throw new Error(`Subnet ${subnetId} does not exist`);
}
return true;
}
Error: "Insufficient stake"#
Check staking requirements before operations:
// Check minimum stake requirement
async function checkStakeRequirement(operation) {
const required = await getMinimumStake(operation);
const current = await getUserStake(address);
if (current < required) {
throw new Error(`Need ${required - current} more TAO staked`);
}
}
Resources & Tools#
Official Resources#
Developer Tools#
Need Help?#
- 📧 Email: support@dwellir.com
- 📚 Docs: You're here!
- 🎯 Dashboard: dashboard.dwellir.com
Start building on Bittensor with Dwellir's enterprise-grade RPC infrastructure. Get your API key →