Solidity → Vyper 0.4 Migration
// BLUEPRINT 01 · OPENZEPPELIN → VYPER 0.4 & SNEKMATE
The fastest path from Solidity to Vyper 0.4. Five canonical OpenZeppelin contracts shown before & after — ERC-20, ERC-721, ERC-4626, two-step ownership, and roles + pausable — inside a pre-wired Moccasin project that clones, compiles, and tests green out of the box. Not a tutorial dump: a working reference repo plus a pattern catalog that maps every Solidity idiom to its idiomatic Vyper 0.4 + Snekmate equivalent.
Vyper 0.4
Solidity
Snekmate
Moccasin
OpenZeppelin
ERC-20 / 721 / 4626
5
Before/After Pairs
6
Tests Green
5
Reference Docs
0.4
Vyper
What's Inside
A clone-and-run Moccasin project, not a slide deck. Each Solidity contract sits beside its Vyper 0.4 rewrite so the diff is the lesson — and the whole repo compiles and tests green before you touch a line.
- 5 before/after pairs — ERC-20, ERC-721, ERC-4626 vault, two-step ownership, and roles + pausable, each shown in Solidity and in idiomatic Vyper 0.4
- Pre-wired Moccasin project — clone,
mox compile, mox test; no manual scaffolding
- Pattern catalog — every Solidity idiom (modifiers, inheritance, interfaces, custom errors) mapped to its Vyper 0.4 module-system equivalent
- Snekmate module map — which audited Snekmate module replaces which OpenZeppelin base, and how to wire it via
uses / initializes
Migration Discipline
The traps in a Solidity→Vyper port aren't syntax — they're the semantic gaps. The blueprint calls each one out with the Vyper 0.4 pattern that closes it.
- Module system over inheritance —
import / uses / initializes replace Solidity's linearized inheritance, with explicit state ownership
- Snekmate, not hand-rolled — ownership, access control, pausable, and token standards come from the audited Snekmate library rather than re-implemented logic
- Two-step ownership — the OZ
Ownable2Step pattern shown in Vyper, with renounce left unexported by default
- Explicit visibility & reentrancy — Vyper's defaults and
@nonreentrant contrasted against Solidity's, so nothing is silently looser after the port
- Security notes ledger — the gotchas a first port gets wrong, written down next to the fix
Tested & Documented
- 6 tests green — the project ships test-passing so the reference contracts are verified, not just illustrative
- Fuzzer machine included — like every packaged product, the suite ships Hypothesis/Titanoboa rules for each external function plus invariants per contract, not bare unit tests
- Migration playbook — a step-by-step order of operations for porting a real Solidity codebase to Vyper 0.4
- Sepolia deploy guide — wiring the modules, deploying with Moccasin, and verifying on a public testnet
Who It's For
- Solidity teams adopting Vyper 0.4 who want a vetted reference instead of trial-and-error
- Auditors and reviewers needing a canonical OZ↔Vyper mapping to reason about ports
- Anyone shipping a Vyper 0.4 token, vault, or access-controlled contract who wants the Snekmate wiring already correct
- Part of the Full-Stack Bundle — the migration layer under the TARE flywheel stack