What would be the process to find out the balance of an account at a specific point in the past?

Is it correct to say that we have to get the balance from the current World State Trie and then roll back every single transaction involving the account from previous blocks until we reach the point in the past (block) that we want?

  • I have a blockchain -> SQL converter with historic balances, if interested , let me know. Its an open source project that is coming soon.
    – Nulik
    Sep 1 '18 at 23:04

Yes, this is right to say, you need to write your own function to restore this or use your ethereum client with "archive" option to remember past blocks when syncing (in geth --gcmode archive).


The second parameter to eth_getBalance is a block number. That will give you the account's balance at that block.

  • I'd like to know how eth_getBalance get that information... what the function does behind the curtains... Sep 1 '18 at 19:12
  • You'd have to check the specific software you were curious about, but presumably the balances are just stored in a local database.
    – user19510
    Sep 1 '18 at 19:15
  • If you're interested in geth's implementation, you might want to start reading here: github.com/ethereum/go-ethereum/blob/master/internal/ethapi/….
    – user19510
    Sep 1 '18 at 19:20
  • I don't believe any client would store balance history. Probably this information is retrieved some other way. Sep 1 '18 at 19:22
  • I suspect you'll find that in popular nodes like geth and Parity, none of the state trie is ever deleted, so as long as you know the root hash (e.g. from the block headers), you can easily query the state at any block.
    – user19510
    Sep 1 '18 at 19:32

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.