Questions after Native Token Policy creation

I’m looking to play around with creating a native token.

When building out the token policy script, I’m looking to add a time-lock with the invalidAfter function but I’m unable to find a source in the official Cardano documentation with the invalidAfter keyword. I do see the “after” and “before” keywords however…

I’m looking to generate a policy similar to this one:

{
   all: [
      {
         pubKeyHash: "721d21508287404332f35f43054bhc223g9ab3z73ad8333c160039f0"
      },
      {
         invalidAfter: 49422890
      }
   ]
}

Would anyone be able to shed some light on this for me, or point me to the right direction?

Thanks all!

In the JSON syntax accepted by cardano-cli this would have to look like:

{
  "type": "all",
  "scripts":
  [
    {
      "type": "sig",
      "keyHash": "721d21508287404332f35f43054bhc223g9ab3z73ad8333c160039f0"
    },
    {
      "type": "before",
      "slot": 49422890
    }
  ]
}

The documentation closest to the source I could find is:
https://github.com/input-output-hk/cardano-node-wiki/blob/main/docs/reference/simple-scripts.md
(I think it used to be in the cardano-node repository itself, but they somehow cleaned up there.)

https://developers.cardano.org/docs/native-tokens/minting-nfts#creating-the-policyid also tries to explain it.

I don’t know why there would have to be an invalidAfter keyword. They just chose to encode this as a type of "before" (note that it is inverse – if it shall be invalid after, it is required to be before) in their JSON syntax.

What is actually used on-chain is not this JSON syntax, anyway, but a translation of that into CBOR that is done by cardano-cli when you give such a file to it. If interested, the specification of that actual CBOR structure can be found at (this is for the current Conway era, there are equivalent places for the previous eras):

So, there are no keywords at all in the on-chain bytes, but integers 0 through 5 that encode this in an efficient way.

1 Like

Hey, this is a much greater response than I was expecting. Thanks a bunch!

1 Like