Skip to main content

Crate pyde_rust_sdk

Crate pyde_rust_sdk 

Source
Expand description

§pyde-rust-sdk

Rust SDK for building dapps + wallets on the Pyde blockchain. Comprehensive surface — account generation, FALCON-512 signing, transaction construction, RPC client (HTTP + WebSocket), event subscriptions, typed contract interaction via the pyde_abi! macro, and the small utility helpers every wallet/dapp needs.

Sister SDK in TypeScript: pyde-ts-sdk. Both target the same chain wire format (Tx, TxType, AuthKeys, FALCON/Poseidon2 byte shapes are pinned across both), and both write the canonical Pyde account keystore (Argon2id + AES-256-GCM, the shared multi-account vault), so a keystore made by one opens in the other and in the otigen CLI. See docs/12-compatibility.md.

§Quick start

ⓘ
use std::sync::Arc;
use pyde_rust_sdk::provider::{HttpTransport, RootProvider};
use pyde_rust_sdk::{Provider, Signer, TxBuilder, Wallet};
use pyde_rust_sdk::types::Address;
use pyde_rust_sdk::util::parse_quanta;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // `otigen devnet` picks a random RPC port — set PYDE_RPC_URL
    // to its advertised URL, or substitute the URL directly.
    let url = std::env::var("PYDE_RPC_URL")
        .unwrap_or_else(|_| "http://127.0.0.1:9933".to_string());
    let transport = HttpTransport::new(&url)?;
    let provider = Arc::new(RootProvider::new(transport));
    let wallet = Wallet::generate()?;
    let recipient = Address::from_hex("0xaa…")?;

    let chain_id = provider.chain_id().await?;
    let nonce = provider.get_nonce(&wallet.address()).await?;
    let mut tx = TxBuilder::new()
        .from(wallet.address())
        .chain_id(chain_id)
        .nonce(nonce)
        .transfer(recipient, parse_quanta("1.5")?)
        .build()?;
    wallet.sign_tx(&mut tx).await?;
    let pending = provider.send_transaction(&tx).await?;
    let receipt = pending.wait_for_receipt().await?;
    println!("committed in wave {}", receipt.wave_id_u64());
    Ok(())
}

See PROPOSAL.md for the full v1 surface plan + phased build schedule.

Re-exports§

pub use contract::Contract;
pub use contract::DecodedEvent;
pub use error::Result;
pub use error::SdkError;
pub use factory::child_address;
pub use factory::child_preimage;
pub use factory::Instantiated;
pub use factory::Salt;
pub use provider::HttpProvider;
pub use provider::HttpTransport;
pub use provider::PendingTx;
pub use provider::PrivateSendHandle;
pub use provider::Provider;
pub use provider::RootProvider;
pub use provider::Transport;
pub use signer::LocalSigner;
pub use signer::Signer;
pub use tx::TxBuilder;
pub use types::AccessEntry;
pub use types::AccessType;
pub use types::AccountInfo;
pub use types::AccountType;
pub use types::Address;
pub use types::AuthKeys;
pub use types::CallOverrides;
pub use types::CallPayload;
pub use types::CallRequest;
pub use types::CommitPayload;
pub use types::Event;
pub use types::EventFilter;
pub use types::FalconPubkey;
pub use types::FalconSignature;
pub use types::FeeData;
pub use types::FeePayer;
pub use types::Log;
pub use types::LogCursor;
pub use types::LogFilter;
pub use types::LogPage;
pub use types::NodeInfo;
pub use types::Receipt;
pub use types::ReceiptStatus;
pub use types::RecentWaveSummary;
pub use types::RevealPayload;
pub use types::RevertCategory;
pub use types::RevertReason;
pub use types::SimulationResult;
pub use types::Tx;
pub use types::TxHash;
pub use types::TxType;
pub use wallet::KdfParams;
pub use wallet::Keystore;
pub use wallet::KeystoreEntry;
pub use wallet::Wallet;
pub use ws::Subscription;
pub use ws::WsProvider;
pub use ws::WsTransport;

Modules§

abi
ABI parsing — extract the pyde.abi custom section from a WASM binary and Borsh-decode it into a typed ContractAbi.
constants
Conventional gas + timing constants for the v1 SDK surface.
contract
Typed contract interaction — Contract runtime + calldata codec + the pyde_abi! proc-macro re-export.
error
SDK error taxonomy.
factory
Factory-pattern off-chain surface.
multisig
Treasury-multisig signature primitive + envelope construction.
provider
JSON-RPC client surface — Provider trait, RootProvider, HTTP transport, and the PendingTx handle.
signer
Signer trait — anything that can sign a tx hash on behalf of an address. Built-in impl: LocalSigner (in-memory FALCON keypair).
tx
Transaction construction, canonical encoding, and tx_hash.
types
Public types — addresses, hashes, FALCON keys, transactions, accounts, RPC responses.
util
Hex and unit-formatting helpers — the small utilities every dapp / wallet needs.
wallet
Wallet + the canonical Pyde account Keystore.
ws
WebSocket transport + typed event subscriptions.

Macros§

pyde_abi
Re-export of the pyde_abi! proc-macro (defined in the sibling pyde-sdk-macros crate). pyde_abi!(StructName, "path/to/abi.json").