
On June 17, 2016, someone drained roughly 3.6 million ether from a program called The DAO, about a third of everything the fund held. Nobody stole a password. Nobody broke into a server. The attacker used the program exactly the way its code allowed.
So was that theft? Or was it the contract doing what it was written to do?
That question is the whole story of smart contracts. To get there, it helps to start with a snack.
So what is a smart contract?
A smart contract is a program that lives on a blockchain and runs automatically when someone triggers it. Ethereum’s documentation describes it as a bundle of code and data sitting at its own address.
Despite the name, it isn’t a legal document, and it isn’t “smart” in the AI sense. It’s a set of if-this-then-that rules that can’t be changed once they’re created. If X happens, do Y. Every time.
The idea is older than Bitcoin. Nick Szabo coined the term in 1994, picturing a digital marketplace where agreements carry themselves out without a middleman. It took until Ethereum went live on July 30, 2015 for a blockchain built to run these programs for anyone.
The vending machine
The comparison Szabo used, and the one Ethereum’s developer docs still open with, is a vending machine.
Think about what happens when you buy a bag of chips. You pick an item, the machine shows a price, you pay, it checks your money, and it hands over the snack. There’s no cashier deciding whether you seem trustworthy. If you only put in $1 for a $2 drink, it doesn’t matter how many times you try, you’re not getting the drink. The rules are built into the machine.

A smart contract works the same way, with a few upgrades a real vending machine doesn’t have:
- The rules are public. Anyone can read a contract’s code before using it, like being able to open up the vending machine and inspect the wiring before you put your money in.
- Nobody owns the plug. Every node on the Ethereum network stores the same contract, so there’s no single machine someone can switch off.
- It can hold money itself. A contract is a type of Ethereum account with its own balance. Unless its code gives someone admin powers, nobody controls it; it just runs as programmed.
Here’s a stripped-down version of what that looks like in Solidity, the most common language for writing smart contracts. It’s simplified from the full cupcake vending machine example on ethereum.org:
function purchase(uint amount) public payable {
require(msg.value >= amount * 1 ether); // paid enough?
require(cupcakes >= amount); // in stock?
cupcakes -= amount; // dispense
}Read it like a checklist: did you pay enough, is there enough stock, then hand it over. If either check fails, the whole purchase is cancelled and nothing changes.
Finematics walks through the vending machine comparison and the “code is law” debate in this explainer, about 15 minutes:
How does one actually run?
A smart contract goes through the same basic life cycle every time.

First, a developer writes the rules in a language like Solidity. Then they deploy it, which means uploading it to the blockchain. Deploying is a transaction, so it costs gas (a fee paid in ETH for computing power), and it costs far more than a normal ETH transfer.
Once it’s live, the contract sits at its own address. Anyone can interact with it by sending a transaction that calls one of its functions. The network runs the code, agrees on the result, and records it. One detail matters a lot here: contracts can’t be deleted by default, and interactions with them can’t be reversed.
Contracts can also call other contracts. Ethereum’s docs describe them as open APIs that other contracts can build on. That’s why people call them “money legos.” One app can snap onto another without asking permission.
What can smart contracts do?
According to ethereum.org, smart contracts can do essentially anything a computer program can. A few real examples:
- Stablecoins, which are tokens designed to track a currency like the dollar.
- Automatic currency exchanges. Apps like Uniswap let people swap tokens without a company in the middle.
- NFTs, which use contracts to create and track unique digital items.
- Savings with conditions. You could write a contract that holds money for a kid and only lets them withdraw it after a certain date.
- Insurance that pays out automatically when a set condition is met.
- Crowdfunding that only releases the money once a goal is hit.
The common thread: anywhere you’d normally need a trusted middleman to hold money and follow the rules, a smart contract can try to do that job instead.
The catch
Smart contracts do exactly what they’re told. That’s the selling point, and it’s also the problem.
Bugs are forever
Remember The DAO? It had a flaw called a reentrancy bug. The attacker kept withdrawing ether before the contract could update its balances, a bit like a vending machine that drops your snack before it subtracts your credit, so you can keep hitting the button.
Since the code couldn’t be edited, the Ethereum community had to decide what to do. ETH holders voted, and over 85% supported a hard fork (a permanent change to the blockchain’s rules). On July 20, 2016, Ethereum moved the funds into a new contract whose only function was letting people withdraw their money back.
Not everyone agreed. Some miners refused to fork, arguing the protocol itself wasn’t broken. They kept the original chain running, and it became Ethereum Classic. The two chains still exist today.

Bugs don’t even need a villain. In November 2017, someone triggered a flaw in a shared piece of code used by Parity’s multi-signature wallets and destroyed it. That locked 513,774 ETH across 587 wallets. Nobody stole the money; it just became unreachable. Parity later admitted it had been warned about the flaw months earlier.
They can’t see the outside world
Say you and a friend want to bet on Saturday’s basketball game using a smart contract. Smart contracts can’t pull in information from outside the blockchain. That’s on purpose: if every node checked a different website, they might disagree, and the whole system depends on agreement.
The workaround is an oracle, a tool that brings outside data onto the blockchain. But now you’re trusting the oracle. As Finematics puts it, oracles reduce the trust you need, but the oracle itself still has to be trusted.

Some things are hard to capture at all. If you rent a car through a smart contract and scratch the bumper, how would the code ever know?
Every action costs something, and there are limits
Running code on Ethereum costs gas, and contracts have size limits. A single contract can be at most 24KB, so bigger apps get split across several contracts.
You might not know what you’re signing
In theory, anyone can read a contract’s code. In practice, the raw data a wallet asks you to approve is nearly unreadable. Ethereum.org warns about “blind signing,” where users approve transactions without understanding them. A newer standard called Clear Signing (ERC-7730) aims to turn that data into plain-language descriptions, but it’s still rolling out.
There’s no undo button
Because interactions are irreversible, there’s no customer service line to call if you send money to the wrong contract or get tricked into approving something bad.
The bottom line
Smart contracts swap “trust the middleman” for “trust the code.” That trade is great when the code is right, and brutal when it isn’t. They’re why Ethereum can run exchanges and stablecoins with no company in charge. They’re also why one bug in 2016 split a blockchain in two.
Back to the question from the beginning: was The DAO attack theft, or the contract working as written? Ethereum answered by rewriting history. Ethereum Classic answered by leaving it alone. People in the crypto world still argue about it.
Ten years later, the story has an odd ending. More than 75,000 ETH left unclaimed from the 2016 refund now funds an Ethereum security endowment. The leftovers from smart contracts’ most famous failure now pay to prevent the next one.
Want to dig deeper?
- ethereum.org: Introduction to smart contracts: the best non-technical starting point, written by the Ethereum community.
- ethereum.org developer docs: Smart contracts: the full cupcake vending machine code, plus limitations and multisig wallets.
- ethereum.org: Timeline of Ethereum forks: the official record of the DAO fork and every upgrade since.
- The Block: The DAO hack at 10: how the hack happened and what became of the leftover funds.
- Chainlink: What is a smart contract?: another beginner explainer. Note that Chainlink sells oracle services, so it has a stake in the oracle side of the story.
- Simply Explained: Smart contracts (video): a short explainer recommended by ethereum.org. It’s from 2017, but the core concept hasn’t changed.
This article is for learning purposes only and isn’t financial advice. Cryptocurrency is high-risk, so always do your own research before making any decisions.
What are smart contracts? Programs that keep their promises was originally published in Youth Blockchain Association on Medium.