This page may contain legacy content

To get our most up-to-date content please access our documentation

July 11, 2021

JavaScript Libraries – Ethers.js vs Web3.js

Table of Contents

Whether you are already dabbling in blockchain development or just starting to learn about the amazing scope of opportunities it offers, you are probably familiar with JavaScript (JS). We’ve previously covered how you can use Web3 with JavaScript through the use of Web3.js. However, we haven’t yet covered the “Ethers.js” JavaScript library. Of course, the popular JavaScript programming language is what “.js” refers to in both Ethers.js vs Web3.js. Ethers.js is an alternative to Web3.js. Its purpose is to offer developers an additional option when it comes to choosing the most suitable Ethereum JavaScript library for their needs. 

When programming on top of the Ethereum network, using either Web3.js or Ethers.js can be hugely helpful. Moreover, you can put ETH JavaScript libraries to work without any hassle. If you are a front-end developer with decent JavaScript knowledge, but do not know much about blockchain, you can still develop hugely powerful dApps. Simply let Moralis manage the backend for you, while you can fully focus on the front-end development. 

Moralis is free to use, and enables you to deploy your dApps super fast and easily. Furthermore, Moralis enables you to easily import either of the two ETH JavaScript libraries with a simple line of code. If you are ready to let Moralis help you gain the edge, make sure to create your free account today!

Ethers.js vs Web3.js

Since Web3.js was on the scene first, we cannot talk about Ethers.js without first touching on Web3.js. As such, we will start by covering the basics of Web3.js, and then focus on Ethers.js. We’ll also cover Ethers.js modules and the main features of Ethers.js. Moreover, we’ll also take a closer look at a practical Ethers.js vs Web3.js comparison overview.

Ethers.js and Complete Beginners

In case you are new to blockchain development or even programming in general, do not let some of the above terms scare you. Even though understanding Ethers.js may seem challenging for a novice, we’ll walk you through all you need to know. Moreover, we made sure to provide you with simple explanations or with links to more beginner-friendly articles throughout the article. To those unfamiliar with JavaScript, we strongly recommend doing a JavaScript Programming course, to get a solid understanding of JavaScript and how to best use it with blockchain.

What is Web3.js?

Web3.js is an open-source library for the JavaScript programming language. It serves for Ethereum-based projects. As such, it essentially enables developers to interact with the Ethereum blockchain. 

The library was built by the Ethereum Foundation and thus has a large community behind it. Web.js includes functions required to communicate with an Ethereum node. The latter is done via a particular protocol known as the JavaScript Object Notation – Remote Procedure Call (JSON-RPC).

Are you not completely sure what Web3 is? If so, do not worry at all. Just take a couple of minutes and read our Ultimate Guide to Web3! Both Web3.js and Ethers.js contain modules. Thus, we must ensure you know what modules are.

What are JavaScript modules?

A great way to look at JavaScript modules is to consider them as book chapters, or sections. All good programmers apply this sort of division principle and divide their programs into modules.

With that said, modules are essential clusters of code. In the case of JavaScript, mainly a combination of words and special characters. Moreover, each module has specific functionality within a larger program.

However, unlike book sections, good programming modules can be removed, added, or shuffled as necessary without affecting the system as a whole. They are basically highly self-contained with distinct functionality. Furthermore, using modules increases maintainability and reusability.

In case you are familiar with any other coding languages, perhaps Java or Python, you may know “Classes.” Classes are a very close analogy to modules.

What is Ethers.js?

Just like Web3.js, Ethers.js is an Ethereum JavaScript library. As such, it also enables developers to interact with the Ethereum blockchain. It is an open-source library via the MIT License. As such, you may be wondering what the point of Ethers.js is, if it serves the same purpose as Web3.js. However, keep in mind that as with any other products or services, Ethers.js and Web3.js each have their own benefits and drawbacks, which we’ll cover later on.

Ethers.js Modules

Ethers.js has four modules – Ethers.provider, Ethers.contract, Ethers.utils, and Ethers.wallets. These modules make up the API (Application Programming Interface). Let’s take an overview of what each of the four Ethers.js modules does.

The Purpose of Ethers.Provider 

Ethers.provider module enables you to abstract a connection to the Ethereum blockchain. As such, developers use it for issuing queries as well as sending signed transactions. This changes the state of the blockchain.

