Version Comparison
| Feature | Web3.js v1.x | Web3.js v3.x |
|---|---|---|
| Release Year | 2017-2020 | 2023+ |
| Architecture | Callback-based | Promise/Async-native |
| TypeScript | Partial | Full TypeScript |
| Bundle Size | ~500KB | ~200KB |
| Modular | No | Yes |
| Subscriptions | Basic | Enhanced |
Why Upgrade to v3?
- Better TypeScript support
- Smaller bundle size
- Improved performance
- Modern async/await patterns
- Better error handling
When to Keep v1
- Legacy project compatibility
- Existing tests passing
- No TypeScript migration needed
- Working callback patterns
Code Examples
v1.x (Callback)
web3.eth.getBalance(
address,
function(err, balance) {
console.log(balance);
}
);
v3.x (Async/Await)
const balance = await
web3.eth.getBalance(address);
console.log(balance);