Here is sample code of how to check ether balance using NodeJS,
// ether.js version 6
import { ethers } from 'ethers';
const provider = new ethers.getDefaultProvider("goerli"); // use goerli testnet
await provider.getBalance('0x48......f2').then((balance) => {
// convert a currency unit from wei to ether
const balanceInEth = ethers.formatEther(balance)
console.log(`balance: ${balanceInEth} ETH`);
});
Notes:
- Replace
goerli
with your network. - Replace
0x48......f2
with your wallet hex.
That's it. Now you can see your wallet balance.
- Last updated 9 months ago
Be the first to leave a comment.
You must login to leave a comment