Plutus.V1.Ledger.Scripts
1. π Overview
2. π§ LANGUAGE PRAGMAS AND IMPORTS
3. ποΈ Core Types
3.1 π₯οΈ Script
3.2 π Validator, MintingPolicy, StakeValidator
3.3 π Datum, Redeemer, Context
3.4 π Hash Types
3.5 βοΈ ScriptError
4. βοΈ Key Functions
4.1 π scriptSize
4.2 π fromCompiledCode
4.3 ποΈ applyArguments
4.4 π evaluateScript
4.5 π¬ runScript / runMintingPolicyScript / runStakeValidatorScript
4.6 π applyValidator / applyMintingPolicyScript / applyStakeValidatorScript
4.7 π unitDatum, unitRedeemer
5. π€ Typeclass Instances
6. π On-Chain Derivations
7. π Glossary
1 π Overview
The Plutus.V1.Ledger.Scripts module provides the core abstractions and utilities for working with on-chain scripts in Plutus:
Script: opaque representation of a UPLC program.Wrappers:
Validator,MintingPolicy, andStakeValidatorfor specific script roles.Data wrappers:
Datum,Redeemer, andContextfor script inputs.Hash types:
ScriptHash,ValidatorHash,DatumHash, etc., for script identification.Evaluation: functions to apply and run scripts, extracting budgets and logs.
Utilities:
scriptSize,fromCompiledCode,applyArguments, and exampleunitDatum/unitRedeemer.
2 π§ LANGUAGE PRAGMAS AND IMPORTS
Extensive pragmas for generics, template Haskell, and disabling warnings for orphans and name shadowing.
Imports for serialization, ByteString, builtins, and untpye UPLC modules.
3 ποΈ Core Types
3.1 π₯οΈ Script
Opaque wrapper around UPLC
Program.Instances:
Generic,NFData,Serialisevia Flat.
3.2 π Validator, MintingPolicy, StakeValidator
Role-specific wrappers adding
Eq,Ord,Serialise,PrettyviaLedgerBytes.
3.3 π Datum, Redeemer, Context
Wrap
BuiltinDatafor script inputs and blockchain context.
3.4 π Hash Types
String literals via
IsString,Eq,Ord,ToData,FromData,UnsafeFromData,PrettyviaLedgerBytes.
3.5 βοΈ ScriptError
Captures expected user errors vs internal evaluation exceptions.
4 βοΈ Key Functions
4.1 π scriptSize
Returns serialized program size.
4.2 π fromCompiledCode
Converts GHC-compiled Plutus Tx code into nameless
Script.
4.3 ποΈ applyArguments
Applies a list of
Dataarguments to a UPLC program.
4.4 π evaluateScript
Runs the CEK evaluator, returning resource budget and log, or throws
ScriptError.
4.5 π¬ runScript / runMintingPolicyScript / runStakeValidatorScript
Helper functions combining application and evaluation.
4.6 π applyValidator / applyMintingPolicyScript / applyStakeValidatorScript
Applies wrapper types to produce a
Scriptwith applied arguments.
4.7 π unitDatum, unitRedeemer
Convenience values for
()data.
5 π€ Typeclass Instances
Eq Script,Ord Script: based on serialized bytes for alpha-equivalence.Show Script: prints<Script>placeholder.PrettyviaPrettyShowfor wrappers.FunctorforapplyArgumentsusesPLC.mkIterApp.
6 π On-Chain Derivations
Enables embedding these types in PlutusTx code.
7 π Glossary
UPLC: Untyped Plutus Core.
CEK: evaluation machine for Plutus Core.
BuiltinData: on-chain data type.
Script: on-chain program encoded as UPLC.
Validator/MintingPolicy/StakeValidator: typed script roles.
Datum/Redeemer/Context: inputs to validators.
ScriptHash/ValidatorHash/etc.: hashed identifiers for scripts.
CompiledCode: code produced by PlutusTx compiler plugin.
SerialiseViaFlat: CBOR using Flat serialization for programs.
ProgramSize: approximate resource usage metric.
Alpha-equivalence: program equality modulo renaming.
Last updated