<p>A validator script locks transaction outputs. This function is where you define conditions to unlock them. <a href="https://plutus.readthedocs.io/en/latest/tutorials/basic-validators.html" rel="nofollow noreferrer">https://plutus.readthedocs.io/en/latest/tutorials/basic-validators.html</a></p>

CC BY-SA 4.0
2022-07-13T04:59:36.490Z
Heads up that the link is dead now.
Matthew Capps
CC BY-SA 4.0
2022-07-14T10:03:22.133Z
Link has been corrected
james
CC BY-SA 4.0
2022-04-19T10:40:59.707Z
2022-07-14T10:03:02.763Z
2022-07-14T10:03:02.763Z
james
<p>On Cardano logic can be enforced on how UTxO's are spend by attaching a &quot;script&quot; 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).</p>
<p>In it core this script is generated from a haskell function that in the plutus-pioneer-program we often call the <code>mkValidator</code> 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 <code>mkValidator</code> 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).</p>
<p>Hope this helps</p>

CC BY-SA 4.0
2022-04-06T15:02:28.037Z
2022-04-06T15:02:28.037Z
Fermat
<p>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</p>

<datum><redeemer><mkvalidator>
What is the mkValidator Script
# What is the mkValidator Script

(Asked by: username_0 on 2022-04-06)

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

**Tags:** datum, redeemer, mkvalidator

---

## 2 answers

### Answer by username_1 on 2022-04-19. Score: 3 | Accepted answer

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>

> **Comments:**
> **username_2**: Heads up that the link is dead now.  
> **username_1**: Link has been corrected  

---

### Answer by username_3 on 2022-04-06. Score: 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


---

