The error that you are getting is due to you are using an invalid redeemer: Redeemer $ Builtins.mkI 17
. The validation script needs () as redeemer. You should use unitRedeemer
. In this case the error is producedoccurs when the offchain part tries to build the transaction, so. Having said that you cannot debug onchain because it never reaches the validator.
tx = mconcat [Constraints.mustSpendScriptOutput oref $ Redeemer $ Builtins.mkI 17 | oref <- orefs]
On other hand, if you fix this, it will fail again because you don't set the time validation constraint in offchain code Constraints.mustValidateIn (from now)
. If you don't set it, the default validity interval is "all the time", and the validator will fail with "deadline not reached".
Additionally, if you fix these two things (valid redeemer and time constraint), it will fail in grab because it will try to spend all UTXOs (the good ones and the others) sitting at the script address, and the validator will reject the transaction.