⚠ Trading involves significant risk of loss. Everything on this site is for education only and is not financial advice.
Lesson 9 of 13 · Free

Smart-contract risk, bridges and hacks

Understand how smart contracts and bridges fail, learn from documented hacks, and estimate how stacked risks reduce a DeFi yield.

Author: Moustafa HijaziContent reviewed: 2026-10-304 min readSelf-study course

What you will learn

  • The main ways smart contracts fail: code bugs, admin keys, oracles and upgrades.
  • How cross-chain bridges work and why they are large targets.
  • What three documented bridge hacks teach about different failure types.
  • How to combine several risk layers into one rough estimate of expected loss.

Explanation

A smart contract is a program stored on a blockchain that holds and moves tokens by fixed rules. Scams and phishing were covered in the Bitcoin course. This lesson is about a different danger: the protocol is honest, but the code or its setup fails.

Main failure types

  • Code bugs: for example reentrancy, where a contract sends funds before updating its records, so an attacker can call it again and withdraw repeatedly. The DAO on Ethereum lost about 3.6 million ETH this way in 2016.
  • Admin keys: many protocols have privileged keys that can pause, change or upgrade contracts. If a key is stolen or misused, users lose funds even when the code is correct. A multisig (multi-signature wallet) needs several keys, for example 5 of 9, to approve an action.
  • Upgradeable contracts: code can be replaced. A timelock delays upgrades, for example by 48 hours, so users can leave first.
  • Oracle manipulation: an oracle feeds external prices to a contract. If it reads a thin market, an attacker can move the price with a flash loan (a loan borrowed and repaid in one transaction) and trick a lending protocol.

An audit is a review of code by a security firm. It reduces risk but does not remove it; several hacked protocols were audited.

Bridges

A bridge moves value between blockchains. The common "lock-and-mint" design locks tokens in a contract on chain A and mints a wrapped token on chain B. The wrapped token is only an IOU. If the locked tokens are stolen, or unbacked tokens are minted, the wrapped token can lose most of its value. Bridges hold large pools in one place, which makes them attractive targets.

Case (2022) Approximate loss Root cause
Wormhole, February about $320 million Signature check bug: 120,000 wrapped ETH minted on Solana without deposits
Ronin, March about $625 million Attackers controlled 5 of 9 validator keys (an operational, not code, failure)
Nomad, August about $190 million A faulty upgrade made invalid messages look valid; many copycats joined

The lesson: risk sits in code, in key management and in upgrades. In the Wormhole case a related company replaced the funds; in other cases users were not fully repaid. Repayment is never guaranteed.

Worked example

Hypothetical example: you deposit €5,000 of a bridged stablecoin into a lending protocol on a Layer 2 network and expect 6% per year. You assign rough, invented annual failure probabilities to each layer: bridge 2%, Layer 2 network 1%, lending protocol 3%, price oracle 1%. Assumptions: layers fail independently; any failure means total loss; fees, gas and taxes ignored.

  1. Probability that no layer fails = 0.98 × 0.99 × 0.97 × 0.99 ≈ 0.932.
  2. Probability of at least one failure ≈ 1 − 0.932 = 0.068, about 6.8%.
  3. Expected loss ≈ €5,000 × 0.068 ≈ €342.
  4. Expected yield = €5,000 × 6% = €300.
  5. Risk-adjusted result ≈ €300 − €342 ≈ −€42 per year.

Compare: holding the stablecoin on its native chain in a simpler protocol with 1% and 2% risks gives 1 − (0.99 × 0.98) ≈ 3.0%, an expected loss of about €149 against perhaps 3% (€150) yield. Each extra layer must pay for itself.

Common mistake

"It is audited, so it is safe"An audit covers one code version at one point in time. It does not cover later upgrades, stolen admin keys, oracle design or the bridge your tokens came through. Treat an audit as a minimum, not a guarantee.

Practice activity

On paper: you consider depositing €10,000 in a pool that promises 9% per year. The tokens arrive via a bridge (assume 3% annual failure risk), the chain itself 2%, and the pool contract 4%. Assume independence and total loss on any failure. Calculate the probability of at least one failure, the expected loss and the risk-adjusted result.

Show solution

No failure = 0.97 × 0.98 × 0.96 ≈ 0.9126. At least one failure ≈ 8.7%.

Expected loss ≈ €10,000 × 0.087 ≈ €874. Expected yield = €900.

Risk-adjusted result ≈ €900 − €874 ≈ €26 per year: almost nothing for a large possible total loss.

Limitations: real probabilities are unknown, failures are often linked (one hack can trigger others), and partial losses or repayments are possible. The method helps you compare structures, not measure true risk.

Key takeaways

  • Smart-contract risk includes code bugs, admin keys, upgrades and oracles.
  • Wrapped tokens are IOUs; if the bridge fails, they can become nearly worthless.
  • Each layer you add (bridge, network, protocol, oracle) multiplies the chance of failure.
  • Audits and timelocks reduce risk; they never remove it, and repayment after a hack is not guaranteed.

Next step

The next lesson looks at NFTs and the tokenisation of real-world assets: what the token actually gives you and where the risks are.

Self-check

Answer the questions, then check your answers. You can retry as often as you like.

1. In a lock-and-mint bridge, what backs the wrapped token on the destination chain?

2. The Ronin bridge loss in 2022 was mainly caused by what?

3. You stack three independent layers with annual failure risks of 1%, 2% and 2%. Roughly what is the chance that at least one fails in a year?

Automatic self-check for your own revision. Your answers are checked in your browser and are not seen or assessed by us. It is not an exam and not a qualification.

Your progress

“Complete” only means you marked the lesson as done. It is not a test of your understanding. Progress and notes are saved only in this browser on this device — not in an account.