ethers.js
Complete Ethereum library and wallet implementation in JavaScript.
A JavaScript library that lets developers connect to the Ethereum blockchain, manage crypto wallets, send transactions, and call smart contracts from a web page or Node.js app.
Ethers.js is a JavaScript library for working with the Ethereum blockchain. Ethereum is a decentralized network where people can hold cryptocurrency (Ether) and run programs called smart contracts. This library gives JavaScript developers the tools to connect to that network, read data from it, send transactions, and manage wallets, all from a web page or a Node.js application.
On the wallet side, the library can create and manage Ethereum wallets entirely within your own code. Private keys never leave the client, which means you are not handing them to a third-party server. It supports importing and exporting wallets in the JSON format used by Geth and Parity (two Ethereum node programs), and it supports the 12-word recovery phrases (BIP 39 mnemonics) that many wallet apps use. Recovery phrases are supported in over ten languages including English, Japanese, Korean, and several Chinese variants.
To interact with the network, you connect through a provider, which is essentially a gateway to an Ethereum node. Ethers.js comes with built-in support for several popular providers: INFURA, Alchemy, Etherscan, Ankr, QuickNode, and MetaMask. A default provider is available for getting started quickly, though for production use the docs recommend getting your own API key from one of these services.
For interacting with smart contracts, you give the library the contract's ABI (a description of its functions and data types) and it automatically creates a JavaScript object that mirrors those functions, so you can call them like regular code. ENS names (the human-readable .eth addresses that map to wallet addresses, similar to how domain names map to IP addresses) are treated as first-class citizens and can be used anywhere a raw address can.
The library is written in TypeScript, has a small bundle size, supports tree-shaking (so you only include what you use), and is fully MIT licensed including all of its dependencies. Documentation is available at docs.ethers.org.
Where it fits
- Build a web app that connects to MetaMask and reads the user's Ether balance.
- Call a smart contract function from JavaScript by supplying its ABI and contract address.
- Create an Ethereum wallet from a 12-word recovery phrase and send a signed transaction to the network.