plutus-ledger-constraints-0.1.0.0: Ledger Constraints
Safe HaskellNone
LanguageHaskell2010

Ledger.Constraints

Description

Constraints for transactions

Synopsis

Documentation

This module defines TxConstraints, a list of constraints on transactions. To construct a value of TxConstraints use the mustPayToTheScript, mustSpendAtLeast, etc functions. Once we have a TxConstraints value it can be used both to generate a transaction that satisfies the constraints (off-chain, using mkTx) and to check whether a given pending transaction meets the constraints (on-chain, using checkScriptContext).

data TxConstraints i o Source #

Restrictions placed on the allocation of funds to outputs of transactions.

Instances

Instances details
Bifunctor TxConstraints Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

Methods

bimap :: (a -> b) -> (c -> d) -> TxConstraints a c -> TxConstraints b d Source #

first :: (a -> b) -> TxConstraints a c -> TxConstraints b c Source #

second :: (b -> c) -> TxConstraints a b -> TxConstraints a c Source #

(Eq i, Eq o) => Eq (TxConstraints i o) Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

(Show i, Show o) => Show (TxConstraints i o) Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

Generic (TxConstraints i o) Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

Associated Types

type Rep (TxConstraints i o) :: Type -> Type Source #

Methods

from :: TxConstraints i o -> Rep (TxConstraints i o) x Source #

to :: Rep (TxConstraints i o) x -> TxConstraints i o Source #

Semigroup (TxConstraints i o) Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

Monoid (TxConstraints i o) Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

(ToJSON i, ToJSON o) => ToJSON (TxConstraints i o) Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

(FromJSON i, FromJSON o) => FromJSON (TxConstraints i o) Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

Monoid (TxConstraints i o) Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

Semigroup (TxConstraints i o) Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

type Rep (TxConstraints i o) Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

type Rep (TxConstraints i o) = D1 ('MetaData "TxConstraints" "Ledger.Constraints.TxConstraints" "plutus-ledger-constraints-0.1.0.0-AdCuTwHqkQFFnwldCwEXkg" 'False) (C1 ('MetaCons "TxConstraints" 'PrefixI 'True) (S1 ('MetaSel ('Just "txConstraints") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [TxConstraint]) :*: (S1 ('MetaSel ('Just "txOwnInputs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [ScriptInputConstraint i]) :*: S1 ('MetaSel ('Just "txOwnOutputs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [ScriptOutputConstraint o]))))

data TxConstraint Source #

Constraints on transactions that want to spend script outputs

Constructors

MustHashDatum DatumHash Datum

The transaction's datum witnesses must contain the given DatumHash and Datum. Useful when you already have a DatumHash and want to make sure that it is the actual hash of the Datum.

MustIncludeDatum Datum

Like MustHashDatum, but the hash of the Datum is computed automatically.

MustValidateIn POSIXTimeRange

The transaction's validity range must be set with the given POSIXTimeRange.

MustBeSignedBy PaymentPubKeyHash

The transaction must add the given PaymentPubKeyHash in its signatories.

MustSpendAtLeast Value

The sum of the transaction's input Values must be at least as much as the given Value.

MustProduceAtLeast Value

The sum of the transaction's output Values must be at least as much as the given Value.

MustSpendPubKeyOutput TxOutRef

The transaction must spend the given unspent transaction public key output.

MustSpendScriptOutput TxOutRef Redeemer

The transaction must spend the given unspent transaction script output.

MustMintValue MintingPolicyHash Redeemer TokenName Integer

The transaction must mint the given token and amount.

MustPayToPubKeyAddress PaymentPubKeyHash (Maybe StakePubKeyHash) (Maybe Datum) Value

The transaction must create a transaction output with a public key address.

MustPayToOtherScript ValidatorHash Datum Value

The transaction must create a transaction output with a script address.

MustSatisfyAnyOf [[TxConstraint]] 

Instances

Instances details
Eq TxConstraint Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

Show TxConstraint Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

Generic TxConstraint Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

Associated Types

type Rep TxConstraint :: Type -> Type Source #

ToJSON TxConstraint Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

FromJSON TxConstraint Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

Pretty TxConstraint Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

type Rep TxConstraint Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

type Rep TxConstraint = D1 ('MetaData "TxConstraint" "Ledger.Constraints.TxConstraints" "plutus-ledger-constraints-0.1.0.0-AdCuTwHqkQFFnwldCwEXkg" 'False) (((C1 ('MetaCons "MustHashDatum" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DatumHash) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Datum)) :+: (C1 ('MetaCons "MustIncludeDatum" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Datum)) :+: C1 ('MetaCons "MustValidateIn" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 POSIXTimeRange)))) :+: (C1 ('MetaCons "MustBeSignedBy" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PaymentPubKeyHash)) :+: (C1 ('MetaCons "MustSpendAtLeast" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value)) :+: C1 ('MetaCons "MustProduceAtLeast" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value))))) :+: ((C1 ('MetaCons "MustSpendPubKeyOutput" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TxOutRef)) :+: (C1 ('MetaCons "MustSpendScriptOutput" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TxOutRef) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Redeemer)) :+: C1 ('MetaCons "MustMintValue" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 MintingPolicyHash) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Redeemer)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TokenName) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Integer))))) :+: (C1 ('MetaCons "MustPayToPubKeyAddress" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PaymentPubKeyHash) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe StakePubKeyHash))) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Datum)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value))) :+: (C1 ('MetaCons "MustPayToOtherScript" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ValidatorHash) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Datum) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value))) :+: C1 ('MetaCons "MustSatisfyAnyOf" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [[TxConstraint]]))))))

