Rust SDK
The Rust SDK is for backends, native mobile clients, embedded systems, and any application where Rust's performance and safety guarantees are wanted. It gives you both low-level control over the OXN protocol and higher-level ergonomics for common cases.
Installation
Add to Cargo.toml:
[dependencies]
oasis-runtime-sdk = "0.13"
tokio = { version = "1", features = ["full"] }
Rust SDK is async; use tokio or another async runtime.
Basic connection
use oasis_runtime_sdk::client::EvmClient;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let client = EvmClient::new("https://rpc.bout.network")?;
let chain_id = client.chain_id().await?;
println!("Chain ID: {}", chain_id);
Ok(())
}
Sending encrypted transactions
The Rust SDK provides a signer type that automatically encrypts:
use oasis_runtime_sdk::client::{EvmClient, EncryptedSigner};
let client = EvmClient::new("https://rpc.bout.network")?;
let signer = EncryptedSigner::from_private_key(&private_key_hex, &client)?;
let tx = signer
.send_transaction()
.to(recipient_address)
.value(1_000_000_000_000_000_000u128) // 1 TBLUAI (testnet display)
.gas_limit(100_000)
.submit()
.await?;
println!("Transaction: {}", tx.hash);
The exact type names and API surface depend on the SDK version. Consult cargo doc --open after installing.
Contract interaction
Rust bindings from ABIs use alloy or ethers-rs conventions. Combined with the OXN encrypted signer:
// Assuming a generated MyToken binding
let token = MyToken::new(token_address, signer.clone());
let tx = token.transfer(recipient, amount).gas_limit(500_000).send().await?;
tx.wait().await?;
Use cases
High-performance indexer. Rust's zero-cost async makes it ideal for reading many blocks in parallel.
Backend service under high load. Rust services can handle more concurrent requests per core than equivalent Go or Node.js services.
Embedded / edge devices. Small memory footprint and no GC make Rust suitable for constrained environments.
Cryptographic backends. If your app does heavy off-chain cryptographic work, Rust's crypto ecosystem (curve25519-dalek, rustcrypto, etc.) is mature.
Address handling
use oasis_runtime_sdk::types::address::{Address, PublicKey};
// EVM address from public key
let evm_address = evm_address_from_pubkey(&pubkey);
// Native oxn1... address from public key
let native_address = Address::from_pk(&PublicKey::Ed25519(pubkey));
println!("{}", native_address); // "oxn1..."
Testing
Standard #[tokio::test] for async tests:
#[tokio::test]
async fn test_encrypted_transfer() {
let client = EvmClient::new("https://rpc.bout.network").unwrap();
// ...
}
Use #[ignore] for integration tests that require testnet:
#[tokio::test]
#[ignore]
async fn test_against_testnet() { /* ... */ }
Run with cargo test -- --ignored.
Next steps
- Go SDK — sibling SDK for services
- JSON-RPC API — raw protocol reference