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

**URL:** <https://forum.cardano.org/t/proving-a-particular-policy-script-constraint-i-e-before/57443>\
**Category:** Native Tokens\
**Created:** [14 April 2021 09:04 UTC](https://forum.cardano.org/t/proving-a-particular-policy-script-constraint-i-e-before/57443 "2021-04-14T09:04:09Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![cedeon](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/cedeon/32/29815_2.png) [@cedeon](https://forum.cardano.org/u/cedeon)\
**Post date:** [14 April 2021 09:04 UTC](https://forum.cardano.org/t/proving-a-particular-policy-script-constraint-i-e-before/57443/1 "2021-04-14T09:04:09Z")

</div>

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

```auto
 "scripts": [
     {
         "keyHash": "b78665f860207c21675bc1127ec75d401d8461edcf8f4ac479555a27",
         "type": "sig"
     },
     {
         "slot": 25606303,
         "type": "before"
     }
 ],
 "type": "all"
}

```

becomes [policyId:956886f8b5ed5528b412c1b3b42ef49d81ea157addce042e59e84f38](https://explorer.cardano-testnet.iohkdev.io/en/transaction?id=3b9830d30a6e4dbab8feaf3bf8cf3356c4cbe8a98404923f7235a7ab88391011)

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 🙂

---

<div class="post-metadata">

**Author:** ![bwbush](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/bwbush/32/29827_2.png) [@bwbush](https://forum.cardano.org/u/bwbush)\
**Post date:** [14 April 2021 11:28 UTC](https://forum.cardano.org/t/proving-a-particular-policy-script-constraint-i-e-before/57443/2 "2021-04-14T11:28:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cedeon](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/cedeon/32/29815_2.png) [@cedeon](https://forum.cardano.org/u/cedeon)\
**Post date:** [14 April 2021 11:33 UTC](https://forum.cardano.org/t/proving-a-particular-policy-script-constraint-i-e-before/57443/3 "2021-04-14T11:33:29Z")

</div>

Thanks 🙂 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 🙂

---

<div class="post-metadata">

**Author:** ![wutzebaer](https://avatars.discourse-cdn.com/v4/letter/w/f6c823/32.png) [@wutzebaer](https://forum.cardano.org/u/wutzebaer)\
**Post date:** [17 April 2021 22:46 UTC](https://forum.cardano.org/t/proving-a-particular-policy-script-constraint-i-e-before/57443/4 "2021-04-17T22:46:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bwbush](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/bwbush/32/29827_2.png) [@bwbush](https://forum.cardano.org/u/bwbush)\
**Post date:** [18 April 2021 00:32 UTC](https://forum.cardano.org/t/proving-a-particular-policy-script-constraint-i-e-before/57443/5 "2021-04-18T00:32:02Z")

</div>

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](https://iohk.io/en/blog/posts/2019/07/31/secure-smart-contracts-with-the-plutus-ebook/) discusses this, and the [Ledger Specification](https://hydra.iohk.io/build/6071891/download/1/ledger-spec.pdf) implicitly describes this.

---

<div class="post-metadata">

**Author:** ![wutzebaer](https://avatars.discourse-cdn.com/v4/letter/w/f6c823/32.png) [@wutzebaer](https://forum.cardano.org/u/wutzebaer)\
**Post date:** [18 April 2021 09:23 UTC](https://forum.cardano.org/t/proving-a-particular-policy-script-constraint-i-e-before/57443/6 "2021-04-18T09:23:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bwbush](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/bwbush/32/29827_2.png) [@bwbush](https://forum.cardano.org/u/bwbush)\
**Post date:** [18 April 2021 12:06 UTC](https://forum.cardano.org/t/proving-a-particular-policy-script-constraint-i-e-before/57443/7 "2021-04-18T12:06:22Z")

</div>

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.)

---

<div class="post-metadata">

**Author:** ![wutzebaer](https://avatars.discourse-cdn.com/v4/letter/w/f6c823/32.png) [@wutzebaer](https://forum.cardano.org/u/wutzebaer)\
**Post date:** [19 April 2021 11:25 UTC](https://forum.cardano.org/t/proving-a-particular-policy-script-constraint-i-e-before/57443/8 "2021-04-19T11:25:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bwbush](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/bwbush/32/29827_2.png) [@bwbush](https://forum.cardano.org/u/bwbush)\
**Post date:** [19 April 2021 13:02 UTC](https://forum.cardano.org/t/proving-a-particular-policy-script-constraint-i-e-before/57443/9 "2021-04-19T13:02:09Z")

</div>

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](http://ouroboros.iohk.io/) and a video [here](https://www.youtube.com/watch?v=LCeK_4o-NCc).

---

<div class="post-metadata">

**Author:** ![wutzebaer](https://avatars.discourse-cdn.com/v4/letter/w/f6c823/32.png) [@wutzebaer](https://forum.cardano.org/u/wutzebaer)\
**Post date:** [10 May 2021 13:58 UTC](https://forum.cardano.org/t/proving-a-particular-policy-script-constraint-i-e-before/57443/10 "2021-05-10T13:58:27Z")

</div>

Someone found out it is actually stored in the cahin

ht-tps://cardano.stackexchange.com/questions/24/how-can-a-node-verify-a-transaction-with-a-script-address-without-the-script/85

---

<div class="post-metadata">

**Author:** ![bwbush](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/bwbush/32/29827_2.png) [@bwbush](https://forum.cardano.org/u/bwbush)\
**Post date:** [15 May 2021 19:50 UTC](https://forum.cardano.org/t/proving-a-particular-policy-script-constraint-i-e-before/57443/11 "2021-05-15T19:50:30Z")

</div>

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 `keyHash`s and `before` | 6 |

The individual scripts are here: [ipns://QmZQEPpi5A4SXCntiUb1carkuB23niLgejtyxLhECQ24pA](https://ipfs.io/ipns/QmZQEPpi5A4SXCntiUb1carkuB23niLgejtyxLhECQ24pA)

---

<div class="post-metadata">

**Author:** ![wutzebaer](https://avatars.discourse-cdn.com/v4/letter/w/f6c823/32.png) [@wutzebaer](https://forum.cardano.org/u/wutzebaer)\
**Post date:** [15 May 2021 20:15 UTC](https://forum.cardano.org/t/proving-a-particular-policy-script-constraint-i-e-before/57443/12 "2021-05-15T20:15:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bwbush](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/bwbush/32/29827_2.png) [@bwbush](https://forum.cardano.org/u/bwbush)\
**Post date:** [15 May 2021 20:22 UTC](https://forum.cardano.org/t/proving-a-particular-policy-script-constraint-i-e-before/57443/13 "2021-05-15T20:22:23Z")

</div>

[Custom Haskell code](https://github.com/functionally/mantis/blob/main/app/Mantis/Chain.hs). Unfortunately, `db-sync` doesn’t record transaction witnesses and `cardano-cli` cannot query them. However, the `cardano-node` repo now has [an example](https://github.com/input-output-hk/cardano-node/tree/1.26.2/cardano-client-demo) of how to walk through all of the blocks and extract information.

---

<div class="post-metadata">

**Author:** ![wutzebaer](https://avatars.discourse-cdn.com/v4/letter/w/f6c823/32.png) [@wutzebaer](https://forum.cardano.org/u/wutzebaer)\
**Post date:** [15 May 2021 20:24 UTC](https://forum.cardano.org/t/proving-a-particular-policy-script-constraint-i-e-before/57443/14 "2021-05-15T20:24:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bwbush](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/bwbush/32/29827_2.png) [@bwbush](https://forum.cardano.org/u/bwbush)\
**Post date:** [15 May 2021 20:32 UTC](https://forum.cardano.org/t/proving-a-particular-policy-script-constraint-i-e-before/57443/15 "2021-05-15T20:32:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![wutzebaer](https://avatars.discourse-cdn.com/v4/letter/w/f6c823/32.png) [@wutzebaer](https://forum.cardano.org/u/wutzebaer)\
**Post date:** [15 May 2021 20:36 UTC](https://forum.cardano.org/t/proving-a-particular-policy-script-constraint-i-e-before/57443/16 "2021-05-15T20:36:18Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bwbush](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/bwbush/32/29827_2.png) [@bwbush](https://forum.cardano.org/u/bwbush)\
**Post date:** [15 May 2021 20:53 UTC](https://forum.cardano.org/t/proving-a-particular-policy-script-constraint-i-e-before/57443/17 "2021-05-15T20:53:37Z")

</div>

The following works for me on NixOS:

1. Clone `git@github.com:functionally/mantis.git`.
2. Remove the `cardano-node/` folder and just clone version 1.26.2 of `git@github.com:input-output-hk/cardano-node.git` 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](https://github.com/functionally/mantis/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.

---

<div class="post-metadata">

**Author:** ![wutzebaer](https://avatars.discourse-cdn.com/v4/letter/w/f6c823/32.png) [@wutzebaer](https://forum.cardano.org/u/wutzebaer)\
**Post date:** [15 May 2021 21:03 UTC](https://forum.cardano.org/t/proving-a-particular-policy-script-constraint-i-e-before/57443/18 "2021-05-15T21:03:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bwbush](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/bwbush/32/29827_2.png) [@bwbush](https://forum.cardano.org/u/bwbush)\
**Post date:** [15 May 2021 21:08 UTC](https://forum.cardano.org/t/proving-a-particular-policy-script-constraint-i-e-before/57443/19 "2021-05-15T21:08:49Z")

</div>

Here are the instructions for using the [IOHK binary cache](https://github.com/input-output-hk/plutus#iohk-binary-cache), if you’re not already using it.

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

---

<div class="post-metadata">

**Author:** ![wutzebaer](https://avatars.discourse-cdn.com/v4/letter/w/f6c823/32.png) [@wutzebaer](https://forum.cardano.org/u/wutzebaer)\
**Post date:** [15 May 2021 21:35 UTC](https://forum.cardano.org/t/proving-a-particular-policy-script-constraint-i-e-before/57443/20 "2021-05-15T21:35:39Z")

</div>

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

[Next page](https://forum.cardano.org/t/proving-a-particular-policy-script-constraint-i-e-before/57443.md?page=2)
