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
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:
- Compile on-chain code into plutus script
- Generate address from plutus script
- Lock funds into plutus script address (Don't forget Datum!!!)
- 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
-
2I 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.– seanJan 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/…)– seanJan 25, 2022 at 15:49
-
1To 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))– seanJan 25, 2022 at 16:05
-
1Yeah, that seems to be true. The
--tx-in-script-file
param ofcardano-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