Validator.

A pure script that gates a UTxO. Returns pass or fail given Datum, Redeemer and Script Context.

Think of it as

A bouncer at the door of a UTxO. Reads the note pinned to the box (datum), checks the wristband you brought (redeemer), looks at who is in the room (context), then decides yes or no.

In depth

A validator (sometimes called a script or smart contract on Cardano) is a pure function that decides whether a UTxO can be spent given its Datum, the Redeemer and the Script Context. At the Plutus Core level, validators signal success by returning unit and failure by raising an error. The Plutus V3 surface (and high-level languages like Aiken) lets you write validators that return Bool, which the compiler translates to the underlying convention. Either way, the UTxO can only be spent when the validator succeeds. Validators are stateless: any state lives in the Datum of the UTxO they protect.

Example

A "signature required" validator checks that the spending transaction is signed by the address listed in the Datum.

Try it interactively Run a validator with different datum + redeemer combos

Next on this path

  1. Datum Custom data attached to an eUTxO. Acts as the “state” of a smart contract output.
  2. Redeemer Data supplied by the spender of an eUTxO. The “action” passed into the validator.
  3. Script Context The full transaction visible to a validator: inputs, outputs, fees, signatories, time range.