0PricingLogin
Web3 & DApp Development Fundamentals · Lesson

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

  1. Connecting to a Provider
  2. Reading Contract Data
  3. Sending Transactions
  4. Listening to Events
← Back to Web3 & DApp Development Fundamentals