Skip to content
Tutorials Center
My learning

Topics

Lesson 2 of 47 ยท Getting Started

Smart Contracts: Features, Uses and Limits

Understand smart contracts: where the idea came from, their key features, real-world applications such as DAOs, DeFi and supply chains, and their limits, with runnable models.

A smart contract is a program stored on a blockchain that runs exactly as written when its conditions are met. The name is a little misleading: it is neither "smart" in the sense of intelligent, nor always a "contract" in the legal sense. It is better to think of it as a piece of shared, tamper-resistant software that holds assets and enforces rules without anyone in the middle.

This lesson steps back from syntax and answers the questions beginners ask before writing any code: where the idea came from, what properties make smart contracts useful, where they are used, and where they fall short. You will also run two small models of contract logic in JavaScript. After it, How a Smart Contract Runs shows the machinery under the hood.

Where the idea came from

The term was coined in the 1990s by the computer scientist and legal scholar Nick Szabo. His classic example is a vending machine. You put in coins, choose a snack, and the machine delivers it. No cashier is needed, no one has to be trusted, and the rules (price, stock) are built into the machine. Szabo's point was that some agreements can be embedded in hardware and software so that breaking them is costly or impossible.

Bitcoin had a limited script system, but the idea only became practical when Ethereum (2015) offered a general programming language and a shared computer on which anyone could deploy such programs. Today the main language for Ethereum contracts is Solidity, which is what this track teaches.

Key features

What makes a smart contract different from an ordinary server program?

  • Distributed. The contract and its results are copied on thousands of nodes. No single company's server can be switched off to stop it.
  • Autonomous. Once deployed, it runs by itself when someone calls it. There is no operator who has to approve each action.
  • Trustless. You do not have to trust the other party, only the code and the network's consensus. Both sides can read the rules first.
  • Self-verifying and self-enforcing. The contract checks the conditions itself (payment received? deadline passed?) and carries out the result (release funds, refund) with no court or bank.
  • Accurate and automatic. A computer does exactly what the code says, every time, so there are no clerical errors from manual processing. Many steps that used to take days happen in one transaction, which also makes them fast.
  • Backed up and transparent. Every execution is recorded in the chain's history, so there is a permanent, auditable trail.
  • Customizable. Any logic you can express in code can be encoded: payments, voting, auctions, tokens, insurance rules.
  • Cost-efficient. Removing intermediaries (escrow agents, notaries, payment processors) saves fees, though you pay gas to run the code.

What contracts can do

Because a contract can hold ETH and tokens and call other contracts, it can act as:

  • A multi-signature account. Funds move only when, say, 3 of 5 owners approve. You will build one in Project: A Multisig Wallet.
  • A store of business logic. Pricing, vesting schedules, royalties and eligibility rules written once and executed identically for everyone.
  • A token or registry. ERC-20 tokens and ERC-721 NFTs are just contracts with a table of balances or owners.
  • A DAO (decentralized autonomous organization). Members hold voting tokens, proposals are submitted on-chain, and approved proposals execute automatically, such as paying a grant from the shared treasury.
  • Glue between services. One contract calls another, which is why finance applications can be composed like building blocks.

Underneath, two technologies cooperate: the blockchain provides tamper-evident storage and agreement among nodes, and cryptography (hashes and digital signatures) proves who authorized each action.

Applications

Area Example use
Finance (DeFi) Lending pools, token exchanges, stablecoins, payment streams
Real estate Recording ownership, escrow that releases payment when the title transfers, fractional ownership tokens
Supply chain Tracking goods from origin to buyer, with payment released on confirmed delivery
Vehicle and asset ownership Digital titles, rental or leasing that unlocks only when payment is current
Music and media Automatic royalty splits when a song is streamed or sold
Government and elections Transparent voting, public records, grant distribution
Healthcare Controlled sharing of records, claims processing, drug traceability
Insurance Parametric policies that pay out automatically when a data feed reports a condition
Gaming and collectibles Items, tickets and in-game assets that players really own
Recordkeeping Timestamped, tamper-resistant documents; reduced fraud because history cannot be quietly changed

