Tenzro Testnet is live —request testnet TNZO
← Back to Tutorials
SDKBeginner

Rust SDK Quickstart

Get up and running with the Tenzro Rust SDK in under 5 minutes. You will connect to the testnet, create a wallet, check your balance, send TNZO, register a decentralized identity, list available AI models, and run inference -- all from Rust.

Prerequisites

  • Rust 1.75+ with Cargo installed
  • Internet connection (for testnet RPC calls)

Estimated time: 5 minutes

Step 1: Create a New Project

Create a fresh Rust project and add the Tenzro SDK dependency:

cargo new my-tenzro-app
cd my-tenzro-app
cargo add tenzro-sdk
cargo add tokio --features full

Your Cargo.toml should now include:

[dependencies]
tenzro-sdk = "0.1"
tokio = { version = "1", features = ["full"] }

Step 2: Connect to Testnet

Open src/main.rs and connect to the Tenzro testnet. The SDK ships with a built-in testnet configuration that points to https://rpc.tenzro.network:

use tenzro_sdk::{TenzroClient, config::SdkConfig};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Connect to the public testnet
    let config = SdkConfig::testnet();
    let client = TenzroClient::connect(config).await?;

    // Verify connection
    let info = client.node_info().await?;
    println!("Connected to Tenzro Network");
    println!("  Version: {}", info.version);
    println!("  Chain ID: {}", info.chain_id);

    let block = client.block_number().await?;
    println!("  Current block: {}", block);

    Ok(())
}

Run it:

cargo run

You should see output confirming the connection:

Connected to Tenzro Network
  Version: 0.1.0
  Chain ID: 1337
  Current block: 482910

Custom Endpoints

To connect to a local node or a custom endpoint, use SdkConfig::new("http://localhost:8545") instead of SdkConfig::testnet(). For mainnet (when available), use SdkConfig::mainnet().

Step 3: Create a Wallet

Create a new Ed25519 wallet. The SDK calls the tenzro_createWallet RPC method under the hood:

use tenzro_sdk::{TenzroClient, config::SdkConfig};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = SdkConfig::testnet();
    let client = TenzroClient::connect(config).await?;

    // Create a new wallet
    let wallet = client.wallet();
    let info = wallet.create_wallet().await?;
    println!("Wallet created!");
    println!("  Address: {}", info.address);

    Ok(())
}

Wallet Security

For production use, Tenzro identities come with auto-provisioned MPC wallets (2-of-3 threshold signing). The simple wallet created here is suitable for testnet experimentation. See Create an Agentic Wallet for the full MPC wallet flow.

Step 4: Fund from Faucet

Request 100 testnet TNZO from the faucet. There is a 24-hour cooldown per address:

// Request testnet tokens
let faucet_response = client.faucet(&info.address).await?;
println!("Faucet: {} TNZO received", faucet_response.amount);
println!("  Tx hash: {}", faucet_response.tx_hash);

Step 5: Check Balance

Query the wallet balance. The SDK supports both the native tenzro_getBalance method and the Ethereum-compatible eth_getBalance:

use tenzro_types::Address;

// Parse the address
let address: Address = info.address.parse()?;

// Get TNZO balance (returns wei -- 18 decimals)
let balance = wallet.get_balance(address.clone()).await?;
println!("Balance: {} wei", balance);

// Get human-readable multi-asset balances
let balances = wallet.get_all_balances(address).await?;
for b in &balances.balances {
    println!("  {}: {} ({})", b.symbol, b.as_decimal(), b.balance);
}

Expected output:

Balance: 100000000000000000000 wei
  TNZO: 100.0 (100000000000000000000)

Step 6: Send TNZO

Transfer TNZO to another address. The SDK handles nonce management, gas estimation, and transaction signing:

// Send 1 TNZO to another address
let recipient = "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb4";
let amount = "1000000000000000000"; // 1 TNZO in wei

let tx_hash = wallet.send_transaction(
    &info.address,  // from
    recipient,       // to
    amount,          // value in wei
).await?;

println!("Transaction sent!");
println!("  Hash: {}", tx_hash);

// Check new balance
let new_balance = wallet.get_balance(address).await?;
println!("  New balance: {} wei", new_balance);

Step 7: Register an Identity

Register a TDIP (Tenzro Decentralized Identity Protocol) identity. Every identity gets an auto-provisioned MPC wallet:

let identity = client.identity();

