[Ethereum] Geth – Check balance on –light mode

cligo-ethereumweb3js

I am running a lightmode geth daemon, and I want to check the balance of my daemon. I read this answer, which says that I cannot use the command that I am currently using, as it requires support for eth.coinbase

geth --exec "web3.fromWei(eth.getBalance(eth.coinbase), 'ether')" attach

Geth synced in lightmode doesn't support use of eth.coinbase. What command can I use? Do I have to run a --syncmode=fast or standard node instead?

Best Answer

If the first account is your addreess you can use

geth --exec "web3.fromWei(eth.getBalance(eth.accounts[0]), 'ether')" attach

For example you can ask for an arbitrary address replacing eth.coinbase with such address

geth --exec "web3.fromWei(eth.getBalance('0xFBb1b73C4f0BDa4f67dcA266ce6Ef42f520fBB98'), 'ether')" attach
Related Topic