Safe Haskell | None |
---|---|
Language | Haskell2010 |
Functions for working with scripts on the ledger.
Synopsis
- newtype Script = Script {
- unScript :: Program DeBruijn DefaultUni DefaultFun ()
- scriptSize :: Script -> Integer
- fromCompiledCode :: CompiledCode a -> Script
- data ScriptError
- = EvaluationError [Text] String
- | EvaluationException String String
- evaluateScript :: forall m. MonadError ScriptError m => Script -> m (ExBudget, [Text])
- runScript :: MonadError ScriptError m => Context -> Validator -> Datum -> Redeemer -> m (ExBudget, [Text])
- runMintingPolicyScript :: MonadError ScriptError m => Context -> MintingPolicy -> Redeemer -> m (ExBudget, [Text])
- runStakeValidatorScript :: MonadError ScriptError m => Context -> StakeValidator -> Redeemer -> m (ExBudget, [Text])
- applyValidator :: Context -> Validator -> Datum -> Redeemer -> Script
- applyMintingPolicyScript :: Context -> MintingPolicy -> Redeemer -> Script
- applyStakeValidatorScript :: Context -> StakeValidator -> Redeemer -> Script
- applyArguments :: Script -> [Data] -> Script
- mkValidatorScript :: CompiledCode (BuiltinData -> BuiltinData -> BuiltinData -> ()) -> Validator
- newtype Validator = Validator {}
- unValidatorScript :: Validator -> Script
- newtype Redeemer = Redeemer {}
- newtype Datum = Datum {}
- mkMintingPolicyScript :: CompiledCode (BuiltinData -> BuiltinData -> ()) -> MintingPolicy
- newtype MintingPolicy = MintingPolicy {}
- unMintingPolicyScript :: MintingPolicy -> Script
- mkStakeValidatorScript :: CompiledCode (BuiltinData -> BuiltinData -> ()) -> StakeValidator
- newtype StakeValidator = StakeValidator {}
- unStakeValidatorScript :: StakeValidator -> Script
- newtype Context = Context BuiltinData
- newtype DatumHash = DatumHash BuiltinByteString
- newtype RedeemerHash = RedeemerHash BuiltinByteString
- newtype ScriptHash = ScriptHash {}
- newtype ValidatorHash = ValidatorHash BuiltinByteString
- newtype MintingPolicyHash = MintingPolicyHash BuiltinByteString
- newtype StakeValidatorHash = StakeValidatorHash BuiltinByteString
- unitRedeemer :: Redeemer
- unitDatum :: Datum
Scripts
A script on the chain. This is an opaque type as far as the chain is concerned.
Instances
Eq Script Source # | Note [Using Flat inside CBOR instance of Script] `plutus-ledger` uses CBOR for data serialisation and `plutus-core` uses Flat. The choice to use Flat was made to have a more efficient (most wins are in uncompressed size) data serialisation format and use less space on-chain. To make `plutus-ledger` work with scripts serialised with Flat, and keep the CBOR format otherwise we have defined a Serialise instance for Script, which is a wrapper over Programs serialised with Flat. The instance will see programs as an opaque ByteString, which is the result of encoding programs using Flat. Because Flat is not self-describing and it gets used in the encoding of Programs, data structures that include scripts (for example, transactions) no-longer benefit for CBOR's ability to self-describe it's format. |
Ord Script Source # | |
Defined in Plutus.V1.Ledger.Scripts | |
Show Script Source # | |
Generic Script Source # | |
NFData Script Source # | |
Defined in Plutus.V1.Ledger.Scripts | |
Serialise Script Source # | |
Defined in Plutus.V1.Ledger.Scripts encodeList :: [Script] -> Encoding decodeList :: Decoder s [Script] | |
type Rep Script Source # | |
Defined in Plutus.V1.Ledger.Scripts type Rep Script = D1 ('MetaData "Script" "Plutus.V1.Ledger.Scripts" "plutus-ledger-api-1.0.0.1-6EvbyJiK8IAAVEtnIJDu5Z" 'True) (C1 ('MetaCons "Script" 'PrefixI 'True) (S1 ('MetaSel ('Just "unScript") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Program DeBruijn DefaultUni DefaultFun ())))) |
scriptSize :: Script -> Integer Source #
The size of a Script
. No particular interpretation is given to this, other than that it is
proportional to the serialized size of the script.
fromCompiledCode :: CompiledCode a -> Script Source #
Turn a CompiledCode
(usually produced by compile
) into a Script
for use with this package.
data ScriptError Source #
EvaluationError [Text] String | Expected behavior of the engine (e.g. user-provided error) |
EvaluationException String String | Unexpected behavior of the engine (a bug) |
Instances
evaluateScript :: forall m. MonadError ScriptError m => Script -> m (ExBudget, [Text]) Source #
Evaluate a script, returning the trace log.
runScript :: MonadError ScriptError m => Context -> Validator -> Datum -> Redeemer -> m (ExBudget, [Text]) Source #
runMintingPolicyScript :: MonadError ScriptError m => Context -> MintingPolicy -> Redeemer -> m (ExBudget, [Text]) Source #
Evaluate a MintingPolicy
with its Context
and Redeemer
, returning the log.
runStakeValidatorScript :: MonadError ScriptError m => Context -> StakeValidator -> Redeemer -> m (ExBudget, [Text]) Source #
Evaluate a StakeValidator
with its Context
and Redeemer
, returning the log.
applyMintingPolicyScript :: Context -> MintingPolicy -> Redeemer -> Script Source #
Apply MintingPolicy
to its Context
and Redeemer
.
applyStakeValidatorScript :: Context -> StakeValidator -> Redeemer -> Script Source #
Apply StakeValidator
to its Context
and Redeemer
.
Script wrappers
mkValidatorScript :: CompiledCode (BuiltinData -> BuiltinData -> BuiltinData -> ()) -> Validator Source #
Instances
Eq Validator Source # | |
Ord Validator Source # | |
Defined in Plutus.V1.Ledger.Scripts | |
Show Validator Source # | |
Generic Validator Source # | |
NFData Validator Source # | |
Defined in Plutus.V1.Ledger.Scripts | |
Serialise Validator Source # | |
Defined in Plutus.V1.Ledger.Scripts encode :: Validator -> Encoding encodeList :: [Validator] -> Encoding decodeList :: Decoder s [Validator] | |
Pretty Validator Source # | |
Defined in Plutus.V1.Ledger.Scripts pretty :: Validator -> Doc ann prettyList :: [Validator] -> Doc ann | |
type Rep Validator Source # | |
Defined in Plutus.V1.Ledger.Scripts |
unValidatorScript :: Validator -> Script Source #
Redeemer
is a wrapper around Data
values that are used as redeemers in transaction inputs.
Instances
Datum
is a wrapper around Data
values which are used as data in transaction outputs.
Instances
mkMintingPolicyScript :: CompiledCode (BuiltinData -> BuiltinData -> ()) -> MintingPolicy Source #
newtype MintingPolicy Source #
MintingPolicy
is a wrapper around Script
s which are used as validators for minting constraints.
Instances
mkStakeValidatorScript :: CompiledCode (BuiltinData -> BuiltinData -> ()) -> StakeValidator Source #
newtype StakeValidator Source #
StakeValidator
is a wrapper around Script
s which are used as validators for withdrawals and stake address certificates.
Instances
Information about the state of the blockchain and about the transaction
that is currently being validated, represented as a value in Data
.
Instances
Hashes
Script runtime representation of a Digest SHA256
.
Instances
newtype RedeemerHash Source #
Script runtime representation of a Digest SHA256
.
Instances
newtype ScriptHash Source #
Script runtime representation of a Digest SHA256
.
Instances
newtype ValidatorHash Source #
Script runtime representation of a Digest SHA256
.
Instances
newtype MintingPolicyHash Source #
Script runtime representation of a Digest SHA256
.
Instances
newtype StakeValidatorHash Source #
Script runtime representation of a Digest SHA256
.
Instances
Example scripts
unitRedeemer :: Redeemer Source #
()
as a redeemer.