I believe the best way to answer this question would be to give examples of the type of information that the script context could contain.

2 Answers 2


The context includes two parts: TxInfo and ScriptPurpose.

data ScriptContext = ScriptContext{
    scriptContextTxInfo :: TxInfo, 
    scriptContextPurpose :: ScriptPurpose 

When people are talking about the script context, they are often referring to the data in TxInfo found here:

data TxInfo = TxInfo
    { txInfoInputs      :: [TxInInfo] -- ^ Transaction inputs
    , txInfoOutputs     :: [TxOut] -- ^ Transaction outputs
    , txInfoFee         :: Value -- ^ The fee paid by this transaction.
    , txInfoMint        :: Value -- ^ The 'Value' minted by this transaction.
    , txInfoDCert       :: [DCert] -- ^ Digests of certificates included in this transaction
    , txInfoWdrl        :: Map StakingCredential Integer -- ^ Withdrawals
    , txInfoValidRange  :: POSIXTimeRange -- ^ The valid range for the transaction.
    , txInfoSignatories :: [PubKeyHash] -- ^ Signatures provided with the transaction, attested that they all signed the tx
    , txInfoRedeemers   :: Map ScriptPurpose Redeemer
    , txInfoData        :: Map DatumHash Datum
    , txInfoId          :: TxId

This includes information about the entire transaction. So if you are using multiple scripts you can see what is being spent/minted/burned/etc with all the scripts you are accessing. Many smart contracts are made up of multiple scripts, all accessed at the same time. At the risk of stating the obvious, understanding what information is available for all the scripts in a transaction, i.e. the TxInfo, is fundamental to architecting smart contracts with Plutus.

  • 1
    Thank you for the great and clear answer. Looking at the data structures is indeed a very good way to look at this.
    – FTM
    Commented Oct 29, 2021 at 17:26

Aiming to contribute to the great answer from Mitchell, I'll add this:

Script context can be understood like the summary of the transaction and can be used to validate it. This includes all inputs txInfoInputs and outputs txInfoOutputs (and more!) of the transaction, those inputs and outputs are UTxOs.

Let's take an example from Lesson 06 (on Oracles) of the Plutus Pioneer Program:

enter image description here

In this example we can find two transactions, let's examine the first one:

Tx 1: this transaction contains 3 inputs txInfoInputs and 3 outputs txInfoOutputs

  • Inputs: UTxOs consumed by the current transaction
  1. UTxO of Oracle script
  2. UTxO of Swap script
  3. UTxO of Buyer
  • Outputs: UTxOs generated by the current transaction
  1. UTxO of Oracle script
  2. UTxO of Seller
  3. UTxO of Buyer

You can use all of those UTxOs to run any kind of validation from your validator script. So far, that's related to two fields of TxInfo. But there is more to explore: Mitchell answer, as you can also combine your validation with a Minting policy for example.

For more information, you can check following links:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.