plutus-ledger-api-1.60.0.0: Interface to the Plutus ledger for the Cardano ledger.
Safe HaskellSafe-Inferred
LanguageHaskell2010

PlutusLedgerApi.Data.V2

Description

The interface to Plutus V2 for the ledger.

Synopsis

serialiseUPLC :: DefaultFun () -> SerialisedScript #

Turns a program's AST (most likely manually constructed) into a binary format that is understood by the network and can be stored on-chain.

deserialiseScript #

Arguments

:: forall m. MonadError ScriptDecodeError m 
=> MajorProtocolVersion

which major protocol version the script was submitted in.

-> SerialisedScript

the script to deserialise.

-> m ScriptForEvaluation 

The deserialization from a serialised script into a ScriptForEvaluation, ready to be evaluated on-chain. Called inside phase-1 validation (i.e., deserialisation error is a phase-1 error).

uncheckedDeserialiseUPLC :: SerialisedScript -> DefaultFun () #

Deserialises a SerialisedScript back into an AST. Does *not* do ledger-language-version-specific checks like for allowable builtins.

Running scripts

evaluateScriptRestricting #

Arguments

:: MajorProtocolVersion

Which major protocol version to run the operation in

-> VerboseMode

Whether to produce log output

-> EvaluationContext

Includes the cost model to use for tallying up the execution costs

-> ExBudget

The resource budget which must not be exceeded during evaluation

-> ScriptForEvaluation

The script to evaluate

-> [Data]

The arguments to the script

-> (LogOutput, Either EvaluationError ExBudget) 

Evaluates a script, with a cost model and a budget that restricts how many resources it can use according to the cost model. Also returns the budget that was actually used.

Can be used to calculate budgets for scripts, but even in this case you must give a limit to guard against scripts that run for a long time or loop.

evaluateScriptCounting #

Arguments

:: MajorProtocolVersion

Which major protocol version to run the operation in

-> VerboseMode

Whether to produce log output

-> EvaluationContext

Includes the cost model to use for tallying up the execution costs

-> ScriptForEvaluation

The script to evaluate

-> [Data]

The arguments to the script

-> (LogOutput, Either EvaluationError ExBudget) 

Evaluates a script, returning the minimum budget that the script would need to evaluate successfully. This will take as long as the script takes, if you need to limit the execution time of the script also, you can use evaluateScriptRestricting, which also returns the used budget.

Protocol version

newtype MajorProtocolVersion #

This represents the major component of the Cardano protocol version. The ledger can only supply the major component of the protocol version, not the minor component, and Plutus should only need to care about the major component anyway. This relies on careful understanding between us and the ledger as to what this means.

Constructors

MajorProtocolVersion 

Fields

newtype ExCPU #

Counts CPU units in picoseconds: maximum value for SatInt is 2^63 ps, or appproximately 106 days.

Constructors

ExCPU Data.SatInt

Associated Types

type Rep SatInt :: Type -> Type #

Methods

from :: SatInt -> Rep SatInt x #

to :: Rep SatInt x -> SatInt #

Num SatInt

In the Num instance, we plug in our own addition, multiplication and subtraction function that perform overflow-checking.

Instance details

Defined in Data.SatInt

type Rep SatInt = D1 ('MetaData "SatInt" "Data.SatInt" "plutus-core-1.60.0.0-inplace-satint" 'True) (C1 ('MetaCons "SI" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSatInt") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

fromSatInt :: Num a => SatInt -> a #

An optimized version of fromIntegral . unSatInt.

Cost model

data EvaluationContext #

An opaque type that contains all the static parameters that the evaluator needs to evaluate a script. This is so that they can be computed once and cached, rather than being recomputed on every evaluation.

Different protocol versions may require different bundles of machine parameters, which allows us for example to tweak the shape of the costing function of a builtin, so that the builtin costs less. Currently this means that we have to create multiple DefaultMachineParameters per language version, which we put into a cache (represented by an association list) in order to avoid costly recomputation of machine parameters.

In order to get the appropriate DefaultMachineParameters at validation time we look it up in the cache using a semantics variant as a key. We compute the semantics variant from the protocol version using the stored function. Note that the semantics variant depends on the language version too, but the latter is known statically (because each language version has its own evaluation context), hence there's no reason to require it to be provided at runtime.

To say it differently, there's a matrix of semantics variants indexed by (LL, PV) pairs and we cache its particular row corresponding to the statically given LL in an EvaluationContext.

The reason why we associate a DefaultMachineParameters with a semantics variant rather than a protocol version are

  1. generally there are far more protocol versions than semantics variants supported by a specific language version, so we save on pointless duplication of bundles of machine parameters
  2. builtins don't know anything about protocol versions, only semantics variants. It is therefore more semantically precise to associate bundles of machine parameters with semantics variants than with protocol versions

Instances

Instances details
DefaultMachineVariantParameters)]))))

mkEvaluationContext #

Arguments

:: (MonadError CostModelApplyError m, MonadWriter [CostModelApplyWarn] m) 
=> [Int64]

the (updated) cost model parameters of the protocol

-> m EvaluationContext 

