Systematic code review checklist for Solidity smart contracts covering style, security, and optimization.
## ROLE
You are a senior smart contract reviewer who conducts thorough code reviews for production contracts.
## CONTEXT
I need to review a Solidity smart contract.
## CONTRACT INFO
- Contract purpose: ${{PURPOSE}}
- Complexity level: ${{COMPLEXITY}}
- External interactions: ${{INTERACTIONS}}
- Review depth: ${{DEPTH}}
## TASK
Provide comprehensive code review:
**1. GENERAL CODE QUALITY**
| Check | Status | Notes |
|-------|--------|-------|
| Solidity version appropriate | | |
| License identifier present | | |
| NatSpec documentation | | |
| Consistent naming conventions | | |
| No magic numbers | | |
| Functions properly ordered | | |
| Imports minimal and necessary | | |
**2. SECURITY REVIEW**
| Check | Status | Notes |
|-------|--------|-------|
| Access control on privileged functions | | |
| Reentrancy protection | | |
| Integer overflow handled | | |
| External call safety | | |
| Input validation | | |
| State changes before calls | | |
| No tx.origin usage | | |
| Proper use of msg.sender | | |
**3. FUNCTION-LEVEL REVIEW**
For each function:
```
Function: functionName()
- [ ] Visibility appropriate
- [ ] Modifiers correct
- [ ] Parameters validated
- [ ] Return values handled
- [ ] Events emitted
- [ ] State changes correct
- [ ] Gas optimized
```
**4. INHERITANCE REVIEW**
| Check | Status |
|-------|--------|
| Inheritance order correct | |
| Virtual/override proper | |
| No diamond problem | |
| Super calls where needed | |
**5. STORAGE REVIEW**
| Check | Status |
|-------|--------|
| Variables packed efficiently | |
| Appropriate visibility | |
| Mappings vs arrays justified | |
| Storage vs memory correct | |
| No uninitialized storage pointers | |
**6. ERROR HANDLING**
| Check | Status |
|-------|--------|
| Custom errors used (gas) | |
| Error messages clear | |
| Require vs revert appropriate | |
| Try/catch for external calls | |
**7. EVENT REVIEW**
| Check | Status |
|-------|--------|
| All state changes emit events | |
| Indexed parameters appropriate | |
| Event data sufficient | |
**8. GAS OPTIMIZATION**
| Check | Status |
|-------|--------|
| Storage reads cached | |
| Loops optimized | |
| Short-circuit evaluation | |
| Calldata vs memory | |
| Unchecked math where safe | |
**9. UPGRADE SAFETY**
| Check | Status |
|-------|--------|
| Storage layout preserved | |
| Initializers protected | |
| No selfdestruct | |
| No delegatecall issues | |
**10. DOCUMENTATION**
| Check | Status |
|-------|--------|
| Contract purpose documented | |
| Function descriptions | |
| Parameter explanations | |
| Return value descriptions | |
| Known limitations noted | |
**11. TESTING REQUIREMENTS**
| Required Test | Status |
|---------------|--------|
| All public functions | |
| Edge cases | |
| Revert conditions | |
| Access control | |
| Integration scenarios | |
**12. REVIEW SUMMARY**
| Category | Score | Priority Fixes |
|----------|-------|----------------|
| Security | /10 | |
| Code Quality | /10 | |
| Gas Efficiency | /10 | |
| Documentation | /10 | |
| **Overall** | /10 | |Or press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
[{PURPOSE][{COMPLEXITY][{INTERACTIONS][{DEPTH]