I have Homework1 of week 5, and it works in the repl (meaning, the test gives the expected result). However, when I try the script in the playground (and remove the test - I don't think that makes a big difference, though, and I removed the line module ...), it's stuck on slot 1, at the bottom:

("txSignatures",Array []),("txValidRange",Object (fromList [("ivFrom",Array [Object (fromList [("tag",String "NegInf")]),Bool True]),("ivTo",Array [Object (fromList [("tag",String "PosInf")]),Bool True])]))])),("unBalancedTxUtxoIndex",Array []),("unBalancedTxValidityTimeRange",Object (fromList [("ivFrom",Array [Object (fromList [("tag",String "NegInf")]),Bool True]),("ivTo",Array [Object (fromList [("contents",Number 1.596059152999e12),("tag",String "Finite")]),Bool True])]))]))])),("mkTxLogTxConstraints",Object (fromList [("txConstraints",Array [Object (fromList [("contents",Array [String "aea02b83a8e055c06b768c2fcbf1101422b78405892b5027144ddb3b",String "d87980",Object (fromList [("unTokenName",String "ABC")]),Number 5.0]),("tag",String "MustMintValue")]),Object (fromList [("contents",Object (fromList [("ivFrom",Array [Object (fromList [("tag",String "NegInf")]),Bool True]),("ivTo",Array [Object (fromList [("contents",Number 1.596059152999e12),("tag",String "Finite")]),Bool True])])),("tag",String "MustValidateIn")])]),("txOwnInputs",Array []),("txOwnOutputs",Array [])]))])
, Slot 1: 00000000-0000-4000-8000-000000000000 {Wallet W872c}:
            Handled request:   Iteration 3 request ID 1
                               Response: "{\"contents\":1596059092999,\"tag\":\"CurrentTime
, Slot 1: 00000000-0000-4000-8000-000000000000 {Wallet W872c}:
            Current requests (1):   Iteration 4 request ID 1
                                    Request: "{\"contents\":{\"unBalancedTxRequiredSignatories\
, Slot 1: 00000000-0000-4000-8000-000000000000 {Wallet W872c}:
            Handled request:   Iteration 4 request ID 1
                               Response: "{\"contents\":{\"contents\":{\"contents\":{\"cont
, Slot 1: 00000000-0000-4000-8000-000000000000 {Wallet W872c}:
            Current requests (0): 
, Slot 1: 00000000-0000-4000-8000-000000000000 {Wallet W872c}:
            Contract instance stopped with error: "WalletError (ValidationError (ScriptFailure (EvaluationError [\"PT5\"] \"CekEvaluationFailure\")))" ]

I don't really understand why the script fails in the playground, while it works perfectly fine in the repl. How to try out the same script in the repl?


== EDIT 15/02/2022

The code: https://gitlab.com/moment-4/courses/plutus-pioneer/plutus-pioneer-program/-/blob/week05/code/week05/src/Week05/Homework1.hs

The important lines (I think):

mkPolicy :: PaymentPubKeyHash -> POSIXTime -> () -> ScriptContext -> Bool
mkPolicy pkh deadline () ctx = 
   txSignedBy txInfo (unPaymentPubKeyHash pkh) &&
      to deadline `contains` txInfoValidRange txInfo
         where txInfo :: TxInfo
               txInfo = scriptContextTxInfo ctx

policy :: PaymentPubKeyHash -> POSIXTime -> Scripts.MintingPolicy
policy pkh deadline = mkMintingPolicyScript $
   $$(PlutusTx.compile [|| mintingPolicyScript ||])
   PlutusTx.liftCode pkh
   PlutusTx.liftCode deadline
         mintingPolicyScript :: PaymentPubKeyHash -> POSIXTime -> Scripts.WrappedMintingPolicyType
         mintingPolicyScript = \pkh' deadline' -> Scripts.wrapMintingPolicy $ mkPolicy pkh' deadline' 

curSymbol :: PaymentPubKeyHash -> POSIXTime -> CurrencySymbol
curSymbol = \pkh' deadline' -> scriptCurrencySymbol (policy pkh' deadline')
  • Can you share your code?
    – kindofdev
    Commented Feb 14, 2022 at 19:23
  • yes, sure, see edit in my description. Thx.
    – Kurt Sys
    Commented Feb 15, 2022 at 16:58

1 Answer 1


I've reproduced exactly the same scenario in the tests (homework 1) over the playground with your code and it works as expected: first attempt mints and second one fails because deadline. Most probably the issue is related to your input. (deadline is posixtime, not slots)

enter image description here

deadline = 1596059191000 . I got it doing in the repl:

import Ledger.TimeSlot
import Data.Default 
slotToBeginPOSIXTime def 100  -- slot 100

enter image description here


After reading your comment the issue comes from this line in offchain code:

Constraints.mustValidateIn (to $ now + 60000)

because the tx doesn't pass the validRange pre-validation phase. If you play using a lower value you'll this in action.

As a side note, this is not a playground thing. You can test with Emulator Trace and won't be able to mint (probably with a different error message).

Hope this is useful.

  • Thx. When I use 100 slots (converted to POSIXTime), it works fine. When I use only 10 slots, it fails. So it seems the first transaction fails depending on the deadline. After bisecting, it seems that it only works if the deadline > POSIXTime of slot 61 (1596059152000) . Any idea why? Can it be because the deadline is already passed (time for compilation etc, but in that case, ~60 slots seems a lot)?
    – Kurt Sys
    Commented Feb 15, 2022 at 20:11
  • Do you mean 10 slots as deadline?
    – kindofdev
    Commented Feb 15, 2022 at 20:16
  • yes, exactly. 10 slots (converted to POSIXTime) - it only works if it's >61 slots (on my laptop), converted to POSIXTime
    – Kurt Sys
    Commented Feb 15, 2022 at 20:23
  • Yeah, that's it, thanks - and yes, extremely useful!! I forgot about that weird now + 60000. That was kind of a hacky solution to get it right - and hacky solutions result often in unexpected results. Anyway, it all makes perfect sense now, great.
    – Kurt Sys
    Commented Feb 16, 2022 at 7:30

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.