I have created a set of accounts in private ethereum networks. I am able to check the balance of all these accounts using the following command:
.
> checkAllBalances();
I have created a web page that will display the balance of all the accounts on the click of a button. So, I want to write a javascript to list the balances. But still need Any more ideas on how to do it?
***
You can write a function that will fetch the account balance using the eth.getBalance() method. Refer the below code:
function checkAllBalances() {
var i = 0;
eth.accounts.forEach( function(e){
console.log("eth.accounts["+i+"]: " + e + " \tbalance: " + web3.fromWei(eth.getBalance(e), "ether") + " ether");
i++;
})
};Code well.
Good Luck coding.
Please remember to subscribe me.
No comments:
Post a Comment