1

Correct me if Im wrong but from my understanding each block has a "stateRoot" property that point to status of the State tree at the time of mining. I also believe that tha state tree contais a list of accounts (user accounts and contracts) and their balance\code.

Is it possible to get the list of accounts and their balance (if not contracts) on each block? I know I can use the "eth_getBalance" RPC call to get the ballance of each account but that wold require me to know before hand which are the accounts.

thanks

  • how do you want to get the balances, with Javascript through web3 or in golang? – Nulik Feb 13 '18 at 21:59
  • blocks do not contain accounts, blocks contain transactions. accounts are stored in levelDB , so you can only get list of transactions for the block, and the from / to addresses where the money went on these transactions – Nulik Feb 13 '18 at 22:02
  • @Nulik I am making RPC requests to geth so if possible I'd like to continue using that method. And yes, I know that the block only contains the to\from, thus my second point. Im just wondering if there is a way of queryng the state tree given the "stateRoot" of each block for example to get the balances of all the accounts on that block. Thanks – Diego Feb 14 '18 at 12:57
  • 1
    well, I am not using web3, but seems that it has all the calls. Kind of like web3.eth.getTransactionFromBlock(), then web3.eth.getBalance() for every 'from` or 'to'. No need to mess with stateRoot, it is more like low level stuff. – Nulik Feb 14 '18 at 15:40
  • yes, that is my current aproach, get each transaction in a block than call getBalance for all accounts in to and from....I was just wondering if it was an easier way. Speaking of which, I am facing this(ethereum.stackexchange.com/questions/39610/…) problem now if you dont mind taking a look. Thanks for your help – Diego Feb 14 '18 at 18:18

Your Answer

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

Browse other questions tagged or ask your own question.