In lecture 3 of the Plutus Pioneer Program Vesting.hs, I noticed that the example vesting give/ grab endpoints work by waiting a number of slots after the deadline. The script then checks deadlineReached = contains (from $ deadline dat) $ txInfoValidRange info.

However, these docs for txInfoValidRange say that the default range is infinite. In the lecture video and in the playground, I don't see that we set the txInfoValidRange explicitly, so I assumed it was infinite, but that means a from range would never contain it.

I must be misunderstanding the linked documentation. At some point, the txValidRange must be getting set on the transactions submitted through the playground, otherwise, deadlineReached would always be false. I can't find where this default is being set though.

Is this set by Plutus clients? In this case, the Playground?

There is a related question here, but I understand the contains function. What I don't understand is how the txInfoValidRange is set.


1 Answer 1


This is the flow from Playground to the onchain validator:

Playground (grab) --> endpoints --> grab (offchain contract) --> validator (onchain).

txInfoValidRange is set by grab (offchain contract) in the following expression:

[line 115-117]

tx :: TxConstraints Void Void
tx = mconcat [Constraints.mustSpendScriptOutput oref unitRedeemer | oref <- orefs] <>
             Constraints.mustValidateIn (from now)

where Constraints.mustValidateIn (from now) specifically establishes that the transaction being built must validate from now to the eternity. If you don't set this Constraint, the default txInfoValidRange (all the time) will set.

  • Ahh, that was the gap in my understanding. The off chain code runs first and sets the TxInfo ValidRange. The validator run onchain and validates the transaction submitted by the offchain code.
    – Eric H.
    Commented Feb 17, 2022 at 5:51

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.