
How to Audit a Smart Contract: Complete Security Checklist (2026)
Smart contracts are immutable once deployed — there is no patch, no rollback, no hotfix. The average DeFi exploit in 2026 costs over $4 million, and the most common causes are reentrancy, integer overflow, and access control failures. This practical tutorial walks you through the complete smart contract security audit checklist — every vulnerability category, how to detect it, and how to fix it before deployment.
This guide covers exactly how to audit a smart contract before deployment, the top 10 vulnerabilities to check, and how to use AI-powered tools to speed up the process.
What Is a Smart Contract Audit?
A smart contract audit is a systematic security review of blockchain code — typically written in Solidity, Rust, Move, or Vyper — to identify vulnerabilities before deployment.
A proper audit answers three questions:
- Can funds be stolen or drained?
- Can the contract be manipulated to behave unexpectedly?
- Does the code do what the documentation says it does?
Professional audits from firms like Trail of Bits, OpenZeppelin, or Certik cost between $5,000 and $50,000 depending on contract complexity. AI-powered pre-audits — like the one offered by Blockhertz — can catch the most critical vulnerabilities in under 60 seconds, for free.
Why Smart Contract Audits Matter in 2026
In 2026, DeFi protocols, NFT projects, and DAOs collectively hold over $200 billion in on-chain value. This makes smart contract vulnerabilities one of the most lucrative attack vectors in cybersecurity.
Notable exploits that a proper audit could have prevented:
- The DAO Hack (2016): $60M drained via reentrancy — the same vulnerability still found in contracts today
- Poly Network (2021): $611M stolen via access control flaw
- Wormhole Bridge (2022): $320M exploited via signature verification bypass
The pattern is consistent: most major exploits involve well-known, documented vulnerability classes that a thorough audit would have caught.
The Smart Contract Security Audit Checklist
Use this checklist before deploying any smart contract to mainnet.
1. Reentrancy Attacks
What it is: An attacker calls your contract's withdraw function, receives ETH, and before your balance updates — calls withdraw again recursively until funds are drained.
What to check:
- Does any function send ETH or tokens before updating state?
- Is the Checks-Effects-Interactions pattern followed?
- Are external calls made before state changes complete?
The fix:
// WRONG — vulnerable to reentrancy
function withdraw(uint amount) external {
require(balances[msg.sender] >= amount);
(bool success,) = msg.sender.call{value: amount}("");
balances[msg.sender] -= amount; // too late
}
// CORRECT — Checks-Effects-Interactions
function withdraw(uint amount) external {
require(balances[msg.sender] >= amount); // Check
balances[msg.sender] -= amount; // Effect
(bool success,) = msg.sender.call{value: amount}(""); // Interact
}
Or use OpenZeppelin's ReentrancyGuard:
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
contract SafeVault is ReentrancyGuard {
function withdraw(uint amount) external nonReentrant {
// protected
}
}
2. Access Control Issues
What it is: Functions that should only be called by the owner or admin can be called by anyone — allowing unauthorized minting, fund withdrawals, or parameter changes.
What to check:
- Does every privileged function have an access modifier?
- Are ownership transfers protected?
- Can any external address call administrative functions?
The fix:
import "@openzeppelin/contracts/access/Ownable.sol";
contract Token is Ownable {
function mint(address to, uint amount)
external onlyOwner {
_mint(to, amount);
}
function setFee(uint newFee)
external onlyOwner {
fee = newFee;
}
}
3. Integer Overflow and Underflow
Integer overflow is one of the most searched and least understood vulnerabilities in Solidity. It occurs when arithmetic exceeds an integer type's maximum value and silently wraps to zero — no error, no revert, no warning. This practical section shows you how to detect and fix it in both legacy and modern Solidity contracts.
What it is: Arithmetic operations that exceed the maximum or minimum value of a data type, causing unexpected results.
What to check:
- Are you using Solidity 0.8.0 or higher? (Built-in overflow protection)
- Do any contracts use older Solidity with manual SafeMath?
- Are unchecked blocks used safely?
The fix:
// Only use unchecked when certain overflow can't happen
unchecked {
for (uint i = 0; i < array.length; ++i) {
// loop body
}
}
4. Tx.origin Authentication
What it is: Using tx.origin for authentication instead of msg.sender allows phishing attacks where a malicious contract tricks users into calling your contract.
What to check:
- Does any function use
tx.originfor authentication? - Replace all
tx.originchecks withmsg.sender
The fix:
// WRONG
require(tx.origin == owner, "Not owner");
// CORRECT
require(msg.sender == owner, "Not owner");
5. Unchecked Return Values
What it is: Low-level calls (send, call, transfer) can fail silently if their return values are not checked.
What to check:
- Are all external call return values checked?
- Is
transfer()used safely (it reverts on failure)? - Are
call()return values always validated?
The fix:
// WRONG — ignores failure
payable(recipient).send(amount);
// CORRECT — check return value
(bool success,) = payable(recipient).call{value: amount}("");
require(success, "Transfer failed");
6. Front-Running Vulnerabilities
What it is: Miners or MEV bots can see pending transactions in the mempool and submit their own transaction with a higher gas fee to execute first — exploiting price-sensitive operations.
What to check:
- Does your contract have functions where transaction order matters?
- Are there price oracle reads that can be sandwiched?
- Are there commit-reveal schemes where needed?
The fix:
- Use commit-reveal patterns for sensitive operations
- Integrate Chainlink VRF for randomness (never use block.timestamp)
- Use slippage protection for DEX interactions
7. Timestamp Dependence
What it is: Using block.timestamp for critical logic is dangerous as miners can manipulate it within a ~900 second window.
What to check:
- Is
block.timestampused for randomness? - Is
block.timestampused for time locks under 15 minutes?
The fix:
- Use
block.timestamponly for time periods longer than 15 minutes - Never use it as a source of randomness
- Use Chainlink for external time validation if precision matters
8. Floating Pragma
What it is: Using pragma solidity ^0.8.0 allows your contract to be compiled with any 0.8.x version, including versions with known bugs.
The fix:
// WRONG — floating pragma
pragma solidity ^0.8.0;
// CORRECT — locked pragma
pragma solidity 0.8.20;
9. Self-Destruct Exposure
What it is: If selfdestruct is callable by unauthorized parties, the entire contract can be destroyed and all funds sent to an arbitrary address.
The fix:
// Protect with access control
function emergencyDestruct(address payable recipient)
external onlyOwner {
selfdestruct(recipient);
}
Note: In most production contracts, selfdestruct should be removed entirely.
10. Gas Limit Issues
What it is: Functions that loop over unbounded arrays can hit the block gas limit, causing permanent denial of service.
The fix:
// WRONG — unbounded loop
function payAll() external {
for (uint i = 0; i < users.length; i++) {
payable(users[i]).transfer(amounts[i]);
}
}
// CORRECT — paginated
function payBatch(uint start, uint end) external {
require(end <= users.length);
for (uint i = start; i < end; i++) {
payable(users[i]).transfer(amounts[i]);
}
}
Smart Contract Audit Checklist — Quick Reference
Critical (must fix before deployment):
- ☐ No reentrancy vulnerabilities
- ☐ All privileged functions have access control
- ☐ No
tx.originused for authentication - ☐ All external call return values checked
- ☐ No self-destruct accessible by non-owners
High Priority:
- ☐ Integer overflow protected (Solidity 0.8+ or SafeMath)
- ☐ No front-running vulnerabilities in critical functions
- ☐ Pragma locked to specific version
- ☐ No unbounded loops that can hit gas limit
Medium Priority:
- ☐ No timestamp dependence for critical logic
- ☐ Events emitted for all state changes
- ☐ Constructor initializes all critical variables
- ☐ No unused variables or dead code
Manual vs AI Smart Contract Audit
| Manual Audit | AI Pre-Audit | |
|---|---|---|
| Cost | $5,000–$50,000 | Free |
| Time | 2–6 weeks | Under 60 seconds |
| Depth | Very deep | Surface + patterns |
| Best for | Pre-deployment final check | Early development, quick checks |
The recommended approach in 2026:
- Use an AI auditor during development to catch issues early
- Fix all AI-identified vulnerabilities
- Get a professional manual audit before mainnet deployment
- Re-run AI audit after any code changes
How to Run a Free AI Smart Contract Audit
Blockhertz AI Auditor scans your contract for all vulnerabilities listed in this guide — in under 60 seconds, for free.
How to use it:
- Go to blockhertz.com/tools/ai-auditor
- Paste your Solidity, Rust, Move, or Vyper contract
- Click "Audit Contract"
- Get a full security report with risk score, findings by severity, and fix recommendations
No signup required for the free tier. No credit card needed.
For contracts that are already deployed, the Blockhertz AI Auditor can now pull the verified source directly from the block explorer — paste an address and pick the chain (Ethereum, Base, Arbitrum, Optimism, Polygon or BNB Chain), and the audit runs against the exact code that is live on-chain, no manual copy-paste required.
Try it free: blockhertz.com/tools/ai-auditor
Conclusion
Smart contract security is not optional in 2026. With billions of dollars locked in on-chain protocols and no ability to patch deployed code, a thorough audit before deployment is one of the most important investments a blockchain developer can make.
Use this checklist on every contract you write. Run an AI pre-audit during development to catch issues early. And before deploying to mainnet with real funds, get a professional manual audit from a reputable security firm.
Your contract's security is your users' money. Treat it accordingly.
Need a quick security check? Run a free AI smart contract audit at blockhertz.com/tools/ai-auditor — results in under 60 seconds.
Frequently Asked Questions
What is an integer overflow in a smart contract audit?
An integer overflow occurs when an arithmetic operation produces a result larger than the maximum value the data type can hold, causing it to wrap around to a very small or negative number. In Solidity, uint8 holds values 0–255; adding 1 to 255 wraps to 0. Auditors check every arithmetic operation — especially in token balances, loop counters, and reward calculations — because a single overflow can let an attacker mint unlimited tokens or drain a contract.
How do you detect integer overflow during a smart contract audit?
Auditors use four complementary approaches: (1) static analysis tools like Slither and MythX flag unchecked arithmetic automatically; (2) manual code review traces every arithmetic path to verify SafeMath usage or Solidity 0.8+ built-in overflow checks; (3) fuzzing with Echidna generates random inputs to trigger edge cases; (4) symbolic execution with Manticore explores all possible numeric states. For Solidity < 0.8, any math without SafeMath or explicit bounds checks is a red flag.
Does Solidity 0.8 automatically prevent integer overflow?
Yes — Solidity 0.8.0 introduced built-in overflow and underflow protection that reverts the transaction automatically. However, code inside unchecked { } blocks bypasses this protection, so auditors specifically review every unchecked block to confirm it is intentional and safe. Contracts compiled with Solidity < 0.8 without SafeMath remain vulnerable.
What should a complete smart contract security checklist include?
A production-grade checklist covers: reentrancy guards on all external calls, integer overflow/underflow protection, proper access control (onlyOwner, role-based), timestamp dependency risks, front-running exposure, oracle manipulation vectors, gas griefing in loops, proper event emission, upgrade proxy risks, and business logic flaws specific to the protocol. OWASP Smart Contract Top 10 and SWC Registry provide the canonical vulnerability taxonomy.
How long does a professional smart contract audit take?
A focused single-contract audit typically takes 3–7 days. A full DeFi protocol with multiple interconnected contracts usually takes 2–4 weeks. Timeline depends on lines of code, protocol complexity, number of external integrations, and whether a prior audit report exists. Rushed audits are the leading cause of missed critical vulnerabilities — never compress below the minimum time the scope demands.
What is the difference between a smart contract audit and a penetration test?
A smart contract audit is a source-code review focused on logic flaws, vulnerability patterns, and standard compliance in Solidity/Vyper code before deployment. A penetration test simulates an active attacker against a live or staging environment, testing the full stack including frontends, APIs, wallet integrations, and off-chain components. For full security coverage, protocols need both — audit before deployment, pentest after launch.
Frequently Asked Questions
What is a smart contract audit?
+
How do you audit a smart contract?
+
How much does a smart contract audit cost?
+
Can I automate smart contract auditing with Hardhat?
+
Resource Hub
Explore our Smart Contract Security Hub →
Free AI auditor, vulnerability guides and security research
Related Articles
Smart Contract Exploit Statistics 2026: Complete Data (Q1–Q3)
Over $2.15 billion stolen across 290+ incidents in Q1–Q3 2026 — yet total losses are down 58% year-over-year. Here’s what the numbers actually mean for smart contract developers.
Read article →Smart Contract SecurityBlockhertz AI Auditor vs CertiK: Which Smart Contract Audit Is Right for Your Project?
CertiK charges $30,000–$200,000 and takes weeks. Blockhertz AI Auditor delivers a full smart contract security report in under 60 seconds. Here's an honest breakdown of when to use each.
Read article →Smart Contract SecurityHow to Fix the 10 Most Common Smart Contract Vulnerabilities in 2026 (With Code)
The audit checklist tells you what to look for. This guide shows you exactly how to fix it — with vulnerable code, patched code, and the reasoning behind every change.
Read article →Related Blockhertz Tools
Explore Blockhertz
Views
88
Read Time
8 min read
Likes
3
Published
Aug 1, 2026
SIGNAL THREAD
NO SIGNALS YET — BE FIRST TO TRANSMIT
Muhammad Asif
Senior Blockchain Developer & Founder, Blockhertz
Blockchain developer and security engineer with 8+ years of experience. Founded Blockhertz in 2018 to build AI-powered tools for Web3 teams — smart contract auditing, architecture generation, gas optimization, and RWA tokenization platforms. Serving clients worldwide.