Architecture
cardano-tx-tools is one Haskell package that exposes a layered set of
libraries and eight thin command-line wrappers over them. This page describes
how the components depend on each other and how a Conway transaction flows
through them.
Components and dependencies
flowchart TD
subgraph clis["Command-line tools"]
diff["tx-diff"]
inspect["tx-inspect"]
graph["tx-graph"]
view["tx-view"]
fetch["tx-fetch"]
validate["tx-validate"]
sign["tx-sign"]
gen["cardano-tx-generator"]
end
subgraph libs["Haskell libraries (Cardano.Tx.*)"]
core["cardano-tx-tools (main lib)<br/>Diff · Blueprint · Rewrite<br/>Graph.Emit · Graph.Rules · View<br/>Sign · Validate · Web2 resolver"]
txbuild["tx-build<br/>Build · Balance · Evaluate"]
n2c["n2c-resolver<br/>opt-in N2C resolver"]
genlib["tx-generator-lib<br/>Generator.*"]
end
subgraph ext["External systems"]
node["local cardano-node<br/>(Node-to-Client)"]
bf["Blockfrost HTTP"]
ccli["cardano-cli<br/>(assemble / submit)"]
end
diff --> core
inspect --> core
graph --> core
view --> core
fetch --> core
validate --> core
sign --> core
gen --> genlib
core --> txbuild
genlib --> core
diff --> n2c
inspect --> n2c
validate --> n2c
n2c --> node
genlib --> node
fetch --> bf
core --> bf
sign -.witness.-> ccli
diff -.unsigned tx.-> ccli
Dependency facts, verified against cardano-tx-tools.cabal:
- The main library (
cardano-tx-tools) depends only on thetx-buildsub-library and re-exports itsBuild/Balance/Ledgermodules. It has nocardano-node-clientsdependency. n2c-resolveris the only library that linkscardano-node-clientsfor read access; it is an opt-in sub-library depended on bytx-diff,tx-inspect, andtx-validate.tx-generator-libis the daemon engine behindcardano-tx-generator; it depends on the main library and oncardano-node-clientsfor submission and chain-follower queries.- The Blockfrost (
Web2) resolver lives inside the main library (Cardano.Tx.Diff.Resolver.Web2) — it is plain HTTP, not a node client — and backs bothtx-fetchand the optional--web2-urlresolver ontx-diff/tx-inspect.
Transaction data flow
All reading tools decode the Conway transaction body (CBOR hex, raw CBOR, or a
cardano-cli JSON text envelope) into the same structural projection,
Cardano.Tx.Diff.conwayDiffProjection. The diff renderer, the inspect
renderer, and the RDF emitter all walk that one projection.
flowchart LR
cbor["Conway tx CBOR<br/>(hex / raw / envelope)"]
proj["conwayDiffProjection<br/>(Cardano.Tx.Diff)"]
bp["Blueprint decode<br/>(CIP-57)"]
rules["Rewrite rules<br/>(collapse + rename)"]
cbor --> proj
proj --> difftool["tx-diff render"]
proj --> inspecttool["tx-inspect render"]
proj --> emit["tx-graph emit<br/>Turtle / JSON-LD"]
bp --> difftool
bp --> emit
rules --> difftool
rules --> inspecttool
rules --> emit
emit --> ttl["graph.ttl"]
ttl --> viewtool["tx-view<br/>cli-tree / asset-flow /<br/>entity-occurrences / json-ld"]
- Blueprint decoding (CIP-57) is shared by
tx-diffandtx-graph: a registered blueprint turns Plutus datum and redeemer fields into typed values. Intx-graphoutput, decode failures stay non-fatal and surface ascardano:decodeErrortriples. - Rewriting rules (the rewriting-rules grammar) are
shared by
tx-inspect --rulesandtx-diff --collapse-rulesthrough one loader, and the same file format drivestx-graph --rulesfor its operator-entity overlay. The engine always appliescollapsefirst, thenrename, regardless of key order in the file. tx-fetchsits upstream oftx-graph: it walks a transaction closure over Blockfrost and writes one<txid>.cborper transaction into<out-dir>/cbor/, whichtx-graph --in-dirthen resolves in-memory into a Turtle lattice.tx-viewsits downstream oftx-graph: it projects an emitted canonical graph through one of four packaged views, each shipped as both a vendor-neutral SPARQL.rqcontract (underviews/) and an in-process Haskell projection that produces the same byte stream without a SPARQL engine.
Signing and validation boundaries
tx-sign and tx-validate sit at the edges of the pipeline:
tx-validateopens a Node-to-Client session against a localcardano-node, resolves the transaction's UTxO, queries protocol parameters and the tip slot, and runs the ledger'sMempool.applyTxrule. Its exit code is the contract pipelines act on (0clean,1structural failure,≥2configuration / resolver error).tx-signunlocks an age-encrypted vault in memory and emits one detached vkey witness; the cleartext key never touches disk and the passphrase is never read fromargv. The witness is then attached withcardano-cli(out of scope for this suite).