Web3 & Blockchain

What Is a Smart Contract? Examples and Limitations

A plain-English guide to smart contracts: how self-executing code works, real business examples and why a single bug can lock up or lose millions.

Quick answer

A smart contract is a program stored on a blockchain that runs automatically when preset conditions are met, such as releasing payment once delivery is confirmed. It removes the middleman for simple rules. But its code is hard to change once deployed, it can't verify real-world facts on its own, and bugs can cost real money.

What Is a Smart Contract? Examples and Limitations

Photo: Unsplash

On this page

Imagine a vending machine. You put in the right amount of money, press a button and the snack drops. No cashier checks your payment or decides whether to hand it over. The machine follows its rules automatically.

That’s the idea behind a smart contract, and it’s the analogy Ethereum’s own documentation uses, crediting computer scientist Nick Szabo, who described smart contracts in the 1990s. Today smart contracts power stablecoins, crypto lending platforms, tokenized funds and some supply chain and insurance pilots.

This guide explains what a smart contract is, how it works, where businesses use it and the limitations you need to understand before trusting one with money.

What a smart contract is, in plain English

A smart contract is a program stored on a blockchain that runs automatically when specific conditions are met. On Ethereum, a smart contract lives at its own address, can hold funds and executes its code whenever someone sends it a transaction.

3 features make it different from ordinary software:

  1. It runs on a shared network. No single company hosts it. Thousands of computers run the same code and agree on the result.
  2. It’s hard to change. Once deployed, the code generally can’t be edited. Interactions with it can’t be reversed.
  3. It’s transparent. On public blockchains, anyone can inspect the code and every transaction it processes.

Despite the name, a smart contract isn’t necessarily a legal contract. It’s code that enforces rules. Sometimes those rules match a legal agreement; often they’re just the logic of an app.

How a smart contract works

Here’s the typical lifecycle:

  1. A developer writes the code, often in Solidity, the most common language for Ethereum and compatible blockchains.
  2. The code is compiled and deployed to the blockchain, which gives it an address.
  3. Users or other contracts send transactions to it, such as “deposit 100 USDC” or “release payment.”
  4. The network executes the code. Every validating node runs it and agrees on the outcome. Users pay a network fee, called gas on Ethereum, for the computation.
  5. The result is recorded on the blockchain, for example a balance updated or tokens transferred.

A simple escrow contract might say: when the buyer deposits funds, hold them. When the buyer confirms delivery, or 30 days pass with no dispute, send the funds to the seller. If a dispute is raised, send the funds to an agreed arbitrator’s address.

The oracle problem

Smart contracts can’t look up real-world information on their own. Ethereum’s documentation says this is by design, since relying on outside data could break consensus between nodes. To learn a stock price, a flight’s arrival time or whether a package was delivered, a contract relies on an oracle, a service that feeds external data onto the blockchain. That makes the oracle a point of trust: if the data is wrong or manipulated, the contract will still execute on it.

Real business examples

Use case What the smart contract does Where it’s used
Stablecoins and tokens Tracks balances and handles transfers, minting and burning of tokens Dollar-backed stablecoins and other digital tokens
Decentralized finance (DeFi) Automates lending, borrowing and trading with collateral rules Crypto lending and exchange protocols
Tokenized funds and bonds Records ownership, restricts transfers to approved investors, distributes payouts Tokenized money market funds and treasuries
Escrow and payments Holds funds and releases them when conditions are met Freelance marketplaces, trade finance pilots
Supply chain Triggers payments or records when shipments are scanned or received Traceability pilots
Parametric insurance Pays out automatically when an oracle reports a trigger event, like a flight delay or rainfall level Insurance pilots
Royalties and licensing Splits revenue among creators automatically on each sale NFT marketplaces, music pilots
Digital identity and credentials Verifies certifications or memberships Credential and access pilots

Tokenized real-world assets are among the fastest-growing areas. Asset managers now issue fund shares as tokens whose transfer rules are enforced by smart contracts. Our guide to real-world asset tokenization explains how that works. In logistics, smart contracts often sit on top of traceability systems; see blockchain in supply chain for what has worked and what hasn’t.

Key takeaway: A smart contract is best at enforcing simple, digital, if-this-then-that rules between parties who don’t want to rely on a middleman. The more a deal depends on real-world facts or human judgment, the weaker the fit.

Why bugs in smart contracts are so costly

In normal software, a bug gets patched in the next update. In a smart contract, the bug may be permanent, and the contract may be holding millions of dollars that anyone in the world can try to take.

2 famous incidents show what’s at stake:

  • The DAO (2016). An investment fund built as an Ethereum smart contract was attacked through a code flaw. According to ethereum.org, the attack drained over 3.6 million ETH. The Ethereum community responded with a hard fork on July 20, 2016 that moved the funds to a contract where holders could withdraw them. Miners who rejected the fork kept the original chain, which became Ethereum Classic.
  • Parity multisig wallets (2017). A bug in a shared code library let a user trigger the library’s self-destruct function, which made a group of multisignature wallets that depended on it unusable. More than 500,000 ETH, worth roughly $150 million at the time, was frozen.

The most common weaknesses today are well documented. OWASP, the security nonprofit, maintains a Smart Contract Top 10 list of vulnerability types, including access control flaws (functions anyone can call that should be restricted), logic errors, price oracle manipulation and reentrancy (where a malicious contract calls back into a contract before it finishes updating balances).

Why are these bugs so expensive?

  • Code is public, so attackers can study it at leisure.
  • Funds are directly accessible, with no bank fraud team in the way.
  • Transactions are irreversible, so stolen funds are hard to recover.
  • Contracts interact with each other, so a flaw in one can cascade into others.

