Skip to content

Commit

Permalink
Clarify what qualifies as valid transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed Jan 7, 2025
1 parent 799c86e commit 26198a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
14 changes: 9 additions & 5 deletions cardano-api/internal/Cardano/Api/Experimental/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ module Cardano.Api.Experimental.Tx
-- ** Balancing a transaction

-- |
-- If we have a UTxO with exactly 12 ADA, and 2 ADA is enough for the fees, we could just construct
-- the transaction like in the previous section directly, and it could be a valid transaction. But still,
-- even if we have exactly 12 ADA, it is unlikely the fees required are exactly 2 ADA, so either we made
-- an invalid transaction, or we are wasting ADA on fees. Also, we may not always want to send all the ADA
-- in the UTxO. So that is were transaction balancing comes in.
-- If we have a UTxO with exactly 12 ADA, we could just construct the transaction like in the
-- previous section directly, and it would be a valid transaction.
--
-- That is because the requirement is that the sum of inputs of the transactions is equal to
-- the sum of the outputs, and that the fees specified are enough, and 2 ADA is more than enough
-- for fees of such a simple transaction on mainnet at the time of writing. But still, even if we
-- have exactly 12 ADA, it is unlikely that the fees required are exactly 2 ADA, so we are likely
-- wasting ADA on fees. Also, we may not always want to send all the ADA in the UTxO. So that is
-- were transaction balancing comes in.
--
-- You can see how to balance a transaction in the documentation of the "Cardano.Api.Fees" module.

Expand Down
9 changes: 6 additions & 3 deletions cardano-api/internal/Cardano/Api/Fees.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ module Cardano.Api.Fees
-- |
-- The documentation of the "Cardano.Api.Tx.Body" module shows how to create a 'TxBodyContent' for a
-- transaction that takes 12 ADA and sends 10 ADA to an address, and spends 2 ADA on fees. If we have a
-- UTxO with exactly 12 ADA, and 2 ADA is enough for the fees, this could be a valid transaction. But still,
-- even if we have exactly 12 ADA, it is unlikely that the fees required are exactly 2 ADA, so either we
-- made an invalid transaction, or we are wasting ADA on fees.
-- UTxO with exactly 12 ADA, this would be a valid transaction.
--
-- The requirement is that the sum of inputs of the transactions is equal to the sum of the outputs,
-- and that the fees specified are enough, and 2 ADA is more than enough for fees of such a simple
-- transaction on mainnet at the time of writing. But still, even if we have exactly 12 ADA, it is
-- unlikely that the fees required are exactly 2 ADA, so we are likely wasting ADA on fees.
--
-- On the other hand, we don't always want to spend all the ADA from a UTxO. Balancing a transaction allows
-- us to send the amount we want to send, pay only the necessary fees (or little more), and it
Expand Down

0 comments on commit 26198a5

Please sign in to comment.