Module

Contract.Transaction

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

#TxBlueprint

type TxBlueprint (ctx :: Type) = { balancer :: TxBalancer Contract Error ctx, balancerCtx :: ctx, buildSteps :: Array TransactionBuilderStep }

Blueprint containing the steps and context required to construct and balance a transaction.

#TxReceipt

type TxReceipt = { submittedTx :: Transaction, txHash :: TransactionHash }

Represents the result of submitting a transaction via submitTxFromBlueprint, which includes the balanced signed transaction along with its hash.

#balanceMultipleTxs

balanceMultipleTxs :: forall (ctx :: Type). TxBalancer Contract Error ctx -> Array { balancerCtx :: ctx, transaction :: Transaction } -> Contract (Array Transaction)

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

#balanceTx

balanceTx :: Warn (Text "Deprecated, use a standalone transaction balancer instead") => 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 :: Warn (Text "Deprecated, use a standalone transaction balancer instead (see `defaultBalancerWithErr`)") => Transaction -> UtxoMap -> BalancerConstraints -> Contract (Either BalanceTxError Transaction)

A variant of balanceTx that returns a balancer error value.

#balanceTxs

balanceTxs :: Warn (Text "Deprecated, use `balanceMultipleTxs` instead") => 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

#hashTransaction

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

#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.

#submitTxFromBlueprint

submitTxFromBlueprint :: forall (ctx :: Type). TxBlueprint ctx -> Contract TxReceipt

Builds, balances, signs, and submits a transaction defined by the given TxBlueprint. Returns a TxReceipt containing the submitted transaction and its hash.

#submitTxFromBuildPlan

submitTxFromBuildPlan :: Warn (Text "Deprecated, use `submitTxFromBlueprint` instead") => UtxoMap -> BalancerConstraints -> Array TransactionBuilderStep -> Contract Transaction

#submitTxFromConstraints

submitTxFromConstraints :: Warn (Text "Contract.TxConstraints is deprecated. Use `submitTxFromBlueprint` instead") => ScriptLookups -> TxConstraints -> Contract TransactionHash

#withBalancedTx

withBalancedTx :: forall (ctx :: Type) (a :: Type). TxBalancer Contract Error ctx -> Transaction -> ctx -> (Transaction -> Contract a) -> Contract a

Execute an action on a balanced transaction (the provided balancer 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 (ctx :: Type) (a :: Type). TxBalancer Contract Error ctx -> Array { balancerCtx :: ctx, transaction :: Transaction } -> (Array Transaction -> Contract a) -> Contract a

Execute an action on an array of balanced transactions (balanceMultipleTxs 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.

Re-exports from Cardano.Provider.Error

Re-exports from Cardano.Transaction.Balancer.Error

#Expected

#Actual

newtype Actual

Constructors

Instances

#explainBalanceTxError

Re-exports from Cardano.Transaction.Balancer.MinFee

#calculateMinFee

calculateMinFee :: forall (r :: Row Type). CalculateMinFeeData r -> Transaction -> UtxoMap -> UInt -> Aff Coin

Calculate the minimum transaction fee.

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

#CtlBalancerContext

type CtlBalancerContext = { balancerConstraints :: BalancerConstraints, extraUtxos :: UtxoMap }

Additional context required by the default CTL balancer.

balancerConstraints: A set of rules that guide or modify the behavior of the balancer.

extraUtxos: Extra (non-wallet) utxos to be considered during balancing, typically used to resolve pre-specified inputs of the unbalanced transaction. See getInputVal in Cardano.Transaction.Balancer for further details.

#CtlBalancer

#defaultBalancerWithErr

defaultBalancerWithErr :: CtlBalancer BalanceTxError

Balances an unbalanced transaction using the specified balancer constraints.

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.Sign

#signTransaction

signTransaction :: Transaction -> Contract Transaction

Signs a transaction with potential failure.

Re-exports from Ctl.Internal.Types.TxBalancer

#TxBalancer

type TxBalancer :: (Type -> Type) -> Type -> Type -> Typetype TxBalancer (m :: Type -> Type) (err :: Type) (ctx :: Type) = Transaction -> ctx -> m (Either err Transaction)

Modules