Rust SDK
The Tenzro Rust SDK (tenzro-sdk) provides a complete client library for interacting with the Tenzro Network from Rust applications. It wraps all 233+ RPC methods into typed async functions using reqwest for HTTP transport. The SDK includes 9 example programs covering common use cases.
Installation
# Add to your Cargo.toml
[dependencies]
tenzro-sdk = "0.1"
tokio = { version = "1", features = ["full"] }# Or via cargo add
cargo add tenzro-sdk
cargo add tokio --features fullQuick Start
use tenzro_sdk::TenzroClient;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let client = TenzroClient::new("https://rpc.tenzro.network")?;
// Check balance
let balance = client.blockchain().get_balance("0xAddress...").await?;
println!("Balance: {} TNZO", balance);
// Send a transaction
let tx = client.blockchain().send_transaction(
"0xRecipient...",
"1000000000000000000", // 1 TNZO
).await?;
println!("Tx hash: {}", tx.hash);
// Chat with an AI model
let response = client.models().chat(
"gemma3-270m",
vec![ChatMessage::user("Hello, Tenzro!")],
).await?;
println!("{}", response.content);
Ok(())
}Client Modules
The Rust SDK provides the same 26 modules as the TypeScript SDK, accessed via builder-style methods on the client:
let client = TenzroClient::new("https://rpc.tenzro.network")?;
// Access modules via methods
client.blockchain() // Block and transaction queries
client.accounts() // Account management
client.models() // AI model operations
client.inference() // Streaming + batch inference
client.identity() // TDIP identity management
client.wallet() // MPC wallet operations
client.payments() // Payment protocols (MPP, x402)
client.staking() // Staking and providers
client.governance() // On-chain governance
client.agents() // AI agent management
client.settlement() // Payment settlement
client.bridge() // Cross-chain operations
client.tokens() // Token registry
client.canton() // Canton/DAML integration
client.tasks() // Task marketplace
client.network() // Node and network info
client.verification() // Proof verification
client.evm() // EVM-compatible methods
client.compliance() // ERC-3643 compliance
client.paymaster() // Gas sponsorship
client.sponsored() // Sponsored transactions
client.erc7802() // Cross-chain token standard
client.skills() // Skills registry
client.tools() // Tools registry
client.contracts() // Smart contract deployment
client.faucet() // Testnet faucetStreaming Inference
use tenzro_sdk::TenzroClient;
use futures::StreamExt;
let client = TenzroClient::new("https://rpc.tenzro.network")?;
let mut stream = client.inference().stream(
"gemma3-270m",
vec![
ChatMessage::system("You are a helpful assistant."),
ChatMessage::user("Explain zero-knowledge proofs."),
],
).await?;
while let Some(event) = stream.next().await {
match event? {
StreamEvent::Token(text) => print!("{}", text),
StreamEvent::Done(usage) => {
println!("\nTokens: {}", usage.total_tokens);
}
StreamEvent::Error(e) => eprintln!("Error: {}", e),
}
}ProviderClient
use tenzro_sdk::ProviderClient;
let provider = ProviderClient::new(
"https://rpc.tenzro.network",
wallet_key,
)?;
// Register as a model provider
provider.register(ProviderConfig {
role: NodeRole::ModelProvider,
stake: "10000000000000000000000".into(), // 10,000 TNZO
}).await?;
// Start serving a model
provider.serve_model(ServeConfig {
model_id: "gemma3-270m".into(),
endpoint: "http://localhost:8080/v1".into(),
pricing: PricingConfig {
per_token: "100000000000000".into(), // 0.0001 TNZO
},
}).await?;Example Programs
The SDK ships with 9 example programs in sdk/tenzro-sdk/examples/:
| Example | Description |
|---|---|
task_marketplace | Post tasks, receive quotes, assign and complete work |
agent_marketplace | Register agent templates, spawn agents, manage swarms |
basic_usage | Balance queries, transactions, and model listing |
identity | Register identities, resolve DIDs, manage credentials |
inference | Streaming and batch AI inference |
bridge | Cross-chain token transfers |
staking | Stake TNZO, register as provider |
governance | List proposals, vote, check voting power |
payments | MPP and x402 payment flows |
# Run an example
cargo run --example task_marketplace
cargo run --example agent_marketplace
cargo run --example basic_usage