Przejdź do głównej zawartości

Rust SDK

openfiat-sdk (openfiat-sdks/rust) — a typed client for a node's JSON-RPC surface, plus Ed25519 wallet signing and Solana chain bridge support.

Install

Pre-1.0 and not published to crates.io yet — depend on it as a git dependency, pinned to a commit:

[dependencies]
openfiat-sdk = { git = "https://github.com/OpenFiat-org/openfiat-sdks", rev = "<commit>" }

Quick start

use openfiat_sdk::{Client, ClientConfig};

let client = Client::new(ClientConfig {
endpoint: "http://localhost:7080".to_string(),
..ClientConfig::default()
});

let version = client.get_version().await?;

Signing and submitting a write

Every sendX method takes the domain's own event struct plus a Keypair — the SDK builds the signed payload and submits it; a node never constructs or signs anything on your behalf:

use openfiat_sdk::wallet::Keypair;
use openfiat_oracles::events::OraclePublish;

let keypair = Keypair::generate(); // or Keypair::from_seed(...) / solana_keyfile::load(...)
let oracle_id = client.send_oracle_publish(publish, &keypair).await?;

Examples

Every example in rust/examples runs against a real node and is covered by an integration test in tests/live_node.rs (run in CI), so a broken example fails the build the same way a broken test would:

Run any of them against a local node:

# terminal 1 — from openfiat-core
cargo run -p openfiat-cli -- --rpc-bind-address 127.0.0.1:7080

# terminal 2 — from openfiat-sdks/rust
cargo run --example trading_bot