What is a smart contract and why you can trust it with money
A smart contract is a program on a blockchain that executes a deal's terms by itself. How it works, how it differs from an ordinary contract and what its risks are.
In this article
A smart contract is a program that lives on a blockchain. It has its own address, like a wallet, and it can receive, hold and send money by rules written in its code. The name misleads: "smart" here means automatic, not intelligent, and "contract" is not a legal agreement but code.
A vending machine as an image
The classic comparison is a vending machine. You insert coins, press a button and the machine gives you the product. No seller you must trust: the mechanism checks the conditions and carries them out. A smart contract is the same machine, only with any number of conditions and "products", and it runs identically for everyone on thousands of computers.
How a smart contract differs from an ordinary program
It is public. The contract's code and state are visible to all in a block explorer. Anyone can check what will happen to the money.
It is executed by the network. There is no server that can be switched off or bribed. Every node of the network runs the code and gets the same result.
It usually cannot be changed after launch. If a contract is written without upgradability, the rules stay the same forever. That is both the main virtue and the main risk - mistakes cannot be fixed.
It cannot "start" anything by itself. A contract acts only in response to a transaction: someone must call its function and pay the network fee.
What a contract can and cannot do
A contract is great at holding money and enforcing rigid rules: "if condition X is met, send amount Y to address Z". But it does not know what happens outside the blockchain. Whether the goods arrived, whether the work was good, whose word is truer - code cannot check any of that.
That is why in real-world deals a smart contract is complemented by a person - the guarantor. The contract ensures the money will not vanish and will be paid by rules, while the guarantor settles questions code cannot: who is right in a dispute. More in the article on escrow and guarantors.
What a contract consists of
Looking inside an escrow contract as an example:
- State - the data the contract remembers: the list of deals, amounts, participants, statuses.
- Functions - actions that can be called: create an offer, accept, confirm receipt, open a dispute.
- Access rules - who may call a function: only the buyer can confirm receipt, only the guarantor can give a ruling.
- Events - entries in the blockchain's journal: "deal created", "deal settled". Interfaces and services read them.
For example, in our contract a deal has five states: none, offer, active, dispute, settled. Transitions between them are strictly limited - for instance from "settled" there is no exit at all. How this is written in code is in the article on the state machine in Solidity.
Risks to know about
Bugs in the code. A contract does exactly what is written, not what the author meant. Several famous losses in blockchain history happened exactly like this. So serious contracts go through testing, static analysis and independent audit - see the article on testing contracts.
Irreversibility. There is no "undo" button. If you signed a transaction to a malicious contract the money cannot be returned.
Dependence on the environment. A contract depends on the tokens and other contracts it interacts with. A token with non-standard behaviour can break the logic - see the article on non-standard tokens.
The human factor around it. A contract can be flawless while the interface is fake. So check the site address and read what you sign.
How to check a smart contract
- Find the contract address on the service's official site.
- Open it in your network's block explorer: check the code is published and verified.
- See who the owner is and what they can do: can they change rules, take money, pause.
- Find out whether there is an audit and what the developers have done before.
More on reading an explorer in the article how to read Etherscan.
What to read next
Now you have the whole picture: the blockchain stores data, the wallet signs, the smart contract executes rules. The next step is to learn what digital assets consist of: tokens and NFTs, and then what to pay with: stablecoins and their risks. Can you read code? See the Solidity tour.
Keep reading
- 1 · Basics
Tokens and NFTs - what they are, how they differ and where they are used
An overview of tokens on Ethereum - fungible (ERC-20) and unique (NFTs, ERC-721 and ERC-1155), how they work, where they are used and what risks they carry.
3 min read - 3 · Under the hood
A tour of the Solidity language - types, functions, errors and events by example
A short practical tour of Solidity for those who can read code: contract structure, types, visibility, modifiers, errors and events. Examples from the escrow.
4 min read
Mentioned in
- What is a blockchain, in plain words
- What is cryptocurrency and where do coins come from
- Bitcoin vs Ethereum - the difference and why deals are built on Ethereum
- Crypto wallet, address and seed phrase: how not to lose your money
- Tokens and NFTs - what they are, how they differ and where they are used
- dApps and DeFi - decentralised applications and finance without middlemen
- Escrow: how a deal with a guarantor works
- Glossary - blockchain, wallets, smart contracts and escrow from A to Z
- The deal lifecycle - from offer to payout, step by step
- ENS - readable names instead of long Ethereum addresses
- Multisig and timelock - managing a contract without a single point of failure
- Ethereum accounts and state - EOAs, contracts and the world state
- A tour of the Solidity language - types, functions, errors and events by example
- Proxies and upgradeable contracts - delegatecall, UUPS and the price of flexibility
- Oracles and the oracle problem - how a blockchain learns about the outside world
- Rollups under the hood - batches, fraud proofs, ZK, blobs and withdrawals
Ready to try it?
Create your first deal in a couple of minutes. The money is locked in a smart contract and paid out by rules you can see in advance.

