Educational content only · We don't sell crypto or give financial advice

Lesson 4.2 · Module 4: Bitcoin and smart-contract platforms

Smart contracts explained

11 min read · Level: Beginner+ · Written by Daniel Reed · Reviewed 20 October 2026

In this lesson you will learn to:

  • Define a smart contract in plain words.
  • Explain the role of gas.
  • Describe the oracle problem and the risk of bugs.
A transaction calls a smart contract; every node runs the same code and updates the same stored data.Transaction+ gas limitSmart contractCode(fixed rules)Stored dataSame resulton every nodeOut of gas → execution stops and changes are undone
A transaction calls a smart contract; every node runs the same code and updates the same stored data.

A vending machine, not a lawyer

The term smart contract was coined by the computer scientist Nick Szabo in the 1990s. His favourite example was a vending machine: put in the right coins, press a button, and the machine delivers the product according to fixed rules, with no shop assistant involved.

On a blockchain, a smart contract is a program stored on the chain. Anyone can send it a transaction, and every node runs the program in exactly the same way to work out the result. Despite the name, it is not a legal contract — it is code that does precisely what it says, whether or not that is what anyone intended.

A shared computer

Ethereum, launched in July 2015, was the first major platform built around this idea. It can be pictured as one shared computer that thousands of nodes run in parallel. Each contract has its own code and its own stored data. When a transaction calls a contract, every node executes the same steps and updates the same data, so they all stay in agreement.

Many other platforms follow similar designs, often with different trade-offs between speed, cost and openness.

Why gas exists

Running a program on thousands of computers is expensive, and a program could accidentally — or maliciously — run forever. Smart-contract platforms solve this with gas: every operation has a fixed cost in gas units, and each transaction sets a maximum. If the program runs out of gas, it stops and its changes are undone. This makes endless loops impossible and attaches a cost to every computation.

What smart contracts are used for

Common examples, described here as mechanisms rather than recommendations:

  • keeping a record of tokens and who holds them (lesson 4.3);
  • escrow-like arrangements that release something only when conditions are met;
  • voting systems for groups that manage shared resources;
  • registries, such as names linked to addresses.

The oracle problem

A blockchain only knows what is recorded on it. A contract about the weather, an exam result or a delivery cannot check the real world by itself. It needs an oracle — a service that brings outside information on chain. But then the contract is only as reliable as the oracle. This is one of the most important limits to understand.

Bugs cannot simply be patched

Once deployed, many contracts cannot be changed. A bug becomes a permanent feature that anyone can exploit. In 2016, a flaw in a high-profile contract called "The DAO" was exploited, and the response led to the permanent split described in lesson 3.3. Since then, auditing, formal verification and carefully designed upgrade mechanisms have become major disciplines — but no audit can promise that code is free of errors.

Key takeaways

  • A smart contract is a program stored on a blockchain that runs exactly as written.
  • Every node runs the same code, so all copies stay in agreement.
  • Gas puts a cost on every operation and stops endless programs.
  • Contracts depend on oracles for outside facts and cannot easily fix their own bugs.

Check yourself

Why is a smart contract not the same as a legal contract?

It is code that runs exactly as written; it has no judgement and is not by itself a legal agreement.

What happens when a transaction runs out of gas?

Execution stops and the changes it made are undone.

What is the oracle problem?

Contracts cannot see the outside world, so they depend on oracles whose reliability limits the contract.

Sources

This lesson is for general education about how the technology works. It is not a recommendation to acquire, sell or hold any crypto-asset and is not financial advice.