Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Utilities to building transactions on top of the cardano-api.
Synopsis
- unsafeBuildTransaction :: HasCallStack => TxBodyContent BuildTx -> Tx
- data InvalidTransactionException = InvalidTransactionException {
- txBodyError :: TxBodyError
- builder :: TxBodyContent BuildTx
- emptyTxBody :: TxBodyContent BuildTx
- addInputs :: TxIns BuildTx -> TxBodyContent BuildTx -> TxBodyContent BuildTx
- addReferenceInputs :: [TxIn] -> TxBodyContent BuildTx -> TxBodyContent BuildTx
- addVkInputs :: [TxIn] -> TxBodyContent BuildTx -> TxBodyContent BuildTx
- addOutputs :: [TxOut CtxTx] -> TxBodyContent BuildTx -> TxBodyContent BuildTx
- addExtraRequiredSigners :: [Hash PaymentKey] -> TxBodyContent BuildTx -> TxBodyContent BuildTx
- mintTokens :: ToScriptData redeemer => PlutusScript -> redeemer -> [(AssetName, Quantity)] -> TxBodyContent BuildTx -> TxBodyContent BuildTx
- burnTokens :: ToScriptData redeemer => PlutusScript -> redeemer -> [(AssetName, Quantity)] -> TxBodyContent BuildTx -> TxBodyContent BuildTx
- setValidityUpperBound :: SlotNo -> TxBodyContent BuildTx -> TxBodyContent BuildTx
- setValidityLowerBound :: SlotNo -> TxBodyContent BuildTx -> TxBodyContent BuildTx
Executing
unsafeBuildTransaction :: HasCallStack => TxBodyContent BuildTx -> Tx Source #
Construct a transction from a builder. It is said unsafe
because the
underlying implementation will perform some sanity check on a transaction;
for example, check that it has at least one input, that no outputs are
negatives and whatnot.
We use the builder only internally for on-chain transaction crafted in the context of Hydra.
data InvalidTransactionException Source #
A runtime exception to capture (programmer) failures when building transactions. This should never happened in practice (famous last words...)!
InvalidTransactionException | |
|
Instances
Constructing
emptyTxBody :: TxBodyContent BuildTx Source #
An empty TxBodyContent
with all empty/zero values to be extended using
record updates.
NOTE: makeTransactionBody
throws when one tries to build a transaction
with scripts but no collaterals. This is unfortunate because collaterals are
currently added after by our integrated wallet.
Similarly, makeTransactionBody
throws when building a transaction with
scripts and no protocol parameters (needed to compute the script integrity
hash). This is also added by our wallet at the moment and this ugly
work-around will be removed eventually (related item
215.
So we currently bypass this by having default but seemingly innofensive
values for collaterals and protocol params in the empty
value
addInputs :: TxIns BuildTx -> TxBodyContent BuildTx -> TxBodyContent BuildTx Source #
Add new inputs to an ongoing builder.
addReferenceInputs :: [TxIn] -> TxBodyContent BuildTx -> TxBodyContent BuildTx Source #
addVkInputs :: [TxIn] -> TxBodyContent BuildTx -> TxBodyContent BuildTx Source #
Like addInputs
but only for vk inputs which requires no additional data.
addOutputs :: [TxOut CtxTx] -> TxBodyContent BuildTx -> TxBodyContent BuildTx Source #
Append new outputs to an ongoing builder.
addExtraRequiredSigners :: [Hash PaymentKey] -> TxBodyContent BuildTx -> TxBodyContent BuildTx Source #
Add extra required key witnesses to a transaction.
mintTokens :: ToScriptData redeemer => PlutusScript -> redeemer -> [(AssetName, Quantity)] -> TxBodyContent BuildTx -> TxBodyContent BuildTx Source #
Mint tokens with given plutus minting script and redeemer.
burnTokens :: ToScriptData redeemer => PlutusScript -> redeemer -> [(AssetName, Quantity)] -> TxBodyContent BuildTx -> TxBodyContent BuildTx Source #
Burn tokens with given plutus minting script and redeemer.
This is really just mintTokens
with negated Quantity
.
setValidityUpperBound :: SlotNo -> TxBodyContent BuildTx -> TxBodyContent BuildTx Source #
Set the upper validity bound for this transaction to some SlotNo
.
setValidityLowerBound :: SlotNo -> TxBodyContent BuildTx -> TxBodyContent BuildTx Source #
Set the lower validity bound for this transaction to some SlotNo
.