Plutus.V2.Ledger.EvaluationContext
- Plutus V2 EvaluationContext TutorialTable of Contents
📖 Introduction
🔙 Module Re-exports 2.1 🔄 Re-exporting V1.EvaluationContext
⚙️ Cost Model Parameter Names 3.1 ⚙️ costModelParamNames
📝 Code Walkthrough
📖 Glossary of Terms
1. 📖 IntroductionThis tutorial covers the
Plutus.V2.Ledger.EvaluationContext
module, which builds upon the V1 evaluation context and exposes the set of valid cost model parameter names for Plutus V2.2. 🔙 Module Re-exports2.1 🔄 Re-exporting V1.EvaluationContext
module Plutus.V2.Ledger.EvaluationContext ( module V1.EvaluationContext , costModelParamNames ) where import Plutus.V1.Ledger.EvaluationContext as V1.EvaluationContext hiding (costModelParamNames)
What happens here: The entire V1 evaluation context API is made available under V2, except the old
costModelParamNames
, so you can reuse all existing context-building functions.
3. ⚙️ Cost Model Parameter NamesThe key addition in this module is the
costModelParamNames
set, defining which cost model parameters are valid under Plutus V2.3.1 ⚙️ costModelParamNames
costModelParamNames :: Set.Set Text.Text costModelParamNames = Map.keysSet $ fromJust Plutus.defaultCostModelParams
Type:
Set.Set Text.Text
— a set of textual parameter names.Implementation:
Plutus.defaultCostModelParams
provides aMaybe (Map Text Text Integer)
of default parameters.fromJust
extracts the map (unsafe if defaults missing).Map.keysSet
yields the set of keys (parameter names).
4. 📝 Code WalkthroughImports:
Plutus.V1.Ledger.EvaluationContext
is brought in asV1.EvaluationContext
.PlutusCore.defaultCostModelParams
gives the V2 defaults.Standard Haskell libraries for
Map
,Maybe
,Set
, andText
.
Re-exporting: All V1 context functions (e.g.,
mkEvaluationContext
,CostModelApplyError
) are available without change.Parameter Names: Use this set to validate incoming cost model parameters when syncing on-chain cost settings.
5. 📖 Glossary of TermsTermDefinitionV1.EvaluationContext
The original Plutus V1 evaluation context API.
defaultCostModelParams
Built-in default cost-model parameters from Plutus Core.
Set.Set Text.Text
A collection of unique
Text
values.Map.keysSet
Extracts the set of keys from a
Map
.fromJust
Unsafe extractor from
Maybe
, crashes onNothing
.
Last updated