Smart Contracts Explained
What a smart contract actually is
A smart contract is a program stored on a blockchain. It has an address (just like a wallet), it holds money, and it runs code when someone interacts with it.
The name is misleading. It is not smart (it does exactly what the code says, nothing more) and it is not a legal contract (it is software). Think of it as an automatic vending machine: you put in money, the machine follows its rules, and something comes out. No negotiation. No judgment calls.
A simple example
Imagine a bet between Alice and Bob: "If it rains tomorrow, Alice pays Bob 1 ETH. If it does not rain, Bob pays Alice 1 ETH."
Without a smart contract, they need to trust each other. With a smart contract:
- Both Alice and Bob send 1 ETH to the contract
- The contract checks a weather data feed (called an oracle) the next day
- If it rained, the contract sends 2 ETH to Bob
- If it did not rain, the contract sends 2 ETH to Alice
- Neither party can cheat or refuse to pay
- Smart contracts are programs on a blockchain that run automatically when triggered.
- They are permanent, transparent, and unstoppable.
- Real applications include exchanges (Uniswap), lending (Aave), and marketplaces (OpenSea).
- Bugs in smart contracts can lead to major losses — always check for audits.
- Oracles (like Chainlink) connect smart contracts to real-world data.
Real smart contracts you use today
Uniswap — a decentralized exchange. Its smart contracts hold over $5 billion in tokens. When you swap ETH for USDC, you interact with a contract that calculates the price using a mathematical formula and executes the trade instantly.
Aave — a lending protocol. You deposit ETH into a smart contract and earn interest. Borrowers deposit collateral and borrow against it. The contract enforces all the rules: interest rates, collateral ratios, and liquidations.
OpenSea — an NFT marketplace. When you buy an NFT, a smart contract transfers the NFT to your wallet and the payment to the seller. No middleman handles the exchange.
What makes smart contracts different from regular programs
| Feature | Regular program | Smart contract |
|---|---|---|
| Runs on | Company's servers | Thousands of blockchain nodes |
| Can be changed | Yes, the company pushes updates | No (code is permanent on-chain) |
| Can be shut down | Yes, by the company | No (runs as long as the blockchain exists) |
| Transparency | Usually closed-source | Code is publicly readable |
| Access | Company decides who can use it | Anyone with a wallet can interact |
| Costs to run | Company pays server bills | Users pay gas fees per transaction |
The risks
Smart contracts are only as good as their code. A bug in a smart contract can be exploited.
The DAO hack (2016): A smart contract on Ethereum held $60 million in ETH. A hacker found a reentrancy bug that let them drain $50 million. This led to Ethereum splitting into two chains (Ethereum and Ethereum Classic).
How to reduce risk: Look for contracts that have been audited by firms like Trail of Bits, OpenZeppelin, or Certora. Check if the project has a bug bounty program. Start with small amounts. And remember: audits reduce risk but do not eliminate it.
Key takeaways
Quiz: Smart Contracts Explained
1 / 5What is a smart contract?