December 11, 2022

Web3.js vs Ethers.js – The Full 2023 Guide to ETH JavaScript Libraries

Table of Contents

In Ethereum development, there are two JavaScript libraries that are quite popular among developers, Web3.js and ethers.js. But which one is better? By comparing the two in an action-packed Web3.js vs ethers.js battle, we’ll see if there’s a reason why the blockchain industry has slowly migrated towards ethers.js and if this library deserves the top spot on the leaderboard compared to Web3.js. However, although both are popular libraries, many experienced developers have found another alternative that has proven to be more beneficial – the Moralis Streams API. Will this API ultimately bring an end to the Web3.js vs ethers.js debate? Let’s find out!

As we dive deeper into the upcoming sections, you’ll learn what ethers.js is. Before explaining what Web3.js is, you’ll also explore “ethers.js 2.0”. Once you know the basics of each of the two Ethereum JS libraries, we will do a thorough Web3.js vs ethers.js comparison. This will help you decide which ETH JavaScript library to utilize during your development endeavors. However, judging by the positive feedback from many dapp (decentralized application) developers who already use Moralis’ Streams API, we believe you’ll be eager to ditch Web3.js and ethers.js yourself. After all, this “ethers.js 2.0” provider is at your disposal with a free Moralis account.       

Web3.js vs Ethers.js

What is Ethers.js?

So, what is ethers.js? Ethers.js is a JavaScript (JS) library that aims to be a complete and compact solution for Ethereum development. Since many other popular blockchains follow Ethereum’s lead and use the same virtual machine (Ethereum Virtual Machine [EVM]), this JS library also supports development on other EVM-compatible programmable blockchains. As such, it’s not surprising why some Ethereum devs listen to the blockchain with ethers.js.

Computer with Ethers.js on it.

In addition to JavaScript support, ethers.js also covers utility functions in TypeScript (TS). Furthermore, this library offers many neat features. For example, it comes with extensive documentation, includes a huge collection of maintained test cases, keeps your private keys in your client safe and sound, and lets you create JavaScript objects from any contract ABI, including ABIv2 and ethers Human-Readable ABI with meta classes. To help you form an even clearer picture of what ethers.js is and some of its other features than the ones stated earlier, let’s look at the following list:

  • 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:

Moralis and Ethers comparison table.

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

It would be wrong to say that the ethers.js library is not a decent open-source solution for listening to the blockchain. After all, it gets the job done. However, as presented above, even this young ETH JavaScript library comes with several limitations, which will hold you back when creating dapps.

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.

Web3.js logo.

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?

Just like ethers.js, Web3.js is also an open-source JS library. However, it was on the scene one year before ethers.js and was created by the Ethereum Foundation. This library’s main purpose is to facilitate seamless interactions with the Ethereum chain. Furthermore, Web3.js establishes communication with Ethereum nodes through the “JavaScript Object Notation – remote procedure call” (JSON-RPC) protocol. A lot like ethers.js, this JS library also features modules. In fact, you can learn about its five modules below: 

  • 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.).
  •“ – You use ““ 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.

Ultimately, it’s safe to say that the two ETH JavaScript libraries are quite similar. They serve the same or very similar purposes. However, there are some distinct differences between the two that we’ll point out in the upcoming “Web3.js vs ethers.js” section! 

Web3.js vs Ethers.js

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:
– Room for improvement
– Provides all you need to get started
– Link to the ethers.js documentation: 
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.

Out of the two ETH JavaScript libraries, ethers.js is noticeably smaller in size. The latter may be the main reason why it loads slightly faster than Web3.js. This may offer better performance, especially for smaller dapps. However, since one or the other library is used for various projects, there’s basically no data for the exact same dapps using Web3.js and ethers.js. Thus, the web performance aspect of the Wweb3.js vs ethers.js comparison remains non-conclusive.

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:

Web3.js vs Ethers.js – The Full 2023 Guide to ETH JavaScript Libraries – Summary

We covered a lot of ground in today’s article. Aside from quite a detailed Web3.js vs ethers.js comparison, we also provided you with summaries of each of the two libraries. As such, even if you’ve never used any of them previously, you now have a solid idea of what they are all about. Ultimately, you learned that in the last two years, ethers.js took the lead and became the ETH JavaScript library that most devs focus on. However, we also explained that there is a new tool many developers have decided to utilize instead – Moralis’ Web3 Streams API. Last but not least, you even had an opportunity to watch a video that neatly outlines the benefits of this future-proof tool.  

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 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.   

Moralis Money
Stay ahead of the markets with real-time, on-chain data insights. Inform your trades with true market alpha!
Moralis Money
Related Articles
February 28, 2023

Arbitrum Testnet – How to Build and Launch Arbitrum Projects

December 27, 2022

Easy Web3 Programming Tutorial for Blockchain Development

August 23, 2022

How to Use Filecoin in Unity for Storage

March 14, 2023

Notify Custom Webhooks – Real-Time Data with Moralis Streams

May 10, 2024

Stream Real-Time Blockchain Data – Top Alchemy Pipelines Alternative

August 10, 2022

How to Pull Data from Polygon Blockchain

October 16, 2023

What is ERC-4337? Full EIP-4337 Guide