What are smart contracts?

Intermediate 3 min read · Updated 2026-11-05

Key takeaways
  • A smart contract is a program deployed on a blockchain that anyone can call and that runs exactly as coded.
  • They power tokens, decentralized exchanges, lending protocols and NFTs.
  • Code is usually public, so rules can be inspected, but bugs can be exploited by anyone and are hard to fix.
  • A contract only knows what's on its blockchain; outside data needs an oracle.

A vending machine made of code

The term goes back to computer scientist Nick Szabo in the 1990s, who compared it to a vending machine: put in the right input, and the machine reliably delivers the output with no clerk involved. On blockchains like Ethereum, a smart contract is code stored at an address. Anyone can send it a transaction, and every node runs the code and agrees on the result.

What they're used for

  • Tokens: most tokens, including many stablecoins, are smart contracts that track balances (on Ethereum, the ERC-20 standard).
  • Decentralized exchanges and lending: see What is DeFi?
  • NFTs: unique tokens (ERC-721) that record ownership of a digital item.
  • DAOs: groups that vote on decisions and treasury spending through contracts.

Why bugs are such a big deal

Deployed contracts often can't simply be patched, and they may hold large amounts of money that anyone in the world can try to exploit. In 2016, a flaw in "The DAO" contract let an attacker drain about 3.6 million ETH, which led Ethereum to a controversial hard fork (the original chain continued as Ethereum Classic). Audits reduce risk but don't eliminate it.

Oracles: getting real-world data in

A contract can't look up a stock price or the weather by itself. Oracles are services that post outside data on-chain. If an oracle is wrong or manipulated, the contract will act on bad data. Chainlink is the best-known oracle network; see its profile.

Approvals: the part users must watch

When you use a token in an app, you usually sign an approval letting the contract move your tokens. Malicious sites trick people into approving unlimited access and then drain the wallet. Read what you sign, and periodically revoke approvals you no longer need.

Frequently asked questions

Are smart contracts legally binding contracts?

Not by themselves. They're code that executes automatically; whether an arrangement is legally enforceable depends on law, not the blockchain.

What languages are they written in?

On Ethereum, mainly Solidity and Vyper. Other chains use Rust, Move and others.

Can a smart contract be changed?

Some are immutable; others use 'upgradeable' patterns controlled by keys or governance, which brings its own trust questions.

Sources and further reading

This guide explains how things work; it isn't financial, legal or tax advice. Crypto is volatile and you can lose money.

😂 Laugh version: launch a fake memecoin