Skip to content

docs: add Brownie to ApeWorx Ape migration guide#2168

Open
PugarHuda wants to merge 1 commit into
codemod:mainfrom
PugarHuda:docs/add-brownie-to-ape-migration-guide
Open

docs: add Brownie to ApeWorx Ape migration guide#2168
PugarHuda wants to merge 1 commit into
codemod:mainfrom
PugarHuda:docs/add-brownie-to-ape-migration-guide

Conversation

@PugarHuda

@PugarHuda PugarHuda commented May 2, 2026

Copy link
Copy Markdown

Summary

Adds a comprehensive migration guide at docs/guides/migrations/brownie-to-ape.mdx for the Brownie → ApeWorx Ape upgrade, documenting the community-built @pugarhuda/brownie-to-ape codemod (source).

The format mirrors the recent React Router v6→v7 migration guide (#2167) — Steps, Before & After, CardGroup/Card components — and has been added to the existing Migrations group in docs/docs.json alongside react-18-19, nuxt-3-4, zod-3-4, msw-v1-v2, and pnpm-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 … (with networknetworks rename, constants moved to ape.utils)
  • Contract.deploy({"from": x, "value": v})Contract.deploy(sender=x, value=v) — tx-dict to kwargs
  • chain.sleep(60)chain.pending_timestamp += 60 — different time-control semantics
  • exceptions.VirtualMachineErrorexceptions.ContractLogicError
  • And ~12 more pattern categories

The @pugarhuda/brownie-to-ape codemod 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 compile succeeds (solc 0.6.12) and ape test --network ::test returns 38 passed, 0 failed in 5.40s on the migrated brownie-mix/token-mix. Full passing log: https://github.com/PugarHuda/brownie-to-ape/blob/main/docs/ape-verify-token-mix.log

What the guide covers

  • 4-step migration flow (run codemod → migrate YAML config → AI/manual cleanup → verify)
  • Table of all 17 transform passes with what each does
  • Before/after code snippets for imports, tx kwargs, network detection, time/blocks, and exceptions
  • Real-world validation table across 5 OSS repos
  • Resource cards linking to GitHub repo, case study, live demo, and AI-step walkthrough

Format / conventions

  • .mdx extension matches existing guides
  • <Steps>, <Step>, <CardGroup>, <Card> components match react-router-v6-v7.mdx, react-18-19.mdx, nuxt-3-4.mdx
  • Single-line frontmatter with title only
  • Insertion in docs.json follows alphabetical/registry-version order of existing entries

Submission context

Submitted to the Codemod "Boring AI" hackathon (DoraHacks 2026, Tracks 1 + 2 + 3).

Test plan

  • Markdown lint: file structure verified locally against react-router-v6-v7.mdx as reference
  • All URLs in the guide resolve (codemod registry, GitHub source, ape-verify log, case study)
  • docs.json JSON validity preserved (single line addition, no syntax change)
  • No existing content modified
  • No external dependencies added

🤖 Generated with Claude Code

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).
@CLAassistant

CLAassistant commented May 2, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants