What is Ethers.js?
- Importing and exporting JSON wallets (e.g., Geth and Parity)
- Using ENS names as first-class citizens (they can be used anywhere an Ethereum address can be used)
- Importing and exporting BIP 39 mnemonic phrases (twelve-word backup phrases) and HD wallets in several languages
- Enables you to connect to Ethereum nodes over JSON-RPC, Etherscan, MetaMask, Infura, Alchemy, or Cloudflare.
- Small size
- Ethers.js is fully TypeScript ready – it includes definition files and full TS sources
- Comes with an open-source MIT license that includes all dependencies
The Moralis Streams API – Ethers.js 2.0?
At this point, we are one step closer to the Web3.js vs ethers.js section. However, by learning about “ethers.js 2.0”, you might lose interest in that comparison and decide to start building with that excellent tool right away instead. After all, many developers are now using the Moralis Streams API as an “ethers.js 2.0” alternative instead of ethers.js. Further, most devs will probably follow that path in the future. Moreover, it’s easy to see why when comparing ethers.js vs Web3 streams. The gist of this comparison can be summarized in the following image:
Reliability, Filtering Events, and More
While both ethers.js and the Web3 Streams API support real-time events and multiple chains, ethers.js 2.0 (a.k.a. Streams API) takes things to the next level. Starting with reliability, with ethers.js, you cannot reach the highest levels since you have to depend on node providers. Further, you always need to ensure that the provider supports the chains you want to focus on and that the nodes stay live. On the other hand, Moralis’ Streams API takes that aspect out of the equation and offers 100% reliability.
With ethers.js 2.0, you also get to filter on-chain events. Accordingly, you can focus on the data that really interest you. Furthermore, the Streams API even offers you to cover multiple addresses. So, instead of creating separate listeners for all contracts, you simply pool them together under a single stream. With this advanced listening tool for on-chain events, you can even focus on wallet addresses. As such, you get to use any changes to any wallet address that interest you as a trigger. This enables you to take your dapps and customer service to the next level. Last but not least, unlike ethers.js, the Moralis Streams API provides you with parsed data. In turn, you do not need to worry about processing the data. Instead, you can focus on utilizing the responses right away.
Streams API – Tool of the Future
With that in mind, you must admit that there are many instances where having an alternative that covers all those additional options would be a real asset. After all, it would make listening to blockchain events a lot more user-friendly. Moreover, after looking at all the advantages listed in the picture above, it’s no surprise that devs are leaving ethers.js. However, before you determine if the Streams API is the right tool for you, make sure to learn more about it.
Furthermore, when you create your free Moralis account, which is your key to the Streams API, you automatically gain access to other powerful tools. These include the industry-leading Web3 Auth API, the ultimate NFT API, and the best Token API. As such, you can create all sorts of killer dapps the easy way.
It’s worth pointing out that in the last two years or so, ethers.js became the go-to ETH JS library. However, to get the most out of the upcoming Web3.js vs ethers.js comparison, you need to know the basics of Web3.js as well.
What is Web3.js?
- “web3.eth“ – This is the module for interacting with the Ethereum network. For additional convenience, it offers several sub-modules (“web3.eth.contract“, “web3.eth.subscribe“, “web3.eth.accounts“, etc.).
- “web3.net“ – You use “web3.net“ if you want to interact with network properties.
- “web3.shh“ – This module lets you interact with the Whisper protocol.
- “web3.utils“ – With the “web3.utils“ module, you can access functions for Ethereum dapps and other packages.
- “web3.bzz“ – This module enables you to interact with the Swarm network.
Web3.js vs Ethers.js
To make this Web3.js vs ethers.js comparison as concise and convenient as possible, we’ll break it down into several categories. As such, we will look at the teams behind them, their popularity, downloads, updates, testing, web performance, documentation, and licenses.
|Teams||– The Ethereum Foundation |
– An extensive organization with many developers offering support
– Lack of clarity of who is responsible for support
|– Richard “RicMoo” Moore |
– Smaller team
– Pretty clear who’s responsible for what
|Popularity||– First-mover advantage|
– More stars and repositories on GitHub
|– Faster speed of growth and adoption|
|Downloads||– 2018: 91,936|
– 2019: 113,272 (+23%)
– 2020: 161,257 (+42%)
– 2021: 247,999 (+54%)
– 2022: 587,567 (+137%)
|– 2018: 53,863|
– 2019: 66,959 (+24%)
– 2020: 163,799 (+145%)
– 2021: 304,273 (+86%)
– 2022: 948,981 (+212%)
|Updates||– Relatively regular updates||– Relatively regular updates|
|Testing||– No pre-written tests||– Pre-written tests and clear documentation of its tests|
|Web Performance||– Larger in size|
– Loads slightly slower
|– Smaller in size|
– Loads slightly faster
|Documentation||– Room for improvement|
– Provides all you need to get started
– Link to the Web3.js documentation: https://web3js.readthedocs.io/en/v3.0.0-rc.5/
|– Room for improvement|
– Provides all you need to get started
– Link to the ethers.js documentation: https://docs.ethers.io/v5/
|License||– LGLv3 license||– MIT license|
Web3.js vs Ethers.js Overview: Teams, Popularity, Downloads, and Updates
The Ethereum Foundation created the Web3.js library and continues to back it. Since this is a large organization, there are many developers offering support. However, when many devs are involved, it also means that there is no clear distinction as to who is responsible for what. On the other hand, Richard “RicMoo” Moore developed ethers.js in 2016 and continues to maintain it. Hence, this also makes things clear about who’s responsible for what.
For a long time, Web3.js was overall a more popular option, mainly because it had the first-mover advantage. Further, according to the stats on GitHub, Web3.js is still in the lead – it has more stars and repositories. However, ethers.js’ speed of growth and adoption puts it in the leading spot. Moreover, looking at the downloads of these two ETH JS libraries, we must be careful not to focus on the overall number of downloads. After all, due to Web3.js’ one-year advantage, that wouldn’t paint a clear picture. Instead, you need to focus on daily downloads per specific year. According to Alchemy’s report from October 2022, ethers.js had nearly twice as many daily downloads as Web3.js in the first three quarters of 2022.
Nonetheless, as a developer, you know that updates are critical. Hence, you probably prefer a library that is always up-to-date and in the best possible shape. After all, it is via updates that support teams remove all known bugs and add new features. That said, both libraries do an equally good job in that aspect.
Web3.js vs Ethers.js Overview: Testing, Web Performance, Documentation, and License
Ethers.js has pre-written tests and clear documentation, which puts it ahead of Web3.js in this perspective. However, it’s important to remember that every new version levels the field.
None of the two ETH JS libraries maintains flawless documentation. However, both docs provide all you need to start working with them. Moreover, personal preferences play a key in that aspect. After all, what may be perfect documentation for one dev may feel poorly structured for another. As such, make sure to explore both docs and decide for yourself.
Note: Always check the version of the library and make sure to use the matching version of the documentation.
As you can see in the table outlined earlier, Web3.js has an LGLv3 license, while ethers.js has an MIT license. So, if your project has specific requirements regarding the license, you need to keep that aspect of the “Web3.js vs ethers.js” debate in mind. That said, in some cases, it is best to hire a license expert.
Bonus: For all of you who enjoy watching videos, here’s also a neat comparison of Moralis’ Streams API and ethers.js:
Whether you decide to use Web3.js, ethers.js, or the Streams API, know that this industry is shaping the future of the digital world. As such, learning how to create killer dapps is a path that offers countless opportunities. With that in mind, make sure to expand your blockchain development horizons by visiting the Moralis docs, our Web3 YouTube channel, and our crypto blog. These outlets provide you with countless tutorials and topics that can help you become a dapp developer for free. For instance, some of our latest articles explain what web3.storage is, how Web3 storage works, what Palm NFT Studio is, and much more.
Of course, you may also take a more professional approach to your crypto education. In that case, enroll in Moralis Academy. There you can partake in countless courses to help you become blockchain certified. However, we recommend you start with blockchain and Bitcoin fundamentals to build a strong foundation.