TimeLock policies

Let’s go by example:

{
  "type": "all",
  "scripts":
  [
    {
      "type": "before",
      "slot": 58500000
    },
    {
      "type": "sig",
      "keyHash": "XXXXXXXXX"
    }
  ]
}

This says that tokens under this policy can be minted (or burned, which is just minting with a negative amount) if all of the following are satisfied: the slot is before 58 500 000 (which is in a little more than three months) and the transaction is signed by XXXXXXXXX.

So, an after wouldn’t make much sense, here. You can only mint after that slot, but you then couldn’t submit a transaction with this policy before that slot, anyway.

You want this type of script, probably.

But why does after exist, when it makes not so much sense? If we take a slightly more complicated example:

{
  "type": "any",
  "scripts":
  [
    {
      "type": "all",
      "scripts":
      [
        {
          "type": "before",
          "slot": 58500000
        },
        {
          "type": "sig",
          "keyHash": "XXXXXXXXX"
        }
      ]
    },
    {
      "type": "all"
      "scripts":
      [
        {
          "type": "after",
          "slot": 58500000
        },
        {
          "type": "sig",
          "keyHash": "YYYYYYYYY"
        },
        {
          "type": "sig",
          "keyHash": "ZZZZZZZZZ"
        }
      ]
    }
  ]
}

Under this policy, the token can be minted if any of the following are satisfied:

  • all of before slot 58 500 000 and signed by XXXXXXXXX, or
  • all of after slot 58 500 000 and signed by YYYYYYYYY and ZZZZZZZZZ

So, the right to mint is transferred from one key to two other keys at that point in time. In this case (if someone wants that for whatever reason), an after makes sense.

The most complete documentation of these scripts that I have found is at https://github.com/input-output-hk/cardano-node/blob/master/doc/reference/simple-scripts.md#json-script-syntax.