How to create your own Ethereum Private Blockchain.

Juniarto Samsudin
3 min readDec 29, 2021
Private Ethereum Blockchain
Photo by Jievani Weerasinghe on Unsplash
  1. Download the standalone bundle of GETH along with the developer tools from repository(abigen, bootnode, disasm, evm, rlpdump, puppeth) from https://geth.ethereum.org/downloads/
  2. Here is the plan, we are going to create two nodes [ node1 and node2] and 1 bootnode.
  3. Create account and data directory for each of node1 and node 2.
node1:$mkdir node1$cd node1$./geth --datadir "./data" account newINFO [12-29|11:36:25.456] Maximum peer count                       ETH=50 LES=0 total=50INFO [12-29|11:36:25.456] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"Your new account is locked with a password. Please give a password. Do not forget this password.Password: password1Repeat password: password2Your new key was generatedPublic address of the key:   0x7521737E9Ea96daC9Fc38436833f93c12c15477CPath of the secret key file: data/keystore/UTC--2021-12-29T03-36-33.294839296Z--7521737e9ea96dac9fc38436833f93c12c15477cnode2:$mkdir node2$cd node2$./geth --datadir "./data" account newINFO [12-29|11:38:28.489] Maximum peer count                       ETH=50 LES=0 total=50INFO [12-29|11:38:28.489] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"Your new account is locked with a password. Please give a password. Do not forget this password.Password:Repeat password:Your new key was generatedPublic address of the key:   0x5f3F5cD224ba89135b7eaC65d0D0Aca15Fe7651ePath of the secret key file: data/keystore/UTC—2021-12-29T03-38-36.942612237Z--5f3f5cd224ba89135b7eac65d0d0aca15fe7651e

4. Create a template file, called blockpoa.json, using puppeth. Sometimes it is called genesis file.

$puppethPlease specify  network name to administer (nospace, hyphens or capital letters please)> blockpoaWhat would you like to do? (default = stats)Select 2: Configure new genesisWhat would you like to do?(default = create)Select 1: Create new genesis from scratchWhich consensus engine to use? (default = clique)Select 1: Clique – proof-of-authorityHow many seconds should blocks take? (default = 15)>5Which accounts are allowed to seal? (mandatory at least one). We only use one node, node1>0x7521737E9Ea96daC9Fc38436833f93c12c15477C>0xWhich accounts should be pre-funded? (adviseable at least one)>0x7521737E9Ea96daC9Fc38436833f93c12c15477C>0x5f3F5cD224ba89135b7eaC65d0D0Aca15Fe7651eShould the precompile-addresses(0x1 .. 0xff) be pre-funded with 1 wei? (adviseable yes)>yesSpecify your chain/network ID if you want an explicit one (default = random) 1+4333, where 1 is ethereum>14333Which folder to save the genesis specs into?(default = current)Will create blockpoa.json, blockpoa-aleth.json, blockpoa-harmony.json, blockpoa-parity.json

at this stage, we will have two files blockpoa.json and blockpoa-harmony.json in our current directory. We need blockpoa.json, copy it to node1 and node 2 directory.

5. Create node1 with genesis file:

./geth — datadir ./data init ./blockpoa.json

Create node2 with genesis file:

./geth — datadir ./data init ./blockpoa.json

6. Create Bootnode:

$mkdir bootnode

$cd bootnode, copy bootnode executable into this directory.

$./bootnode -genkey boot.key

$./bootnode -nodekey boot.key , or

$./bootnode -nodekey “./boot.key” -verbosity 7 -addr “127.0.0.1:30301”

take note of enode: enode://e7ee36d59e6cba14cc92b819b2500d96963dbe81afd129e92e22dbf3e134047e179ebc4d3fc5995eba8b2f500e01be25e25d60210bebde626ec497e7cda43b50@127.0.0.1:0?discport=30301

7. Connect node1 and node2 to bootnode:

password.txt is a file containing your password for each node.

At node1:

./geth --networkid 14333 --datadir "./data" --bootnodes enode://e7ee36d59e6cba14cc92b819b2500d96963dbe81afd129e92e22dbf3e134047e179ebc4d3fc5995eba8b2f500e01be25e25d60210bebde626ec497e7cda43b50@127.0.0.1:0?discport=30301 --port 30303 --ipcdisable --syncmode full --http --allow-insecure-unlock --http.corsdomain "*" --http.addr 192.168.1.110 --http.port 8545 --unlock 0x7521737E9Ea96daC9Fc38436833f93c12c15477C --password password.txt --mine console

At node2:

./geth --networkid 14333 --datadir "./data" --bootnodes enode://e7ee36d59e6cba14cc92b819b2500d96963dbe81afd129e92e22dbf3e134047e179ebc4d3fc5995eba8b2f500e01be25e25d60210bebde626ec497e7cda43b50@127.0.0.1:0?discport=30301 --port 30304 --ipcdisable --syncmode full --http --allow-insecure-unlock --http.corsdomain "*" --http.addr 192.168.1.110 --http.port 8546 --unlock 0x5f3F5cD224ba89135b7eaC65d0D0Aca15Fe7651e --password password.txt console

The names of the HTTP/RPC-related options were changed in Geth v1.9.19 under #21105.

From:

--rpc                  
--rpcaddr value
--rpcport value
--rpcapi value
--rpc.gascap value
--rpccorsdomain value
--rpcvhosts value

To:

--http                            
--http.addr value
--http.port value
--http.api value
--http.rpcprefix value
--http.corsdomain value
--http.vhosts value

8. To get javascript console to node1:

./geth attach http://127.0.0.1:8545

Several important command:

a. Check account balance:

eth.getBalance(‘0x7521737e9ea96dac9fc38436833f93c12c15477c’)

9.04625697166532776746648320380374280103671755200316906557262609325821325312e+74

eth.getBalance(‘0x5f3F5cD224ba89135b7eaC65d0D0Aca15Fe7651e’)

9.04625697166532776746648320380374280103671755200316906558262375061821325312e+74

Seems like node1 and node2 account has the same balance. Are they sharing the same balance?

eth.accounts

[“0x7521737e9ea96dac9fc38436833f93c12c15477c”]

eth.accounts[0]

“0x7521737e9ea96dac9fc38436833f93c12c15477c”

eth.getBalance(eth.accounts[0])

9.04625697166532776746648320380374280103671755200316906557262609325821325312e+74

9. To connect Metamask account to our private ethereum

Create new network using the following details:

Network Name: blockpoa

New RPC URL: http://127.0.0.1:8545

Chain ID: 14333

Currency Symbol(optional):

Block Explorer URL(optional):

10. Since we have a lot of ether in our private network, maybe we can send some ether to our metamask account:

eth.sendTransaction({from:eth.accounts[0], to:”0xcCc79Ee7E0600122c8CfE531eDe1625CBa23CD48",value: web3.toWei(100, “ether”)})

--

--