The Purpose of Ethers.Contract

In order to deploy and interact with smart contracts, we use Ethers.contract module. Deploying smart contracts is one of the main purposes of this module. Moreover, it packs functions that allow developers to ‘listen’ for events that a smart contract emits. This module also allows you to get information about smart contracts and call functions provided by a smart contract.

The Purpose of Ethers.Utils

Whenever you need to format data and process user inputs, you need to use the Ethers.utils module. This module makes building dApps a lot easier.

The Purpose of Ethers.Wallet

As the ‘.wallet’ suggests, this modulus serves to provide the ability to connect to an existing Ethereum address (an Ethereum wallet). Aside from allowing the establishment of connections, it can also create new wallets and sign transactions.

Ethers.js Main Features

Let’s take a closer look at the key features of Ethers.js. In short, Ethers.js allows you to:

  • Keep your keys in your client safely and soundly.
  • Enables you to import and export JSON wallets and HD Wallets.
  • Allows you to import and export  BIP 39 mnemonic phrases (t.i. 12-word backup phrases).
  • Provides access to meta-classes that create JavaScript objects from any contract Application Binary Interface (ABI) (including Human-Readable ABI and ABIv2).
  • It enables you to connect to Ethereum nodes.
  • In Ethers.js, ENS names are first-class citizens – developers can use them anywhere Ethereum addresses take place.
  • Ethers.js is very small – 88 kb (compressed) / 284 kb (uncompressed).
  • Offers complete functionality for all your Ethereum needs.
  • Comes with extensive documentation.
  • Offers a large collection of test cases.
  • It is fully TypeScript ready – comes with definition files and full TypeScript source.
  • It has the MIT License that includes all dependencies – completely open-source so you can do with it all you can think of.

Ethers.js vs Web3.js – The Main Aspects

By this point, you should already have a solid understanding of what Ethers.js and Web3.js are. Moreover, you should also have a relatively clear picture of what to use them for. Hopefully, you also know why you need them if you want to develop dApps on the Ethereum blockchain. 

In this section, we go through the main aspects of the Ethers.js vs Web3.js comparison. This should help you decide which Ethereum JavaScript library may be more suitable for your project. Though, you should know that you do not need to overthink this selection as you can work successfully with either of the two options when using Moralis. Beyond this, Moralis also features native support for things like IPFS, and now features full WebSocket support for Moralis Speedy Nodes. This means you can build dApps easier than ever with the use of Moralis. Be sure to sign up for a free account today, and get access to over five million requests per day with no cost at all! However, let us generally compare Ethers.js vs Web3.js.

Ethers.js vs Web3.js – Who Is Behind It?

Web3.js is a project of the Ethereum Foundation (a non-profit organization). On the other hand, Ethers.js is developed and maintained by Richard “RicMoo” Moore.

Having a whole organization behind a project means there are more developers offering support. However, it also means that it is not clear whose responsibility it is to ensure all is in order. Again, it is up to your preferences to decide what kind of backing you prefer.

Ethers.js vs Web3.js – Overall Popularity

Since Web3.js is older, it makes sense that it is more popular (overall use cases). Using GitHub as a reference, Web.js has more stars and more repositories. However, Ethers.js is experiencing faster growth in popularity.

Ethers.js vs Web3.js – Number Of Downloads

Looking at the overall number of downloads doesn’t make sense as Web3.js has been on the scene noticeably longer. Thus, considering daily downloads makes more sense. According to, Ethers.js is a winner in that aspect, though it is a tight call.

Ethers.js vs Web3.js – Maintenance

Regular updates ensure that the support team removes all known bugs and adds new features. Unfortunately, there is no clear winner in this aspect. Both ETH JavaScript Libraries have teams that update them on a relatively regular basis. 

Ethers.js vs Web3.js – Tests

In case you want to go with the Ethereum JavaScript library that has pre-written tests, Ethers.js may be the right choice for you. They have clear documentation of their tests. Nevertheless, keep in mind that that conclusion is based on previous versions of the Ethers.js.

Ethers.js vs Web3.js – Web Performance

Due to the much smaller size of Ethers.js, it loads slightly faster. However, its size may play a noticeable role only on small dApps. Moreover, there is not sufficient speed test data for the exact same dApps to confirm this web performance advantage.

Ethers.js vs Web3.js – Documentation Quality