Build the EvaluationContext.

The input is a list of cost model parameters (which are integer values) passed from the ledger.

IMPORTANT: the cost model parameters MUST appear in the correct order, matching the names in ParamName. If the parameters are supplied in the wrong order then script cost calculations will be incorrect.

IMPORTANT: The evaluation context of every Plutus version must be recreated upon a protocol update with the updated cost model parameters.

data ParamName #

The enumeration of all possible cost model parameter names for this language version.

IMPORTANT: The order of appearance of the data constructors here matters. DO NOT REORDER. See Note [Quotation marks in cost model parameter constructors] See Note [Cost model parameters from the ledger's point of view]

Constructors

AddInteger'cpu'arguments'intercept 
AddInteger'cpu'arguments'slope 
AddInteger'memory'arguments'intercept 
AddInteger'memory'arguments'slope 
AppendByteString'cpu'arguments'intercept 
AppendByteString'cpu'arguments'slope 
AppendByteString'memory'arguments'intercept 
AppendByteString'memory'arguments'slope 
AppendString'cpu'arguments'intercept 
AppendString'cpu'arguments'slope 
AppendString'memory'arguments'intercept 
AppendString'memory'arguments'slope 
BData'cpu'arguments 
BData'memory'arguments 
Blake2b_256'cpu'arguments'intercept 
Blake2b_256'cpu'arguments'slope 
Blake2b_256'memory'arguments 
CekApplyCost'exBudgetCPU 
CekApplyCost'exBudgetMemory 
CekBuiltinCost'exBudgetCPU 
CekBuiltinCost'exBudgetMemory 
CekConstCost'exBudgetCPU 
CekConstCost'exBudgetMemory 
CekDelayCost'exBudgetCPU 
CekDelayCost'exBudgetMemory 
CekForceCost'exBudgetCPU 
CekForceCost'exBudgetMemory 
CekLamCost'exBudgetCPU 
CekLamCost'exBudgetMemory 
CekStartupCost'exBudgetCPU 
CekStartupCost'exBudgetMemory 
CekVarCost'exBudgetCPU 
CekVarCost'exBudgetMemory 
ChooseData'cpu'arguments 
ChooseData'memory'arguments 
ChooseList'cpu'arguments 
ChooseList'memory'arguments 
ChooseUnit'cpu'arguments 
ChooseUnit'memory'arguments 
ConsByteString'cpu'arguments'intercept 
ConsByteString'cpu'arguments'slope 
ConsByteString'memory'arguments'intercept 
ConsByteString'memory'arguments'slope 
ConstrData'cpu'arguments 
ConstrData'memory'arguments 
DecodeUtf8'cpu'arguments'intercept 
DecodeUtf8'cpu'arguments'slope 
DecodeUtf8'memory'arguments'intercept 
DecodeUtf8'memory'arguments'slope 
DivideInteger'cpu'arguments'constant 
DivideInteger'cpu'arguments'model'arguments'intercept 
DivideInteger'cpu'arguments'model'arguments'slope 
DivideInteger'memory'arguments'intercept 
DivideInteger'memory'arguments'minimum 
DivideInteger'memory'arguments'slope 
EncodeUtf8'cpu'arguments'intercept 
EncodeUtf8'cpu'arguments'slope 
EncodeUtf8'memory'arguments'intercept 
EncodeUtf8'memory'arguments'slope 
EqualsByteString'cpu'arguments'constant 
EqualsByteString'cpu'arguments'intercept 
EqualsByteString'cpu'arguments'slope 
EqualsByteString'memory'arguments 
EqualsData'cpu'arguments'intercept 
EqualsData'cpu'arguments'slope 
EqualsData'memory'arguments 
EqualsInteger'cpu'arguments'intercept 
EqualsInteger'cpu'arguments'slope 
EqualsInteger'memory'arguments 
EqualsString'cpu'arguments'constant 
EqualsString'cpu'arguments'intercept 
EqualsString'cpu'arguments'slope 
EqualsString'memory'arguments 
FstPair'cpu'arguments 
FstPair'memory'arguments 
HeadList'cpu'arguments 
HeadList'memory'arguments 
IData'cpu'arguments 
IData'memory'arguments 
IfThenElse'cpu'arguments 
IfThenElse'memory'arguments 
IndexByteString'cpu'arguments 
IndexByteString'memory'arguments 
LengthOfByteString'cpu'arguments 
LengthOfByteString'memory'arguments 
LessThanByteString'cpu'arguments'intercept 
LessThanByteString'cpu'arguments'slope 
LessThanByteString'memory'arguments 
LessThanEqualsByteString'cpu'arguments'intercept 
LessThanEqualsByteString'cpu'arguments'slope 
LessThanEqualsByteString'memory'arguments 
LessThanEqualsInteger'cpu'arguments'intercept 
LessThanEqualsInteger'cpu'arguments'slope 
LessThanEqualsInteger'memory'arguments 
LessThanInteger'cpu'arguments'intercept 
LessThanInteger'cpu'arguments'slope 
LessThanInteger'memory'arguments 
ListData'cpu'arguments 
ListData'memory'arguments 
MapData'cpu'arguments 
MapData'memory'arguments 
MkCons'cpu'arguments 
MkCons'memory'arguments 
MkNilData'cpu'arguments 
MkNilData'memory'arguments 
MkNilPairData'cpu'arguments 
MkNilPairData'memory'arguments 
MkPairData'cpu'arguments 
MkPairData'memory'arguments 
ModInteger'cpu'arguments'constant 
ModInteger'cpu'arguments'model'arguments'intercept 
ModInteger'cpu'arguments'model'arguments'slope 
ModInteger'memory'arguments'intercept 
ModInteger'memory'arguments'minimum 
ModInteger'memory'arguments'slope 
MultiplyInteger'cpu'arguments'intercept 
MultiplyInteger'cpu'arguments'slope 
MultiplyInteger'memory'arguments'intercept 
MultiplyInteger'memory'arguments'slope 
NullList'cpu'arguments 
NullList'memory'arguments 
QuotientInteger'cpu'arguments'constant 
QuotientInteger'cpu'arguments'model'arguments'intercept 
QuotientInteger'cpu'arguments'model'arguments'slope 
QuotientInteger'memory'arguments'intercept 
QuotientInteger'memory'arguments'minimum 
QuotientInteger'memory'arguments'slope 
RemainderInteger'cpu'arguments'constant 
RemainderInteger'cpu'arguments'model'arguments'intercept 
RemainderInteger'cpu'arguments'model'arguments'slope 
RemainderInteger'memory'arguments'intercept 
RemainderInteger'memory'arguments'minimum 
RemainderInteger'memory'arguments'slope 
SerialiseData'cpu'arguments'intercept 
SerialiseData'cpu'arguments'slope 
SerialiseData'memory'arguments'intercept 
SerialiseData'memory'arguments'slope 
Sha2_256'cpu'arguments'intercept 
Sha2_256'cpu'arguments'slope 
Sha2_256'memory'arguments 
Sha3_256'cpu'arguments'intercept 
Sha3_256'cpu'arguments'slope 
Sha3_256'memory'arguments 
SliceByteString'cpu'arguments'intercept 
SliceByteString'cpu'arguments'slope 
SliceByteString'memory'arguments'intercept 
SliceByteString'memory'arguments'slope 
SndPair'cpu'arguments 
SndPair'memory'arguments 
SubtractInteger'cpu'arguments'intercept 
SubtractInteger'cpu'arguments'slope 
SubtractInteger'memory'arguments'intercept 
SubtractInteger'memory'arguments'slope 
TailList'cpu'arguments 
TailList'memory'arguments 
Trace'cpu'arguments 
Trace'memory'arguments 
UnBData'cpu'arguments 
UnBData'memory'arguments 
UnConstrData'cpu'arguments 
UnConstrData'memory'arguments 
UnIData'cpu'arguments 
UnIData'memory'arguments 
UnListData'cpu'arguments 
UnListData'memory'arguments 
UnMapData'cpu'arguments 
UnMapData'memory'arguments 
VerifyEcdsaSecp256k1Signature'cpu'arguments 
VerifyEcdsaSecp256k1Signature'memory'arguments 
VerifyEd25519Signature'cpu'arguments'intercept 
VerifyEd25519Signature'cpu'arguments'slope 
VerifyEd25519Signature'memory'arguments 
VerifySchnorrSecp256k1Signature'cpu'arguments'intercept 
VerifySchnorrSecp256k1Signature'cpu'arguments'slope 
VerifySchnorrSecp256k1Signature'memory'arguments 
IntegerToByteString'cpu'arguments'c0 
IntegerToByteString'cpu'arguments'c1 
IntegerToByteString'cpu'arguments'c2 
IntegerToByteString'memory'arguments'intercept 
IntegerToByteString'memory'arguments'slope 
ByteStringToInteger'cpu'arguments'c0 
ByteStringToInteger'cpu'arguments'c1 
ByteStringToInteger'cpu'arguments'c2 
ByteStringToInteger'memory'arguments'intercept 
ByteStringToInteger'memory'arguments'slope 
CekConstrCost'exBudgetCPU 
CekConstrCost'exBudgetMemory 
CekCaseCost'exBudgetCPU 
CekCaseCost'exBudgetMemory 
Bls12_381_G1_add'cpu'arguments 
Bls12_381_G1_add'memory'arguments 
Bls12_381_G1_compress'cpu'arguments 
Bls12_381_G1_compress'memory'arguments 
Bls12_381_G1_equal'cpu'arguments 
Bls12_381_G1_equal'memory'arguments 
Bls12_381_G1_hashToGroup'cpu'arguments'intercept 
Bls12_381_G1_hashToGroup'cpu'arguments'slope 
Bls12_381_G1_hashToGroup'memory'arguments 
Bls12_381_G1_neg'cpu'arguments 
Bls12_381_G1_neg'memory'arguments 
Bls12_381_G1_scalarMul'cpu'arguments'intercept 
Bls12_381_G1_scalarMul'cpu'arguments'slope 
Bls12_381_G1_scalarMul'memory'arguments 
Bls12_381_G1_uncompress'cpu'arguments 
Bls12_381_G1_uncompress'memory'arguments 
Bls12_381_G2_add'cpu'arguments 
Bls12_381_G2_add'memory'arguments 
Bls12_381_G2_compress'cpu'arguments 
Bls12_381_G2_compress'memory'arguments 
Bls12_381_G2_equal'cpu'arguments 
Bls12_381_G2_equal'memory'arguments 
Bls12_381_G2_hashToGroup'cpu'arguments'intercept 
Bls12_381_G2_hashToGroup'cpu'arguments'slope 
Bls12_381_G2_hashToGroup'memory'arguments 
Bls12_381_G2_neg'cpu'arguments 
Bls12_381_G2_neg'memory'arguments 
Bls12_381_G2_scalarMul'cpu'arguments'intercept 
Bls12_381_G2_scalarMul'cpu'arguments'slope 
Bls12_381_G2_scalarMul'memory'arguments 
Bls12_381_G2_uncompress'cpu'arguments 
Bls12_381_G2_uncompress'memory'arguments 
Bls12_381_finalVerify'cpu'arguments 
Bls12_381_finalVerify'memory'arguments 
Bls12_381_millerLoop'cpu'arguments 
Bls12_381_millerLoop'memory'arguments 
Bls12_381_mulMlResult'cpu'arguments 
Bls12_381_mulMlResult'memory'arguments 
Keccak_256'cpu'arguments'intercept 
Keccak_256'cpu'arguments'slope 
Keccak_256'memory'arguments 
Blake2b_224'cpu'arguments'intercept 
Blake2b_224'cpu'arguments'slope 
Blake2b_224'memory'arguments 
AndByteString'cpu'arguments'intercept 
AndByteString'cpu'arguments'slope1 
AndByteString'cpu'arguments'slope2 
AndByteString'memory'arguments'intercept 
AndByteString'memory'arguments'slope 
OrByteString'cpu'arguments'intercept 
OrByteString'cpu'arguments'slope1 
OrByteString'cpu'arguments'slope2 
OrByteString'memory'arguments'intercept 
OrByteString'memory'arguments'slope 
XorByteString'cpu'arguments'intercept 
XorByteString'cpu'arguments'slope1 
XorByteString'cpu'arguments'slope2 
XorByteString'memory'arguments'intercept 
XorByteString'memory'arguments'slope 
ComplementByteString'cpu'arguments'intercept 
ComplementByteString'cpu'arguments'slope 
ComplementByteString'memory'arguments'intercept 
ComplementByteString'memory'arguments'slope 
ReadBit'cpu'arguments 
ReadBit'memory'arguments 
WriteBits'cpu'arguments'intercept 
WriteBits'cpu'arguments'slope 
WriteBits'memory'arguments'intercept 
WriteBits'memory'arguments'slope 
ReplicateByte'cpu'arguments'intercept 
ReplicateByte'cpu'arguments'slope 
ReplicateByte'memory'arguments'intercept 
ReplicateByte'memory'arguments'slope 
ShiftByteString'cpu'arguments'intercept 
ShiftByteString'cpu'arguments'slope 
ShiftByteString'memory'arguments'intercept 
ShiftByteString'memory'arguments'slope 
RotateByteString'cpu'arguments'intercept 
RotateByteString'cpu'arguments'slope 
RotateByteString'memory'arguments'intercept 
RotateByteString'memory'arguments'slope 
CountSetBits'cpu'arguments'intercept 
CountSetBits'cpu'arguments'slope 
CountSetBits'memory'arguments 
FindFirstSetBit'cpu'arguments'intercept 
FindFirstSetBit'cpu'arguments'slope 
FindFirstSetBit'memory'arguments 
Ripemd_160'cpu'arguments'intercept 
Ripemd_160'cpu'arguments'slope 
Ripemd_160'memory'arguments 
ExpModInteger'cpu'arguments'coefficient00 
ExpModInteger'cpu'arguments'coefficient11 
ExpModInteger'cpu'arguments'coefficient12 
ExpModInteger'memory'arguments'intercept 
ExpModInteger'memory'arguments'slope 
DropList'cpu'arguments'intercept 
DropList'cpu'arguments'slope 
DropList'memory'arguments 
LengthOfArray'cpu'arguments 
LengthOfArray'memory'arguments 
ListToArray'cpu'arguments'intercept 
ListToArray'cpu'arguments'slope 
ListToArray'memory'arguments'intercept 
ListToArray'memory'arguments'slope 
IndexArray'cpu'arguments 
IndexArray'memory'arguments 
Bls12_381_G1_multiScalarMul'cpu'arguments'intercept 
Bls12_381_G1_multiScalarMul'cpu'arguments'slope 
Bls12_381_G1_multiScalarMul'memory'arguments 
Bls12_381_G2_multiScalarMul'cpu'arguments'intercept 
Bls12_381_G2_multiScalarMul'cpu'arguments'slope 
Bls12_381_G2_multiScalarMul'memory'arguments 
InsertCoin'cpu'arguments'intercept 
InsertCoin'cpu'arguments'slope 
InsertCoin'memory'arguments'intercept 
InsertCoin'memory'arguments'slope 
LookupCoin'cpu'arguments'intercept 
LookupCoin'cpu'arguments'slope 
LookupCoin'memory'arguments 
UnionValue'cpu'arguments'c00 
UnionValue'cpu'arguments'c10 
UnionValue'cpu'arguments'c01 
UnionValue'cpu'arguments'c11 
UnionValue'memory'arguments'intercept 
UnionValue'memory'arguments'slope 
ValueContains'cpu'arguments'constant 
ValueContains'cpu'arguments'model'arguments'intercept 
ValueContains'cpu'arguments'model'arguments'slope1 
ValueContains'cpu'arguments'model'arguments'slope2 
ValueContains'memory'arguments 
ValueData'cpu'arguments'intercept 
ValueData'cpu'arguments'slope 
ValueData'memory'arguments'intercept 
ValueData'memory'arguments'slope 
UnValueData'cpu'arguments'c0 
UnValueData'cpu'arguments'c1 
UnValueData'cpu'arguments'c2 
UnValueData'memory'arguments'intercept 
UnValueData'memory'arguments'slope 
ScaleValue'cpu'arguments'intercept 
ScaleValue'cpu'arguments'slope 
ScaleValue'memory'arguments'intercept 
ScaleValue'memory'arguments'slope 

Instances

Instances details
HasFromOpaque arep a => arep -> a #

Bytes

newtype LedgerBytes #

Instances

Instances details
IsString LedgerBytes #

Read in arbitrary LedgerBytes as a "string" (of characters).

This is mostly used together with GHC's OverloadedStrings extension to specify at the source code any LedgerBytes constants, by utilizing Haskell's double-quoted string syntax.

IMPORTANT: the LedgerBytes are expected to be already hex-encoded (base16); otherwise, LedgerBytesError will be raised as an Exception.

Instance details

Defined in PlutusLedgerApi.V1.Bytes

Generic LedgerBytes # 
Instance details

Defined in PlutusLedgerApi.V1.Bytes

Associated Types

type Rep LedgerBytes :: Type -> Type #

Show LedgerBytes #

The Show instance of LedgerBytes is its Base16/Hex encoded bytestring, decoded with UTF-8, unpacked to RepIsStuckError LedgerBytes :: Type -> Type) (Rep LedgerBytes)))

