How to get a balance of Ether with ethers.js
Jul 3, 2021
--
const ethers = require('ethers')const network = 'rinkeby' // use rinkeby testnet
const provider = ethers.getDefaultProvider(network)
const address = '0xF02c1c8e6114b1Dbe8937a39260b5b0a374432bB'provider.getBalance(address).then((balance) => {
// convert a currency unit from wei to ether
const balanceInEth = ethers.utils.formatEther(balance)
console.log(`balance: ${balanceInEth} ETH`)
})
Support
If you find this article is helpful, it would be greatly appreciated if you could tip Ether to the address below. Thank you!
0x0089d53F703f7E0843953D48133f74cE247184c2