rustao 0.2.0

Rust SDK for the AO protocol on Arweave
Documentation

rustao – Rust SDK for AO

Crates.io docs.rs License

rustao is an asynchronous Rust library for interacting with the AO protocol on Arweave. It provides a clean, ergonomic API to send messages, spawn processes, perform dry runs, query compute endpoints, and handle hybrid encryption – matching the functionality of the official goao SDK.


πŸš€ Features

  • βœ… Async/Await – Built on tokio for high performance.
  • πŸ“¨ Send Messages – Sign and send messages to AO processes.
  • 🌱 Spawn Processes – Deploy new processes from module transactions.
  • πŸ§ͺ Dry Runs – Simulate message execution without committing.
  • πŸ“Š Compute Queries – Fetch process state via HTTP compute endpoints.
  • πŸ” Wait for Results – Poll until a message result is available.
  • πŸ” Hybrid Encryption – RSA‑OAEP + AES‑GCM for secure payloads.
  • 🧾 Arweave Wallet Support – Sign using JWK files.
  • πŸ”‘ Local Crypto – Embedded RSA signing (from arweave-rust) for security.

πŸ“¦ Installation

Add this to your Cargo.toml:

[dependencies]
rustao = { path = "../rustao" }
tokio = { version = "1", features = ["full"] }
serde_json = "1.0"

πŸ—οΈ Modules

rustao::crypto

Local RSA cryptographic operations (cloned from arweave-rust for security):

  • Driver::generate_key() – Generate new RSA-PSS key pair
  • PrivateKey::sign(data) – Sign data with RSA-PSS
  • PrivateKey::verify(data, signature) – Verify signature

rustao::core

Core Arweave types:

  • TransactionData – Transaction data structure

rustao::Client

Main client for interacting with AO:

  • send_message() – Send messages to processes
  • spawn_process() – Spawn new processes
  • dry_run() – Simulate execution
  • get_compute_json() – Query process state

rustao::ARSigner

Wallet signing:

  • ARSigner::from_file(path) – Load from JWK file
  • sign(data) – Sign data
  • address() – Get wallet address

πŸš€ Quick Start

use rustao::{Client, ARSigner, Tag};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Load your Arweave wallet (JWK file)
    let signer = ARSigner::from_file("wallet.json")?;

    // Create a client
    let client = Client::new(signer);

    // The process you want to interact with
    let process_id = "6wqH8ue2-bnJG7j--FV0KGYzSs53ObFDofDITb7qtxI";

    // Send a simple message
    let msg_id = client.send_message(
        process_id,
        b"{\"action\": \"hello\"}",
        vec![Tag::new("Action", "Message")],
        None,
        None,
    ).await?;
    println!("Message sent: {}", msg_id);

    Ok(())
}

πŸ§ͺ Testing

Run all tests:

cargo test

Run live network tests:

cargo test test_send_message -- --ignored

πŸ“± Example Dapp

See /home/tony/rustao-example for a complete Dapp that fetches dApps from AoStore:

cd rustao-example
cargo run

Then visit http://localhost:8080


πŸ§‘β€πŸ’» Contributing

Contributions are welcome! Please open an issue or pull request.


License

MIT License. See the LICENSE file for details.


πŸ™ Acknowledgements