Other limitations to understand

  • Immutability cuts both ways. You can’t easily fix a mistake. Some teams use “upgradeable” designs, but that reintroduces trust in whoever controls the upgrade keys.
  • Garbage in, garbage out. A contract can only be as accurate as its inputs and oracles.
  • Legal status varies. Some states, including Arizona in 2017 and Tennessee in 2018, passed laws saying a contract can’t be denied legal effect solely because it uses a smart contract. But code alone rarely covers disputes, liability or consumer protections. This is not legal advice.
  • Regulation still applies. Automating a financial activity doesn’t exempt it from securities, commodities, anti-money laundering or consumer rules. See who regulates crypto in the US.
  • Costs and speed. Every operation costs network fees, and public blockchains have limits on computation and contract size.
  • Privacy. On public blockchains, transaction data is visible to everyone, which many businesses can’t accept.
  • Scams. Malicious contracts can be designed to drain wallets that approve them. Our guide on how to avoid crypto scams covers common tricks.

Smart contract vs. traditional contract

Factor Smart contract Traditional contract
Enforcement Automatic, by code By parties, courts or arbitrators
Speed Executes in seconds to minutes Days to months for disputes
Flexibility Hard to amend once deployed Can be renegotiated or amended
Handles ambiguity Poorly, needs exact rules Well, through interpretation
Real-world facts Needs an oracle Evidence and judgment
Transparency Code and transactions often public Usually private
Error recovery Often irreversible Courts can unwind or award damages

Many real deployments combine the 2: a written legal agreement that references the smart contract and covers what happens if something goes wrong.

Where to start: evaluating a smart contract project

If you’re a business owner or product leader considering smart contracts, use these 6 steps:

  1. Define the rule you want to automate. If you can’t write it as a clear if-then statement, it’s probably not a good fit.
  2. Ask why it needs a blockchain. If one trusted party could run the logic in a normal database, that’s usually cheaper. Multi-party processes with low trust are the sweet spot.
  3. Identify your data sources. Which oracles or systems will feed the contract, and what happens if they fail?
  4. Use proven building blocks. Well-tested open-source libraries reduce risk compared with writing everything from scratch.
  5. Budget for security. Plan for independent audits, automated testing, bug bounties and monitoring. Our pre-launch software QA checklist is a good companion.
  6. Write the legal layer. Pair the code with terms covering disputes, upgrades, liability and compliance.

Developers can explore the basics with a test network before deploying anything with real value. AI tools can help write and review code; see how AI coding assistants are changing software teams, but don’t treat AI review as a substitute for a professional audit.

The bottom line

A smart contract is self-executing code on a blockchain: reliable for simple, digital rules, transparent and hard to tamper with. Those same traits make mistakes permanent and expensive. Use smart contracts where automation between parties who don’t fully trust each other adds real value, invest heavily in security and keep a legal agreement behind the code. For related terms like oracle, gas and DeFi, see our glossary.

Sources

Questions readers ask

Frequently asked questions

What is a smart contract in simple terms?

A smart contract is a computer program stored on a blockchain that automatically carries out an agreement when set conditions are met. Think of a vending machine: put in the right payment, pick an item and it's dispensed without a cashier. Smart contracts work the same way for digital assets, like releasing a payment when a buyer confirms delivery, without a bank or broker in the middle.

What is an example of a smart contract?

A common example is a stablecoin, where a smart contract tracks who owns tokens and handles every transfer. Other examples include crypto lending platforms that automatically liquidate collateral when its value drops, escrow contracts that release payment on delivery, tokenized funds that only allow approved investors to hold shares, and insurance pilots that pay out automatically when a flight delay is reported by an oracle.

Are smart contracts legally binding?

Sometimes. A smart contract is code, not automatically a legal contract. If it meets the usual requirements for a contract, such as offer, acceptance and consideration, it can be enforceable, and states like Arizona and Tennessee have laws saying a contract can't be denied legal effect just because it uses a smart contract. Most businesses pair the code with a written agreement. This is not legal advice.

Can a smart contract be changed or deleted?

Generally no. Once deployed, a smart contract's code usually can't be edited, and transactions it has processed can't be reversed. Developers sometimes use upgradeable designs, where a contract points to replaceable logic, or include a pause function. Those options make fixes possible but mean someone holds special control, which users have to trust. That's why testing and audits before launch matter so much.

What language are smart contracts written in?

Most smart contracts on Ethereum and compatible blockchains are written in Solidity, a language designed for the Ethereum Virtual Machine. Vyper is another Ethereum option. Other blockchains use different languages, such as Rust for Solana and Move for some newer networks. Developers typically use testing frameworks and well-audited open-source libraries rather than writing every component from scratch.

What is a smart contract audit and do I need one?

A smart contract audit is an independent security review of a contract's code, looking for bugs, logic errors and known vulnerabilities before it handles real money. If your contract will hold or move funds, you should get one, and many projects get several. Audits reduce risk but don't guarantee safety, so teams also use automated testing, bug bounties and ongoing monitoring after launch.

What is the biggest risk of smart contracts?

The biggest risk is a code bug or design flaw that attackers exploit to steal or lock funds, since transactions are usually irreversible and the code is public. The 2016 DAO attack drained over 3.6 million ETH. Other major risks include manipulated oracle data, compromised admin keys on upgradeable contracts, and malicious contracts that trick users into approving access to their wallets.

Reader reviews

Was this guide useful

No reviews yet. Share your experience and help other readers.

Write a review
Your rating
Never shown publicly

Reviews are checked before they appear. We never show your email. Please review only places or services you have used.

Manishdai
Written by

Manishdai

Manishdai writes about the technology that is reshaping every industry — from AI agents and cloud platforms to healthtech, fintech and the IT companies building it all across the United States.