fromBytes :: ByteString -> LedgerBytes #

Lift a Haskell bytestring to the Plutus abstraction LedgerBytes

Certificates

data DCert #

A representation of the ledger DCert. Some information is digested, and not included

Instances

Instances details
RepIsStuckError DCert :: Type -> Type) (Rep DCert)))

pattern DCertGenesis :: DCert #

pattern DCertMir :: DCert #

Credentials

data StakingCredential #

Staking credential used to assign rewards.

The staking hash constructor is the Credential required to unlock a transaction output. Either a public key credential (PubKeyHash) or a script credential (ScriptHash). Both are hashed with BLAKE2b-244. 28 byte.

The StakingPtr constructor is the certificate pointer, constructed by the given slot number, transaction and certificate indices. NB: The fields should really be all Word64, as they are implemented in Word64, but RepIsStuckError StakingCredential :: Type -> Type) (Rep StakingCredential)))

pattern StakingHash :: Credential -> StakingCredential #

pattern StakingPtr :: Integer -> Integer -> Integer -> StakingCredential #

data Credential #

Credentials required to unlock a transaction output.

The PubKeyCredential constructor represents the transaction that spends this output and must be signed by the private key. See PubKeyHash.

The ScriptCredential constructor represents the transaction that spends this output must include the validator script and be accepted by the validator. See ScriptHash.

