What is Web3.js?
JS Modules Explained
Now that you know what JS modules are, let’s take a quick overview of Web.js modules:
- Web3.eth: The Eth module is there for interacting with the Ethereum network. It offers several sub-modules, including Web3.eth.subscribe, Web3.eth.contract, Web3.eth.accounts, Web3.eth.personal, and more.
- Web3.*.net: The Net module is there for interacting with network properties. Of course, it may be used as a sub-module to interact with Ethereum (Web3.eth.net).
- Web3.bzz: The Bzz module is there for interacting with the swarm network.
- Web3.shh: The Shh module is there for interacting with the whisper protocol.
- Web3.utils: This module provides utility functions for Ethereum dApps and other web3.js packages.
Like with most programming languages, platforms, and libraries, it is best to use their documentation for more details. You can find the link to the Web3.js documentation in the “Web3.js vs Ethers.js – Documentation” section below.
What is Ethers.js?
Just like Web3.js, Ethers.js also has several modules. To be exact, there are four modules in this JS library: Ethers.contract, Ethers.provider, Ethers.utils, and Ethers.wallets. These modules are the core of the Ethers.js’ API (Application Programming Interface). Moreover, let’s take a quick overview of all four Ethers.js modules:
- Ethers.Provider: This module enables you to establish a connection with the Ethereum blockchain. You use it to issue queries and send signed transactions. Through this module, Ethers.js users get to change the state of the blockchain.
- Ethers.Contract: You use this module to deploy and interact with smart contracts. While deploying smart contracts is one of the main purposes of Ethers.Contract, it has more to offer. As such, it also packs functions that enable developers to ‘listen’ to smart contract events (sync and index smart contract events). Furthermore, you also use this module to get information about smart contracts and call particular functions provided by smart contracts.
- Ethers.Utils: You will use this module when you want to format data and process user inputs. As such, Ethers.utils makes building dApps a whole lot easier.
- Ethers.Wallet: As you can assume based on the ‘.wallet’, Ethers.Wallet provides a way to connect to any existing Ethereum address (an Ethereum wallet). On top of that important feature, this module also enables you to create new wallets and sign transactions.
For more details regarding Ethers.js main features, check out our Ethers.js vs Web3.js comparison.
Web3.js vs Ethers.js – ETH JS Libraries Side-by-side
So far we’ve covered the basics of both JS ETH libraries, including their modules. As such, you should have a proper understanding of what Ethers.js and Web3.js are. Also, you now know what they are used for. As such, you understand they are very important for developing dApps on the Ethereum blockchain or other EVM-compatible chains.
In the following subsection, we’ll cover the main aspects of both JS libraries. As a result, you will be able to use this Web3.js vs Ethers.js comparison to determine which of the two options to use. However, please note that you do not need to overthink this. We assure you that you can work successfully with either of the two JS ETH libraries. This is especially true when using Moralis. Though Web3.js is currently the native choice, we are planning a transition to Ethers.js. However, luckily covering the crypto-related backend using Moralis is as simple as it gets. In most instances, you only need to copy and paste short snippets of code provided by Moralis’ documentation. With that said, let’s do the Web3.js vs Ethers.js comparison.
Web3.js vs Ethers.js – A Comparison
In the subsections that follow, we will compare Web3.js vs Ethers.js in the following aspects:
- The team behind it
- Web performance
Web3.js vs Ethers.js – The Team Behind It
- Web3.js: It is a project of the Ethereum Foundation (a non-profit organization). With an entire organization behind a project, there are more developers offering support. Unfortunately, this also means that there is no clear responsibility as to who should ensure that all is in order.
- Ethers.js: It was developed and is maintained by Richard “RicMoo” Moore. This clearly puts full responsibility on RicMoo.
As you can see, each of the backing types has its pros and cons. What kind of backing do you prefer?
Web3.js vs Ethers.js – Popularity
Here, you need to keep in mind that Web3.js was created first. As such, it makes sense that it wins the overall use cases title. By leaning on GitHub’s data, Web3.js has more stars and more repositories. On the other hand, when it comes to the speed of growth in popularity, Ethers.js comes on top.
Web3.js vs Ethers.js – Downloads
Another way to compare these two JS libraries is to look at the download. However, the overall number of downloads doesn’t paint a clear picture. Since Web3.js has been on the scene noticeably longer it has an unfair advantage. Luckily, we can rather focus on daily downloads. According to npm-stat.com, Ethers.js is a winner in that aspect.
Web3.js vs Ethers.js – Staying Updated
It is important to go with a library that is updated regularly and properly. That way it ensures that the support team removes all known bugs and adds new features in a timely manner. According to available reviews and devs feedback, both ETH JS libraries are updated relatively regularly.
Web3.js vs Ethers.js – Testing
When it comes to testing, Ethers.js may be the better choice. It has pre-written tests and clear documentation of its tests. However, you should keep in mind that this conclusion is based on previous versions of the Ethers.js. With the new version, things may be different.
Web3.js vs Ethers.js – Web Performance
Ethers.js loads slightly faster thanks to its noticeably smaller size, which may offer better performance. Though, the size factor plays a noticeable role only when it comes to small dApps. Also, it is important to point out that there is not sufficient speed test data for the exact same dApps using Web3.js and Ethers.js. Thus, any performance advantage remains to be confirmed.
Web3.js vs Ethers.js – Documentation
- The Web3.js documentation: https://web3js.readthedocs.io/en/v1.7.0/
- The Ethers.js documentation: https://docs.ethers.io/v5/
Web3.js vs Ethers.js – License
- Web3.js: It has an LGLv3 license.
- Ethers.js: It has an MIT license.
We’ve covered a lot of ground and have managed to wrap up our Web3.js vs Ethers.js comparison. By now you know that both JS ETH libraries offer several modules that enable you to interact with the Ethereum chain. Moreover, you’ve learned that each library has its advantages and disadvantages. However, the blockchain industry as a whole is slowly migrating towards a younger alternative – Ethers.js. This same transition is also in the pipeline for Moralis. Though, this is not something you need to worry about when developing dApps with this ultimate Web3 development platform. You only need to create your free Moralis account, create a Moralis server, and initialize Moralis. One way to do this is to create your HTML and JS code files from scratch. However, you may also use the most practical Ethereum dApp boilerplate. This ultimate Web3 boilerplate enables you to deploy dApps in minutes.
Furthermore, in case you want to continue your free blockchain development education, make sure to visit the Moralis’ blog and the Moralis’ YouTube channel. You can find a ton of high-quality content there, including many interesting example projects. Some of the latest topics cover NFT API alternatives, gasless transactions, how to build a Web3 login with Web3 authentication, DAO smart contract example, WalletConnects Android SDK, Web3 wallets, GameFi and play-to-earn (P2E), how to interact with smarts contract through a website, Ethereum gas fees, and much more. However, if you are determined to become a blockchain developer sooner rather than later, you may want to consider a more professional approach. If so, you should enroll in Moralis Academy. That way you’ll gain access to many high-quality courses, a remarkable community, and professional mentors. This trio will enable you to go full-time crypto in no time.