tx3_sdk/lib.rs
1//! # TX3 Rust SDK
2//!
3//! Ergonomic Rust SDK for interacting with TX3 protocols, TII files, and TRP servers.
4//!
5//! TX3 is a DSL and protocol suite for defining and executing UTxO-based transactions in a
6//! declarative, type-safe way.
7//!
8//! ## Quick start
9//!
10//! ```ignore
11//! use serde_json::json;
12//! use tx3_sdk::trp::{Client, ClientOptions};
13//! use tx3_sdk::{CardanoSigner, Party, PollConfig, Tx3Client};
14//!
15//! let signer = CardanoSigner::from_mnemonic(
16//! "addr_test1...",
17//! "word1 word2 ... word24",
18//! )?;
19//!
20//! let protocol = tx3_sdk::tii::Protocol::from_file("./examples/transfer.tii")?;
21//! let trp = Client::new(ClientOptions {
22//! endpoint: "https://trp.example.com".to_string(),
23//! headers: None,
24//! });
25//!
26//! let tx3 = Tx3Client::new(protocol, trp)
27//! .with_profile("preprod")
28//! .with_party("sender", Party::signer(signer))
29//! .with_party("receiver", Party::address("addr_test1..."))
30//! .with_party("middleman", Party::address("addr_test1..."));
31//!
32//! let status = tx3
33//! .tx("transfer")
34//! .arg("quantity", json!(10_000_000))
35//! .resolve()
36//! .await?
37//! .sign()?
38//! .submit()
39//! .await?
40//! .wait_for_confirmed(PollConfig::default())
41//! .await?;
42//!
43//! println!("Confirmed at stage: {:?}", status.stage);
44//! ```
45//!
46//! ## Links
47//!
48//! - [TX3 Documentation](https://docs.txpipe.io/tx3)
49
50pub mod core;
51pub mod facade;
52pub mod tii;
53pub mod trp;
54
55pub use facade::signer::{CardanoSigner, Ed25519Signer};
56pub use facade::{
57 Error, Party, PollConfig, ResolvedTx, SignRequest, SignedTx, Signer, SubmittedTx, Tx3Client,
58 TxBuilder, WitnessInfo,
59};