1

We are facing a problem with the web3.eth.getBalance(address [, defaultBlock] [, callback]) ( here the doc ). The function works well for last block, or for a small number of blocks in the past, but it does not returns ( it apparently hangs ) for block deeper in the history. What's the reason of this behavior?

  • 2
    what is the sync mode you are using? – Nulik Jul 27 '18 at 15:54
2

The balance of an address is stored in the "Ethereum World State", this state is updated in each block registering changes produced by the processed transactions.

To return the balance at a block number your node needs to have the world state at that block.

Since querying for balances at old block is very uncommon operation new versions of geth started to remove old version of the world state to save space on disk.

If you need access to balances in old blocks you will have to launch your node in 'archiving' mode. This mode uses a lot of disk space, close to 1TB recently.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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