Problem
The ethers.js library is large (~200KB minified), which impacts initial page load times and bundle size for the website.
Proposed Solution
Migrate from ethers.js to viem (a lighter, tree-shakeable Ethereum library ~15KB) for the blockchain data collection script.
Scope
scripts/calculate-fork-risk.ts - the only file using ethers.js
- No changes to frontend code
Risk & Verification Needed
This is a critical data pipeline - the script calculates real fork risk values displayed on the live site. Before switching:
- Add test coverage to verify fork risk calculations
- Compare output before/after migration (run both versions against same RPC)
- Coordinate timing with low-traffic period for quick rollback if needed
Technical Notes
- ethers.js v6 is currently being used
- viem has similar APIs but may require refactoring RPC calls
- Consider keeping both temporarily with a flag to switch between them
Impact
- Bundle size reduction: ~185KB (estimated)
- Improved Time to Interactive (TTI)