Transaction submit error on Testnet for time-locked policy script

I have set up a native token on the Cardano Testnet and for a simple minting policy, it works correctly, that is, I am able to mint the new token. For example, if I use the following policy script:

{
  "type": "sig",
  "keyHash": "key_hash_here"
}

It works correctly. However, if I use a more complex script like a time-locked policy like this:

{
  "type": "all",
  "scripts":
  [
    {
      "type": "before",
      "slot": 24026549
    },
    {
      "type": "sig",
      "keyHash": "key_hash_here"
    }
  ]
}

It does not work and gives me the following error:
‘Command failed: transaction submit Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraMary (ApplyTxError [LedgerFailure (UtxowFailure (ScriptWitnessNotValidatingUTXOW (fromList [ScriptHash “37c55dfc86332c58613f40f43b2d074f22153b0602c4701a1a50e4a5”])))])’

The signing transaction is as follows:

cardano-cli transaction sign \
	     --signing-key-file pay.skey \
	     --signing-key-file policy/policy.skey \
	     --script-file policy/policy.script \
	     --testnet-magic 1097911063 \
	     --tx-body-file matx.raw \
         --out-file matx.signed

My guess is that I’m missing a signature, but not sure which one.

I found the answer. In the build transaction, an additional parameter should be added:

--invalid-hereafter 24028537

This should be the same value entered in the policy script under the before section for the slot.

The question remains however is what parameter should be we use if we have multiple optional conditions, for before and after.

4 Likes

Thank you so much for the solution. I got the same problem and now it’s fixed. Thanks

1 Like

If one has multiple before and after conditions in the script, then one needs to use --invalid-before and --invalid-after parameters that match the script condition that is valid for the current slot (and thereabouts). Basically, the command-line parameters need to constrain the submitted transaction to slot numbers for which the script will be certain to validate and the current slot (the tip of the blockchain) needs to fall within those slot numbers, too.

oh thanks! I lost two hours for this hahah it was so simple! thank you again!

1 Like