<p>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)</p>
<p><a href="https://i.sstatic.net/tiaeU.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/tiaeU.png" alt="enter image description here" /></a></p>
<p>deadline = 1596059191000 . I got it doing in the repl:</p>
<pre><code>import Ledger.TimeSlot
import Data.Default 
slotToBeginPOSIXTime def 100  -- slot 100
</code></pre>
<p><a href="https://i.sstatic.net/Aj1fq.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Aj1fq.png" alt="enter image description here" /></a></p>
<p><strong>EDIT 1</strong></p>
<p>After reading your comment the issue comes from this line in offchain code:</p>
<p><code>Constraints.mustValidateIn (to $ now + 60000)</code></p>
<p>because the tx doesn't pass the validRange pre-validation phase. If you play using a lower value you'll this in action.</p>
<p>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).</p>
<p>Hope this is useful.</p>

CC BY-SA 4.0
2022-02-15T20:11:36.910Z
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
CC BY-SA 4.0
2022-02-15T20:16:50.450Z
Do you mean 10 slots as deadline?
kindofdev
CC BY-SA 4.0
2022-02-15T20:23:06.013Z
yes, exactly. 10 slots (converted to POSIXTime) - it only works if it's >61 slots (on my laptop), converted to POSIXTime
Kurt Sys
CC BY-SA 4.0
2022-02-16T07:30:19.100Z
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
CC BY-SA 4.0
2022-02-15T18:11:54.953Z
2022-02-15T20:27:29.770Z
2022-02-15T20:27:29.770Z
kindofdev
<p>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 <code>module ...</code>), it's stuck on slot 1, at the bottom:</p>
<pre><code>(&quot;txSignatures&quot;,Array []),(&quot;txValidRange&quot;,Object (fromList [(&quot;ivFrom&quot;,Array [Object (fromList [(&quot;tag&quot;,String &quot;NegInf&quot;)]),Bool True]),(&quot;ivTo&quot;,Array [Object (fromList [(&quot;tag&quot;,String &quot;PosInf&quot;)]),Bool True])]))])),(&quot;unBalancedTxUtxoIndex&quot;,Array []),(&quot;unBalancedTxValidityTimeRange&quot;,Object (fromList [(&quot;ivFrom&quot;,Array [Object (fromList [(&quot;tag&quot;,String &quot;NegInf&quot;)]),Bool True]),(&quot;ivTo&quot;,Array [Object (fromList [(&quot;contents&quot;,Number 1.596059152999e12),(&quot;tag&quot;,String &quot;Finite&quot;)]),Bool True])]))]))])),(&quot;mkTxLogTxConstraints&quot;,Object (fromList [(&quot;txConstraints&quot;,Array [Object (fromList [(&quot;contents&quot;,Array [String &quot;aea02b83a8e055c06b768c2fcbf1101422b78405892b5027144ddb3b&quot;,String &quot;d87980&quot;,Object (fromList [(&quot;unTokenName&quot;,String &quot;ABC&quot;)]),Number 5.0]),(&quot;tag&quot;,String &quot;MustMintValue&quot;)]),Object (fromList [(&quot;contents&quot;,Object (fromList [(&quot;ivFrom&quot;,Array [Object (fromList [(&quot;tag&quot;,String &quot;NegInf&quot;)]),Bool True]),(&quot;ivTo&quot;,Array [Object (fromList [(&quot;contents&quot;,Number 1.596059152999e12),(&quot;tag&quot;,String &quot;Finite&quot;)]),Bool True])])),(&quot;tag&quot;,String &quot;MustValidateIn&quot;)])]),(&quot;txOwnInputs&quot;,Array []),(&quot;txOwnOutputs&quot;,Array [])]))])
, Slot 1: 00000000-0000-4000-8000-000000000000 {Wallet W872c}:
            Handled request:   Iteration 3 request ID 1
                               Response: &quot;{\&quot;contents\&quot;:1596059092999,\&quot;tag\&quot;:\&quot;CurrentTime
, Slot 1: 00000000-0000-4000-8000-000000000000 {Wallet W872c}:
            Current requests (1):   Iteration 4 request ID 1
                                    Request: &quot;{\&quot;contents\&quot;:{\&quot;unBalancedTxRequiredSignatories\
, Slot 1: 00000000-0000-4000-8000-000000000000 {Wallet W872c}:
            Handled request:   Iteration 4 request ID 1
                               Response: &quot;{\&quot;contents\&quot;:{\&quot;contents\&quot;:{\&quot;contents\&quot;:{\&quot;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: &quot;WalletError (ValidationError (ScriptFailure (EvaluationError [\&quot;PT5\&quot;] \&quot;CekEvaluationFailure\&quot;)))&quot; ]
</code></pre>
<p>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?</p>
<p>Thanks!</p>
<p><strong>== EDIT 15/02/2022</strong></p>
<p>The code: <a href="https://gitlab.com/moment-4/courses/plutus-pioneer/plutus-pioneer-program/-/blob/week05/code/week05/src/Week05/Homework1.hs" rel="nofollow noreferrer">https://gitlab.com/moment-4/courses/plutus-pioneer/plutus-pioneer-program/-/blob/week05/code/week05/src/Week05/Homework1.hs</a></p>
<p>The important lines (I think):</p>
<pre><code>mkPolicy :: PaymentPubKeyHash -&gt; POSIXTime -&gt; () -&gt; ScriptContext -&gt; Bool
mkPolicy pkh deadline () ctx = 
   txSignedBy txInfo (unPaymentPubKeyHash pkh) &amp;&amp;
      to deadline `contains` txInfoValidRange txInfo
         where txInfo :: TxInfo
               txInfo = scriptContextTxInfo ctx

policy :: PaymentPubKeyHash -&gt; POSIXTime -&gt; Scripts.MintingPolicy
policy pkh deadline = mkMintingPolicyScript $
   $$(PlutusTx.compile [|| mintingPolicyScript ||])
   `PlutusTx.applyCode`
   PlutusTx.liftCode pkh
   `PlutusTx.applyCode`
   PlutusTx.liftCode deadline
      where 
         mintingPolicyScript :: PaymentPubKeyHash -&gt; POSIXTime -&gt; Scripts.WrappedMintingPolicyType
         mintingPolicyScript = \pkh' deadline' -&gt; Scripts.wrapMintingPolicy $ mkPolicy pkh' deadline' 

curSymbol :: PaymentPubKeyHash -&gt; POSIXTime -&gt; CurrencySymbol
curSymbol = \pkh' deadline' -&gt; scriptCurrencySymbol (policy pkh' deadline')
</code></pre>

CC BY-SA 4.0
2022-02-14T19:23:33.803Z
Can you share your code?
kindofdev
CC BY-SA 4.0
2022-02-15T16:58:32.433Z
yes, sure, see edit in my description. Thx.
Kurt Sys
<plutus-pioneer-program><plutus-playground><error><week05>
what is "WalletError (ValidationError (ScriptFailure (EvaluationError [\"PT5\"] \"CekEvaluationFailure\")))" when trying in playground?
# what is "WalletError (ValidationError (ScriptFailure (EvaluationError [\"PT5\"] \"CekEvaluationFailure\")))" when trying in playground?

(Asked by: username_0 on 2022-02-14)

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?
Thanks!
== 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.applyCode`
   PlutusTx.liftCode pkh
   `PlutusTx.applyCode`
   PlutusTx.liftCode deadline
      where 
         mintingPolicyScript :: PaymentPubKeyHash -> POSIXTime -> Scripts.WrappedMintingPolicyType
         mintingPolicyScript = \pkh' deadline' -> Scripts.wrapMintingPolicy $ mkPolicy pkh' deadline' 

curSymbol :: PaymentPubKeyHash -> POSIXTime -> CurrencySymbol
curSymbol = \pkh' deadline' -> scriptCurrencySymbol (policy pkh' deadline')

**Tags:** plutus-pioneer-program, plutus-playground, error, week05
> **Comments:**
> **username_1**: Can you share your code?  
> **username_0**: yes, sure, see edit in my description. Thx.  

---

## 1 answers

### Answer by username_1 on 2022-02-15. Score: 1 | Accepted answer

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)

deadline = 1596059191000 . I got it doing in the repl:
import Ledger.TimeSlot
import Data.Default 
slotToBeginPOSIXTime def 100  -- slot 100


EDIT 1
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.

> **Comments:**
> **username_0**: 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)?  
> **username_1**: Do you mean 10 slots as deadline?  
> **username_0**: yes, exactly. 10 slots (converted to POSIXTime) - it only works if it's >61 slots (on my laptop), converted to POSIXTime  
> **username_0**: 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.  

---