// Register a human identity
let result = identity.register_human("Alice").await?;
println!("Identity registered!");
println!("  DID: {}", result.did);
println!("  Status: {}", result.status);

// Resolve the identity to verify
let info = identity.resolve(&result.did).await?;
println!("  Type: {:?}", info.identity_type);
println!("  KYC Tier: {}", info.kyc_tier);

Expected output:

Identity registered!
  DID: did:tenzro:human:550e8400-e29b-41d4-a716-446655440001
  Status: active
  Type: Human
  KYC Tier: 0

Step 8: List Available Models

Discover AI models available on the network:

let inference = client.inference();

// List all available models
let models = inference.list_models().await?;
println!("Available models ({}):", models.len());
for model in &models {
    println!("  {} - {} ({})",
        model.model_id,
        model.name,
        model.status,
    );
}

Example output:

Available models (5):
  gemma3-270m - Gemma 3 270M (available)
  qwen3.5-0.8b - Qwen 3.5 0.8B (available)
  qwen3-4b - Qwen 3 4B (available)
  phi-4-mini - Phi 4 Mini (available)
  gemma4-9b - Gemma 4 9B (available)

Step 9: Run Inference

Send an inference request to a model. The network routes it to the best available provider based on latency and price:

// Run inference
let response = inference.request(
    "gemma3-270m",                  // model ID
    "Explain blockchain in one sentence.", // prompt
    Some(100),                       // max tokens
).await?;

println!("Model response: {}", response.output);
println!("Tokens used: {}", response.tokens_used);
println!("Cost: {} TNZO", response.cost);

Example output:

Model response: A blockchain is a distributed, immutable ledger that records transactions across a network of computers without requiring a central authority.
Tokens used: 24
Cost: 0.0012 TNZO

Complete Example

Here is the full quickstart in a single main.rs:

use tenzro_sdk::{TenzroClient, config::SdkConfig};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // 1. Connect to testnet
    let config = SdkConfig::testnet();
    let client = TenzroClient::connect(config).await?;

    let info = client.node_info().await?;
    println!("Connected to Tenzro (chain {})", info.chain_id);

    // 2. Create a wallet
    let wallet = client.wallet();
    let wallet_info = wallet.create_wallet().await?;
    println!("Wallet: {}", wallet_info.address);

    // 3. Fund from faucet
    let faucet = client.faucet(&wallet_info.address).await?;
    println!("Funded: {} TNZO", faucet.amount);

    // 4. Check balance
    let address = wallet_info.address.parse()?;
    let balance = wallet.get_balance(address).await?;
    println!("Balance: {} wei", balance);

    // 5. Register identity
    let identity = client.identity();
    let id_result = identity.register_human("Alice").await?;
    println!("DID: {}", id_result.did);

    // 6. List models
    let inference = client.inference();
    let models = inference.list_models().await?;
    println!("Models available: {}", models.len());

    // 7. Run inference
    let response = inference.request(
        "gemma3-270m",
        "What is Tenzro Network?",
        Some(100),
    ).await?;
    println!("Response: {}", response.output);

    Ok(())
}

Sub-Client Reference

The TenzroClient exposes specialized sub-clients for every part of the network:

Sub-ClientAccessPurpose
WalletClientclient.wallet()Create wallets, check balances, send transactions
InferenceClientclient.inference()List models, run inference, stream responses
IdentityClientclient.identity()Register and resolve TDIP identities
PaymentClientclient.payment()MPP, x402, and native payment flows
AgentClientclient.agent()Register agents, send messages, delegate tasks
GovernanceClientclient.governance()List proposals, vote, check voting power
SettlementClientclient.settlement()Escrow, micropayments, batch settlement
TokenClientclient.token()Create tokens, cross-VM transfers, wrap TNZO
StakingClientclient.staking()Stake/unstake TNZO, register as provider
BridgeClientclient.bridge()Cross-chain bridges (LayerZero, CCIP, deBridge)
CryptoClientclient.crypto()Sign, verify, encrypt, hash, key exchange
NftClientclient.nft()Create collections, mint, transfer NFTs
ComplianceClientclient.compliance()ERC-3643 compliance rules, KYC enforcement
ContractClientclient.contract()Deploy and call smart contracts
TeeClientclient.tee()TEE attestation and enclave operations
ZkClientclient.zk()ZK proof generation and verification

What You Learned

Next Steps

Build More with Tenzro

Ready to build something more complex? Explore the full SDK documentation and examples.