Interact with the Bittensor blockchain to manage wallets, stake TAO, register neurons, query subnets/metagraphs, track emissions, and set neuron weights.
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install bittensor-sdk或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install bittensor-sdk⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/bittensor-sdk/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: bittensor-sdk description: Comprehensive Bittensor blockchain interaction skill with wallet management, staking, subnet operations, neuron registration, and emissions tracking. Use for: bittensor operations, subtensor queries, stake/unstake TAO, register neurons, query subnet info, wallet operations, metagraph analysis, emissions tracking, and weight management. license: MIT compatibility: Requires Python 3.8+, bittensor>=8.0.0, network access to Bittensor network endpoints metadata: author: bittensor_quest version: "1.0.0" ---
Comprehensive Bittensor blockchain interaction skill for agents. Enables seamless interaction with the Bittensor decentralized AI network through the Python SDK.
Bittensor is a decentralized machine learning network where independent subnets compete for TAO token emissions. This skill provides agents with full access to:
pip install bittensor>=8.0.0
cp -r skills/bittensor-sdk ~/.opencode/skills/
The skill initializes the Subtensor interface for blockchain interaction:
import bittensor as bt
# Connect to mainnet
subtensor = bt.Subtensor(network="finney")
# Connect to testnet
subtensor = bt.Subtensor(network="test")
# Custom network with fallback endpoints
subtensor = bt.Subtensor(
network="finney",
fallback_endpoints=["wss://entrypoint-finney.opentensor.ai:443"],
retry_forever=True
)
from bittensor import wallet
# Load existing wallet
wallet = bt.Wallet()
# Create new wallet
wallet = bt.Wallet(name="my_wallet", hotkey="miner1")
# Check balances
coldkey_balance = wallet.coldkey_balance
print(f"Coldkey balance: {coldkey_balance}")
# Get all subnet netuids
netuids = subtensor.get_all_subnets_netuid()
print(f"Available subnets: {netuids}")
# Get detailed subnet info
subnet_info = subtensor.get_subnet_info(netuid=1)
print(f"Subnet 1 info: {subnet_info}")
from bittensor import Balance
# Stake TAO to a hotkey
amount = Balance.from_tao(10.0) # 10 TAO
result = subtensor.add_stake(
wallet=wallet,
netuid=1,
hotkey_ss58="5Hx...", # Hotkey SS58 address
amount=amount,
safe_staking=True, # Enable price protection
allow_partial_stake=True
)
print(f"Stake result: {result}")
# Burned registration (recycle TAO)
result = subtensor.burned_register(
wallet=wallet,
netuid=1
)
# POW registration (computational proof)
result = subtensor.register(
wallet=wallet,
netuid=1
)
# Get metagraph for a subnet
metagraph = subtensor.metagraph(netuid=1)
print(f"Number of neurons: {metagraph.n}")
print(f"Stake per neuron: {metagraph.S}")
print(f"Rewards: {metagraph.R}")
print(f"Hotkeys: {metagraph.hotkeys}")
import numpy as np
# Validator sets weights for miners
uids = np.array([0, 1, 2, 3, 4]) # Miner UIDs
weights = np.array([0.2, 0.3, 0.2, 0.15, 0.15]) # Normalized weights
result = subtensor.set_weights(
wallet=validator_wallet,
netuid=1,
uids=uids,
weights=weights,
wait_for_inclusion=True,
wait_for_finalization=True
)
import bittensor as bt
from bittensor import Balance
import numpy as np
# Initialize
subtensor = bt.Subtensor(network="finney")
wallet = bt.Wallet(name="miner_wallet", hotkey="miner1")
# Check balance
balance = subtensor.get_balance(wallet.coldkey.ss58_address)
print(f"Balance: {balance.tao} TAO")
# Register on subnet 1
print("Registering neuron...")
result = subtensor.register(
wallet=wallet,
netuid=1,
wait_for_inclusion=True
)
# Get metagraph info
metagraph = subtensor.metagraph(netuid=1)
print(f"Neurons on subnet 1: {metagraph.n}")
# Check my neuron
my_uid = metagraph.hotkeys.index(wallet.hotkey.ss58_address)
my_neuron = metagraph.neurons[my_uid]
print(f"My UID: {my_uid}")
print(f"My stake: {my_neuron.stake}")
print(f"My emission: {my_neuron.emission}")
import bittensor as bt
from bittensor import Balance
import numpy as np
# Initialize
subtensor = bt.Subtensor(network="finney")
validator_wallet = bt.Wallet(name="validator", hotkey="val1")
# Get metagraph
metagraph = subtensor.metagraph(netuid=1)
print(f"Total miners: {metagraph.n}")
# Calculate weights based on performance
weights = np.zeros(metagraph.n)
for i in range(metagraph.n):
weights[i] = metagraph.R[i] * 0.7 + metagraph.S[i] * 0.3
# Normalize weights
weights = weights / weights.sum()
# Set weights
result = subtensor.set_weights(
wallet=validator_wallet,
netuid=1,
uids=np.arange(metagraph.n),
weights=weights,
wait_for_inclusion=True,
wait_for_finalization=True
)
print(f"Weights set: {result.success}")
Problem: Unable to connect to network Solution:
# Use fallback endpoints
subtensor = bt.Subtensor(
network="finney",
fallback_endpoints=[
"wss://entrypoint-finney.opentensor.ai:443",
"wss://finney.opentensor.io:443"
],
retry_forever=True
)
Problem: Too many requests error Solution:
import time
time.sleep(1) # Rate limit delays
Problem: Registration fails repeatedly Solutions:
Problem: Wallet not found Solution:
# Create new wallet
wallet = bt.Wallet(name="new_wallet", hotkey="new_hotkey")
wallet.create_if_non_existing()
subtensor.close() when doneWhen presenting Bittensor SDK results to users:
...
安装 Bittensor SDK 后,可以对 AI 说这些话来触发它
Help me get started with Bittensor SDK
Explains what Bittensor SDK does, walks through the setup, and runs a quick demo based on your current project
Use Bittensor SDK to interact with the Bittensor blockchain to manage wallets, stake TAO...
Invokes Bittensor SDK with the right parameters and returns the result directly in the conversation
What can I do with Bittensor SDK in my data & analytics workflow?
Lists the top use cases for Bittensor SDK, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/bittensor-sdk/ 目录(个人级,所有项目可用),或 .claude/skills/bittensor-sdk/(项目级)。重启 AI 客户端后,用 /bittensor-sdk 主动调用,或让 AI 根据上下文自动发现并使用。
Bittensor SDK 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
Bittensor SDK 可免费安装使用。请查阅仓库了解许可证信息。
Interact with the Bittensor blockchain to manage wallets, stake TAO, register neurons, query subnets/metagraphs, track emissions, and set neuron weights.
Bittensor SDK 属于「Data & Analytics」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my data & analytics tasks using Bittensor SDK
Identifies repetitive steps in your workflow and sets up Bittensor SDK to handle them automatically