data ScriptInputConstraint a Source #

Constructors

ScriptInputConstraint 

Fields

Instances

Instances details
Functor ScriptInputConstraint Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

Eq a => Eq (ScriptInputConstraint a) Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

Show a => Show (ScriptInputConstraint a) Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

Generic (ScriptInputConstraint a) Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

Associated Types

type Rep (ScriptInputConstraint a) :: Type -> Type Source #

ToJSON a => ToJSON (ScriptInputConstraint a) Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

FromJSON a => FromJSON (ScriptInputConstraint a) Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

Pretty a => Pretty (ScriptInputConstraint a) Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

type Rep (ScriptInputConstraint a) Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

type Rep (ScriptInputConstraint a) = D1 ('MetaData "ScriptInputConstraint" "Ledger.Constraints.TxConstraints" "plutus-ledger-constraints-0.1.0.0-AdCuTwHqkQFFnwldCwEXkg" 'False) (C1 ('MetaCons "ScriptInputConstraint" 'PrefixI 'True) (S1 ('MetaSel ('Just "icRedeemer") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Just "icTxOutRef") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TxOutRef)))

data ScriptOutputConstraint a Source #

Constructors

ScriptOutputConstraint 

Fields

Instances

Instances details
Functor ScriptOutputConstraint Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

Eq a => Eq (ScriptOutputConstraint a) Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

Show a => Show (ScriptOutputConstraint a) Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

Generic (ScriptOutputConstraint a) Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

Associated Types

type Rep (ScriptOutputConstraint a) :: Type -> Type Source #

ToJSON a => ToJSON (ScriptOutputConstraint a) Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

FromJSON a => FromJSON (ScriptOutputConstraint a) Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

Pretty a => Pretty (ScriptOutputConstraint a) Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

type Rep (ScriptOutputConstraint a) Source # 
Instance details

Defined in Ledger.Constraints.TxConstraints

type Rep (ScriptOutputConstraint a) = D1 ('MetaData "ScriptOutputConstraint" "Ledger.Constraints.TxConstraints" "plutus-ledger-constraints-0.1.0.0-AdCuTwHqkQFFnwldCwEXkg" 'False) (C1 ('MetaCons "ScriptOutputConstraint" 'PrefixI 'True) (S1 ('MetaSel ('Just "ocDatum") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Just "ocValue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value)))

Defining constraints

mustPayToTheScript :: forall i o. ToData o => o -> Value -> TxConstraints i o Source #

mustPayToTheScript d v locks the value v with a script alongside a datum d.

If used in OffChain, this constraint creates a script output with d and v and adds d in the transaction's datum witness set. The script address is derived from the typed validator that is provided in the ScriptLookups with typedValidatorLookups.

If used in OnChain, this constraint verifies that d is part of the datum witness set and that the new script transaction output with d and v is part of the transaction's outputs.

mustPayToPubKey :: forall i o. PaymentPubKeyHash -> Value -> TxConstraints i o Source #

mustPayToPubKey pkh v is the same as mustPayWithDatumToPubKeyAddress, but without any staking key hash and datum.

mustPayToPubKeyAddress :: forall i o. PaymentPubKeyHash -> StakePubKeyHash -> Value -> TxConstraints i o Source #

mustPayToPubKeyAddress pkh skh v is the same as mustPayWithDatumToPubKeyAddress, but without any datum.

mustPayWithDatumToPubKey :: forall i o. PaymentPubKeyHash -> Datum -> Value -> TxConstraints i o Source #

mustPayWithDatumToPubKey pkh d v is the same as mustPayWithDatumToPubKeyAddress, but without the staking key hash.

mustPayWithDatumToPubKeyAddress :: forall i o. PaymentPubKeyHash -> StakePubKeyHash -> Datum -> Value -> TxConstraints i o Source #

mustPayWithDatumToPubKeyAddress pkh skh d v locks a transaction output with a public key address.

If used in OffChain, this constraint creates a public key output with pkh, skh, d and v and maybe adds d in the transaction's datum witness set.

If used in OnChain, this constraint verifies that d is part of the datum witness set and that the public key transaction output with pkh, skh, d and v is part of the transaction's outputs.

mustMintCurrency :: forall i o. MintingPolicyHash -> TokenName -> Integer -> TxConstraints i o Source #

Same as mustMintCurrentWithRedeemer, but sets the redeemer to the unit redeemer.

mustMintCurrencyWithRedeemer :: forall i o. MintingPolicyHash -> Redeemer -> TokenName -> Integer -> TxConstraints i o Source #

mustMintCurrencyWithRedeemer mph r tn a creates the given amount a of the currency specified with mph, r and tn.

If used in OffChain, this constraint mints a currency using mph, r, tn and a, adds mph in the transaction's minting policy witness set and adds r in the transaction's redeemer witness set. The minting policy must be provided in the ScriptLookups with typedValidatorLookups or mintingPolicy.

If used in OnChain, this constraint verifies that the minted currenty mph, tn and a is part of the transaction's minting information.

mustMintValue :: forall i o. Value -> TxConstraints i o Source #

Same as mustMintValueWithRedeemer, but sets the redeemer to the unit redeemer.

mustMintValueWithRedeemer :: forall i o. Redeemer -> Value -> TxConstraints i o Source #

Same as mustMintCurrentWithRedeemer, but uses the minting policy hash, token name and amount provided by Value.

Note that we can derive the MintingPolicyHash from the Value's currency symbol.

mustSpendAtLeast :: forall i o. Value -> TxConstraints i o Source #

mustSpendAtLeast v requires the sum of the transaction's inputs value to be at least v.

If used in OffChain, this constraint adds the missing input value with an additionnal public key output using the public key hash provided in the ScriptLookups with ownPaymentPubKeyHash and optionnaly ownStakePubKeyHash.

If used in OnChain, this constraint verifies that the sum of the transaction's inputs value to be at least v.

mustSpendPubKeyOutput :: forall i o. TxOutRef -> TxConstraints i o Source #

mustSpendPubKeyOutput utxo must spend the given unspent transaction public key output.

If used in OffChain, this constraint adds utxo as an input to the transaction. Information about this utxo must be provided in the ScriptLookups with unspentOutputs.

If used in OnChain, this constraint verifies that the transaction spends this utxo.

mustSpendScriptOutput :: forall i o. TxOutRef -> Redeemer -> TxConstraints i o Source #

mustSpendScriptOutput utxo red must spend the given unspent transaction script output.

If used in OffChain, this constraint adds utxo and red as an input to the transaction. Information about this utxo must be provided in the ScriptLookups with unspentOutputs. The validator must be either provided by unspentOutputs or through otherScript. The datum must be either provided by unspentOutputs or through otherData.

If used in OnChain, this constraint verifies that the transaction spends this utxo.

mustValidateIn :: forall i o. POSIXTimeRange -> TxConstraints i o Source #

mustValidateIn r requires the transaction's validity time range to be contained in r.

If used in OffChain, this constraint sets the transaction's validity time range to r.

If used in OnChain, this constraint verifies that the time range r is entirely contained in the transaction's validity time range.

mustBeSignedBy :: forall i o. PaymentPubKeyHash -> TxConstraints i o Source #

mustBeSignedBy pk requires the transaction to be signed by the public key pk.

If used in OffChain, this constraint adds pk in the transaction's public key witness set.

If used in OnChain, this constraint verifies that pk is part of the transaction's public key witness set.

mustProduceAtLeast :: forall i o. Value -> TxConstraints i o Source #

mustProduceAtLeast v requires the sum of the transaction's outputs value to be at least v.

If used in OffChain, this constraint adds the missing output value with an additionnal public key output using the public key hash provided in the ScriptLookups with ownPaymentPubKeyHash and optionnaly ownStakePubKeyHash.

If used in OnChain, this constraint verifies that the sum of the transaction's outputs value to be at least v.

mustIncludeDatum :: forall i o. Datum -> TxConstraints i o Source #

mustIncludeDatum d requires the transaction to include the datum d.

If used in OffChain, this constraint adds d in the transaction's datum witness set alongside it's hash (which is computed automatically).

If used in OnChain, this constraint verifies that d is part of the transaction's datum witness set.

mustPayToOtherScript :: forall i o. ValidatorHash -> Datum -> Value -> TxConstraints i o Source #

mustPayToOtherScript vh d v locks the value v with the given script hash vh alonside a datum d.

If used in OffChain, this constraint creates a script output with vh, d and v and adds d in the transaction's datum witness set.

If used in OnChain, this constraint verifies that d is part of the datum witness set and that the script transaction output with vh, d and v is part of the transaction's outputs.

mustHashDatum :: DatumHash -> Datum -> TxConstraints i o Source #

mustHashDatum dh d requires the transaction to include the datum hash dh and actual datum d.

If used in OffChain, this constraint adds dh and d in the transaction's datum witness set.

If used in OnChain, this constraint verifies that dh and d are part of the transaction's datum witness set.

Queries on constraints

modifiesUtxoSet :: forall i o. TxConstraints i o -> Bool Source #

Check whether every transaction that satisfies the constraints has to modify the UTXO set.

isSatisfiable :: forall i o. TxConstraints i o -> Bool Source #

Are the constraints satisfiable?

On-chain validation

checkScriptContext :: forall i o. ToData o => TxConstraints i o -> ScriptContext -> Bool Source #

Does the ScriptContext satisfy the constraints?

Off-chain transaction generation

data UnbalancedTx Source #

An unbalanced transaction. It needs to be balanced and signed before it can be submitted to the ledger. See note [Submitting transactions from Plutus contracts] in Wallet.

Constructors

UnbalancedTx 

Fields

Instances

Instances details
Eq UnbalancedTx Source # 
Instance details

Defined in Ledger.Constraints.OffChain

Show UnbalancedTx Source # 
Instance details

Defined in Ledger.Constraints.OffChain

Generic UnbalancedTx Source # 
Instance details

Defined in Ledger.Constraints.OffChain

Associated Types

type Rep UnbalancedTx :: Type -> Type Source #

ToJSON UnbalancedTx Source # 
Instance details

Defined in Ledger.Constraints.OffChain

FromJSON UnbalancedTx Source # 
Instance details

Defined in Ledger.Constraints.OffChain

ToSchema UnbalancedTx Source # 
Instance details

Defined in Ledger.Constraints.OffChain

Pretty UnbalancedTx Source # 
Instance details

Defined in Ledger.Constraints.OffChain

type Rep UnbalancedTx Source # 
Instance details

Defined in Ledger.Constraints.OffChain

type Rep UnbalancedTx = D1 ('MetaData "UnbalancedTx" "Ledger.Constraints.OffChain" "plutus-ledger-constraints-0.1.0.0-AdCuTwHqkQFFnwldCwEXkg" 'False) (C1 ('MetaCons "UnbalancedTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "unBalancedTxTx") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Tx) :*: S1 ('MetaSel ('Just "unBalancedTxRequiredSignatories") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map PaymentPubKeyHash (Maybe PaymentPubKey)))) :*: (S1 ('MetaSel ('Just "unBalancedTxUtxoIndex") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map TxOutRef TxOut)) :*: S1 ('MetaSel ('Just "unBalancedTxValidityTimeRange") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 POSIXTimeRange))))

data MkTxError Source #

Instances

Instances details
Eq MkTxError Source # 
Instance details

Defined in Ledger.Constraints.OffChain

Show MkTxError Source # 
Instance details

Defined in Ledger.Constraints.OffChain

Generic MkTxError Source # 
Instance details

Defined in Ledger.Constraints.OffChain

Associated Types

type Rep MkTxError :: Type -> Type Source #

ToJSON MkTxError Source # 
Instance details

Defined in Ledger.Constraints.OffChain

FromJSON MkTxError Source # 
Instance details

Defined in Ledger.Constraints.OffChain

Pretty MkTxError Source # 
Instance details

Defined in Ledger.Constraints.OffChain

Methods

pretty :: MkTxError -> Doc ann Source #

prettyList :: [MkTxError] -> Doc ann Source #

type Rep MkTxError Source # 
Instance details

Defined in Ledger.Constraints.OffChain

type Rep MkTxError = D1 ('MetaData "MkTxError" "Ledger.Constraints.OffChain" "plutus-ledger-constraints-0.1.0.0-AdCuTwHqkQFFnwldCwEXkg" 'False) (((C1 ('MetaCons "TypeCheckFailed" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ConnectionError)) :+: C1 ('MetaCons "TxOutRefNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TxOutRef))) :+: (C1 ('MetaCons "TxOutRefWrongType" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TxOutRef)) :+: (C1 ('MetaCons "DatumNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DatumHash)) :+: C1 ('MetaCons "MintingPolicyNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 MintingPolicyHash))))) :+: ((C1 ('MetaCons "ValidatorHashNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ValidatorHash)) :+: C1 ('MetaCons "OwnPubKeyMissing" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "TypedValidatorMissing" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "DatumWrongHash" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DatumHash) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Datum)) :+: C1 ('MetaCons "CannotSatisfyAny" 'PrefixI 'False) (U1 :: Type -> Type)))))

mkTx :: (FromData (DatumType a), ToData (DatumType a), ToData (RedeemerType a)) => ScriptLookups a -> TxConstraints (RedeemerType a) (DatumType a) -> Either MkTxError UnbalancedTx Source #

Turn a TxConstraints value into an unbalanced transaction that satisfies the constraints. To use this in a contract, see submitTxConstraints and related functions.

adjustUnbalancedTx :: UnbalancedTx -> UnbalancedTx Source #

Each transaction output should contain a minimum amount of Ada (this is a restriction on the real Cardano network).

TODO: In the future, the minimum Ada value should be configurable.

Combining multiple typed scripts into one transaction

mkSomeTx :: [SomeLookupsAndConstraints] -> Either MkTxError UnbalancedTx Source #

Given a list of SomeLookupsAndConstraints describing the constraints for several scripts, build a single transaction that runs all the scripts.

Lookups

data ScriptLookups a Source #

Constructors

ScriptLookups 

Fields

Instances

Instances details
Show (ScriptLookups a) Source # 
Instance details

Defined in Ledger.Constraints.OffChain

Generic (ScriptLookups a) Source # 
Instance details

Defined in Ledger.Constraints.OffChain

Associated Types

type Rep (ScriptLookups a) :: Type -> Type Source #

Semigroup (ScriptLookups a) Source # 
Instance details

Defined in Ledger.Constraints.OffChain

Monoid (ScriptLookups a) Source # 
Instance details

Defined in Ledger.Constraints.OffChain

ToJSON (ScriptLookups a) Source # 
Instance details

Defined in Ledger.Constraints.OffChain

FromJSON (ScriptLookups a) Source # 
Instance details

Defined in Ledger.Constraints.OffChain

type Rep (ScriptLookups a) Source # 
Instance details

Defined in Ledger.Constraints.OffChain

typedValidatorLookups :: TypedValidator a -> ScriptLookups a Source #

A script lookups value with a script instance. For convenience this also includes the minting policy script that forwards all checks to the instance's validator.

If called multiple times, only the first typed validator is kept:

typedValidatorLookups tv1 <> typedValidatorLookups tv2 <> ...
    == typedValidatorLookups tv1

unspentOutputs :: Map TxOutRef ChainIndexTxOut -> ScriptLookups a Source #

A script lookups value that uses the map of unspent outputs to resolve input constraints.

mintingPolicy :: MintingPolicy -> ScriptLookups a Source #

A script lookups value with a minting policy script.

otherScript :: Validator -> ScriptLookups a Source #

A script lookups value with a validator script.

otherData :: Datum -> ScriptLookups a Source #

A script lookups value with a datum.

paymentPubKey :: PaymentPubKey -> ScriptLookups a Source #

A script lookups value with a payment public key

ownPaymentPubKeyHash :: PaymentPubKeyHash -> ScriptLookups a Source #

A script lookups value with a payment public key hash.

If called multiple times, only the payment public key hash is kept:

ownPaymentPubKeyHash pkh1 <> ownPaymentPubKeyHash pkh2 <> ...
    == ownPaymentPubKeyHash pkh1

ownStakePubKeyHash :: StakePubKeyHash -> ScriptLookups a Source #

A script lookups value with a stake public key hash.

If called multiple times, only the stake public key hash is kept:

ownStakePubKeyHash skh1 <> ownStakePubKeyHash skh2 <> ...
    == ownStakePubKeyHash skh1