Skip to main content

Read ETH Balance with ethers.js

Query an Ethereum address’s native ETH balance using ethers.js v6. Query an Ethereum address’s native ETH balance using ethers.js v6.

Explanation

This snippet connects to a public Ethereum RPC endpoint and reads an address’s balance. Key concepts:
  • JsonRpcProvider connects to an Ethereum node via HTTP.
  • getBalance() returns the balance in wei (the smallest ETH unit).
  • ethers.formatEther() converts wei to a human-readable ETH string.
Use this pattern to display wallet balances in any frontend application.

Code


Canonical knowledge ID: code-example:read-eth-balance-ethersjs