Key takeaways
- A smart contract is a program stored on a blockchain. Once deployed, it runs exactly as written whenever someone calls it, without a company in the middle.
- Contracts power stablecoins, decentralized exchanges, lending markets, NFTs and tokenized funds.
- “Code is law” cuts both ways: a bug is executed just as faithfully as a feature, and it is visible to every attacker.
- Most big losses come from a few patterns: logic bugs, stolen or misused admin keys, bad price data, and flawed bridges.
Smart contracts are what turned blockchains from payment networks into platforms. A smart contract is a piece of code stored at an address on a chain like Ethereum. It can hold funds, keep records and follow rules: if this happens, do that. Anyone can use it by sending a transaction, and nobody, not even the people who wrote it, can quietly change how it behaves unless that ability was built in.
That design makes new kinds of finance possible. It also creates new kinds of risk. This guide explains both. For the machinery underneath, read How Ethereum Works first.
A simple example
Imagine a vending machine. You put in the right coins, press a button and the machine releases a drink. No shop assistant is needed, and the machine treats everyone the same. A smart contract is a digital version. A basic escrow contract might say: hold the buyer’s payment; release it to the seller when the buyer confirms delivery, or refund the buyer if nothing happens within 30 days. Once deployed, neither side can change those terms.
What smart contracts are used for
| Use | What the contract does | Examples |
|---|---|---|
| Tokens | Keeps a record of who owns how many units | USDC, LINK, UNI |
| Exchanges | Holds pools of tokens and swaps them at a formula price | Uniswap, Curve |
| Lending | Takes collateral, issues loans and sells collateral if it falls too far | Aave, Morpho |
| Stablecoins | Mints and burns tokens, sometimes against crypto collateral | USDS, USDe |
| Tokenized assets | Tracks ownership of fund shares or bonds | BlackRock BUIDL, Franklin Templeton funds |
| Multisig wallets | Requires several signatures to move funds | Safe |
Our guide to DeFi covers the financial uses in more depth.
What makes them different from normal software
- Public: the code and every interaction are visible to anyone, including attackers.
- Holds money directly: a bug does not just crash an app, it can release funds.
- Hard to change: deployed code is usually permanent. Fixing a bug may mean deploying a new contract and asking everyone to move.
- Composable: contracts call each other like building blocks. That makes innovation fast but means one failure can spread.
- No undo: there is no bank or court that can reverse a confirmed transaction.
How smart contracts fail
1. Logic bugs
The code does something its authors did not intend. The classic case is The DAO in 2016, an early investment fund on Ethereum. A flaw called reentrancy let an attacker repeatedly withdraw funds before the contract updated its balance, draining about a third of its ether. The Ethereum community responded with a hard fork to return the funds, which is why Ethereum Classic exists as a separate chain today. Rounding errors, missing checks on who can call a function, and wrong order of operations still cause losses every year.
2. Admin key and access control failures
Many contracts can be upgraded or paused by an admin key, often held in a multisig wallet. If those keys are stolen, or a signer is tricked into approving a malicious change, the attacker gets full control. Some of the largest crypto thefts, including the $1.5 billion taken from the exchange Bybit in February 2025, came from attackers compromising the process around signing rather than finding a bug in the contract itself.
3. Oracle manipulation
Contracts cannot read the internet, so prices come from oracles. If a lending protocol reads a price from a single thin market, an attacker can push that price around with a large trade, often using a flash loan, which is a huge loan that must be repaid in the same transaction. The protocol then lends far too much against inflated collateral.
4. Bridge failures
Bridges lock assets on one chain and issue copies on another. They hold large pools of funds and depend on complex verification, which makes them prime targets. The Ronin bridge lost about $625 million in 2022 after attackers took control of validator keys; Wormhole lost about $325 million the same year through a flaw in how it verified signatures.
5. Economic and design flaws
Sometimes the code works exactly as designed, but the design breaks under stress: a stablecoin that loses its peg, liquidations that cannot keep up in a crash, or incentives that reward attacks. Smaller chains can face these problems too; the recent Initia exploit forced a chain halt.
How projects reduce the risk
- Audits: independent security firms review the code before launch. Audits find many issues but are no guarantee; plenty of audited contracts have been exploited.
- Bug bounties: paying ethical hackers to report flaws instead of exploiting them.
- Formal verification: mathematically proving the code matches a specification, used for the most critical systems.
- Time locks: delaying admin changes for days so users can leave if they disagree.
- Battle testing: code that has held billions for years without incident has earned some trust that new code has not.
Questions to ask before using a contract
- How long has it been live, and how much value does it hold?
- Has it been audited, by whom, and were the findings fixed?
- Can it be upgraded or paused, and who holds those keys? Is there a time lock?
- Where does it get prices from?
- Does it depend on a bridge or another protocol that could fail?
- What exactly am I approving when my wallet asks me to sign?
That last question matters most for everyday users. Approving a malicious contract is how many wallet drainers work, as our guide to common crypto scams explains.
You might also like
Sources: ethereum.org: Introduction to smart contracts, ethereum.org: Smart contract security, ethereum.org: Oracles, FBI: North Korea responsible for $1.5 billion Bybit hack





