Plutus : Plutus.V1.Ledger Essentials
📌 Table of Contents
📁 What Is
Plutus.V1.Ledger?🧱 Core Modules Breakdown
📬 Working with Addresses
🔐 Working with Signatures & Keys
💰 Working with Values
🧾 Working with Transactions
🧪 Script Contexts & Purpose
🛠 Utilities (Time, Interval, etc.)
🧠 Glossary of Terms
🧪 Validator Script Examples
🔧 Typed Validator Wrappers
🧪 Emulator Trace Integration
1️⃣ 📁 What Is Plutus.V1.Ledger?
Plutus.V1.Ledger?Plutus.V1.Ledger is a collection of types and utilities from the Plutus smart contract platform used to build secure, type-safe smart contracts for Cardano. It includes definitions for:
Addresses
Transactions
Values
Script contexts
Signatures and more
2️⃣ 🧱 Core Modules Breakdown
Address
Work with Cardano addresses
Value
Represent and manipulate tokens
Tx, TxInfo
Transaction and transaction context
Scripts, ScriptContext
For writing validators
Contexts
Access to signatures, redeemers, datums
Interval, Slot, Time
Handling time and validity ranges
3️⃣ 📬 Working with Addresses
Addressis either a public key hash or a script hash.Use
scriptHashAddressto create an address from a validator script hash.
4️⃣ 🔐 Working with Signatures & Keys
PubKeyHash: Identifies wallets.txSignedBy :: TxInfo -> PubKeyHash -> Boolchecks if a transaction is signed by a given key.
5️⃣ 💰 Working with Values
Valueis a map ofCurrencySymbol -> TokenName -> Amount.Use
singletonto construct a token bundle:
Combine values using
+,-, orvalueOf.
6️⃣ 🧾 Working with Transactions
TxInfogives all information about the transaction.Key fields:
txInfoInputs,txInfoOutputstxInfoSignatoriestxInfoValidRange
Use it in validators:
7️⃣ 🧪 Script Contexts & Purpose
ScriptContext: Execution context of a Plutus script.ScriptPurpose: Why the script is running (e.g., Spending, Minting).
Access redeemer with
findOwnInput,findDatum, etc.
8️⃣ 🛠 Utilities (Time, Interval, etc.)
Use
POSIXTimeandPOSIXTimeRangefor timelocks.Example:
9️⃣ 🧠 Glossary of Terms
Address
Script or wallet hash for locking funds
Value
Multi-asset bundle of tokens
TxInfo
Transaction information (inputs, signers, outputs)
ScriptContext
Runtime context passed to validators
PubKeyHash
Hash of wallet public key
CurrencySymbol
Identifier for a token type
TokenName
Token label (e.g., "MyCoin")
POSIXTime
UTC time representation
Validator
Script that determines if a transaction is allowed
🔟 🧪 Validator Script Examples
🔐 Signature Check Validator
⏰ Timelock Validator
💸 Minimum ADA Sent to Address
1️⃣1️⃣ 🔧 Typed Validator Wrappers
1️⃣2️⃣ 🧪 Emulator Trace Integration
Use this with endpoints for lock/spend via submitTxConstraints.
✅ Summary
The Plutus.V1.Ledger module is your toolkit for interacting with the Cardano ledger when writing smart contracts. It provides powerful primitives to:
Read transaction data
Check authorization
Work with tokens and addresses
Enforce timelocks and intervals
Last updated