A collection of vulnerable and secure Solidity smart contract examples for educational purposes.
Built and maintained by the Blockhertz team.
This repository helps blockchain developers understand common smart contract vulnerabilities by showing:
- ❌ Vulnerable code (what NOT to do)
- ✅ Secure code (the correct pattern)
- 📖 Explanation of each vulnerability
- 🔧 How to fix it
The most common smart contract vulnerability. Caused the $60M DAO hack in 2016.
📁 vulnerabilities/reentrancy/
📖 Full Guide
Anyone can call privileged functions. Caused the $611M Poly Network hack.
📁 vulnerabilities/access-control/
📖 Full Guide
Real example: BEC Token hack — $900M (2018)
📁 vulnerabilities/integer-overflow/ 📖 Full Guide
📁 vulnerabilities/tx-origin/
📖 Coming soon
MEV bots exploit transaction ordering.
📁 vulnerabilities/front-running/
📖 Coming soon
Check your contracts for all these vulnerabilities automatically in 60 seconds.
🔍 Try Blockhertz AI Auditor Free
- Paste any Solidity, Rust, Move, or Vyper contract
- Get risk score (0-100)
- See findings by severity
- Get fix recommendations
- No signup required
| Tool | Description |
|---|---|
| AI Smart Contract Auditor | Security scan in 60 seconds |
| AI Architecture Generator | C4 diagrams from text |
| AI Gas Optimizer | Reduce gas costs automatically |
| AI Tokenomics Designer | Token distribution + PDF report |
- 📖 How to Audit a Smart Contract
- 📖 Reentrancy Attack Guide
- 📖 Solidity Gas Optimization
- 📖 SWC Registry
- 📖 Consensys Best Practices
Found a vulnerability example we missed? Open a PR — contributions welcome!
MIT License — free to use for educational purposes.
⭐ Star this repo if it helped you!