- 👉 View on Codemod Registry: @enamorak/doublesigma-ethers-v5-to-v6
- ⭐ Website: https://doublesigma.onrender.com/
- 🤑 Video: https://youtu.be/RIiDbEIrk70
- 📱 Presentation: https://disk.yandex.ru/i/br4UM0vIpTOXSA
- 🌍 Github: https://github.com/enamorak/DoubleSigma
- 🛑 X: https://x.com/arkhangels25781/status/2050342260684779736?s=20
- 📢 Telegram: https://t.me/cyberpunk_production/1180?single
- Published registry package: @enamorak/doublesigma-ethers-v5-to-v6
- Latest benchmark source:
docs/benchmark-latest.json - Current suite result: 8/8 successful, 84 rewrites, 84 changed files, ~33.6s cumulative runtime
| Repository | Result | Rewrites | Impact | Time |
|---|---|---|---|---|
| flashbots/ethers-provider-flashbots-bundle | ✅ | 3 | 100.0% (3/3) | 0.823s |
| Uniswap/v3-sdk | ✅ | 8 | 12.7% (8/63) | 0.585s |
| ProjectOpenSea/opensea-js | ✅ | 5 | 4.4% (5/113) | 1.141s |
| wagmi-dev/wagmi | ✅ | 0 | 0.0% (0/1069) | 3.039s |
| rainbow-me/rainbowkit | ✅ | 24 | 3.6% (24/670) | 4.253s |
| aave/aave-v3-core | ✅ | 15 | 18.5% (15/81) | 2.923s |
| NomicFoundation/hardhat | ✅ | 29 | 1.8% (29/1580) | 19.962s |
| traderjoe-xyz/joe-v2 | ✅ | 0 | — (0 scanned) | 0.879s |
- Accuracy posture: deterministic ast-grep rules (structural patterns on the TS/JS AST), rule-level confidence tags (
high/medium/low), and 0 false positives reported in benchmark runs. - Quantum features:
quantumInsightsreports latent markers (latentBigNumberMarkers,latentNestedProviderMarkers,latentDeployedCalls,latentEthersProjectImports) plussuperpositionCoverage. - AI features: optional Groq advisory reviews changed files and returns notes/metrics (
tokensUsed,filesProcessed,apiCalls) without auto-applying edits.
DoubleSigma is a deterministic migrator for common ethers v5 → v6 API patterns. Rewrites use ast-grep (the same engine as Codemod JSSG): local runs use @ast-grep/napi; the Registry package runs the same rules inside the codemod:ast-grep sandbox. The tool ships with:
- CLI and local web UI (same engine).
- GitHub URL import via the official zipball API (no local
gitrequired). - A catalog of every codemod (titles, descriptions,
was/nowhints) exposed atGET /api/rules. - After each run, the API returns
appliedRulesSummary(what actually rewrote your code) andrulesWithoutMatch(catalog entries that did not hit).
Published package on Codemod Registry: @enamorak/doublesigma-ethers-v5-to-v6.
DoubleSigma uses @ast-grep/napi — the same AST engine powering the official JSSG framework from Codemod.com. Every transformation is:
- AST-based — no regex over source files, no fragile whole-file
String#replacepasses; edits are driven by ast-grepfindAlland byte-range rewrites insrc/codemods/ast-helpers.ts. - Deterministic — same input always produces the same output.
- Context-aware — respects language syntax (tree-sitter grammar), not flat text patterns.
Rule modules mirror the JSSG layout and ship under publish/ethers-v5-to-v6/ for Codemod Registry workflows.
Registry publish
- Recommended (no local Git): In GitHub → Settings → Secrets and variables → Actions, add
CODEMOD_API_KEYfrom go.codemod.com/api-keys. Never commit API keys or paste them into issues/chat. Then Actions → “Publish Codemod Registry” → Run workflow. The runner runsnpm install,npm run registry:bundle,workflow validate, andcodemod publish. - Local:
npm run registry:bundle, then frompublish/ethers-v5-to-v6runnpx codemod publish .(Git must be onPATH; otherwise you may seeRolldown UnresolvedEntry).
- Install dependencies:
npm install - Start the dev server:
npm run ui - Open the URL printed in the terminal — by default
http://127.0.0.1:3847
The page shows:
- Migrate tab: transformation catalog, local path or GitHub HTTPS form, results (log, metrics, applied rules, diff snippets).
- Benchmarks tab: the curated multi-repo list, Run all / per-repo Run, Export CSV/JSON (same dry-run engine as
npm run benchmark).
Production-style run: npm run build then npm start (same UI from dist/).
The dashboard UI is English (steps, presets, catalog). Run npm run ui so /api/presets and /api/rules resolve; opening index.html via a static-only server will break JSON loading.
- Large footprint: ethers v5 remains widespread across Web3 JS/TS repos; many projects postponed v6 because the API surface changed (providers,
BigNumber, events, deployment helpers). A broad view of public repos is easy to explore on GitHub repository search for ethers.js. - Codemod Registry gap: As of the hackathon timeframe, no dedicated “ethers v5 → v6” codemod sat beside common migrations (ESLint, Express, React patterns, etc.) in public registry narratives — positioning a focused, deterministic tool matters.
- v6 is the stable target: v6 has been the supported line for new work; v5 is effectively maintenance-only for many teams — automating the jump reduces calendar time and review load.
| DoubleSigma | Manual migration | Generic codemods | |
|---|---|---|---|
Ethers v5→v6 + @ethersproject/* |
✅ Dedicated rule catalog (deterministic core + reviewed import-path rules) | ❌ Slow, inconsistent | ❌ No standard Web3 migration in public registry narratives |
| False positives (core rules) | ✅ AST-level deterministic transforms (ast-grep) | ❌ Human error | |
| Quantum-style latent scan | ✅ Debt signals in API/UI | ❌ | ❌ |
| Optional AI (Groq) | ✅ Advisory only (no auto-apply from LLM) | ❌ | |
| Real GitHub benchmarks | ✅ 8-repo dry-run harness + CSV/JSON/HTML export | ❌ |
The Benchmarks tab also shows Readiness (rewrites ÷ quantum latentBigNumberMarkers when > 0) and explains 0 rewrites (e.g. viem-only wagmi v2, JSBI-heavy Uniswap SDK, or patterns not covered yet).
The canonical list lives in data/benchmark-repositories.json (8 public targets: Flashbots, Uniswap v3 SDK, OpenSea JS, wagmi, RainbowKit, Aave v3 core, Hardhat, Trader Joe v2 — each with owner / repo / ref for the zipball API plus optional expectedPatterns / difficulty for the UI). Jury-facing narrative and tables: docs/benchmark-results.md.
| How | What you get |
|---|---|
| UI | Benchmarks tab → run one repo or Run all → Export CSV / JSON. |
| CLI | npm run benchmark → writes docs/benchmark-latest.json and prints a Markdown table. |
| API | POST /api/benchmark with { "repoUrl": "https://github.com/owner/repo", "ref": "main" } → JSON metrics (+ quantumInsights when enabled). |
Do not invent README numbers: after a full run, copy the CLI table or summarize from docs/benchmark-latest.json, then refresh docs/benchmark-results.md. Honest Impact (% of scanned JS/TS files touched) and time-saved estimates are defined in docs/BENCHMARKING.md and in the Benchmarks tab UI.
Note: Some repos are viem-first (e.g. wagmi v2), JSBI-first (e.g. Uniswap v3-sdk numerics), or Solidity-heavy — 0 rewrites can be honest. The catalog now rewrites common @ethersproject/abi and @ethersproject/providers imports toward ethers (see rule confidence in the UI). Always review diffs before applying.
See the top section Registry + Benchmarks + Accuracy for the latest measured run, precision notes, and quantum/AI capabilities.
npm install
npm run buildLocal project
npm run migrate -- migrate /path/to/project --quantum
npm run migrate -- migrate /path/to/project --apply --quantumGitHub repository (download to a temp folder; dry-run deletes the folder by default)
npm run migrate -- migrate --url https://github.com/compound-finance/compound-js --quantumKeep the temp clone after a dry-run:
npm run migrate -- migrate --url https://github.com/owner/repo --keep-temp --quantum- Install + build
npm install npm run build
- Start web UI
Open
npm run ui
http://127.0.0.1:3847, then use Migrate or Benchmarks tabs. - Run benchmark suite
This refreshes
npm run benchmark
docs/benchmark-latest.json. - Run tests / pre-submit gate
npm test npm run pre-submit - Optional AI advisory
- Copy
.env.example→.env - Set
GROQ_API_KEY - Re-run UI/CLI with AI enabled
- Copy
DoubleSigma is production-ready for Node hosting with PORT support and npm run start.
- Push this repository to GitHub.
- In Render, create a new Web Service from the repo.
- Use these settings:
- Build Command:
npm install && npm run build - Start Command:
npm run start - Runtime: Node
- Build Command:
- Add environment variables in Render dashboard:
NODE_ENV=productionGROQ_API_KEY=<optional>PORTis provided by Render automatically (fallback is3847locally)
- Deploy. Render will provide a public URL for judges.
Infrastructure config is included in render.yaml.
| Method | Path | Purpose |
|---|---|---|
GET |
/ |
Dashboard (static HTML). |
GET |
/api/rules |
JSON catalog: { rules: CodemodRuleMeta[] } (id, title, confidence, description, was, now, optional docsUrl). |
GET |
/api/presets |
Curated GitHub repos for the UI (reads data/benchmark-repositories.json, then public/presets.json, then cwd fallbacks). |
POST |
/api/benchmark |
{ repoUrl, ref?, quantum?, ai? } → BenchmarkRunResponse (metrics, rulesTriggered, quantumInsights, optional aiMetrics / aiNotes). |
GET |
/presets.json |
Same JSON array as presets (explicit route + static fallback). |
GET |
/api/health |
Liveness. |
POST |
/api/migrate |
Body: { path, mode?, quantum?, ai? } or { url, ref?, mode?, cleanup?, quantum?, ai? }. |
Successful responses include:
metrics— files scanned, files changed, total rewrites.appliedRulesSummary—{ id, rewriteCount, filesAffected }[](recommended transforms for this repo).rulesWithoutMatch— catalog rule IDs that did not match any file.diffs— short-/+previews per file.workDir/cleanedUp— for GitHub runs (temp path; whether it was removed after dry-run).quantumInsights— whenquantum: true, a read-only scan of latent v5-shaped markers (BigNumber /ethers.providers/.deployed()/@ethersproject/) plus a heuristic score; no extra file mutations.aiMetrics/aiNotes— whenai: trueandGROQ_API_KEYis set, an advisory Groq pass reviews up to five changed files that still look v5-shaped. Output is not auto-applied; inspectaiNotesin the UI or JSON.
- Copy
.env.exampleto.envin the project root. - Set
GROQ_API_KEYfrom Groq Cloud Console (free tier). - Run
npm run uior CLI with--ai. Never commit.envor paste keys into issues/chat.
If the key is missing, migrations still run; aiMetrics will show zeros and aiNotes will explain the skip.
Rules are merged in src/codemods/rulesCatalog.ts (core + 02-bigint.ts + 04-contracts.ts + 05-ethersproject.ts). Each rule uses ast-grep findAll plus deterministic slice-based rewrites from ast-helpers.ts (no String#replace on the full source). Examples:
ethers.providers.Web3Provider→ethers.BrowserProviderethers.providers.JsonRpcProvider/providers.JsonRpcProvider→ethers.JsonRpcProviderethers.providers.getNetwork(→ethers.getNetwork((verify for your usage).sendTransaction(→.broadcastTransaction((call-expression pattern$RX.sendTransaction(…)— review: contracts also exposesendTransaction)ethers.constants.AddressZero/HashZero→ethers.ZeroAddress/ethers.ZeroHash- Common
ethers.utils.*→ root helpers (dataSlice,zeroPadValue,toQuantity,getBytes, bytes32 helpers, …) - BigNumber arithmetic/comparisons (reviewed, medium confidence):
.add(),.sub(),.mul(),.div(),.eq(),.gt(),.lt(),.gte(),.lte() ethers.BigNumber.from(identifier)→BigInt(identifier)(medium confidence)
See the web catalog or GET /api/rules for the full list with descriptions.
CLI ──┬──► migrationJob ──► dry-run / apply ──► codemods (rulesCatalog + @ast-grep/napi)
│
└──► migrateFromGithub ──► githubArchive (zipball) ──► migrationJob
server.ts ──► POST /api/migrate, POST /api/benchmark, GET /api/rules, GET /api/presets, GET /presets.json
public/index.html ──► Migrate + Benchmarks, Groq metrics, CSV/JSON/HTML export
npm testFast gate (build + tests; network integration skipped when CI=true unless RUN_REAL_REPO_TESTS=1):
npm run pre-submitSKIP_NETWORK_TESTS=1— skip integration tests locally.- In CI, set
RUN_REAL_REPO_TESTS=1to enable network tests whenCI=true.
Full benchmarks hit GitHub for every row in data/benchmark-repositories.json — use npm run benchmark when you have time and a stable network.
Manifest: tests/integration/repos.manifest.json (4 repos; includes one repo where zero rewrites are expected so we only assert scan coverage).
- Rules are syntax-driven, not type-aware: ast-grep does not know whether a value is a
Providervs aContract, so medium-confidence rewrites (e.g.sendTransaction, identifierBigNumberchains) still need human review. - GitHub HTTPS only for URL import (no GitLab in-app; unauthenticated API rate limits apply).
- Groq AI is advisory only (no auto-apply); rate limits and model availability apply.
- Narrow
await x.deployed()removal can misfire if a non-ethers API uses the same shape — rare; still review.
See docs/CASE_STUDY.md.
MIT
Official ethers migration guide: Migrating from v5.