Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is Web3.js?
Web3.js is a JavaScript library that helps developers interact with the Ethereum blockchain by providing tools to send transactions, read blockchain data, and interact with smart contracts.
Click to reveal answer
beginner
What is ethers.js?
Ethers.js is a lightweight JavaScript library designed to interact with the Ethereum blockchain. It focuses on simplicity, security, and providing a clean API for tasks like sending transactions and reading data.
Click to reveal answer
intermediate
Name one key difference between Web3.js and ethers.js.
Web3.js is larger and older with more features, while ethers.js is smaller, more modular, and designed for better security and ease of use.
Click to reveal answer
intermediate
Which library provides better support for ENS (Ethereum Name Service) resolution?
Ethers.js provides better and more straightforward support for ENS resolution compared to Web3.js.
Click to reveal answer
intermediate
Why might a developer choose ethers.js over Web3.js?
A developer might choose ethers.js because it is easier to use, has better documentation, is more secure by design, and offers a smaller bundle size for web apps.
Click to reveal answer
Which library is known for being more lightweight and modular?
ANeither is modular
BWeb3.js
Cethers.js
DBoth are equally heavy
✗ Incorrect
Ethers.js is designed to be lightweight and modular, making it easier to use in modern web applications.
Which library was released first?
ANeither is related to Ethereum
Bethers.js
CBoth released at the same time
DWeb3.js
✗ Incorrect
Web3.js is the older library and was released before ethers.js.
Which library offers better built-in support for ENS (Ethereum Name Service)?
Aethers.js
BNeither supports ENS
CWeb3.js
DBoth support ENS equally
✗ Incorrect
Ethers.js provides better and more straightforward ENS support.
Which library is generally considered easier to learn for beginners?
Aethers.js
BWeb3.js
CBoth are equally difficult
DNeither is beginner-friendly
✗ Incorrect
Ethers.js has a simpler API and better documentation, making it easier for beginners.
Which library is more focused on security by design?
AWeb3.js
Bethers.js
CBoth have the same security focus
DNeither focuses on security
✗ Incorrect
Ethers.js emphasizes security and safer defaults in its design.
Explain the main differences between Web3.js and ethers.js.
Think about size, ease of use, and features.
You got /4 concepts.
Why might a developer prefer ethers.js for a new Ethereum project?
Consider developer experience and app performance.
You got /5 concepts.
Practice
(1/5)
1. Which of the following is a key difference between Web3.js and ethers.js?
easy
A. ethers.js is a backend-only library, Web3.js is frontend-only.
B. Web3.js only works with Bitcoin, ethers.js only with Ethereum.
C. ethers.js cannot send transactions, Web3.js can.
D. Web3.js is larger and older, while ethers.js is lighter and simpler.
Solution
Step 1: Understand library origins
Web3.js is an older, larger library designed for Ethereum interaction.
Step 2: Compare library features
ethers.js is newer, designed to be lightweight and simpler to use.
Final Answer:
Web3.js is larger and older, while ethers.js is lighter and simpler. -> Option D
Quick Check:
Library size and age = A [OK]
Hint: Remember: Web3.js is big and old; ethers.js is small and new [OK]
Common Mistakes:
Thinking ethers.js only works on backend
Confusing blockchain support (Bitcoin vs Ethereum)
Believing ethers.js can't send transactions
2. Which of the following is the correct way to create a provider using ethers.js?
easy
A. const provider = new ethers.providers.JsonRpcProvider();
B. const provider = new Web3.providers.HttpProvider();
C. const provider = new ethers.Web3Provider();
D. const provider = new Web3.eth.JsonRpcProvider();
Solution
Step 1: Recall ethers.js provider syntax
ethers.js uses ethers.providers.JsonRpcProvider() to create a JSON RPC provider.
Step 2: Identify correct syntax
const provider = new ethers.providers.JsonRpcProvider(); matches the correct ethers.js syntax; others mix Web3.js or incorrect classes.
Final Answer:
const provider = new ethers.providers.JsonRpcProvider(); -> Option A
A. Missing provider URL when creating Web3 instance.
B. getBalance() is not an async function.
C. The address format is incorrect.
D. console.log cannot print balance.
Solution
Step 1: Check Web3 instance creation
Web3 requires a provider URL (like HTTP or WebSocket) when instantiated to connect to Ethereum.
Step 2: Identify missing provider
The code creates new Web3() without a provider, so calls like getBalance will fail.
Final Answer:
Missing provider URL when creating Web3 instance. -> Option A
Quick Check:
Web3 needs provider URL [OK]
Hint: Always pass provider URL to Web3 constructor [OK]
Common Mistakes:
Thinking getBalance is not async
Assuming address format is wrong
Believing console.log can't print balance
5. You want to send a transaction using ethers.js and wait for it to be mined. Which code snippet correctly does this?
hard
A. const tx = await provider.sendTransaction(txData);
await tx.wait();
B. const tx = await signer.sendTransaction(txData);
await tx.wait();
console.log('Mined:', tx.hash);
C. const tx = signer.sendTransaction(txData);
console.log('Mined:', tx.hash);
D. const tx = await signer.send(txData);
await tx.wait();
Solution
Step 1: Identify correct method to send transaction
In ethers.js, signer.sendTransaction() sends a transaction and returns a transaction response.
Step 2: Wait for transaction mining
Calling tx.wait() waits for the transaction to be mined before proceeding.
Step 3: Confirm correct usage
const tx = await signer.sendTransaction(txData;
await tx.wait();
console.log('Mined:', tx.hash); correctly awaits sending, then waits for mining, then logs the hash.