1

I understand that the state of Ethereum is its set of accounts, either EOA's or contracts.

But the genesis.json specifies no accounts; instead it defines, e.g., difficulty and gas-limit (block).

So, why do I often see that genesis.json defines the initial state of an Ethereum-based blockchain?

2

When you start up a new Ethereum chain it is possible to specify users' accounts and balances, and even contracts in the Genesis block, so that the blockchain starts up with some state.

An example is Quorum with QuorumChain consensus. This uses the Genesis block to create a contact, initialise it and create some accounts with balances. There's no proof-of-work mining in Quorum, so no Ether is created; it all needs to be specified in the Genesis block and the total supply is fixed forever.

See an example of this here, shown truncated in the following genesis.json. The "alloc" block first creates a contract at address 0x20 and initialises its storage. The next lines initialise some account addresses with large balances of (private-chain) Ether.

{
  "alloc": {
    "0x0000000000000000000000000000000000000020": {
      "code": "606060405236156100c45760e060020a60003504631290948581146100...<truncated>...",
      "storage": {
        "0x0000000000000000000000000000000000000000000000000000000000000001": "0x02",
        "0x0000000000000000000000000000000000000000000000000000000000000002": "0x04",
        "0x29ecdbdf95c7f6ceec92d6150c697aa14abeb0f8595dd58d808842ea237d8494": "0x01",
        "0x6aa118c6537572d8b515a9f9154be55a3377a8de7991cd23bf6e5ceb368688e3": "0x01",
        ...
      }
    },
    "0xed9d02e382b34818e88b88a309c7fe71e65f419d": {
      "balance": "1000000000000000000000000000"
    },
    "0xca843569e3427144cead5e4d5999a3d0ccf92b8e": {
      "balance": "1000000000000000000000000000"
    },
    "0x0fbdc686b912d7722dc86510934589e0aaf3b55a": {
      "balance": "1000000000000000000000000000"
    },
    ...
   }
  },
  "coinbase": "0x0000000000000000000000000000000000000000",
  "config": {
    "homesteadBlock": 0
  },
  "difficulty": "0x0",
  "extraData": "0x",
  "gasLimit": "0x2FEFD800",
  "mixhash": "0x00000000000000000000000000000000000000647572616c65787365646c6578",
  "nonce": "0x0",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp": "0x00"
}

On the public Mainnet Ethereum chain, you are correct that the initial state was basically empty by design, but that doesn't limit use of the Genesis block to create state in other chains.

  • Thank you - so, this genesis.json creates contract accounts, which is state by definition. By initializing accounts with ether, are the accounts created in this case? – Shuzheng Nov 10 '17 at 8:59
  • "By initializing accounts with ether, are the accounts created in this case?" - Yes. Of course you'll need to know the private keys to use the accounts: the account addresses in the genesis.json file will have been generated previously and the private keys saved as per usual. Once the blockchain is running they simply exist with 10^27 Wei and can be used as normal EOAs. – benjaminion Nov 10 '17 at 10:51

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.