Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mueller committed Dec 17, 2024
1 parent 82069a9 commit 79efc9d
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ A collection of libraries that are helpful for building Cardano apps with Haskel
* `convex-coin-selection`: Coin selection and transaction balancing
* `convex-mockchain`: Minimal mockchain for tests
* `convex-optics`: Some optics for plutus-ledger-api and cardano-api
* `convex-tx-mod`: Command-line tool for working with transactions

The API documentation (Haddocks) is published [here](https://j-mueller.github.io/sc-tools/)

Expand All @@ -22,6 +23,62 @@ The `main` branch uses the following versions of its major dependencies:
|`ghc`|9.6.6|
|`cabal`|3.10.3.0|

## Evaluating Transactions

The command-line tool `convex-tx-mod` can be used to download and analyse fully resolved transactions from blockfrost. Example:

```shell
export BLOCKFROST_TOKEN=<blockfrost_token>
convex-tx-mod download bba17fd7b99fd88e5cfffb3223cf3988367f5fa7371f6549474310b0453e4c0a -o tx.json
convex-tx-mod graph -f tx.json -o graph.dot
```

Note that the `BLOCKFROST_TOKEN` variable must be set to a token for the network that the transaction is from (ie mainnet, preprod).

This downloads the serialised transaction and all its inputs to `tx.json` and then generates a dot graph in `graph.dot`.

```dot
digraph "resolved-transactions" {
graph [rankdir=LR];
node [shape=record
,style=filled
,bgcolor=gray93
,height=0.1];
txin_08705f19ca5f9aa702b13a54ad059c0b97dd39d05d91d10b2f01e24af01e3b0b_1 [label="0870...3b0b#1|script\ ea07...de6b|Ada:\ 939327.723740\nda8c...1d24.4c51:\ 171930652363\nf580...6b4c.4d5350:\ 1\nf580...6b4c.6263e0101384dace4d7a8dadf0e6d45c8d43c8872604118ee82e3f2212934917:\ 9223371653497800693\n"
,style=rounded];
txin_0dc17712e37a4e741767db2f90d4ffbf69faf88b9bed4c47864f7bd912924bea_0 [label="0dc1...4bea#0|script\ f580...6b4c|Ada:\ 1.961050\nf580...6b4c.4d534753:\ 1\n"
,style=rounded];
txin_2536194d2a976370a932174c10975493ab58fd7c16395d50e62b7c0e1949baea_0 [label="2536...baea#0|pubkey\ 0000...0000|Ada:\ 18.114930\n"
,style=rounded];
txin_27901a20af0d603a779df0b805cc75154623c666294f8d6e3c1000253f39d7c8_2 [label="2790...d7c8#2|pubkey\ 5b7e...165b|Ada:\ 322.159130\n"
,style=rounded];
txin_3359ada19f8b0af32d5f4aea95ea9d1b5642ed0b3041b4d5139a44af6d64d361_0 [label="3359...d361#0|script\ c3e2...7c4c|Ada:\ 3.300000\nda8c...1d24.4c51:\ 1513000000\n"
,style=rounded];
txin_bba17fd7b99fd88e5cfffb3223cf3988367f5fa7371f6549474310b0453e4c0a_0 [label="bba1...4c0a#0|pubkey\ 9aeb...ff8f|Ada:\ 8114.192960\n"
,style=rounded];
txin_bba17fd7b99fd88e5cfffb3223cf3988367f5fa7371f6549474310b0453e4c0a_1 [label="bba1...4c0a#1|script\ ea07...de6b|Ada:\ 931214.830780\nda8c...1d24.4c51:\ 173443652363\nf580...6b4c.4d5350:\ 1\nf580...6b4c.6263e0101384dace4d7a8dadf0e6d45c8d43c8872604118ee82e3f2212934917:\ 9223371653497800693\n"
,style=rounded];
txin_bba17fd7b99fd88e5cfffb3223cf3988367f5fa7371f6549474310b0453e4c0a_2 [label="bba1...4c0a#2|pubkey\ 5b7e...165b|Ada:\ 323.493450\n"
,style=rounded];
txin_cf4ecddde0d81f9ce8fcc881a85eb1f8ccdaf6807f03fea4cd02da896a621776_0 [label="cf4e...1776#0|pubkey\ 0000...0000|Ada:\ 12.486070\n"
,style=rounded];
txin_d46bd227bd2cf93dedd22ae9b6d92d30140cf0d68b756f6608e38d680c61ad17_0 [label="d46b...ad17#0|pubkey\ 0000...0000|Ada:\ 68.429870\n"
,style=rounded];
tx_bba17fd7b99fd88e5cfffb3223cf3988367f5fa7371f6549474310b0453e4c0a [label="Transaction|Fee:\ Ada:\ 0.665670|bba17fd7b99fd88e5cfffb3223cf3988367f5fa7371f6549474310b0453e4c0a|Withdrawal:\ stake17y02a946720zw6pw50upt2arvxsvvpvaghjtl054h0f0gjsfyjz59\ (Ada:\ 0.00)"];
txin_08705f19ca5f9aa702b13a54ad059c0b97dd39d05d91d10b2f01e24af01e3b0b_1 -> tx_bba17fd7b99fd88e5cfffb3223cf3988367f5fa7371f6549474310b0453e4c0a [label=spend];
txin_27901a20af0d603a779df0b805cc75154623c666294f8d6e3c1000253f39d7c8_2 -> tx_bba17fd7b99fd88e5cfffb3223cf3988367f5fa7371f6549474310b0453e4c0a [label=spend];
txin_3359ada19f8b0af32d5f4aea95ea9d1b5642ed0b3041b4d5139a44af6d64d361_0 -> tx_bba17fd7b99fd88e5cfffb3223cf3988367f5fa7371f6549474310b0453e4c0a [label=spend];
txin_0dc17712e37a4e741767db2f90d4ffbf69faf88b9bed4c47864f7bd912924bea_0 -> tx_bba17fd7b99fd88e5cfffb3223cf3988367f5fa7371f6549474310b0453e4c0a [label=reference];
txin_2536194d2a976370a932174c10975493ab58fd7c16395d50e62b7c0e1949baea_0 -> tx_bba17fd7b99fd88e5cfffb3223cf3988367f5fa7371f6549474310b0453e4c0a [label=reference];
txin_cf4ecddde0d81f9ce8fcc881a85eb1f8ccdaf6807f03fea4cd02da896a621776_0 -> tx_bba17fd7b99fd88e5cfffb3223cf3988367f5fa7371f6549474310b0453e4c0a [label=reference];
txin_d46bd227bd2cf93dedd22ae9b6d92d30140cf0d68b756f6608e38d680c61ad17_0 -> tx_bba17fd7b99fd88e5cfffb3223cf3988367f5fa7371f6549474310b0453e4c0a [label=reference];
txin_27901a20af0d603a779df0b805cc75154623c666294f8d6e3c1000253f39d7c8_2 -> tx_bba17fd7b99fd88e5cfffb3223cf3988367f5fa7371f6549474310b0453e4c0a [label=collateral];
tx_bba17fd7b99fd88e5cfffb3223cf3988367f5fa7371f6549474310b0453e4c0a -> txin_bba17fd7b99fd88e5cfffb3223cf3988367f5fa7371f6549474310b0453e4c0a_0;
tx_bba17fd7b99fd88e5cfffb3223cf3988367f5fa7371f6549474310b0453e4c0a -> txin_bba17fd7b99fd88e5cfffb3223cf3988367f5fa7371f6549474310b0453e4c0a_1;
tx_bba17fd7b99fd88e5cfffb3223cf3988367f5fa7371f6549474310b0453e4c0a -> txin_bba17fd7b99fd88e5cfffb3223cf3988367f5fa7371f6549474310b0453e4c0a_2;
}
```

## Building transactions

We use the `TxBodyContent BuildTx BabbageEra` type from `cardano-api` as the basic type for building transactions. The `MonadBuildTx` class from `Convex.BuildTx` is essentially a writer for `TxBodyContent` modifications. `Convex.BuildTx` defines a number of helper functions for common tasks such as spending and creating Plutus script outputs, minting native assets, setting collateral, etc.
Expand Down

0 comments on commit 79efc9d

Please sign in to comment.