#
Vesting Example
By
#
Script Contexts
Lecture 3, Part 2
Remember that a validator takes 3 arguments:
- Datum
- Redeemer
- Script context
The script context is the focus of this lecture. The type is defined in
Plutus.V1.Ledger.API
.
That package must be added to your Cabal configuration when you want to use
ScriptContext
. The module is defined in Plutus.V2.Ledger.Contexts
Its constructor looks like this:
ScriptContext
scriptContextTxInfo :: TxInfo
scriptContextPurpose :: ScriptPurpose
The purpose can be one of:
- Minting
- Spending (the one we've been most concerned with)
- Rewarding
- Certifying
TxInfo describes much information about the transaction:
- Inputs
- Outputs - think about inputs and outputs as they relate to the UTxO model
- Fee
- Forge - the amount of newly forged native tokens
- DCert
- Wdrl - staking withdrawals / rewards
- ValidRange - the time range the tx is valid for
- Signatories - any signatures provided (list of public keys)
- Data - scripts that spend an output need to include the datum. Scripts that send money to a script provide the has of the datum
- Id