Reading Contract Data
Call view functions.
Calling View Functions
Reading data from a contract is free — it does not change state, cost gas, or require a signature. These are view and pure functions.
With ethers.js you attach to a deployed contract and call them like normal JavaScript methods.
You Need the ABI
To talk to a contract, ethers needs its ABI — the interface describing each function. You can use the full compiled ABI or a minimal human-readable one:
const abi = [
"function name() view returns (string)",
"function balanceOf(address) view returns (uint256)",
];const abi = [
"function name() view returns (string)",
"function balanceOf(address) view returns (uint256)",
];All lessons in this course
- Connecting to a Provider
- Reading Contract Data
- Sending Transactions
- Listening to Events