Replies: 4 comments 3 replies
-
// If account balance is 1 ETH
const balance = await provider.getBalance(address);
console.log(balance.toString()); // prints 100000000000... 18 zeros
// to format the value in a readable format
console.log(ethers.utils.formatEther(balance)); // prints 1.0 You can find more info about BigNumber in the docs. |
Beta Was this translation helpful? Give feedback.
-
@tytom2003 Do you still have any questions? Or did the link from @zemse help. I would recommend especially checking out the notes near the bottom if you are new to Ethereum development. |
Beta Was this translation helpful? Give feedback.
-
Hi.. I've used zemse's code above to get the eth balance of a wallet and it's working 100%. How do I get the balance of a specific token in a wallet, not eth.. Thanks.. |
Beta Was this translation helpful? Give feedback.
-
@williamoc74 You have to call the balanceOf function in the respective token contract.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
how to get number form ethers.getBalance(addres)?
when i write ethers.getBalance(addres) in js file. Then, i compile it. it result show "BigNumber { _hex: '0x056bab21836e634000', _isBigNumber: true }". How change the result to number?
Thank you very much.
Beta Was this translation helpful? Give feedback.
All reactions