Skip to main content

makeValidator

Once on-chain contracts are not typed. Instead they only receive generic data arguments.

This is why makeValidator exsists.

the type signature is not too complicated:

export function makeValidator(
typedValidator: Term<
PLam<
PType,
PLam<
PType,
PLam<
typeof PScriptContext,
PBool
>
>
>
>,
errorMessage?: string
): TermFn<[PData,PData,PData], PUnit>

as you can see it takes any typed validator and returns a generic untyped validator so that the node will be able to evaluate it correctly.

use makeValidator only for spending scripts

as you can see; makeValidator expects a contract with 3 arguments.

this means it can only be used for contracts with Spending as PScriptPurpose

for all other purposes you likely want to use makeRedeemerValidator

errorMessage

Optionally you can pass a string that will be included in the on-chain script and passed to ptrace in case of failure