A smart contract is a program stored on a blockchain that runs automatically when its predefined conditions are met, without needing a person or company to execute it manually. They're the foundation of most applications built on Ethereum. The Ethereum Foundation maintains the canonical explanation of how they execute.

Definition

A smart contract is code deployed to a blockchain that enforces an agreement's terms automatically. Once deployed, it runs exactly as written and can't be altered by any single party, including its creator, unless that ability was explicitly built in.

The name is a poor one and causes real confusion, so it is worth setting aside early. A smart contract is not a contract in the legal sense: it is not an agreement between named parties, no court is involved, and nothing about it is smart. It does not interpret intent, weigh fairness, or make judgments. It is a program with a bank account, running on a network that will execute it identically for anyone who asks. A vending machine is the standard analogy and it holds up well: insert the right input and the defined output follows, with no clerk deciding whether you deserve it.

What makes that arrangement interesting is the combination of two properties that rarely coexist. The code is public, so anyone can read exactly what it will do before touching it. And it is autonomous, so once deployed it keeps running whether or not its author is still around, still solvent, or still interested. Nobody has to be trusted to honor the terms, because nobody is in a position to dishonor them.

How they execute

When a transaction calls a smart contract, every node on the network runs the same code and reaches the same result, then updates the shared ledger accordingly. This is what lets a contract function without a trusted intermediary.

The consequence of every node running everything is that computation on a blockchain is extraordinarily expensive by ordinary standards. The same work is being done thousands of times over, in parallel, and paid for each time. This is why smart contracts are written to do as little as possible and why gas fees exist at all: you are not paying for a computer, you are paying for a global network to agree on the result.

Contracts are also inert. Nothing runs on a schedule, and a contract cannot wake itself up; it does nothing at all until a transaction calls it. Anything that appears to happen automatically at a certain time is someone, somewhere, sending a transaction to trigger it, and usually being paid to do so. Determinism is the other requirement: since every node must reach the identical result, contracts cannot use randomness or read anything outside the chain on their own, which turns out to be the source of their most important limitation.

Examples

A simple example is a decentralized lending app that automatically releases collateral once a loan is repaid, no bank employee involved. Smart contracts also power token standards such as ERC-20, NFT marketplaces, and decentralized finance applications broadly.

The thing worth noticing across those examples is that most of what you interact with in crypto already is a smart contract, whether or not the interface says so. Every token that is not a chain's native coin is a contract tracking balances internally. Every decentralized exchange is a contract holding pooled funds and pricing trades by formula. Every staking pool, lending market, and NFT collection is the same. The wallet you use shows friendly names and buttons; underneath, you are calling functions on programs that strangers wrote.

Limitations

Smart contracts only do exactly what their code says. Bugs or oversights in that code can be exploited, and mistakes are often irreversible once deployed. They also can't independently verify real-world facts without external data feeds, which introduces its own trust question.

The first limitation is the expensive one. Immutability is a guarantee that cuts in both directions: the same property that stops a founder from rewriting the rules against you stops anyone from fixing a bug in your favor. In ordinary software a flaw is patched on Tuesday. In a smart contract holding funds, a flaw is a standing invitation, and the money is gone before anyone can respond. This is the mechanism behind nearly every large DeFi loss, and it is why audits, formal verification, and battle-tested code matter so much more here than elsewhere.

The second limitation, the oracle problem, is subtler and rarely explained honestly. A contract can only see the chain it lives on. It cannot know a share price, a delivery, an election result, or the weather, so any contract that depends on real-world facts needs an oracle to feed data in, and the whole arrangement then rests on that oracle being correct and honest. Which means the trustless system has a trusted component bolted to the side of it, and manipulating the data feed has repeatedly proven easier than attacking the contract.

Worth adding a third, since marketing usually skips it: "immutable" is frequently untrue in practice. Most real contracts include upgrade mechanisms and admin privileges, often controlled by a multisig or a small team, because shipping unfixable code is terrifying. That is often the sensible engineering choice, and it also means someone can change the rules. Whether a contract actually has an admin key, and who holds it, is one of the most useful questions you can ask about any protocol, and one of the least frequently asked.

And a fourth, which is really a category error rather than a limitation: code cannot enforce anything off the chain. A contract can move tokens because tokens live where the contract lives. It cannot transfer a house, repossess a car, or compel a person to deliver goods, because none of those things are on a blockchain and no amount of clever programming puts them there. Contracts that touch the physical world always depend on a legal system or a company to bridge the gap, which means the trustless part ends precisely where the real world begins.

What they are actually good for

Put the limitations together and a clear picture emerges of where smart contracts genuinely earn their keep. They excel when everything relevant is already on the chain, the rules can be stated unambiguously, and the value of removing a middleman is high: swapping one token for another, lending against on-chain collateral, distributing funds by a fixed formula, proving who owns a digital asset. In every one of those, the contract needs to know nothing about the world and nobody needs to be trusted to act.

They are a bad fit for anything requiring judgment, negotiation, or knowledge of external facts, which is most of what human agreements are actually about. The early promise that smart contracts would replace lawyers has quietly not happened, and the reason is structural rather than a matter of the technology maturing. What they replaced instead is a narrower thing: the clearing house, the escrow agent, the exchange operator. That is a smaller claim than the original pitch, and it is the one that turned out to be true.