I am playing around with a private blockchain, and I realize that I do not know how to get the "genesis block" info. The eth.getBlock(0) does not show the Genesis information, for example, pre-fund by "alloc".

So, how can I retrieve the information of the Genesis block?

My Genesis file looks like:

  "gasLimit": "0x30000000",
  "difficulty": "0x1",
  "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "coinbase": "0x0000000000000000000000000000000000000000",
  "alloc": {
    "e9722f81388f8f99771cad2770aba1f4b9e2d86c": {
      "balance": "1000000000000000000000000"
    }
  },

What I want to know is how can I get the "alloc" information through the web3 or JSON-RPC API.

  • Do you mean the genesis block of the mainnet or of your private chain? – TC8 Jan 31 at 7:15
  • My private chain. I have the Genesis file. What makes me confused is I think the information should have been written into the block, but I do not know how to get the information (for example, through web3). – alpha Jan 31 at 7:48

for the public networks, those values are defined in a config file. For geth you can find those values in this file (for mainnet, and testnets)

https://github.com/ethereum/go-ethereum/blob/master/params/config.go#L33

regarding a private network, well you need a genesis file to initialize your network, so you should have it somewhere. However, it is possible to reverse engineer most values. Give a look at the rpc methods:

https://github.com/ethereum/wiki/wiki/JSON-RPC

for example, from your javascript console ($ geth attach "http://localhost:8545") calling

> net.version

will return you the networkId

> eth.getBlock('latest')

will return you the latest block from which you can find the gasLimit, etc

  • How to get the "alloc" information? How to get the address and balance in "alloc"? – alpha Jan 31 at 7:55
  • 1
    I dont think you can using RPC methods. Browsing https://github.com/ethereum/go-ethereum/blob/master/core/genesis.go it looks that the alloc addresses and balances are saved in geth DB. What makes sense since it is required to have a genesis file to init a node. Therefore all node will know about the alloc info. The info being saved in the node DB it is for sure possible to recover them. Nevertheless I dont have an answer on how to do it – salanfe Jan 31 at 8:15
  • It does make sense, thanks! – alpha Jan 31 at 10:40

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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