3

Charles Hoskinson indicated in this tweet that he favors the term "programmable validator" to the term "smart contract" with regard to Cardano.

Quoting the tweet Charles Hoskinson is responding to, "In Cardano, "smart-contracts" tend to refer to the combination of the on-chain validator(s) and the off-chain code that's driving it / them."

Here's what I've gathered so far. (This is speculation. Please do not believe it and please do correct it in the answers and comments.)

All operations (and data) necessary for Cardano to function are executed (and stored) on 3rd party-owned compute resources known as "validation nodes" (with the caveat that Cardano itself owns a number of "validation nodes"). The results returned by these 3rd parties can be trusted, statically speaking, thanks to redundancy -- each operation is performed by all nodes in a random sample of validation nodes, and results are checked against each other.

This also describes code running "on-chain" and AFAIK is similar to how contracts execute on Ethereum.

All blockchains have "off-chain" code driving the miners or validators.

Are all these statements correct? If not please correct me and if so, what's the big difference between Cardano contracts and contracts on other chains alluded to in the above tweets?

1 Answer 1

8

You are asking a few questions here, so I'll try my best to point you in the right direction. I feel like KtorZ did a great job explaining it, but it doesn't hurt to put it into different words.


Terminology

Validator or Validator Script: (not to be confused with validation nodes) Code used to say "yes" or "no" to transactions spending UTxOs at the script address

Minting Policy: Code used to say "yes" or "no" to transactions forging tokens from the policy address

On-Chain Code: Validator Scripts and Minting Policies (for the most part). This code is run by the validation nodes in conjunction with relevant transactions.

Off-Chain Code: Code for building and submitting transactions. Typically referring to wallet code, but technically the Cardano CLI can fulfill the same role to some extent


Background

A common misconception about Cardano "smart contracts" is that the "on-chain" code is a program. That you send some "smart contract" to live on the blockchain and it "runs" or "executes" like a normal program with processes and state.

This is wrong.

In reality, the "on-chain" code is just used passively to validate transactions. It just says "yes" or "no".

So, "off-chain" you can build whatever transaction you want: mint a million stable coins or take all the liquidity of a DEX for your own. The "on-chain" Minting Policies and Validator Scripts are what keep you from doing that. The "on-chain" code doesn't do anything, it just keeps you from doing bad things.


Answer

This is the distinction I think people are trying to make.

What's the difference between programmable validators and smart contracts?

Smart contracts on other chains are pieces of code that have shared, mutable state and imperative logic to change that state. More similar to programs people are used to writing.

On Cardano, state may be stored on chain, but the logic of how to change state lives off-chain and the on-chain code just validates your transaction. It will never produce anything or change state for you.

One might call other chains' model "smart contracts" and Cardano's model "programmable validators". What's important is that they achieve the same goal with different paradigms.

4
  • Sorry this is so long. Commented Oct 2, 2021 at 8:15
  • Thanks @mitchell-turner! So in summary, on Cardano, contracts that execute on-chain can only function to accept or reject transactions (submitted to that contract's address), as opposed to on other chains where smart contracts can create transactions. Is that right?
    – mathandy
    Commented Oct 4, 2021 at 6:50
  • 1
    That's close. I think you're using "transaction" slightly wrong. On Cardano, a transaction is literally the proposed state change, and it must be validated to be executed. Whereas on other chains, a transaction is telling a smart contract what you want, and it tries to perform the state changes for you. If that makes sense. Commented Oct 4, 2021 at 21:40
  • That does make sense. Thanks again @MitchelTurner!
    – mathandy
    Commented Oct 4, 2021 at 23:01

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.