In this post, I am going to share about what genesis.json file is and how you start a private network with Geth. Geth is a Go-Implementation of the Ethereum Protocol.
What Will I Learn?
- What is genesis.json
- How to start your private network with Geth
Requirements
- Geth Installed (if you have not installed Geth, read my previous post)
- basic understanding of blockchain and genesis block
- Preferred UNIX based platform (Linux/Mac)
Difficulty
Intermediate
Tutorial Contents
genesis.json
genesis.json is a JSON file that stores how the genesis block looks like, to initialize your own private blockchain.
The name genesis.json is by convention.
{
"config": {
"chainId": 33,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"nonce": "0x0000000000000033",
"timestamp": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x8000000",
"difficulty": "0x100",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x3333333333333333333333333333333333333333",
"alloc": {}
}
genesis.json
config- Configuration to describe the chain.nonce- Need to be used to initialize the blockchain.timestamp- State when was the block generated.parentHash- Hash of the entire parent block header.gasLimit- Ether require gas to make transaction. However, there is an upper limit for the gas payment. The higher the limit, the more complicated smart contract can be done.difficulty- Defines how difficult to mine a new block.mixhash- combined with nonce.coinbase- Your address.alloc- Preallocated Ether accounts
To read more about details of each of the parameters, check out this stackexchange answer.
Create a Genesis Block
The directory currently look like this:
/
|- genesis.json
Run geth --datadir=./chaindata/ init ./genesis.json to generate the chaindata which will set genesis block for your chain.
It will generate a chaindata file. From there, run geth --datadir=./chaindata/ to start the geth
Then the private network has started.
Now, look for the ipc (for mac/linux) location.
INFO [01-31|11:39:40] IPC endpoint opened: /Volumes/HDD/files/blockchain/ethereum/chaindata/geth.ipc
You have successfully created a genesis block! In the next tutorial, I will share about getting started with EthereumTestRPC NPM library.
Curriculum
Posted on Utopian.io - Rewarding Open Source Contributors