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:JsonRpcProviderconnects 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.
Code
Canonical knowledge ID:
code-example:read-eth-balance-ethersjs