Not every idea needs a blockchain. If one trusted party can run the system cheaply, a normal database is simpler and faster. Smart contracts shine when several parties who do not fully trust each other need a shared record and automatic enforcement.

Challenges and limits

An honest picture includes the problems:

  • Immutability cuts both ways. Deployed code cannot be edited, so a bug stays unless you planned for upgradeability. The 2016 DAO attack, a reentrancy bug, drained millions of dollars and led Ethereum to split.
  • "Code is law" is blunt. The contract does what it says even if it was not what you meant. There is no support desk and no chargeback.
  • The oracle problem. Contracts cannot fetch web data or the weather themselves; they need trusted data feeds. See Oracles, Randomness and Off-Chain Data.
  • Cost and scale. Every operation costs gas, storage is expensive and throughput on the main chain is limited, which is why many applications use layer-2 networks.
  • Privacy. On-chain data is public by default.
  • Legal uncertainty. Whether a contract is enforceable in court, who is liable for a bug, and how regulations apply vary by country and are still evolving.
  • User risk. Lost keys cannot be reset, and signing a malicious transaction cannot be undone.
  • Security. Contracts hold money, so they attract attackers. See Common Vulnerabilities and Audits, Tools and Best Practices.

Try it: a vending machine contract

Szabo's example translates directly into a tiny state machine. The model below keeps a price, stock and balance, and refuses invalid requests the way require would. Note that every operation either completes entirely or changes nothing.

JS Szabo's vending machine

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Try it: a parametric insurance policy

A smarter example shows autonomy and the oracle problem together. The policy pays a farmer automatically if a rainfall figure, reported by a trusted data feed, is below a threshold at the end of the season. Nobody has to file a claim, but the result is only as honest as the feed.

JS Self-enforcing insurance with an oracle

Press Run (or Ctrl + Enter) to see the console output here.

No output.

What is real: the features, the application areas and the challenges describe real smart-contract systems. What is the stand-in: both models are plain JavaScript objects, so nothing is distributed, immutable or paid in real tokens, and the "oracle" is a function you control.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which everyday object did Nick Szabo use to explain a smart contract?

    A vending machine enforces its rules (price, stock) by itself, with no cashier to trust. That is the idea behind a smart contract.
  2. 2. What does trustless mean in this context?

    Trustless means the parties do not need to trust each other: the rules are public code that the network enforces.
  3. 3. Why can a deployed contract not simply fetch today's weather?

    Every node must reach the same result, so a contract cannot call arbitrary web services. An oracle publishes the data on-chain.
  4. 4. What is one major challenge of immutability?

    Because deployed code cannot be changed, mistakes are permanent. The 2016 DAO attack is the well-known example.
  5. 5. When is a plain database usually a better choice than a smart contract?

    A blockchain adds cost and complexity. It pays off when parties lack a common trusted operator.

Summary

  • A smart contract is a program on a blockchain that holds assets and enforces rules automatically. The idea comes from Nick Szabo's vending-machine analogy and became practical with Ethereum.
  • Core features: distributed, autonomous, trustless, self-verifying and self-enforcing, accurate and fast, transparent and customizable, and often cheaper than intermediaries.
  • Contracts act as multisig accounts, tokens, registries and DAOs, and are used in finance, real estate, supply chains, ownership records, royalties, voting, healthcare and insurance.
  • Limits: immutability, "code is law", the oracle problem, gas cost and scale, public data, legal uncertainty, user mistakes and security risk.
  • Use a blockchain when several mutually distrusting parties need shared state and automatic enforcement; otherwise a database may be simpler.

Next: see what happens inside the network when a contract executes in How a Smart Contract Runs.