Proving a particular policy script constraint i.e 'before'

I have a basic native token policy script json file that ensures tokens can only be minted before a specific slot i.e.

 "scripts": [
         "keyHash": "b78665f860207c21675bc1127ec75d401d8461edcf8f4ac479555a27",
         "type": "sig"
         "slot": 25606303,
         "type": "before"
 "type": "all"

becomes policyId:956886f8b5ed5528b412c1b3b42ef49d81ea157addce042e59e84f38

My question is: how do I prove this to people, (prove that I can no longer mint tokens after said slot)?. I appreciate it gets hashed and becomes my policyId so it is as simple as sharing this file publicly (with full keyHash) and inviting people to run cardano-cli transaction policyid --script-file $SCRIPT on their own?

Feeling like i’ve misunderstood a key concept here, some clarification would be appreciated :slight_smile:


Yes, if you share this file publicly, perhaps via a link in the minting metadata, then someone knowledgeable can audit the minting by (1) viewing and studying the script, (2) verifying that it hashes to the policy ID, and (3) querying the ledger to see how many tokens were minted of each asset before the expiration slot.

Thanks :slight_smile: Cardano’s native assets are so elegant that it caused me to doubt myself! Glad to hear its this simple and I presume in time someone will make a nice web front end with a db to hold these script to hash mappings for public good :slight_smile:

1 Like

But how can a node verify the transaction without the script itself?

My understanding is that the nodes have the script when they verify the transaction: The script is part of the signed transaction, but only the script’s hash (not the whole script) is in the transaction body and stored on the blockchain after the transaction has been verified. The Plutus Book discusses this, and the Ledger Specification implicitly describes this.

1 Like

But where do they get the script,when i start up a node a month later and it revalidates the blockchain?

1 Like

I don’t think they can get the script later, and I don’t think that a node you start months later actually validates every past transaction. Rather, it discovers the consensus of past validations of block-producing nodes, as embodied in the state of the blockchain among all the nodes.

The specifics should be described in the documentation for Ouroboros. These great questions of yours are motivating me to dig into the Ouroboros papers and videos. I’ll post any clarifications or elaborations in this thread.

One implication of this situation is that one needs an off-chain record of scripts and contracts, if they will be later used or audited. (This is my motivation, for instance, for storing a “permanent” copy of my NFT-minting scripts on IPFS.)

1 Like

ok means we have to trust the stake-pool node that he validated the transaction’s script correctly… sounds sketchy

Every stakepool node attempts to verify the transaction, and the consensus of the stakepool nodes determines whether the transaction is valid and added to the blockchain. So we really need to trust the majority of the stakepools, the Ouroboros consensus protocol, and the correctness of its software implementation. There is an animation and game illustrating Ouroboros here and a video here.


Someone found out it is actually stored in the cahin


1 Like

Thanks again for pointing me to the link with documentation. I was able to use this information to retrieve all the scripts that have witnessed transactions on mainnet so far. It’s interesting to see what sort of scripts people are using:

Policy Description Number of Policies
before 2
keyHash 1345
keyHash and before 2945
keyHash or after 1
before and after 1
keyHash and keyHash 2
before and after and keyHash 1
keyHash and keyHash and before 1
complex combination of keyHashs and before 6

The individual scripts are here: ipns://QmZQEPpi5A4SXCntiUb1carkuB23niLgejtyxLhECQ24pA

1 Like

Hi how did you managed this? With the cli or db-sync? Or what else?

Custom Haskell code. Unfortunately, db-sync doesn’t record transaction witnesses and cardano-cli cannot query them. However, the cardano-node repo now has an example of how to walk through all of the blocks and extract information.

Cool is this feature already included in your tool or was it just a proof of concept?

I added the feature this morning. It was a good exercise in learning how to access the data in blocks, and I was curious to see what sort of monetary policy scripts folks have been using for tokens.

Some of the older Plutus documentation and commentary seems to indicate that Plutus scripts will not be stored in the blocks like the Shelley and Mary scripts now are. It will be interesting to see if that is really true; I imagine that we’ll know when the Plutus testnet become available.

Cool looks interesting, do you have any buildinstructions for mantis? The cardano-node folder and .gitmodules is empty. Do i just have to clone the node into it and then nix-shell?

The following works for me on NixOS:

  1. Clone
  2. Remove the cardano-node/ folder and just clone version 1.26.2 of there.
  3. Run a nix-shell. Using the IOHK caches speeds this up immensely.
  4. Execute cabal v1-build or cabal v1-run.

I haven’t tried it on a non-NixOS installation of Nix, or on a non-Nix system. There’s and odd interaction between the Nix derivations used by cardano-node and git submodules that appeared with cardano-node-1.25.0, and I haven’t resolved that yet. I need to overhall the build configuration, and creating a straightforward and robust build for this is high on my to-do list, but stuff like extracting scripts from mainnet is more fun. Please feel free to post issues. The tool is a quirky because at this point it’s evolving and mostly just focused on the use cases that I’ve been encountering.

Ok build is running… see you in some hours ^^

1 Like

Here are the instructions for using the IOHK binary cache, if you’re not already using it.

I’m now sufficiently motivated to work on streamlining the build! :blush:

1 Like

I’ve added the cache but it still takes a long time, but i think it’s only on the first time