9

I've just read something that suggests Validators aren't actually kept on the blockchain. To save the space, only the hash of the Validator is kept at the UTxO and users willing to spend it must themselves provide the Validator code with matching hash value.

Besides the funny fact that on-chain code doesn't actually live on the chain, that brings a number of questions, of which the first and most obvious will be:

  1. How the actual Validators are stored? I mean the repositories may and should be distributed and each SC author could provide their own source of the code, but
  2. Is there any standard format of such packages (most likely containing also off-chain code) that could be loaded into wallets or other clients?
  3. Since the hash refers to a compiled version of the Validator, i.e. the Plutus Script code, how could users make sure that the binary is a result of compilation of the source the author publishes? Having the compilator and libraries being developed and optimized, it's almost sure the compilation results will vary over time, obviously changing the hash.

2 Answers 2

4

As stated by Samual, the code that a validator runs to check whether or not a transaction is valid is send and stored in the transaction body. So all scripts, be it plutus or simple v1 and v2 scripts, are stored on chain and are retrievable.

That said, those scripts are stored in a serialized way to compress the data (CBOR hex is used). If you want to look up any used script a cardano forum user keeps track of them [1] (credits to him). They also can be looked up via some blockchain explores.

For example, look at a transaction claiming an utxo at the simple always succeed plutus script address [2]. Using an online tool caller cbor.me we see that the datum/redeemer was 42 (182a in CBOR hex). The contract bytecode is also listed there but this is non-human readable plutus core.

Now for the off-chain part that safely can construct transactions for users, that needs to be distributed by the writer of that script. I know that IOHK is building a Dapp store to safely distribute such offline code.

And lastly, you are correct! The plutus script hashes to the address, so if one would change the code a new address should be used. Note however that complex Dapps may use several contracts, for example look at the Occam dex that they showed of [4] They used 3 contracts to implement certain behavior. So overtime use cases may change and other addresses will be used.

0

Auxiliary scripts are an attribute in the txbody that can have the validator script in it if it's small enough. You could also have metadata that links your users to the script off-chain.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.