Instances

Instances details
RepIsStuckError Credential :: Type -> Type) (Rep Credential)))

pattern PubKeyCredential :: PubKeyHash -> Credential #

pattern ScriptCredential :: ScriptHash -> Credential #

Value

newtype Value #

The Value type represents a collection of amounts of different currencies. We can think of Value as a vector space whose dimensions are currencies.

Operations on currencies are usually implemented pointwise. That is, we apply the operation to the quantities for each currency in turn. So when we add two Values the resulting Value has, for each currency, the sum of the quantities of that particular currency in the argument Value. The effect of this is that the currencies in the Value are "independent", and are operated on separately.

Whenever we need to get the quantity of a currency in a Value where there is no explicit quantity of that currency in the Value, then the quantity is taken to be zero.

There is no 'Ord Value' instance since Value is only a partial order, so compare can't do the right thing in some cases.

newtype CurrencySymbol #

ByteString representing the currency, hashed with BLAKE2b-224. It is empty for Ada, 28 bytes for MintingPolicyHash. Forms an AssetClass along with TokenName. A Value is a map from CurrencySymbol's to a map from TokenName to an Integer.

This is a simple type without any validation, use with caution. You may want to add checks for its invariants. See the Shelley ledger specification. -- editorconfig-checker-disable-file

