Docs

Bittensor - Decentralized Machine Learning Network

Complete guide to Bittensor integration with Dwellir RPC. Learn how to build on Bittensor, access JSON-RPC methods, and optimize your AI/ML applications.

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.

Get your API key

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:

Bittensor RPC Endpoints
HTTPS
curl -sS -X POST https://api-bittensor-mainnet.n.dwellir.com/<API_Keys_Are_Not_Made_for_Bots> \  -H 'Content-Type: application/json' \  -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
import { JsonRpcProvider } from 'ethers';const provider = new JsonRpcProvider(  'https://api-bittensor-mainnet.n.dwellir.com/<API_Keys_Are_Not_Made_for_Bots>');const latest = await provider.getBlockNumber();console.log('block', latest);
import requestsurl = 'https://api-bittensor-mainnet.n.dwellir.com/<API_Keys_Are_Not_Made_for_Bots>'payload = {  'jsonrpc': '2.0', 'id': 1,  'method': 'eth_blockNumber', 'params': []}resp = requests.post(url, json=payload)print(resp.json())
package mainimport (  "bytes"  "fmt"  "io"  "net/http")func main() {  url := "https://api-bittensor-mainnet.n.dwellir.com/<API_Keys_Are_Not_Made_for_Bots>"  payload := []byte(`{"jsonrpc":"2.0","id":1,"method":"eth_blockNumber","params":[]}`)  resp, err := http.Post(url, "application/json",    bytes.NewBuffer(payload))  if err != nil { panic(err) }  defer resp.Body.Close()  body, _ := io.ReadAll(resp.Body)  fmt.Println(string(body))}

Installation & Setup

Network Information

ParameterValueDetails
Chain IDN/ASubstrate-based
Block Time12 secondsAverage
Native TokenTAO21M max supply
ConsensusYumaML Validation

API Reference

account_nextIndex
archive_v1_body
archive_v1_call
archive_v1_finalizedHeight
archive_v1_genesisHash
archive_v1_hashByHeight
archive_v1_header
archive_v1_stopStorage
archive_v1_storage
archive_v1_storageDiff
archive_v1_storageDiff_stopStorageDiff
author_hasKey
chainHead_v1_body
chainHead_v1_call
chainHead_v1_continue
chainHead_v1_follow
chainHead_v1_header
chainHead_v1_stopOperation
chainHead_v1_storage
chainHead_v1_unfollow
chainSpec_v1_chainName
chainSpec_v1_genesisHash
chainSpec_v1_properties
chain_getHead
chain_getRuntimeVersion
chain_subscribeAllHeads
chain_subscribeRuntimeVersion
chain_unsubscribeAllHeads
chain_unsubscribeFinalisedHeads
chain_unsubscribeFinalizedHeads
chain_unsubscribeNewHead
chain_unsubscribeNewHeads
chain_unsubscribeRuntimeVersion
childstate_getKeys
childstate_getKeysPaged
childstate_getKeysPagedAt
childstate_getStorage
childstate_getStorageEntries
childstate_getStorageHash
childstate_getStorageSize
debug_getBadBlocks
debug_getRawBlock
debug_getRawHeader
debug_getRawReceipts
debug_getRawTransaction
delegateInfo_getDelegate
delegateInfo_getDelegated
delegateInfo_getDelegates
eth_coinbase
eth_hashrate
eth_mining
eth_protocolVersion
eth_sendTransaction
eth_signTransaction
neuronInfo_getNeuron
neuronInfo_getNeuronLite
neuronInfo_getNeurons
neuronInfo_getNeuronsLite
offchain_localStorageClear
offchain_localStorageGet
offchain_localStorageSet
state_callAt
state_getChildReadProof
state_getKeys
state_getKeysPagedAt
state_getPairs
state_getReadProof
state_getStorageAt
state_getStorageHash
state_getStorageHashAt
state_getStorageSize
state_getStorageSizeAt
state_queryStorage
state_subscribeRuntimeVersion
state_subscribeStorage
state_traceBlock
state_unsubscribeRuntimeVersion
state_unsubscribeStorage
subnetInfo_getAllDynamicInfo
subnetInfo_getAllMechagraphs
subnetInfo_getAllMetagraphs
subnetInfo_getColdkeyAutoStakeHotkey
subnetInfo_getDynamicInfo
subnetInfo_getLockCost
subnetInfo_getMechagraph
subnetInfo_getMetagraph
subnetInfo_getSelectiveMechagraph
subnetInfo_getSelectiveMetagraph
subnetInfo_getSubnetHyperparams
subnetInfo_getSubnetHyperparamsV2
subnetInfo_getSubnetInfo
subnetInfo_getSubnetInfo_v2
subnetInfo_getSubnetState
subnetInfo_getSubnetToPrune
subnetInfo_getSubnetsInfo
subnetInfo_getSubnetsInfo_v2
subscribe_newHead
swap_currentAlphaPrice
swap_simSwapAlphaForTao
swap_simSwapTaoForAlpha
system_accountNextIndex
system_addLogFilter
system_addReservedPeer
system_chainType
system_localListenAddresses
system_localPeerId
system_nodeRoles
system_peers
system_removeReservedPeer
system_reservedPeers
system_resetLogFilter
system_syncState
system_unstable_networkState
transactionWatch_v1_submitAndWatch
transactionWatch_v1_unwatch
transaction_v1_broadcast
transaction_v1_stop
unsubscribe_newHead

Bittensor exposes both an Ethereum-compatible JSON-RPC (via Frontier) and native Substrate RPC. Use either or both depending on your integration.

Custom RPC Extensions

Bittensor nodes also expose custom RPC namespaces for chain‑specific AI/ML data:

  • subnetInfo_*: subnet configuration, hyperparameters, metagraphs
  • neuronInfo_*: neuron and mechagraph data
  • delegateInfo_*: delegation and delegate details
  • swap_*: TAO and 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:

JavaScript
// 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:

JavaScript
// 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:

JavaScript
// 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:

JavaScript
// 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:

JavaScript
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:

JavaScript
// WebSocket connection for real-time updates
const wsProvider = new WebSocketProvider(
  'wss://api-bittensor-mainnet.n.dwellir.com/YOUR_API_KEY'
);

// 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:

JavaScript
// 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:

JavaScript
// 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?


Start building on Bittensor with Dwellir's enterprise-grade RPC infrastructure. Get your API key