Smart contract

Smart contract: A smart contract is a program stored on a blockchain that runs automatically when set conditions are met. Once deployed, anyone can check its code and it executes the same way for everyone, without a company in the middle. Smart contracts power token swaps, lending apps, stablecoins and NFTs, mostly on Ethereum and similar networks.

By Matt Willemsen, Director of Research, reviewed by Ben Simpson. Updated November 2026. General education only.

How a smart contract works

A smart contract follows “if this, then that” logic. Ethereum’s developer documentation compares it to a vending machine: put in the right input and you get a set output. Each action is a blockchain transaction, so it costs a network fee, called gas on Ethereum. The term was coined by computer scientist Nick Szabo in the 1990s, years before blockchains could run them.

Where smart contracts are used

Most of DeFi runs on smart contracts. A decentralised exchange uses them to hold liquidity pools and price swaps, lending apps use them to manage collateral and loans, and token contracts record who owns each token. Apps built on top of these contracts are often called dapps.

Smart contract risks

Code can contain bugs, and many contracts cannot be changed once deployed, so a flaw can be exploited before anyone can fix it. Some contracts can be upgraded by an admin key, which means you are trusting whoever controls that key. Contracts that rely on outside price data also depend on an oracle. A security audit reduces risk but does not remove it.

What this means for investors

When you connect a wallet to an app, you often approve a smart contract to move a token on your behalf. Only approve contracts you have checked, review old approvals from time to time and keep long-term holdings in a separate wallet from the one you use for apps. A smart contract does exactly what its code says, which is not always what its website says.

Frequently asked questions

Is a smart contract legally binding?

Not automatically. A smart contract is code that executes on a blockchain. Whether an arrangement is legally enforceable depends on the law that applies, not on the code.

Can a smart contract be changed?

It depends on how it was built. Some are fixed once deployed. Others use an upgrade pattern controlled by an admin key or a governance vote, which adds trust in whoever holds that control.

Do smart contracts only run on Ethereum?

No. Ethereum popularised them, and many other networks, including Solana and Ethereum layer 2 networks, also run smart contracts.

Related guides