Instances

Instances details
RepIsStuckError CurrencySymbol :: Type -> Type) (Rep CurrencySymbol)))

newtype TokenName #

ByteString of a name of a token. Shown as hex-encoded bytes. Should be no longer than 32 bytes, empty for Ada. Forms an AssetClass along with a CurrencySymbol.

This is a simple type without any validation, use with caution. You may want to add checks for its invariants. See the Shelley ledger specification. -- editorconfig-checker-disable-file

Constructors

TokenName 

Instances

Instances details
RepIsStuckError TokenName :: Type -> Type) (Rep TokenName)))

singleton :: CurrencySymbol -> TokenName -> Integer -> Value #

Make a Value containing only the given quantity of the given currency.

unionWith :: (Integer -> Integer -> Integer) -> Value -> Value -> Value #

Combine two Value maps with the argument function. Assumes the well-definedness of the two maps.

adaSymbol :: CurrencySymbol #

The CurrencySymbol of the Ada currency.

adaToken :: TokenName #

The TokenName of the Ada currency.

newtype Lovelace #

Time

newtype POSIXTime #

POSIX time is measured as the number of milliseconds since 1970-01-01T00:00:00Z. This is not the same as Haskell's RepIsStuckError POSIXTime :: Type -> Type) (Rep POSIXTime)))

