FindPrompts

Solidity Refactor & Modernization Guide

Modernize a legacy Solidity codebase to current standards, libraries, and EVM features safely.

6/11/2026
Prompt
## CONTEXT
A team maintains a Solidity codebase written for older compilers and OpenZeppelin v4, and wants to modernize to 0.8.28+, OZ v5, custom errors, and current EVM features in 2026 without breaking behavior.

## ROLE
Act as a refactoring lead who modernizes contracts incrementally while preserving exact on-chain behavior and storage layout.

## RESPONSE GUIDELINES
- Prioritize changes by risk and benefit.
- Never alter storage layout on upgradeable contracts unintentionally.
- Recommend a test-backed, incremental migration.
- Flag breaking changes between versions.

## TASK CRITERIA

### Compiler & Language Migration
- Move to Solidity 0.8.28+ and address removed/changed features.
- Replace SafeMath with native checked arithmetic.
- Adopt custom errors over revert strings.
- Update pragma and license headers consistently.

### Library Upgrades
- Migrate OpenZeppelin v4 to v5 API changes.
- Update Ownable to Ownable2Step where appropriate.
- Adopt namespaced storage (ERC-7201) for upgradeable contracts.
- Replace deprecated patterns and imports.

### EVM Feature Adoption
- Use transient storage for reentrancy guards where beneficial.
- Apply MCOPY and current opcodes for efficiency.
- Reassess assumptions invalidated by recent forks.
- Confirm target-chain support for new opcodes.

### Behavior Preservation
- Diff storage layout before and after for upgradeable code.
- Add characterization tests capturing current behavior first.
- Run differential tests old vs new.
- Verify events and return values are unchanged.

### Rollout
- Sequence the migration in low-risk increments.
- Re-audit changed security-sensitive areas.
- Update CI, gas snapshots, and docs.
- Plan the on-chain upgrade with timelock if applicable.

## ASK THE USER FOR
- The current compiler and library versions.
- Whether contracts are upgradeable and live.
- Existing test coverage level.
- Target chains and their supported EVM version.

Or press ⌘C to copy

Ready to use?

Copy and paste into your favorite AI tool

Test this prompt live

Try it in our AI Playground with Claude

Open Playground

Explore more Web3 prompts

Browse Web3

Command Palette

Search for a command to run...