Can anyone write a short comparison between the most important features of the two libraries?
6 Answers
For me, it is less about features (however there are a couple cool features/design choices in ethers.js).
Ethers.js is:
- smaller
- well tested
- well documented
- well maintained
- less buggy
If you want to use ethers, you might want to check Waffle, a framework for creating smart contracts with ethers.
-
Do you think this still holds true? My anecdotal experience is that most examples right now use web3 Commented Aug 4, 2021 at 2:22
-
1@CesarVarela the fact that "web3.js" includes "web3" in their name helps them get more user adoption, hence more examples shared on the Internet. But that does not change the fact that ethers is superior. Commented Oct 15, 2021 at 11:53
-
After spending more time with both, I have to agree with you, they just played the SEO game better :) Commented Oct 19, 2021 at 2:48
web3.js vs. ethers.js
https://medium.com/l4-media/announcing-ethers-js-a-web3-alternative-6f134fdd06f3
One major difference between ethers.js and web3 is how they handle key management and interaction with the ethereum blockchain. Web3 assumes that there is a local node connected to the application. That node is assumed to store keys, sign transactions, and interact with and read the ethereum blockchain. In reality, this is not often the case — most users are not running geth locally. Metamask effectively emulates that environment through a browser application, and so most web3 apps require Metamask to hold keys, sign transactions, and interact with the ethereum mainnet.
Ethers.js takes a different approach that we believe gives developers more flexibility. Ethers.js separates the “node” into two separate roles:
A “wallet” that holds keys and signs transaction, and
A “provider” that serves as an anonymous connection to the ethereum network, checking state and sending transactions
The 2 main advantages of ethers.js in my mind are:
- ENS names are first-class citizens
- key management and state - separation of concerns
There are a number of other differentiating factors.
https://medium.com/l4-media/announcing-ethers-js-a-web3-alternative-6f134fdd06f3
Why I prefer ethers.js over web3.js
- List item
- less buggy
- Huge size difference. Web3 is very bulky for a frontend use
- concise documentation
- Easier for beginners
- New Projects are using ethers.js over web3
For web3, well it is a mist standard.
You'll get a good idea using the sample apps here: https://github.com/adrianmcli/web3-vs-ethers
On top of all the good answers written here, I'd like to add Adrian Li's recently published comparison of web3 vs ethers.js:
It's a GitHub repo with a comprehensible README and code examples.
Ether.js is developed and maintained by Rick Moore – A canadian developer.
Web3.js is a developed and maintained by Ethereum Foundation. So, there is a wider support for Web3.js as more number of developers are behind it.
Ethers.js has 4k github starts on Feb 2, 2022. Web3.js is older library. So it is more popular. It has 13.4k github stars on Feb 2, 2022.
Ethers.js offers full type-script support. Web3.js started typescript support after v1.3.0
Advantages of Ethers.js over Web3.js
- Ethers.js has pre-written tests with proper documentation. So,it is better for testing smart contracts. Ether.js is only 77kb compressed. So it is very light.
- ENS name can be used in place of contract address.
- Separate handling of key-management and state(provider) which increases security.