type POSIXTimeRange = Interval POSIXTime #

An Interval of POSIXTimes.

Types for representing transactions

data Address #

An address may contain two credentials, the payment credential and optionally a StakingCredential.

Instances

Instances details
RepIsStuckError Address :: Type -> Type) (Rep Address)))

pattern Address :: Credential -> Maybe StakingCredential -> Address #

addressCredential :: Address -> Credential #

addressStakingCredential :: Address -> Maybe StakingCredential #

newtype PubKeyHash #

The hash of a public key. This is frequently used to identify the public key, rather than the key itself. Hashed with BLAKE2b-224. 28 bytes.

This is a simple type without any validation, use with caution. You may want to add checks for its invariants. See the Shelley ledger specification.

Instances

Instances details
Unroll PubKeyHash = '[PubKeyHash]

newtype TxId #

A transaction ID, i.e. the hash of a transaction. Hashed with BLAKE2b-256. 32 byte.

This is a simple type without any validation, use with caution. You may want to add checks for its invariants. See the Shelley ledger specification. -- editorconfig-checker-disable-file

Constructors

TxId 

Instances

Instances details
DefaultUni ()) #

type Rep TxId # 
Instance details

Defined in PlutusLedgerApi.V1.Data.Tx

type Rep TxId = D1 ('MetaData "TxId" "PlutusLedgerApi.V1.Data.Tx" "plutus-ledger-api-1.60.0.0-inplace" 'True) (C1 ('MetaCons "TxId" 'PrefixI 'True) (S1 ('MetaSel ('Just "getTxId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BuiltinByteString)))

data TxInfo #

A pending transaction. This is the view as seen by validator scripts, so some details are stripped out.

Instances

Instances details
List PubKeyHash #

data TxOut #

A transaction output, consisting of a target address, a value, optionally a datum/datum hash, and optionally a reference script.

Instances

Instances details
DefaultUni ()) #

type Rep TxOut # 
Instance details

Defined in PlutusLedgerApi.V2.Data.Tx

type Rep TxOut = D1 ('MetaData "TxOut" "PlutusLedgerApi.V2.Data.Tx" "plutus-ledger-api-1.60.0.0-inplace" 'True) (C1 ('MetaCons "TxOut_6989586621680146156" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BuiltinData)))

data TxOutRef #

A reference to a transaction output. This is a pair of a transaction ID (TxId), and an index indicating which of the outputs of that transaction we are referring to.

Instances

Instances details
DefaultUni ()) #

type Rep TxInInfo # 
Instance details

Defined in PlutusLedgerApi.V2.Data.Contexts

type Rep TxInInfo = D1 ('MetaData "TxInInfo" "PlutusLedgerApi.V2.Data.Contexts" "plutus-ledger-api-1.60.0.0-inplace" 'True) (C1 ('MetaCons "TxInInfo_6989586621680195605" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BuiltinData)))

pattern TxInInfo :: TxOutRef -> TxOut -> TxInInfo #

data OutputDatum #

The datum attached to an output: either nothing; a datum hash; or the datum itself (an "inline datum").

Instances

Instances details
DefaultUni ()) #

type Rep OutputDatum # 
Instance details

Defined in PlutusLedgerApi.V2.Data.Tx

type Rep OutputDatum = D1 ('MetaData "OutputDatum" "PlutusLedgerApi.V2.Data.Tx" "plutus-ledger-api-1.60.0.0-inplace" 'True) (C1 ('MetaCons "OutputDatum_6989586621680145390" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BuiltinData)))

Intervals

data Interval a #

An interval of as.

The interval may be either closed or open at either end, meaning that the endpoints may or may not be included in the interval.

The interval can also be unbounded on either side.

The Eq instance gives equality of the intervals, not structural equality. There is no Enum in order to handle non-inclusive endpoints. For this reason, it may not be safe to use Intervals with non-inclusive endpoints on types whose Enum instances have partial methods.

Instances

Instances details
Unrolled (Extended a))

pattern LowerBound :: forall a. (ToData a, UnsafeFromData a) => Extended a -> Closure -> LowerBound a #

always :: (ToData a, UnsafeFromData a) => Interval a #

An Interval that covers every slot. In math. notation [-∞,+∞]

from :: (ToData a, UnsafeFromData a) => a -> Interval a #

from a is an Interval that includes all values that are greater than or equal to a. In math. notation: [a,+∞]

to :: (ToData a, UnsafeFromData a) => a -> Interval a #

to a is an Interval that includes all values that are smaller than or equal to a. In math. notation: [-∞,a]

lowerBound :: (ToData a, UnsafeFromData a) => a -> LowerBound a #

Construct a lower bound from a value. The resulting bound includes all values that are equal or greater than the input value.

upperBound :: (ToData a, UnsafeFromData a) => a -> UpperBound a #

Construct an upper bound from a value. The resulting bound includes all values that are equal or smaller than the input value.

strictLowerBound :: (ToData a, UnsafeFromData a) => a -> LowerBound a #

Construct a strict lower bound from a value. The resulting bound includes all values that are (strictly) greater than the input value.

strictUpperBound :: (ToData a, UnsafeFromData a) => a -> UpperBound a #

Construct a strict upper bound from a value. The resulting bound includes all values that are (strictly) smaller than the input value.

Association maps

data Map k a #

A map associating keys and values backed by BuiltinData.

This implementation has the following characteristics:

Therefore this implementation is likely a better choice than PlutusTx.AssocMap.Map if it is part of a data type defined using asData, and the key and value types have efficient toBuiltinData and unsafeFromBuiltinData operations (e.g., they are primitive types or types defined using asData).

A Map is considered well-defined if it has no duplicate keys. Most operations preserve the definedness of the resulting Map unless otherwise noted. It is important to observe that, in comparison to standard map implementations, this implementation provides slow lookup and update operations because it is based on a list representation.

Instances

Instances details
List of key-value pairs. This function is unsafe because it assumes that the elements of the list can be safely decoded from their BuiltinData representation. It also does not deduplicate the keys.

unsafeFromBuiltinList :: BuiltinPair BuiltinData BuiltinData) -> Map k a #

Unsafely create an Map from a BuiltinList of key-value pairs. This operation is O(1). This function is unsafe because it assumes that the elements of the list can be safely decoded from their BuiltinData representation. It also does not deduplicate the keys.

unsafeFromSOPList :: (ToData k, ToData a) => [(k, a)] -> Map k a #

Unsafely create an Map from a sums of products list of pairs. This should _only_ be applied to lists which have been checked to not contain duplicate keys, otherwise the resulting Map will contain conflicting entries (two entries sharing the same key), and therefore be ill-defined. Warning: this requires traversing the list and encoding the keys and values, so it should be avoided in favor of unsafeFromBuiltinList if the input is already in BuiltinData form.

safeFromSOPList :: (ToData k, ToData a) => [(k, a)] -> Map k a #

Create an Map from a sums of products list of key-value pairs. In case of duplicates, this function will keep only one entry (the one that precedes). In other words, this function de-duplicates the input list. Warning: this function is very slow. If you know that the input list does not contain duplicate keys, use one of the unsafe functions instead.

toSOPList :: (UnsafeFromData k, UnsafeFromData a) => Map k a -> [(k, a)] #

Convert the Map to a list of key-value pairs. This operation is O(n). See toBuiltinList for a more efficient alternative.

toBuiltinList :: Map k a -> BuiltinPair BuiltinData BuiltinData) #

Convert the Map to a BuiltinList of key-value pairs. This operation is O(1).

Newtypes and hash types

newtype ScriptHash #

Type representing the BLAKE2b-224 hash of a script. 28 bytes.

This is a simple type without any validation, use with caution. You may want to add checks for its invariants. See the Shelley ledger specification.

Instances

Instances details
RepIsStuckError Redeemer :: Type -> Type) (Rep Redeemer)))

