08

About a minute.

Last time:pages seal the page before.

Smart contracts are vending machines

A contract is a program stored on Ethereum. It holds assets and follows its code — not a clerk's mood.

Try it

A vending machine on the sidewalk. Insert ETH, snack drops. Nobody behind the glass.

The glass

—

Maya 1.00 ETH · snacks 0

Snack: 0.25 ETH. The machine does not haggle.

Nick Szabo's old image still helps: a vending machine. You put in the right coins, you get the snack. No one behind the counter decides you look suspicious. A smart contract is that idea as software. It lives at an address, it has a balance, and it only moves funds or data the way its code allows.

Anyone can call a public function (and pay gas). The contract can check who called it — “only the owner may withdraw” — because every transaction carries a sender. Once deployed, the code is typically stuck. If the author left a bug, the bug is the law until a new contract is deployed and people choose to use it.

This is how tokens, NFT markets, lending pools, and on-chain games exist without a single server owning the balances. It is also how hacks happen: the code did exactly what it said, and what it said was unsafe. Read what you sign. Start with small amounts.

You just used a toy contract. Insert the right amount, snack drops. Ask nicely without ETH, nothing happens. That one if-statement is the seed of almost every on-chain permission system.

Takeaway

Smart contracts are unstoppable vending machines. They are powerful because they are literal — including their bugs.

Blocks