DeveloperBreeze

Public Node Development Tutorials, Guides & Insights

Unlock 1+ expert-curated public node tutorials, real-world code snippets, and modern dev strategies. From fundamentals to advanced topics, boost your public node skills on DeveloperBreeze.

Getting Wallet Balance Using Ethers.js in Node.js

Tutorial October 24, 2024

Wallet Address: 0xYourEthereumAddress
Wallet Balance: 2.345 ETH
  • Ethers.js: We are using Ethers.js to interact with the Ethereum blockchain. Ethers.js simplifies the process of querying the blockchain and formatting the data for developers.
  • Provider: Whether you use Infura or a public node, the provider allows us to connect to the Ethereum network. Infura is commonly used because of its reliability and scalability, but public nodes can work as well if you're looking for a simple alternative.
  • getBalance(): This function queries the Ethereum network for the balance of the wallet in wei (the smallest unit of ETH). We then use ethers.utils.formatEther() to convert the balance from wei to Ether.