Article From:

Through geth to configure the private chain of Ethernet, it is the starting point of learning Ethernet. And how to configure genesis.json is the most critical step. If there are errors in it, some will lead to inability to initiate the private chain, others will lead to the subsequent learning process.An indescribable mistake.

However, there is a lot of configuration content that can be found on the Internet, many of the versions that are only applicable before v1.4, even the genesis.json on the GitHub itself, and the chainId configuration of the geth is also problematic.

Based on the author’s own practice, the following genesis.json can be applied to the current geth Version (v1.6.6).

  "config": {
        "chainId": 10,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
  "alloc"      : {},
  "coinbase"   : "0x0000000000000000000000000000000000000000",
  "difficulty" : "0x02000000",
  "extraData"  : "",
  "gasLimit"   : "0x2fefd8",
  "nonce"      : "0x0000000000000042",
  "mixhash"    : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp"  : "0x00"


A few mistakes that often come across:

  • Fatal: invalid genesis file: missing 0x prefix for hex data:This error message is very clear, that is, in your JSON file, you need to add the 0x prefix to the 16 binary data.

  • Fatal: invalid genesis file: hex string has odd length: From v1.6, the set of sixteen binary numbers can not be odd numbers, such as 0x0, but 0x00.

  • Fatal: failed to write genesis block: genesis has no chain configuration :This error message means that there is a lack of config in your JSON file. To see this information, we do not need to return the geth to the v1.5 version. Instead, we need to add the config part.

  • Error: invalid sender undefined: This error does not result in initialization failure, but it will occur at later transfers (eth.sendTransaction) or when smart contracts are deployed. The solution is that chainId can’t be set to 0. If you complete the official match on the GitHubThis error will be generated by setting a file.

PS:If this article is helpful to you, please go ahead or say something.

Leave a Reply

Your email address will not be published. Required fields are marked *