Skip to content

Commit 1ff7ff7

Browse files
committed
docs: comprehensive documentation matching official Bittensor Python SDK quality
- Complete rewrite of all documentation (39 files, 17,874 lines) - README.md: architecture diagram, crate table, feature flags, code examples - Getting started guide with connection, queries, transfers, wallets - Architecture overview with data flow diagrams and extension points - Full crate references: wallet, chain-client, synapse, axon, dendrite, metagraph - 12 query module references (account, delegate, neuron, subnet, staking, etc.) - 10 extrinsic module references (staking, transfer, weights, registration, etc.) - CLI reference (btcli-rs) with all subcommands - TUI dashboard reference - Python bindings reference (bittensor_rs package) - WASM bindings reference for browser usage - Migration guide from Python SDK to Rust with before/after examples - Glossary and FAQ - Removed obsolete docs (chain.md, validator.md, types.md, utils.md) - Fixed all old API paths (bittensor_rs → bittensor_chain)
1 parent dfc818c commit 1ff7ff7

50 files changed

Lines changed: 17561 additions & 2995 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 132 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# bittensor-rs
22

3-
Rust SDK for the Bittensor network — wallet management, chain interaction, neuron serving, and subnet monitoring.
3+
Rust SDK for the Bittensor decentralized AI network. Wallet management, chain interaction, neuron serving, and subnet monitoring, built on subxt 0.50 with typed storage queries and extrinsics.
44

55
## Architecture
66

@@ -69,9 +69,50 @@ Rust SDK for the Bittensor network — wallet management, chain interaction, neu
6969
| **bittensor-wasm** | WASM bindings for browser usage |
7070
| **bittensor-examples** | Runnable code samples |
7171

72+
## Feature Flags
73+
74+
### bittensor-chain
75+
76+
| Feature | Default | Description |
77+
|---|---|---|
78+
| `storage-subscriptions` | yes | Enable `subscribe_storage` event stream |
79+
| `drand` | no | Drand randomness beacon verification |
80+
| `mev-shield` | no | Post-quantum MEV protection for extrinsics |
81+
| `integration-tests` | no | Integration test suite (requires local node) |
82+
83+
### bittensor-metagraph
84+
85+
| Feature | Default | Description |
86+
|---|---|---|
87+
| `ml-backend` | no | ML-based weight scoring backend |
88+
89+
### bittensor-cli
90+
91+
| Feature | Default | Description |
92+
|---|---|---|
93+
| `mev` | no | MEV-shield protected transactions |
94+
95+
## Python SDK vs Rust SDK
96+
97+
| Feature | Python SDK | Rust SDK |
98+
|---|---|---|
99+
| Performance | Interpreter overhead | Native binary, zero-cost abstractions |
100+
| Memory safety | GC managed | Compile-time borrow checking |
101+
| Concurrency | GIL-limited async | Native async with tokio, no GIL |
102+
| WASM support | No | Full wasm-bindgen support |
103+
| Python bindings | Native | Via bittensor-pyo3 (`bittensor_rs`) |
104+
| Typing | Runtime duck typing | Static types, subxt-generated metadata |
105+
| Keyfile format | NaCl secretbox | Same NaCl secretbox, cross-compatible |
106+
| Chain client | substrate-interface | subxt 0.50, typed storage + extrinsics |
107+
72108
## Getting Started
73109

74-
Add to your `Cargo.toml`:
110+
### Requirements
111+
112+
- Rust 1.85+ (Edition 2024)
113+
- A running Subtensor node (finney, test, or local)
114+
115+
### Add Dependencies
75116

76117
```toml
77118
[dependencies]
@@ -80,19 +121,104 @@ bittensor-chain = "0.1"
80121
bittensor-wallet = "0.1"
81122
```
82123

83-
Connect and query:
124+
Or via cargo:
125+
126+
```sh
127+
cargo add bittensor-core bittensor-chain bittensor-wallet
128+
```
129+
130+
### Connect and Query
84131

85132
```rust,no_run
86133
use bittensor_chain::prelude::SubtensorClient;
87134
use bittensor_core::config::NetworkConfig;
88135
136+
#[tokio::main]
137+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
138+
let client = SubtensorClient::from_config(NetworkConfig::finney()).await?;
139+
let block = client.at_current_block().await?;
140+
println!("Connected at block {:?}", block.block_hash());
141+
Ok(())
142+
}
143+
```
144+
145+
### Query Balance
146+
147+
```rust,no_run
148+
use bittensor_chain::prelude::*;
149+
use bittensor_core::config::NetworkConfig;
150+
use bittensor_core::balance::Balance;
151+
89152
let client = SubtensorClient::from_config(NetworkConfig::finney()).await?;
153+
let balance: Balance = bittensor_chain::queries::account::get_balance(
154+
client.rpc(), &account_id
155+
).await?;
156+
println!("Balance: {balance}");
90157
```
91158

92-
## Requirements
159+
### Transfer TAO
93160

94-
- Rust 1.85+ (Edition 2024)
95-
- A running Subtensor node (finney, test, or local)
161+
```rust,no_run
162+
use bittensor_chain::prelude::*;
163+
use bittensor_core::config::NetworkConfig;
164+
use bittensor_core::balance::Balance;
165+
166+
let client = SubtensorClient::from_config(NetworkConfig::finney()).await?;
167+
let signer = subxt_signer::sr25519::Keypair::from_uri("//Alice")?;
168+
let dest = subxt_signer::sr25519::PublicKey::from_uri("//Bob")?;
169+
let amount = Balance::from_tao(1.0);
170+
171+
bittensor_chain::extrinsics::transfer::transfer(
172+
client.rpc(), &signer, &dest, amount.to_rao()
173+
).await?;
174+
```
175+
176+
### Create a Wallet
177+
178+
```rust
179+
use bittensor_wallet::prelude::*;
180+
181+
let mut wallet = Wallet::new("default");
182+
let mnemonic = wallet.create_coldkey("my-password")?;
183+
println!("Back up this mnemonic: {mnemonic}");
184+
println!("Coldkey address: {}", wallet.get_coldkeypub()?);
185+
186+
let hotkey = wallet.create_hotkey()?;
187+
println!("Hotkey address: {}", hotkey.ss58_address());
188+
```
189+
190+
### Network Endpoints
191+
192+
| Network | WebSocket URL |
193+
|---|---|
194+
| Finney (mainnet) | `wss://entrypoint-finney.opentensor.ai:443` |
195+
| Testnet | `wss://test.finney.opentensor.ai:443` |
196+
| Local | `ws://127.0.0.1:9944` |
197+
| Archive | `wss://archive.finney.opentensor.ai:443` |
198+
199+
You can also connect directly with `SubtensorClient::from_url`:
200+
201+
```rust,no_run
202+
let client = SubtensorClient::from_url("wss://entrypoint-finney.opentensor.ai:443").await?;
203+
```
204+
205+
## Documentation
206+
207+
Full documentation is available in the `docs/` directory:
208+
209+
- [Documentation Index](docs/index.md)
210+
- [Getting Started](docs/getting-started.md)
211+
- [Architecture](docs/architecture.md)
212+
213+
## Metadata
214+
215+
Chain metadata is stored at `metadata/finney.scale` and auto-loaded at compile time. When the Finney runtime upgrades, regenerate the metadata and API bindings:
216+
217+
```sh
218+
cargo install subxt-cli@0.50.0 --locked
219+
subxt metadata --url wss://entrypoint-finney.opentensor.ai:443 -f bytes > metadata/finney.scale
220+
cargo check -p bittensor-chain
221+
```
96222

97223
## License
98224

0 commit comments

Comments
 (0)