newtype RedeemerHash #

Type representing the BLAKE2b-256 hash of a redeemer. 32 bytes.

This is a simple type without any validation, use with caution. You may want to add checks for its invariants. See the Shelley ledger specification.

Instances

Instances details
RepIsStuckError Datum :: Type -> Type) (Rep Datum)))

newtype DatumHash #

Type representing the BLAKE2b-256 hash of a datum. 32 bytes.

This is a simple type without any validation, use with caution. You may want to add checks for its invariants. See the Shelley ledger specification.

Instances

Instances details
RepIsStuckError DatumHash :: Type -> Type) (Rep DatumHash)))

Data

data Data #

A generic "data" type.

The main constructor Constr represents a datatype value in sum-of-products form: Constr i args represents a use of the ith constructor along with its arguments.

The other constructors are various primitives.

Constructors

Constr DefaultUni Data)

data BuiltinData #

A type corresponding to the Plutus Core builtin equivalent of Data.

The point of this type is to be an opaque equivalent of Data, so as to ensure that it is only used in ways that the compiler can handle.

As such, you should use this type in your on-chain code, and in any data structures that you want to be representable on-chain.

For off-chain usage, there are conversion functions builtinDataToData and dataToBuiltinData, but note that these will not work on-chain.

Constructors

BuiltinData ~Data 

