Module

Contract.Transaction

A module that defines the different transaction data types, balancing functionality, transaction fees, signing and submission.

#balanceTx

balanceTx :: Transaction -> UtxoMap -> BalancerConstraints -> Contract Transaction

Balance a single transaction.

UtxoMap is a collection of UTxOs used as inputs that are coming from outside of the user wallet.

balanceTxE is a non-throwing version of this function.

Use balanceTxs to balance multiple transactions and prevent them from using the same input UTxOs.

#balanceTxE

balanceTxE :: Transaction -> UtxoMap -> BalancerConstraints -> Contract (Either BalanceTxError Transaction)

A variant of balanceTx that returns a balancer error value.

#balanceTxs

balanceTxs :: Array { balancerConstraints :: BalancerConstraints, transaction :: Transaction, usedUtxos :: UtxoMap } -> Contract (Array Transaction)

Balances each transaction using specified balancer constraint sets and locks the used inputs so that they cannot be reused by subsequent transactions.

#createAdditionalUtxos

createAdditionalUtxos :: forall (tx :: Type). Coercible tx Transaction => tx -> Contract UtxoMap

Builds an expected utxo set from transaction outputs. Predicts output references (TransactionInputs) for each output by calculating the transaction hash and indexing the outputs in the order they appear in the transaction. This function should be used for transaction chaining in conjunction with mustUseAdditionalUtxos balancer constraint.

#getTxAuxiliaryData

getTxAuxiliaryData :: TransactionHash -> Contract (Either GetTxMetadataError AuxiliaryData)

Fetch transaction auxiliary data. Returns Right when the transaction exists and auxiliary data is not empty

#submit

submit :: Transaction -> Contract TransactionHash

Submits a Transaction, which is the output of signTransaction.

#submitE

submitE :: Transaction -> Contract (Either ClientError TransactionHash)

Submits a Transaction that normally should be retreived from signTransaction. Preserves the errors returned by the backend in the case they need to be inspected.

#withBalancedTx

withBalancedTx :: forall (a :: Type). Transaction -> UtxoMap -> BalancerConstraints -> (Transaction -> Contract a) -> Contract a

Execute an action on a balanced transaction (balanceTx will be called). Within this function, all transaction inputs used by this transaction will be locked, so that they are not used in any other context. After the function completes, the locks will be removed. Errors will be thrown.

#withBalancedTxs

withBalancedTxs :: forall (a :: Type). Array { balancerConstraints :: BalancerConstraints, transaction :: Transaction, usedUtxos :: UtxoMap } -> (Array Transaction -> Contract a) -> Contract a

Execute an action on an array of balanced transactions (balanceTxs will be called). Within this function, all transaction inputs used by these transactions will be locked, so that they are not used in any other context. After the function completes, the locks will be removed. Errors will be thrown.

#hashTransaction

hashTransaction :: Warn (Text "Deprecated: hashTransaction. Use Cardano.Types.Transaction.hash") => Transaction -> TransactionHash

Re-exports from Cardano.Types

Re-exports from Cardano.Types.OutputDatum

Re-exports from Cardano.Types.PoolPubKeyHash

Re-exports from Cardano.Types.ScriptRef

Re-exports from Cardano.Types.Transaction

Re-exports from Ctl.Internal.BalanceTx.Error

#Expected

#Actual

newtype Actual

Constructors

Instances

#explainBalanceTxError

Re-exports from Ctl.Internal.Contract.AwaitTxConfirmed

#isTxConfirmed

isTxConfirmed :: TransactionHash -> Contract Boolean

Check if a transaction is confirmed at the moment, i.e. if its UTxOs are available to spend. If you want to delay until a transaction is confirmed, use awaitTxConfirmed or its variants.

#awaitTxConfirmedWithTimeoutSlots

awaitTxConfirmedWithTimeoutSlots :: Int -> TransactionHash -> Contract Unit

Same as awaitTxConfirmed, but allows to specify a timeout in slots for waiting. Throws an exception on timeout. Will fail to confirm if the transaction includes no outputs. https://github.com/Plutonomicon/cardano-transaction-lib/issues/1293

#awaitTxConfirmedWithTimeout

awaitTxConfirmedWithTimeout :: Seconds -> TransactionHash -> Contract Unit

Same as awaitTxConfirmed, but allows to specify a timeout in seconds for waiting. Throws an exception on timeout. Will fail to confirm if the transaction includes no outputs. https://github.com/Plutonomicon/cardano-transaction-lib/issues/1293

#awaitTxConfirmed

awaitTxConfirmed :: TransactionHash -> Contract Unit

Wait until a transaction with given hash is confirmed. Use awaitTxConfirmedWithTimeout if you want to limit the time of waiting. Will fail to confirm if the transaction includes no outputs. https://github.com/Plutonomicon/cardano-transaction-lib/issues/1293

Re-exports from Ctl.Internal.Contract.MinFee

#calculateMinFee

calculateMinFee :: Transaction -> UtxoMap -> UInt -> Contract Coin

Calculate the minimum transaction fee.

Re-exports from Ctl.Internal.Contract.QueryHandle.Error

Re-exports from Ctl.Internal.Contract.Sign

#signTransaction

signTransaction :: Transaction -> Contract Transaction

Signs a transaction with potential failure.

Modules