[Ethereum] Clique: Genesis File

cliquegenesisgo-ethereum

What are the mandatory parameters of genesis.json File in PoA? and what are their expected values? for ex. values of

byzantiumBlock
epi155Block
DAOForkBlock
EIP150Block
EIP158Block
epoch
nonce
mixhash

When I tried to change the value of nonce and mixhash and then started the node, it did not start.

Best Answer

Use something like this:

{
    "config": {
        "chainId": <yourChainId>,
        "homesteadBlock": 0,
        "eip150Block": 0,
        "eip155Block": 0,
        "eip158Block": 0,
        "byzantiumBlock": 0,
        "clique": {
            "period": <yourPeriodInSecs>,
            "epoch": <yourEpochInBlocks>
        }
    },
    "alloc": {
        "0000000000000000000000000000000000000001": { "balance": "1" },
        "0000000000000000000000000000000000000002": { "balance": "1" },
        "0000000000000000000000000000000000000003": { "balance": "1" },
        "0000000000000000000000000000000000000004": { "balance": "1" },
        "0000000000000000000000000000000000000005": { "balance": "1" },
        "0000000000000000000000000000000000000006": { "balance": "1" },
        "0000000000000000000000000000000000000007": { "balance": "1" },
        "0000000000000000000000000000000000000008": { "balance": "1" },
        "<yourPreallocAccount>": { "balance": "<yourPreallocAmount>" }
    },
    "coinbase": "0x0000000000000000000000000000000000000000",
    "difficulty": "1",
    "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000<yourInitialSigners>0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "gasLimit": "<yourInitialGasLimit>",
    "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "nonce": "0",
    "timestamp": "<yourUnixTimeStamp>"
}
  • yourChainId: Just use a number.
  • yourPeriodInSecs: Block time in seconds. 5 or 10 are good values to start with.
  • yourEpochInBlocks: The default of 30000 is usually good enough.
  • yourPreallocAccount, yourPreallocAmount: Since no coins are created through mining, the preallocated amounts are all you have. Give an account some coins here. (No prefixed "0x".)
  • yourInitialSigners: You need at least one initial signer. Add its account address here.
  • yourInitialGasLimit: The initial gas limit per block. Depends on what you want to do. (Consider 21000 gas/transfer, for example.)
  • yourUnixTimeStamp: The number of seconds since the Unix epoch (1970-01-01).

Notes:

  • The other elements in config are optional; the way they are set here get you a blockchain that works like the current Ethereum (except for Clique). They control the blockchain behavior. You'll find more about what they mean by searching for them.
  • The other accounts in alloc are predefined contracts that get initialized by this. Not strictly necessary but recommended.
  • AFAIK, all the other genesis block elements must be like they are here.