2

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.

2
  • Do you mean the genesis block of the mainnet or of your private chain?
    – TC8
    Commented Jan 31, 2018 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
    Commented Jan 31, 2018 at 7:48

1 Answer 1

1

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

2
  • How to get the "alloc" information? How to get the address and balance in "alloc"?
    – alpha
    Commented Jan 31, 2018 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
    Commented Jan 31, 2018 at 8:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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