0

I installed a node on the pc with the parameters geth --rpc --rpcaddr localhost --rpcport 8545 and I want to check the account balance:

const Web3 = require('web3')
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
const address = '0xbdfd7125408363bfa36b8e83753b53dd695eef24' 
web3.eth.getBalance(address, (err, wei) => {
  console.log(balance = web3.utils.fromWei(wei, 'ether'))
})

but the balance is always 0, although there are funds there, what’s the problem?

5
  • Is geth connected to mainnet? Has it finished syncing? – Ismael Dec 4 '19 at 5:03
  • @Ismael How to check which network geth is connected to? Get attach shows currentBlock: 9047446, highestBlock: 9047561, knownStates: 75526676, pulledStates: 75522784, startingBlock: 9047228 – Ayurpwnz Dec 4 '19 at 5:07
  • Default is mainnet. It seems your node hasn't finished syncing. You cannot use it until it has synced. – Ismael Dec 4 '19 at 5:14
  • @Ismael Geth parameters: geth --rpc --rpcaddr localhost --rpcport 8545 The problem is that geth cannot be fully synchronized, 1 in 1, it always lags a few blocks – Ayurpwnz Dec 4 '19 at 5:17
  • full node on a normal pc rarely works, try fast sync – Majd TL Dec 4 '19 at 9:46

Browse other questions tagged or ask your own question.