Ergonomic Cardano transaction builder built on top of cardano-serialization-lib (CSL). Focused on dApp / Plutus script interactions and full Conway-era governance.
- Build only. You bring your own selected UTxOs and an external signer.
build()returns an unsignedcsl::Transactionwith the witness set already populated for scripts / datums / redeemers — just attachVkeywitnessentries on the signing side. - No coin selection, no provider integration, no signing. Those concerns live elsewhere by design — keeping this layer thin makes it composable.
| Area | API |
|---|---|
| Inputs | SpendingInput::Pubkey / Plutus / NativeScript |
| Reference inputs | add_reference_input (or implicit via ScriptSource::Reference) |
| Outputs | Output::new(addr).lovelace(..).assets(..).inline_datum(..).script_ref(..) |
| Collateral | add_collateral, collateral_return, total_collateral |
| Mint / burn | MintAction::plutus(..) / MintAction::native(..) with signed quantities |
| Certificates | Cert::* for staking and all Conway-era flavors |
| Withdrawals | add_withdrawal, add_plutus_withdrawal |
| Governance — voting | add_vote(Vote { voter, action, choice, anchor }) |
| Governance — proposals | add_proposal(ProposalSpec { .. }) |
| Validity | validity_start, ttl |
| Metadata | metadata(label, datum), auxiliary_script |
See examples/plutus_spend.rs for a Plutus spend + mint with a reference script and collateral.
Minimal pubkey-only transfer:
use tx_builder::prelude::*;
let tx = {
let mut b = TxBuilder::new(¶ms);
b.change_address(&wallet)
.add_pubkey_input(&utxo)
.add_output(Output::new(&dest).lovelace(2_000_000))
.ttl(100_000_000);
b.build()?
};
let cbor = hex::encode(tx.to_bytes());TxBuilder::build() walks this fixed order, mirroring what CSL needs:
- Inputs (regular + Plutus + native-script).
- Reference inputs (explicit + implicit from
ScriptSource::Reference). - Outputs.
- Collateral inputs / return / total.
- Required signers.
- Mint.
- Certificates.
- Withdrawals.
- Voting & proposals.
- Validity range.
- Metadata + auxiliary scripts.
- Script-data hash (only if Plutus witnesses present).
add_change_if_needed(change).build_tx().
- Ex-units are placeholders. Pass the
csl::ExUnitsyou get from an evaluator (OgmiosevaluateTransaction, Blockfrosttx/evaluate, your ownaiken simulate, etc.). The values you give toSpendingInput::plutus/MintAction::plutusare used verbatim — there's no on-the-fly evaluation in this crate. - Redeemer indices. CSL fixes the index after sorting inputs / mints — the
0placeholders inside the builder are intentional. - CSL method-name drift. CSL is in active development; if a method like
set_collateral_return_and_totaloradd_with_plutus_witnesshas been renamed between minor versions, you'll get a clear compile error and a one-line fix. - Cost models. Pass all cost models you might need (PlutusV1/V2/V3) in
ProtocolParameters::cost_models. CSL hashes only the ones referenced, so over-supplying is safe.
cardano-multiplatform-lib— dcSpark's fork of CSL with a different design.pallas-txbuilder— Rust-native (no WASM lineage), part of the broader Pallas stack.
For pure-Rust environments (no JS interop) pallas-txbuilder is often cleaner; this crate is the right pick when you're already locked to CSL.