DeveloperBreeze

Blockchain Development Programming Tutorials, Guides & Best Practices

Explore 30+ expertly crafted blockchain development tutorials, components, and code examples. Stay productive and build faster with proven implementation strategies and design patterns from DeveloperBreeze.

Sending Transactions and Interacting with Smart Contracts Using Infura and Ethers.js

Tutorial October 24, 2024

Token Balance: 1000000000000000000

This output is the token balance in the smallest unit (e.g., Wei for Ether or the smallest denomination for the token), and you can convert it to the token’s base unit if needed.

Getting Wallet Balance Using Ethers.js in Node.js

Tutorial October 24, 2024

  • 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.

Once you've successfully retrieved the balance, you can expand your script to add more features. For example: