TX3 Rust SDK
Ergonomic Rust SDK for interacting with UTxO-based blockchains using the Tx3 toolkit.
What is TX3?
TX3 is a domain-specific language (DSL) and protocol suite for defining and executing UTxO-based blockchain transactions in a declarative, type-safe manner. It abstracts the complexity of UTXO management and transaction construction while maintaining flexibility for complex DeFi and smart contract interactions.
Quick start
Add the SDK to your project:
[]
= "0.9"
= "1"
Full lifecycle (recommended facade)
use json;
use ;
use ;
let signer = from_mnemonic?;
let protocol = from_file?;
let trp = new;
let tx3 = new
.with_profile
.with_party
.with_party;
// this will call the TRP to compile the intent into
// a fully-defined transaction.
let invocation = tx3
.tx
.arg
.resolve
.await?;
// this will use the configured parties (those which are `signers`) to
// sign the transaction.
let signed = invocation.sign?;
// this will submit the signed payload to the chain using the TRP server.
let submitted = signed.submit.await?;
// this will poll the submitted tx waiting for confirmation that is has
// reached the chain.
let status = submitted
.wait_for_confirmed
.await?;
println!;
Concepts
Protocols
Protocols are defined in TII files and loaded via tii::Protocol.
let protocol = from_file?;
Parties
Parties are declared in the protocol and attached to the client:
Party::address(...)for read-only parties (address only)Party::signer(...)for signing parties (address comes from signer)
Parties are injected into invocation args by name. You can still override any param
explicitly with .arg(...) if needed.
Signers
Signers produce TRP witnesses from a tx hash.
CardanoSigneris Cardano-specific and derives keys using the Cardano pathm/1852'/1815'/0'/0/0.Ed25519Signeris a generic raw-key signer (address required at setup).
use CardanoSigner;
let signer = from_mnemonic?;
Profiles
Profiles are set at the client level and applied to all invocations:
let tx3 = new.with_profile;
Waiting for status
There are two wait modes:
wait_for_confirmed(default for most apps)wait_for_finalized(stronger finality)
let confirmed = submitted.wait_for_confirmed.await?;
let finalized = submitted.wait_for_finalized.await?;
Advanced: low-level TRP client
If you need full control, use the low-level TRP client directly:
use ;
let client = new;
// ... build ResolveParams and call client.resolve(...)
Testing
- Unit tests are co-located with modules via
#[cfg(test)]. - End-to-end (e2e) tests are under
sdk/tests/and run as Cargo test targets.
# from rust-sdk/sdk
License
Apache-2.0