What is ethers.js?
Answer
ethers.js is a modern, complete Ethereum JavaScript library that is the de facto standard for new Web3 development, largely replacing web3.js. Created by Richard Moore in 2016. Advantages over web3.js: (1) Smaller bundle — ~88KB vs web3.js ~1MB+; (2) TypeScript native — full TypeScript types built-in; (3) Cleaner API — provider/signer separation is more intuitive; (4) BigNumber handling — v6 uses native BigInt; (5) Better testing — widely used with Hardhat and Foundry. Key components: Provider — read-only Ethereum connection: const provider = new ethers.JsonRpcProvider("https://eth-mainnet.g.alchemy.com/v2/KEY"); Signer — account that can sign transactions: const signer = await provider.getSigner(); Contract — interface to smart contract: const contract = new ethers.Contract(address, abi, signerOrProvider). Call view function: const balance = await contract.balanceOf(address). Send transaction: const tx = await contract.transfer(to, amount); await tx.wait(). Ethers v6 (2023) introduced significant API changes from v5.
Previous
What is Web3.js and what is it used for?
Next
What is IPFS and how is it used with blockchain?