Wednesday, October 7, 2026
Learn / Ethereum and smart contracts

What is a smart contract?

A smart contract is a program stored on a blockchain that runs automatically when its conditions are met, with no company in the middle.

Ethereum and smart contracts Illustration: Cryptoweek

A smart contract is a computer program stored on a blockchain. It holds a set of rules and carries them out automatically when someone sends it a transaction, with no bank, broker or other middleman approving each step. Despite the name, it is neither especially clever nor necessarily a contract in the legal sense.

How does a smart contract work?

The usual comparison is a vending machine, an analogy from the computer scientist Nick Szabo, who coined the term in the 1990s. You put in the right money and press a button, and the machine releases the snack. No shop assistant is needed, because the rules are built into the machine.

A smart contract works the same way with digital assets. A developer writes the rules as code and publishes it to a blockchain such as Ethereum, where it receives its own address. Anyone can then send it a transaction. Every node, meaning each computer that keeps a copy of the blockchain, runs the code and checks that the result is the same. Running the code costs a gas fee, paid by the person who sent the transaction.

What are smart contracts used for?

  • Tokens. Most crypto tokens are smart contracts that keep a list of who owns how many units.
  • Trading and lending. A decentralized exchange uses contracts to swap one token for another.
  • NFTs. A contract records which wallet owns each unique item.
  • Group decisions. A DAO uses contracts to count votes and release shared funds.

A smart contract can only see what is on its own blockchain. To react to outside facts, such as a market price, it relies on a data service called an oracle.

What can go wrong?

Code does what it says, not what its author meant. Once published, most smart contracts cannot be edited, and transactions cannot be reversed. A mistake in the code can therefore be used by anyone who finds it. In 2016, an attacker drained about a third of the ether held by an early investment fund called The DAO by exploiting a flaw in its contract.

Projects try to reduce the risk by paying outside firms to audit their code. An audit lowers the odds of a bug but does not rule one out. Some contracts are built so that their developers can upgrade them, which allows fixes but means users must trust whoever holds that power.

Is a smart contract legally binding?

Not by default. A smart contract is software, and whether it creates a legal agreement depends on the ordinary contract law of the place involved and on what the parties intended. If the code and a written agreement disagree, a court may have to decide which one counts. Laws differ by country and state, and this area is still developing.

This guide explains how things work. It is not financial, legal or tax advice. Last updated .