Very closely attributed to its name, the genesis block is the first or origin block of a private network on Ethereum. The genesis block contains all the essential information to configure the network as well as find related peers. It’s basically the config file for your Ethereum network. In fact to boot up your network, you actually need to pass in the location of the file as a param.
The genesis file is a simple JSON file that contains config thresholds. Here’s an example,
Though this file is by no means comprehensive, it does contain all the params that create a good base network.
-
config The file starts out with the “config” block which contains all the config parameters and thresholds that control the networks basic operations. Read more here .
- chainId: Protects the network from a replay attack . It acts like a offset to prevent attackers from deciphering continuous values in your network.
- homesteadBlock: Homestead is the second major release of Ethereum(the first release is Frontier). The value 0 means that you are using this release.
-
difficulty This determines how difficult it is to mine in your network. When developing on a test network, set it to the lowest possible value so you don’t have to wait too long for mining blocks.
-
gasLimit This defines the limit of gas cost per block. Set this value high to avoid being limited when testing.
-
nonce & mixhash Nonce and mixhash are values which when combines, allows to verify that a block has really been cryptographically mined, and thus is valid. The mixhash is 256-bit hash which proves, when combined with the 64-bit nonce, that a sufficient amount of computation has been carried out on this block: the Proof-of-Work (PoW).
-
alloc Allows defining a list of pre-filled wallets. That’s an Ethereum specific functionality to handle the “Ether pre-sale” period. You can also leave this as an empty hash.
There are many more parameters and configuration options you can add to the genesis block, but the ones mentioned above are the ones you’ll be absolutely needing.
Now that we have the genesis block, how do you start the network? Simple. Just run the following command (make sure you have geth installed!),
The above commands are for the Mac OS.
These commands do a few things:
- The first utilises the genesis file to seed the blockchain.
- It uses the datadir to store all state necessary to maintain the newly created blockchain.
- The second command opens up the console to that network.
- The IPC (interprocess communication) path is the local pipe between the node and UI and is only local to your host. It becomes important when attaching a console to a running node.
- Assign a port address to prevent the network from clashing with an already running process.
You’ve just started your own private Ethereum network!
Subscribe to our newsletter
Get the latest updates from our team delivered directly to your inbox.
Related Posts
5 advantages of using Hyperledger Fabric for your Enterprise Blockchain
"Why should I use Hyperledger Fabric for my Enterprise Blockchain?", "What is the preferred way of implementing Hyperledger Fabric?". Everything answered.
Six ways the blockchain can be an advantage for Supply Chain
The blockchain for supply chain is going to be the standard in the industry in the next five years. We've already seen the adoption of the blockchain technology with our supply chain customer, and this article focuses on the advantages that the blockchain has on the supply chain industry.
6 Blockchain frameworks to build Enterprise Blockchain & how to choose them?
Let us help you list some of the open frameworks for blockchain (both public and private blockchain frameworks), that can help you develop your Enterprise Blockchain solution faster and better. Learn more.