Plutus.V1.Ledger.Credential
1. 📜 Overview
2. 🔧 LANGUAGE EXTENSIONS AND IMPORTS
3. 🗄️ Data Types
3.1 🌾 StakingCredential
3.2 🛂 Credential
4. 🤝 Typeclass Instances
5. 🏭 On‑chain Derivations
6. 📚 Glossary
1 📜 Overview
The Plutus.V1.Ledger.Credential module defines how spending and staking rights are represented on‑chain:
StakingCredential: credentials used for staking rewards.Credential: credentials required to unlock a transaction output (either a public key or a script).Implements
Prettyand on‑chain equality (PlutusTx.Eq) for both types.Derives serialization and lifting instances for on‑chain use.
2 🔧 LANGUAGE EXTENSIONS AND IMPORTS
Pragmas:
DataKinds,DeriveAnyClass,DerivingVia,OverloadedStrings,TemplateHaskellfor deriving and on‑chain support.Compiler options to control specialization and interface pragmas.
Imports:
NFData,Genericfor deep evaluation and generic deriving.PubKeyHash,ValidatorHashfor credential types.PlutusTxmodules for on‑chain equality and serialization.Prettyprinterfor human‑readable instances.
3 🗄️ Data Types
3.1 🌾 StakingCredential
Constructors:
StakingHash Credential: staking via a hash of a payment credential.StakingPtr i j k: pointer to a certificate (slot, tx index, cert index).
Use case: associates staking rewards with credentials.
3.2 🛂 Credential
Constructors:
PubKeyCredential pkh: unlocked by a signature matchingpkh.ScriptCredential vh: unlocked by providing a validator script with hashvh.
Use case: specifies how an output can be spent.
4 🤝 Typeclass Instances
Class:
PrettyfromPrettyprinter.Behavior: formats each constructor with its contents.
Class:
EqfromPlutusTx, used in on‑chain code.Behavior: memberwise equality,
INLINABLEfor compiler support.
Formats credentials with labels.
Compares credentials by matching constructor and underlying hash.
5 🏭 On‑chain Derivations
makeIsDataIndexed: generates
IsDatafor serializing to Plutus Core, with explicit constructor indices.makeLift: generates
Liftinstances to embed Haskell values in on‑chain code.
6 📚 Glossary
StakingCredential: credential for staking rewards, either hash or pointer.
Credential: spending credential, either public key or script hash.
PubKeyHash: hash of a public key.
ValidatorHash: hash of a validator script.
NFData: class for deep (normal form) evaluation.
Generic: GHC generics for deriving boilerplate.
Pretty: class for pretty printing.
PlutusTx.Eq: on‑chain equality class.
makeIsDataIndexed: Template Haskell for on‑chain data serialization.
makeLift: Template Haskell for lifting values into PlutusTx code.
Last updated