Neither of the two ETH JavaScript libraries has perfect documentation. As such, you will want to cover the key points of your interests and determine, which one better fits your project. You can find the link to the currently latest versions (at the time of writing) below.

Ethers.js vs Web3.js – License

Web3.js has an LGLv3 license, while Ethers.js has an MIT license. In case your project has specific requirements regarding the license, you should look into that. Perhaps even consider hiring an expert to determine, which of the two ETH JavaScript libraries is more suitable for you.

Ethers.js & Web3.js Documentation

We should all express gratitude to be alive in times when a lot of information is available to us, just by having a computer and internet access. Both the Web3.js and Ethers.js documentation is available online for free. In case you prefer to dig deeper into the nitty-gritty, find the link to each documentation of the two libraries below:

As a programming language, JavaScript is always evolving, and thus its libraries must be updated as well. Even more so in reference to blockchain technology. So, teams are releasing updates and newer visions of both ETH JavaScript libraries regularly. 

At the point of writing Web3.js version is 1.3.4, while Ethers.js is 5.4. In case you are following any tutorials, make sure to use the matching version of either of the two ETH JavaScript libraries (if creators haven’t updated their tutorials to use the latest versions).

Moralis & Ethereum JavaScript Library

In case you’ve been living under the rock and haven’t heard of Moralis yet, let us get you up to date. Moralis is a complete Web3 app development platform. Its purpose is to help developers save precious time, increase engagement and boost growth. It takes care of the back-end aspects of dApps by using simple (often single line) commands. As such, front-end developers can easily create and deploy Web3 apps, or dApps, extremely fast. 

Furthermore, to show you how easy it is and to inspire you to build dApps yourself, we’ve used Moralis to create a simple dApp in only 3 minutes. Since Moralis is designed to serve a very wide range of developers looking to create Web3 apps with ease, it enables you to use either Ethers.js or Web3.js. And as promised, it is very simple (the exact code line is given below).

Whichever Ethereum JavaScript library you choose to use, you will first need to obtain your Speedy Node URL. The next step is to import the library of your choice. 

How to Import Web3.js using Moralis

In case you decide you want to use Web3.js with Moralis, you need to use the following line of code:

<script src=””></script>

As an alternative, you may import the Web3.js library via npm. In that case, you need to use the following lines of code:

npm install web3

const Web3 = require(‘web3’);

How to Import Ethers.js using Moralis

In case you decide you want to use Ethers.js with Moralis, you need to use the following line of code:

<script src=”” type=”application/javascript”></script>

As an alternative, you may import the Ethers.js library via npm. In that case, you need to use the following lines of code:

npm install ethers

// JavaScript, NodeJS

const { ethers } = require(“ethers”);

// ES6 or typescript

import { ethers } from “ethers”;

Ethers.js vs Web3.js – Summary

Ethers.js and Web3.js are the two Ethereum JavaScript libraries. They enable using JavaScript programming language to create, deploy, and interact with smart contracts. Web3.js has been on the scene longer and has more projects using it. However, currently, Ethers.js has more daily downloads and has been experiencing faster growth in popularity. Currently, there is no clear winner among the two libraries – they both serve their purpose well. With that said, it is up to each developer and their team to determine whether to use Ethers.js or Web3.js. 

Whichever Ethereum JavaScript library you choose, you can put it to use with the fastest turnaround by using the serverless Web3 backend infrastructure platform Moralis. This complete dApp development platform saves developers huge amounts of time. Furthermore, it enables front-end developers to cover backend aspects of dApp creation with single lines of code. Check it out yourself! Jump into building something awesome using JavaScript by devoting your maximum attention to the front-end. Create your free account today!

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
April 18, 2024

Moralis Launches Moralis Nodes

April 9, 2024

Moralis Launches Wallet History Endpoint

March 17, 2023

Moralis Launches NFT Image Preview Feature

January 17, 2023

Moralis to Add Aptos Support

September 22, 2022

GM2 Unveils Tech Partnership with Moralis

October 16, 2023

Introducing Gnosis Chain Support

October 21, 2022

Moralis Introduces Support for Ronin Network

October 4, 2022

BNB Chain Joins Moralis x Google Defining DeFi Hackathon as Gold Tier Sponsor

November 23, 2023

Moralis Introduces Base Support