6

I'm curious, is it possible to find the source code of the validation script of a smart contract (as well as other parts) that is already on the blockchain?

Or this code automatically picking up into the spending transaction that is referring to the smart contract address?

As I know, we need to provide the actual validation script in the spending transaction.

On the one hand it is a question of transparency, on the other hand of intellectual property.

2 Answers 2

7

Not exactly, the only part of the smart contract that actually lives on-chain is the script hash. Think of it as a compressed/hashed representation of how the real script (run off-chain) should work. These hashes are then used to create script addresses whose UTXOs can only be used as inputs for a new transaction if that transaction's script hash matches the hash at the script address.

In other words, script addresses act as guards for their UTXOs, and the only way to get past the guard (and thus use the UTXO as an input for your transaction) is to provide a proof that your transaction complies exactly with the logic set forth by the guard's author. The actual logic must therefore be performed in a local environment. There can be many ways to acquire the code itself, which the upcoming dApp certification program will help with.

1
  • 1
    In addition to what @nomad0 said, since one has to prove when consuming an UTxO at such an address what the "quard" is by appending the scripts logic to the transaction, from then on the logic is public. That is, since anyone can view that transaction, the appended script logic is also publicly viewable and verifiable. Note though that this logic is in some non human readable Plutus core form.
    – Fermat
    Jan 25 at 8:05
5

You can find the actual compiled Plutus Core bytecode on-chain. However, it is not human readable source code, but rather pre-processed / compiled haskell code.

As you mention, it is passed along as part of the transaction and it is "executed by nodes during transaction validation ‘live’ on the chain" (see https://docs.cardano.org/plutus/learn-about-plutus).

You can find examples of how the code appears on-chain on cardanoscan, eg here's a random recent example:

https://cardanoscan.io/transaction/68cfaf710b7267cd01b0b3d3e6889548a5776e653bdb44ae6a9512daa44bcbce?tab=contracts

Here's also some info on how those scripts can be created / exported for use in a tx:

https://plutus.readthedocs.io/en/latest/plutus/howtos/exporting-a-script.html

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.