0

I already know how to retrieve the ether balance of MY account with the below command.

web3.eth.getBalance(MY_ADDRESS).

But, I can't seem to find a way to retrieve the ether balance of ANY account.

Does anyone know how to retrieve the balance of any account?

Any references or help will be thankful.

1 Answer 1

4

You can just use web3.eth.getBalance('0x2910543af39aba0cd09dbb2d50200b3e800a63d2') for example. For more info: https://stackoverflow.com/questions/32312884/how-do-i-get-the-balance-of-an-account-in-ethereum

8
  • It works even if the address is not within my Ethereum node (Geth)? because I attach the Geth JavaScript Console and use eth.getBalance('ANY ETHER ADDRESS') and it does not return the balance correctly.
    – JayB Kim
    Mar 23, 2018 at 10:04
  • I don't understand what you mean with "not within my Ethereum node". Your node should connect to the network and get the latest state of the blockchain. Balances should also be updated accordingly. My guess is that your node is not up to date, but impossible to say with this information. Mar 23, 2018 at 10:38
  • If you are running against a locally running node and trying to get historical balances, that node will have to be running as an archive node, otherwise it will return zero balance. Non archive nodes return current balances but not historical balances. In fact, that’s the difference. Mar 23, 2018 at 12:54
  • @LauriPeltonen I have a remote server that is running Geth, and it is synchronizing up to the latest state of the blockchain. If I use eth.getBalance() to look up how many Ethereum an address has (any addresses of any blocks I find in Etherscan) in JavaScript Console, it returns 0.
    – JayB Kim
    Mar 24, 2018 at 14:14
  • @Thomas Jay Rush I am not sure what you mean by non archive nodes. How can I make my node "non archive node"?
    – JayB Kim
    Mar 24, 2018 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.