I've understand that the on-chain code is stored in the blockchain through Playground module which is in sync against a local node. But how to "publish" this code to run anywhere? It's an accessible process, It must have some "certification"?


1 Answer 1


First of all on-chain code isn't stored in the blockchain, the hash of on-chain code is.

To use on-chain validator on testnet or mainnet steps are:

  1. Compile on-chain code into plutus script
  2. Generate address from plutus script
  3. Lock funds into plutus script address (Don't forget Datum!!!)
  4. Pass plutus script for validation to unlock funds from plutus script address

You can try going trough Alonzo exercises for an example how to do all of these steps.

And as for certification I don't think there is an official available certification yet

  • 2
    I think that statement - that on-chain code is not stored on the blockchain - can be a little misleading. It might not be stored (or even executed) directly in that first locking transaction, but when you compose a transaction to spend those funds that transaction will hold the script, which will be stored and made visible on the blockchain and it is also executed directly on-chain by every node validating the transaction. Please correct me if Im wrong here.
    – sean
    Jan 25, 2022 at 15:48
  • 1
    (Looking at cardano-db-sync it even creates a table for the scripts that it takes directly from the blockchain: github.com/input-output-hk/cardano-db-sync/blob/…)
    – sean
    Jan 25, 2022 at 15:49
  • 1
    To add to the answer, here's two resources on how to publish the on-chain code: plutus.readthedocs.io/en/latest/plutus/howtos/… docs.cardano.org/plutus/Plutus-transactions (scroll down to 3. Create your transaction with the accompanying Plutus script(s))
    – sean
    Jan 25, 2022 at 16:05
  • 1
    Yeah, that seems to be true. The --tx-in-script-file param of cardano-cli transaction build is saving the file in the transaction, so a given node can run the script code from that transaction. Jan 25, 2022 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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