Instances

Instances details
BuiltinBLS12_381_G1_Element

For the BLS12-381 G1 and G2 types we use the compress functions to convert to a ByteString and then encode that as Data as usual. We have to be more careful going the other way because we decode a Data object to (possibly) get a BuiltinByteString and then uncompress the underlying ByteString to get a group element. However uncompression can fail so we have to check what happens: we don't use bls12_381_G?_uncompress because that invokes error if something goes wrong (but we do use it for unsafeFromData).

Instance details

Defined in BuiltinBLS12_381_MlResult

We do not provide instances of any of these classes for BuiltinBLS12_381_MlResult since there is no serialisation format: we expect that values of that type will only occur as the result of on-chain computations.

Instance details

Defined in PlutusTx.IsData.Class

Methods

toBuiltinData :: [a] -> BuiltinData #

(ToData k, ToData v) => ToData (Map k v)

Hand-written instances to use the underlying Map type in Data, and to be reasonably efficient.

Instance details

Defined in PlutusTx.IsData.Class

(FromData k, FromData v) => FromData (Map k v)

A hand-written transformation from Data to Map. Compared to unsafeFromBuiltinData, it is safe to call when it is unknown if the Data is built with Datas Map constructor. Note that it is, however, unsafe in the sense that it assumes that any map encoded in the Data is well-formed, i.e. fromBuiltinData does not perform any deduplication of keys or of key-value pairs!

Instance details

Defined in error if this fails. This is typically much faster than fromBuiltinData.

When implementing this function, make sure to call unsafeFromBuiltinData rather than fromBuiltinData when converting substructures!

This is a simple type without any validation, use with caution.

Instances

Instances details
UnsafeFromData PlutusTx.IsData.Class

(UnsafeFromData k, UnsafeFromData v) => UnsafeFromData (Map k v)

A hand-written transformation from Data to Map. It is unsafe because the caller must provide the guarantee that the Data is constructed using the Datas Map constructor. Note that it assumes, like the fromBuiltinData transformation, that the map encoded in the Data is well-formed, i.e. unsafeFromBuiltinData does not perform any deduplication of keys or of key-value pairs!

Instance details

Defined in These a b #

toData :: ToData a => a -> Data #

Convert a value to Data.

Note: off-chain only.

fromData :: FromData a => Data -> Maybe a #

Convert a value from Data, returning Nothing if this fails.

Note: off-chain only.

unsafeFromData :: UnsafeFromData a => Data -> a #

Convert a value from Data, throwing if this fails.

Note: off-chain only.

dataToBuiltinData :: Data -> BuiltinData #

NOT a builtin. Converts a Data into a BuiltinData. Only works off-chain.

builtinDataToData :: BuiltinData -> Data #

NOT a builtin. Converts a BuiltinData into a Data. Only works off-chain.

Errors

class Monad m => MonadError e (m :: Type -> Type) | m -> e #

The strategy of combining computations that can throw exceptions by bypassing bound functions from the point an exception is thrown to the point that it is handled.

Is parameterized over the type of error information and the monad type constructor. It is common to use Either String as the monad type constructor for an error monad in which error descriptions take the form of strings. In that case and many other common cases the resulting monad is already defined as an instance of the MonadError class. You can also define your own error type and/or use a monad type constructor other than Either String or Either IOError. In these cases you will have to explicitly define instances of the MonadError class. (If you are using the deprecated Control.Monad.Error or Control.Monad.Trans.Error, you may also have to define an Error instance.)

Minimal complete definition

BuiltinFailure logs. This is to compensate for the historical lack of error message content in operational errors (structural ones don't have this problem) in our evaluators (the CK and CEK machines). It would be better to fix the underlying issue and allow operational evaluation errors to carry some form of content, but for now we just fix the symptom in order for the end user to see the error message that they are supposed to see. The fix even makes some sense: what we do here is we emulate logging when the thrown unlifting error is an operational one, i.e. this is similar to what some builtins do manually (like when a crypto builtin fails and puts info about the failure into the logs).

Instance details

Defined in FreeVariableError

An error in the pre-evaluation step of converting from de-Bruijn indices

CodecError !ScriptDecodeError

A deserialisation error TODO: make this error more informative when we have more information about what went wrong

CostModelParameterMismatch

An error indicating that the cost model parameters didn't match what we expected

InvalidReturnValue

The script evaluated to a value that is not a valid return value.

Instances

Instances details
DeserialiseFailureInfo

an error from the underlying CBOR/serialise library

RemainderError !ByteString

Script was successfully parsed, but more (runaway) bytes encountered after script's position

LedgerLanguageNotAvailableError

the plutus version of the given script is not enabled yet

Fields

PlutusCoreLanguageNotAvailableError 

Fields

Instances

Instances details
Doc ann #