Tenzro Testnet is live —request testnet TNZO

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 full

Quick 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 faucet

Streaming 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?;

Transaction Signing

Every Tenzro transaction is hybrid post-quantum signed: a classical Ed25519 signature and an ML-DSA-65 (FIPS 204) signature, both verified synchronously by the node against the canonical Transaction::hash() preimage (which commits to the wallet's ML-DSA-65 public key). An invalid or missing signature on either leg returns JSON-RPC error -32003. Two supported flows:

1. Atomic server-side sign + send (recommended). Auth is mandatory — present Authorization: DPoP <jwt> + DPoP: <proof> headers. The node identifies the signing wallet from the bearer JWT, constructs the hash preimage, signs both legs, verifies them, and submits to the mempool — all in one call. Private keys never travel over the wire. WalletClient::send() is a thin wrapper over this RPC.

let tx_hash = client
    .wallet()
    .send(from_address, to_address, 1_000_000_000_000_000_000)
    .await?;

2. Offline sign, then submit. Call tenzro_signTransaction to obtain {signature, public_key, pq_signature, pq_public_key, timestamp, tx_hash}, then resubmit later via eth_sendRawTransaction with all six fields intact. Use this for batched or air-gapped submission.

Durable State

The node persists AI infrastructure to RocksDB and restores it on restart — SDK consumers see consistent state across node upgrades and reboots:

  • Model catalogModelRegistry writes ModelInfo records under info:<model_id> in CF_MODELS; models survive restart without re-registration.
  • Agent runtimeAgentRuntime persists RegisteredAgent, AgentLifecycleInfo, and parent→children spawn trees under agent:/lifecycle:/children: prefixes in CF_AGENTS. Terminated agents are retained for audit of state_history, registration_fee, and tenzro_did.
  • SwarmsSwarmManager persists SwarmState under swarm:<swarm_id> in CF_AGENTS with write-through on create, status transitions, and termination.

Example Programs

The SDK ships with 9 example programs in sdk/tenzro-sdk/examples/:

ExampleDescription
task_marketplacePost tasks, receive quotes, assign and complete work
agent_marketplaceRegister agent templates, spawn agents, manage swarms
basic_usageBalance queries, transactions, and model listing
identityRegister identities, resolve DIDs, manage credentials
inferenceStreaming and batch AI inference
bridgeCross-chain token transfers
stakingStake TNZO, register as provider
governanceList proposals, vote, check voting power
paymentsMPP and x402 payment flows
# Run an example
cargo run --example task_marketplace
cargo run --example agent_marketplace
cargo run --example basic_usage