Ethereum Developer Web3.js, Ethers.js and Ethereum APIs 1 — Questions and Answers
Question 1: What is the primary purpose of the ethers.js library in Ethereum development?
- To interact with the Ethereum blockchain from JavaScript/TypeScript applications (Correct answer)
- To compile Solidity contracts into bytecode
- To simulate Ethereum transactions off-chain
- To deploy contracts to multiple EVM networks simultaneously
Correct answer: To interact with the Ethereum blockchain from JavaScript/TypeScript applications
Ethers.js is a lightweight JavaScript library for connecting to Ethereum nodes, signing transactions, and interacting with smart contracts.
Question 2: What is a Provider in the context of ethers.js?
- A read-only connection to an Ethereum node for querying blockchain data (Correct answer)
- An object that holds a private key for signing transactions
- A class that compiles Solidity code at runtime
- A middleware layer between the frontend and the contract
Correct answer: A read-only connection to an Ethereum node for querying blockchain data
A Provider in ethers.js represents a connection to the Ethereum network, enabling read-only queries like fetching balances and blocks.
Question 3: What is a Signer in ethers.js?
- An abstraction that holds a private key and can sign and send transactions (Correct answer)
- A function that verifies the validity of a signature
- A node operator that validates blocks
- A contract that manages key recovery
Correct answer: An abstraction that holds a private key and can sign and send transactions
A Signer in ethers.js is an abstraction over a private key, enabling signing messages and sending transactions to the Ethereum network.
Question 4: What does ABI stand for in Ethereum development?
- Application Binary Interface (Correct answer)
- Automated Blockchain Interpreter
- Abstract Base Interface
- Address Binding Index
Correct answer: Application Binary Interface
The ABI (Application Binary Interface) defines how to encode and decode function calls and return values when interacting with a smart contract.
Question 5: Which JSON-RPC method is used to get the ETH balance of an address on Ethereum?
- eth_getBalance (Correct answer)
- eth_accounts
- eth_getTransactionCount
- eth_call
Correct answer: eth_getBalance
`eth_getBalance` returns the Wei balance of a given address at a specified block number.
Question 6: What is MetaMask's primary role in a browser-based dApp?
- An injected wallet that provides a Web3 provider and Signer to the dApp (Correct answer)
- A smart contract deployed on Ethereum to manage user sessions
- A decentralized storage solution for dApp data
- A compiler for Solidity code in the browser
Correct answer: An injected wallet that provides a Web3 provider and Signer to the dApp
MetaMask injects a `window.ethereum` provider object into the browser, enabling dApps to request account access and sign transactions.
What is the primary purpose of the ethers.js library in Ethereum development?