Smart Contracts
A smart contract is a program that lives on the blockchain and executes automatically when certain conditions are met.
The vending machine analogy
Think of a vending machine:
- You insert money
- You select a product
- The machine automatically gives you the product
There's no employee deciding whether to give you the product or not. The rules are programmed and they execute automatically.
A smart contract works the same way, but on the blockchain:
IF you receive 1 ETH from address
0xABCTHEN send 1000 USDC to address0xABC
That's it. The difference from a normal program is that it executes on its own, and once deployed no one can modify it or stop it — not even whoever wrote it.
What are they for?
Smart contracts are the foundation of almost everything interesting in crypto:
| Application | How it uses smart contracts |
|---|---|
| Decentralized exchanges | Automatic token swapping |
| Lending (DeFi) | Collateral and automatic liquidations |
| NFTs | Ownership and transfer of digital art |
| DAOs | Automatic voting and governance |
| Stablecoins | Maintaining the dollar peg |
Example: Decentralized exchange
When you swap ETH for USDC on Uniswap:
No one is "approving" your transaction. The code executes the same for everyone.
The risk isn't where you think
Understanding Solidity isn't what protects you. Money gets lost in one very specific moment: when your wallet asks you to sign and you accept without knowing what you're accepting.
That deserves its own page, with the four types of signature, which one is dangerous, and the checklist:
→ What to check before signing
Contracts also fail on their own
Even if you do everything right, the contract can have bugs. It's happened to large, audited protocols:
| Year | Project | Loss | Cause |
|---|---|---|---|
| 2016 | The DAO | $60M | Bug in the withdrawal function |
| 2023 | Euler Finance | $197M | Vulnerability in liquidations |
| 2023 | Curve Finance | $73M | Bug in the Vyper language |
| 2024 | Orbit Bridge | $82M | Compromised keys |
That's why it's worth preferring old, heavily-used protocols over new, shiny ones: not because they're infallible, but because they've gone more years without breaking.
Code is law (but be careful)
In crypto there's a phrase, "code is law." It means whatever is programmed into the smart contract is what will happen, no exceptions.
This has advantages (no one can censor you) but also downsides (if you get robbed, there's no "customer service" to help you).
Remember
- There's no "undo" button on the blockchain
- There's no bank to call to cancel a transaction
- Your security is 100% your responsibility
Sign vs Approve
To understand the critical difference between signing a message and approving a contract (where 90% of hacks happen), read the section Sign vs Approve in DeFi in 5 Minutes.
Summary
- Smart contracts are automatic programs on the blockchain
- They power applications like exchanges, lending, and NFTs
- They carry risks: bugs, excessive approvals, malicious contracts
- Always verify what you're signing before approving a transaction
If you came looking for something else:I'm about to receive crypto · I want to cash out to local currency · Start from the beginning