1

In Plutus scripts there is a mkValidator where it takes in the datum , redeemer , and script context. In the plutus-pionner-program , the plutus scripts they show us uses these three parameters to decide if a transaction will go through. I am looking at the the plutus-use-cases repo and in it most of the scrips dont do it the same why they do it in the lectures. How does this mkValidator work , what is the purpose of it , and is there additional resources that I can read or watch on this

2 Answers 2

3

A validator script locks transaction outputs. This function is where you define conditions to unlock them. https://plutus.readthedocs.io/en/latest/tutorials/basic-validators.html

2
  • Heads up that the link is dead now. Jul 13 at 4:59
  • Link has been corrected
    – james
    Jul 14 at 10:03
3

On Cardano logic can be enforced on how UTxO's are spend by attaching a "script" to the transaction + some inputs that will be used to run the script (the datum, redeemer and context). Visualize this script as a black box where the inputs go in and a boolean is the output. If given the inputs the black box return true, then the UTxO may be consumed (the enforced logic of the script is met).

In it core this script is generated from a haskell function that in the plutus-pioneer-program we often call the mkValidator function (it can have any name). This function should have at least 3 inputs, namely the datum, redeemer and context. But note that it can have more inputs that you could define! This mkValidator function is then compiled to a script that is used on the blockchain using template haskell. In this stage all function inputs are filled in expect the datum, redeemer and context (these should be filled in the usage on the blockchain when a UTxO connected to this script is consumed).

Hope this helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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