docs: add Brownie to ApeWorx Ape migration guide#2168
Open
PugarHuda wants to merge 1 commit into
Open
Conversation
Adds a comprehensive migration guide for the Brownie -> ApeWorx Ape
upgrade, documenting the community-built `@pugarhuda/brownie-to-ape`
codemod that automates 80-95% of the migration with zero false
positives using AST-based transforms via ast-grep.
Brownie was the dominant Python framework for Ethereum smart-contract
development from 2019, and was officially deprecated in 2023. Many
projects (including major DeFi codebases like Yearn) still depend on
it -- this guide gives users a one-command path to Ape.
The codemod handles 17 deterministic transform passes:
- Import rewrites (network -> networks, ZERO_ADDRESS -> ape.utils, etc.)
- tx-dict to kwargs ({"from": x} -> sender=x)
- chain.sleep / chain.mine API changes
- Wei -> convert auto-rewrite with import injection
- Exception class renames
- Whale-impersonation idiom (accounts.at force=True)
- AI-friendly TODOs for patterns the codemod cannot safely rewrite
Validated on 5 OSS Brownie projects (token-mix, brownie_fund_me,
smartcontract-lottery, aave_brownie_py_freecode,
yearn/brownie-strategy-mix) with 0 false positives. End-to-end
verified on brownie-mix/token-mix: `ape compile` succeeds and
`ape test --network ::test` returns 38 passed / 0 failed in 5.40s
after the codemod plus ~30 LOC of AI/manual cleanup.
Submitted to the Codemod "Boring AI" hackathon (DoraHacks 2026).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a comprehensive migration guide at
docs/guides/migrations/brownie-to-ape.mdxfor the Brownie → ApeWorx Ape upgrade, documenting the community-built@pugarhuda/brownie-to-apecodemod (source).The format mirrors the recent React Router v6→v7 migration guide (#2167) —
Steps,Before & After,CardGroup/Cardcomponents — and has been added to the existing Migrations group indocs/docs.jsonalongsidereact-18-19,nuxt-3-4,zod-3-4,msw-v1-v2, andpnpm-catalog.Why this is useful
Brownie was the dominant Python framework for Ethereum smart-contract development from 2019, and was officially deprecated in 2023 in favor of ApeWorx Ape. Many public projects (including major DeFi codebases like Yearn Finance) still depend on it. Migrating a typical Brownie project means rewriting 50–200 mechanical patterns by hand:
from brownie import …→from ape import …(withnetwork→networksrename, constants moved toape.utils)Contract.deploy({"from": x, "value": v})→Contract.deploy(sender=x, value=v)— tx-dict to kwargschain.sleep(60)→chain.pending_timestamp += 60— different time-control semanticsexceptions.VirtualMachineError→exceptions.ContractLogicErrorThe
@pugarhuda/brownie-to-apecodemod automates all of these via 17 deterministic AST transform passes (using ast-grep on Tree-sitter Python), with explicit FP guards. It's been validated on 5 real OSS Brownie projects (brownie-mix/token-mix,PatrickAlphaC/brownie_fund_me,PatrickAlphaC/smartcontract-lottery,PatrickAlphaC/aave_brownie_py_freecode,yearn/brownie-strategy-mix) with 0 false positives.End-to-end verified: after the codemod plus ~30 LOC of AI/manual cleanup,
ape compilesucceeds (solc 0.6.12) andape test --network ::testreturns 38 passed, 0 failed in 5.40s on the migratedbrownie-mix/token-mix. Full passing log: https://github.com/PugarHuda/brownie-to-ape/blob/main/docs/ape-verify-token-mix.logWhat the guide covers
Format / conventions
.mdxextension matches existing guides<Steps>,<Step>,<CardGroup>,<Card>components matchreact-router-v6-v7.mdx,react-18-19.mdx,nuxt-3-4.mdxdocs.jsonfollows alphabetical/registry-version order of existing entriesSubmission context
Submitted to the Codemod "Boring AI" hackathon (DoraHacks 2026, Tracks 1 + 2 + 3).
Test plan
docs.jsonJSON validity preserved (single line addition, no syntax change)🤖 Generated with Claude Code