Skip to main content

Crate tx3_sdk

Crate tx3_sdk 

Source
Expand description

§TX3 Rust SDK

Ergonomic Rust SDK for interacting with TX3 protocols, TII files, and TRP servers.

TX3 is a DSL and protocol suite for defining and executing UTxO-based transactions in a declarative, type-safe way.

§Quick start

use serde_json::json;
use tx3_sdk::trp::{Client, ClientOptions};
use tx3_sdk::{CardanoSigner, Party, PollConfig, Tx3Client};

let signer = CardanoSigner::from_mnemonic(
    "addr_test1...",
    "word1 word2 ... word24",
)?;

let protocol = tx3_sdk::tii::Protocol::from_file("./examples/transfer.tii")?;
let trp = Client::new(ClientOptions {
    endpoint: "https://trp.example.com".to_string(),
    headers: None,
});

let tx3 = Tx3Client::new(protocol, trp)
    .with_profile("preprod")
    .with_party("sender", Party::signer(signer))
    .with_party("receiver", Party::address("addr_test1..."))
    .with_party("middleman", Party::address("addr_test1..."));

let status = tx3
    .tx("transfer")
    .arg("quantity", json!(10_000_000))
    .resolve()
    .await?
    .sign()?
    .submit()
    .await?
    .wait_for_confirmed(PollConfig::default())
    .await?;

println!("Confirmed at stage: {:?}", status.stage);

Re-exports§

pub use facade::signer::CardanoSigner;
pub use facade::signer::Ed25519Signer;
pub use facade::Error;
pub use facade::Party;
pub use facade::PollConfig;
pub use facade::ResolvedTx;
pub use facade::SignRequest;
pub use facade::SignedTx;
pub use facade::Signer;
pub use facade::SubmittedTx;
pub use facade::Tx3Client;
pub use facade::TxBuilder;
pub use facade::WitnessInfo;

Modules§

core
Core types and data structures for the Tx3 SDK.
facade
Ergonomic facade for the full TX3 lifecycle.
tii
Transaction Invocation Interface (TII) for loading and interacting with TX3 protocols.
trp
Transaction Resolve Protocol (TRP) Client