<p>Cardano faucet uses API directly to build it's transactions:</p>
<p><a href="https://github.com/input-output-hk/cardano-faucet/blob/f1b83b4fe649c6dabffa483820f0d5ec47fb2633/cardano-faucet/src/Cardano/Faucet/TxUtils.hs#L25" rel="nofollow noreferrer">https://github.com/input-output-hk/cardano-faucet/blob/f1b83b4fe649c6dabffa483820f0d5ec47fb2633/cardano-faucet/src/Cardano/Faucet/TxUtils.hs#L25</a></p>

CC BY-SA 4.0
2024-08-28T03:52:35.860Z
Great example, thanks!
a_juggler
CC BY-SA 4.0
2024-08-27T19:42:45.900Z
2024-08-27T19:42:45.900Z
Samuel Leathers
<p>Sam's example is perfectly fine however we have another way to construct txs that may be more convenient via various lenses:</p>
<p><a href="https://github.com/IntersectMBO/cardano-cli/blob/25a9cfd09052ce838dd08f6da3a22c24bc474a9d/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs#L871" rel="nofollow noreferrer">https://github.com/IntersectMBO/cardano-cli/blob/25a9cfd09052ce838dd08f6da3a22c24bc474a9d/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs#L871</a></p>
<p>Then you can call <a href="https://github.com/IntersectMBO/cardano-api/blob/966462bdadcf332704dd32232eb4fb405b3c83ca/cardano-api/internal/Cardano/Api/Fees.hs#L1018" rel="nofollow noreferrer">makeTransactionBodyAutoBalance</a> to create a balanced tx.</p>

CC BY-SA 4.0
2024-08-29T15:33:13.590Z
Great!  Thanks for the reference.
a_juggler
CC BY-SA 4.0
2024-08-28T17:02:23.010Z
2024-08-28T17:02:23.010Z
Jimbo
<p>Can anybody provide an example of building a simple Tx using just Haskell and Cardano-Api?</p>
<p>(I know that there are other great tools for building Tx's, but I'm curious about using Cardano-Api.)</p>

<cardano-api>
Building Tx with cardano-api
# Building Tx with cardano-api

(Asked by: username_0 on 2024-08-27)

Can anybody provide an example of building a simple Tx using just Haskell and Cardano-Api?

(I know that there are other great tools for building Tx's, but I'm curious about using Cardano-Api.)

**Tags:** cardano-api

---

## 2 answers

### Answer by username_1 on 2024-08-27. Score: 2 | Accepted answer

Cardano faucet uses API directly to build it's transactions:

<https://github.com/input-output-hk/cardano-faucet/blob/f1b83b4fe649c6dabffa483820f0d5ec47fb2633/cardano-faucet/src/Cardano/Faucet/TxUtils.hs#L25>

> **Comments:**
> **username_0**: Great example, thanks!  

---

### Answer by username_2 on 2024-08-28. Score: 1

Sam's example is perfectly fine however we have another way to construct txs that may be more convenient via various lenses:

<https://github.com/IntersectMBO/cardano-cli/blob/25a9cfd09052ce838dd08f6da3a22c24bc474a9d/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs#L871>

Then you can call [makeTransactionBodyAutoBalance](https://github.com/IntersectMBO/cardano-api/blob/966462bdadcf332704dd32232eb4fb405b3c83ca/cardano-api/internal/Cardano/Api/Fees.hs#L1018) to create a balanced tx.

> **Comments:**
> **username_0**: Great!  Thanks for the reference.  

---

