CIP-???? | Parameterised Reference Scripts #354
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allow a parameterised script on-chain to mint proof that a script is generated by it, and also for that minted output to be used as a reference script.
---- New Details ----
Currently there are two main script types on Cardano- Validators and Mint Scripts.
Validators decide whether an output can be spent from an address, and Mint Scripts decide whether a new output can be created from an address.
A Parameterised Reference Script would be similar to Mint Scripts, as it follows the same general form of producing a new output which has undergone a layer of validation. However, the output wouldn't be a representation of value or some arbitrary tokenized asset, but would be a reference to a spendable Validator or Mint Script (Or, potentially another parameterised script- but this is a more complex case).
This output would contain a reference to the script it was generated from. It would also contain the args used to generate it.
An example use case for this is NFTs. If I want to make a validator which has a special case for NFTs, it is currently a complex project and there would be some sort of oracle, verification or trust process required.
A short example of why NFTs in particular would be good to verify is contracts which require uniqueness: it is simple to lock some asset with a token, allowing the owner to encapsulate that value and transfer it using the token. A secure contract would always guarantee the uniqueness of the key, which depends on the fact whether a token is actually an NFT. However, the idea is more general than NFTs, they are just a good explanatory case.
With Parameterised Reference Scripts, I consider this example from https://github.com/input-output-hk/plutus-pioneer-program/blob/main/code/week05/src/Week05/NFT.hs
It is technically trivial to verify some generated contract (...simply run the producing parameterised function with that input again) by applying the TxOutRef to the parameterised version. It is clearly useful to be able to do this efficiently from a Plutus script (any on-chain smart contract)- but it is currently not practically feasible to do this. This reasoning justifies a CIP which makes this use case practical if not possible.
My initial spec would be as follows:
A parameterised script may be used to mint an output corresponding to any other kind of script. This output must encode two values: "fromScriptHash", and "args". "fromScriptHash" is the hash of the parameterised script. "args" is the plutus data values which are fed into the parameterised contract to produce the output scripts.
This output will always be spent to the hash of the produced script. If the parameterised script is stored as a reference script, then the output will also be spendable as a reference script (where the source is resolved by taking the args stored at the output, jumping back to the parameterised script, and generating the source by providing the args.) Otherwise, without the use of a reference script, the script can be provided per-use.
One way I imagine this CIP being used:
How was this workflow actually improved by this CIP?
There is less trust in the NFT process required. It is much easier to agree on formats for proof of uniqueness through parameterization.
Entirely verified on chain.
Open for dialogue about more specific details of this proposal if anyone has anything to say.