# rustao β Rust SDK for AO
[](https://crates.io/crates/rustao)
[](https://docs.rs/rustao)
[](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`:
```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
```rust
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:
```bash
cargo test
```
Run live network tests:
```bash
cargo test test_send_message -- --ignored
```
---
## π± Example Dapp
See `/home/tony/rustao-example` for a complete Dapp that fetches dApps from AoStore:
```bash
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
- Built on top of [arweave-rust](https://github.com/kimtony123/arweave-rust) for cryptographic operations
- Inspired by [goao](https://github.com/ar-aostore/goao)