Beginners guide to Ethereum (3) — explain the genesis file and use it to customize your blockchain

Overview

Important Notes before you start

What is a genesis file

{"config": {"chainId": 15, "homesteadBlock": 0,"eip155Block": 0,"eip158Block": 0},"difficulty": "20","gasLimit": "2100000","alloc": {"7df9a875a174b3bc565e6424a0050ebc1b2d1d82": 
{ "balance": "300000" },
"f41c74c9ae680c1aa78f42e5647a62f353b7bdde":
{ "balance": "400000" }
}}

Start coding!

cat > genesis.json
geth init genesis.json --datadir test
geth --helpgeth init --help // the two output is different
geth --networkid 123 --datadir test console 
// remember the datadir has to be the same
eth.getBalance("7df9a875a174b3bc565e6424a0050ebc1b2d1d82")
miner.setEtherbase("7df9a875a174b3bc565e6424a0050ebc1b2d1d82")
// you can also use arbitrary address as long as there are 40 digits
miner.start()

Wrap up

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
李婷婷 Lee Ting Ting

Founder of Z Institute | Blockchain dev & security audit | Berkeley Blockchain Lab | HKUST | IG: tinaaaaalee | Github: tina1998612