Skip to main content

pyde_rust_sdk/
lib.rs

1//! # pyde-rust-sdk
2//!
3//! Rust SDK for building dapps + wallets on the [Pyde](https://pyde.network)
4//! blockchain. Comprehensive surface — account generation, FALCON-512
5//! signing, transaction construction, RPC client (HTTP + WebSocket),
6//! event subscriptions, typed contract interaction via the
7//! [`pyde_abi!`] macro, and the small utility helpers every
8//! wallet/dapp needs.
9//!
10//! Sister SDK in TypeScript: `pyde-ts-sdk`. Both target the same
11//! chain wire format (Tx, TxType, AuthKeys, FALCON/Poseidon2 byte
12//! shapes are pinned across both), and both write the canonical Pyde
13//! account keystore (Argon2id + AES-256-GCM, the shared multi-account
14//! vault), so a keystore made by one opens in the other and in the
15//! `otigen` CLI. See `docs/12-compatibility.md`.
16//!
17//! ## Quick start
18//!
19//! ```rust,ignore
20//! use std::sync::Arc;
21//! use pyde_rust_sdk::provider::{HttpTransport, RootProvider};
22//! use pyde_rust_sdk::{Provider, Signer, TxBuilder, Wallet};
23//! use pyde_rust_sdk::types::Address;
24//! use pyde_rust_sdk::util::parse_quanta;
25//!
26//! #[tokio::main]
27//! async fn main() -> anyhow::Result<()> {
28//!     // `otigen devnet` picks a random RPC port — set PYDE_RPC_URL
29//!     // to its advertised URL, or substitute the URL directly.
30//!     let url = std::env::var("PYDE_RPC_URL")
31//!         .unwrap_or_else(|_| "http://127.0.0.1:9933".to_string());
32//!     let transport = HttpTransport::new(&url)?;
33//!     let provider = Arc::new(RootProvider::new(transport));
34//!     let wallet = Wallet::generate()?;
35//!     let recipient = Address::from_hex("0xaa…")?;
36//!
37//!     let chain_id = provider.chain_id().await?;
38//!     let nonce = provider.get_nonce(&wallet.address()).await?;
39//!     let mut tx = TxBuilder::new()
40//!         .from(wallet.address())
41//!         .chain_id(chain_id)
42//!         .nonce(nonce)
43//!         .transfer(recipient, parse_quanta("1.5")?)
44//!         .build()?;
45//!     wallet.sign_tx(&mut tx).await?;
46//!     let pending = provider.send_transaction(&tx).await?;
47//!     let receipt = pending.wait_for_receipt().await?;
48//!     println!("committed in wave {}", receipt.wave_id_u64());
49//!     Ok(())
50//! }
51//! ```
52//!
53//! See [`PROPOSAL.md`](https://github.com/pyde-net/pyde-rust-sdk/blob/main/PROPOSAL.md)
54//! for the full v1 surface plan + phased build schedule.
55
56// ── Module declarations ──────────────────────────────────────────────
57
58pub mod abi;
59pub mod constants;
60pub mod contract;
61pub mod error;
62pub mod factory;
63pub mod multisig;
64pub mod provider;
65pub mod signer;
66pub mod tx;
67pub mod types;
68pub mod util;
69pub mod wallet;
70pub mod ws;
71
72// ── Top-level re-exports — what 95% of users reach for. ──────────────
73
74pub use contract::{pyde_abi, Contract, DecodedEvent};
75pub use error::{Result, SdkError};
76pub use factory::{child_address, child_preimage, Instantiated, Salt};
77pub use provider::{
78    HttpProvider, HttpTransport, PendingTx, PrivateSendHandle, Provider, RootProvider, Transport,
79};
80pub use signer::{LocalSigner, Signer};
81pub use tx::TxBuilder;
82pub use types::{
83    AccessEntry, AccessType, AccountInfo, AccountType, Address, AuthKeys, CallOverrides,
84    CallPayload, CallRequest, CommitPayload, Event, EventFilter, FalconPubkey, FalconSignature,
85    FeeData, FeePayer, Log, LogCursor, LogFilter, LogPage, NodeInfo, Receipt, ReceiptStatus,
86    RecentWaveSummary, RevealPayload, RevertCategory, RevertReason, SimulationResult, Tx, TxHash,
87    TxType,
88};
89pub use wallet::{KdfParams, Keystore, KeystoreEntry, Wallet};
90pub use ws::{Subscription, WsProvider, WsTransport};