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

Ledger.Constraints.TxConstraints

Description

Constraints for transactions

Synopsis

Documentation

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)))

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]))))

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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

Are the constraints satisfiable?

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

The minimum Value that satisfies all MustSpendAtLeast constraints

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

The minimum Value that satisfies all MustProduceAtLeast constraints

requiredDatums :: forall i o. TxConstraints i o -> [Datum] Source #

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

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