Skip to main content

ombrachain — Rust SDK

Crate oficial Rust pentru OmbraChain. Folosește ed25519-dalek, reqwest (HTTP/SSE), tokio, serde_json cu preserve_order.

Install

[dependencies]
ombrachain = "0.2"
tokio = { version = "1", features = ["full"] }
num-bigint = "0.4"
futures-util = "0.3"

Quick start

use ombrachain::{Wallet, OmbraClient, TxBuilder, constants};
use num_bigint::BigUint;
use futures_util::StreamExt;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let wallet = Wallet::from_mnemonic("...12 words...", "")?;
let client = OmbraClient::new("https://api.ombra-net.com");

let acct = client.get_account(wallet.address()).await?;
let nonce = acct["nonce"].as_u64().unwrap();

// ── Fork V6 — agent run ──
let run_id = TxBuilder::compute_agent_run_id(wallet.address(), nonce, "Explain Bitcoin");
let conv_id = TxBuilder::compute_conversation_id(wallet.address(), None);

let tx = TxBuilder::build_agent_request_tx(
wallet.address(), &run_id, &conv_id,
"Explain Bitcoin in 100 words",
&["web_search", "chain_query"],
&BigUint::from(constants::MICRO_OMBRA), // 1 OMBRA escrow
100, None, None,
nonce, wallet.private_key(),
);
client.submit_tx(&tx).await?;

let mut events = Box::pin(client.stream_events());
while let Some(evt) = events.next().await {
println!("{:?}", evt?);
}
Ok(())
}

Cross-language compatibility

serde_json::Value cu preserve_order feature menține insertion order la serialize → bit-exact cu TS/Python/Java/C#/C++/Go.