What is a smart contract? Cardano validators explained | Crypto from Zero #20

Nov 24 · explainer

Watch on YouTube · the figures on screen (JSON) · every claim and how it resolved

Transcript

Cold open

Every DEX, lending market and stablecoin on Cardano runs on smart contracts. Here is what one actually is, how Cardano's version works, and how the chain's smart-contract work was spread across its latest few hundred blocks.

Rules that run themselves

A smart contract is a program stored on the blockchain that enforces rules without anyone in the middle. Lock coins under a contract and they can only be moved by a transaction that satisfies its rules: pay back the loan, give the pool its fair swap, wait until the deadline.

A vending machine

Think of a vending machine. Put in the right coins, press the button, and the snack drops, with no shopkeeper deciding whether to serve you. A smart contract is a vending machine for digital assets: lock tokens under it, and they only come out when someone meets its exact conditions.

Cardano's version: validators

On Cardano, a contract is usually a validator: a script that answers yes or no when someone tries to spend a UTxO locked under it. The UTxO carries a datum, the contract's stored state. The spender supplies a redeemer, their reason for spending. The validator checks both against the transaction, and if it says no, nothing moves.

A savings lock

Here is a simple validator: a savings lock. Someone locks one hundred ADA under a validator whose datum says: only my key, and not before the first of January. In March, a stranger tries to spend it, and the validator says no: wrong key. In December the owner tries: no, too early. In January the owner tries again, with the right key after the date, and the validator says yes.

Code, and only code

Every DEX swap, loan and stablecoin mint in Cardano's DeFi is a smart contract saying yes or no. A DEX, or decentralised exchange, lets people swap tokens straight from their wallets. Understanding that the rules are code, and only code, is the key to both what DeFi can do and what can go wrong.

Who is using the compute?

That is how it works on paper. Here is what the chain recorded. Every Cardano block has a budget for smart-contract computing. This is who used it. Across the last 400 blocks, about 2.2 hours, 160 different validators ran at least once, between them 1,275 executions. The busiest single validator accounted for 21.2 percent of every execution step spent on Cardano in that window. The top five together, 55.3 percent. Put the other way: it takes 4 validators to reach half of all the compute this chain did. Those executions paid 64 ADA in script fees. These are validator hashes, not protocol names. Which script belongs to which application is not something the chain records, and this channel does not guess at it.

The short version

So, in short. A smart contract is a program the chain enforces; on Cardano, a validator approves or refuses each attempt to spend what it guards.

No new claim today: a lesson explains how something works, and calls are made and scored in the Monday, Wednesday and Friday episodes. That is smart contracts, explained. Next time: What is DeFi, and what is it made of? Every lesson of Crypto from Zero is in the playlist linked below, in order, and every Monday, Wednesday and Friday this channel measures Cardano straight from the chain.

Every figure is computed from a Cardano node we run ourselves. Not financial advice. Want the next one? Follow the channel.