Setting up a private Ethereum blockchain network is not an extremely difficult task for engineers. I have been tasked to have multiple nodes in Ethereum private networks with all recent updates. Though it's simple to have it, However, it may be a bit of a challenge for beginners.
I will skip some technical details and avoid using some jargon so that everyone can understand the basic concepts. With updates, there are some modifications required and for your Ref below.
Create Two files
1, Genesis.json and pass.txt
genesis.json
{
"config": {
"chainId": 1369,
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0
},
"alloc" : {},
"coinbase" : "0x0000000000000000000000000000000000000000",
"difficulty" : "0x20000",
"extraData" : "",
"gasLimit" : "0x888000",
"nonce" : "0x0000000000000042",
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00"
}
Pass.txt (you can change the password on your wish)
seed
Node 1 initiation
$ geth --identity "Node1" --datadir node1-datadir init ./genesis.json
$ WADDR1=`geth --datadir ./node1-datadir --password pass.txt account new | egrep "Public address of the key:" | awk '{print $6}'`
#node1
$ geth --port 30303 --networkid 1369 --nodiscover --syncmode 'full' --datadir=./node1-datadir --maxpeers=10 --http --http.api "eth,personal,web3,miner,net,admin,personal,debug" --http.vhosts localhost.local,localhost,127.0.0.1 --http.rpcprefix / --rpc --rpcport 8545 --rpcaddr 127.0.0.1 --rpccorsdomain "*" --rpcapi "eth,net,web3,admin,debug,personal,miner" --allow-insecure-unlock --mine --miner.threads=1 --miner.etherbase=0x0000000000000000000000000000000000000000 --unlock $WADDR1 --password pass.txt --verbosity 5 --nat extip:172.26.7.19
Custom options on above
rpcaddress , networkid , port, nat ip(optional)
ensure the port 8545 is open and accessible with public IP
Once you executed keep the screen running
Node2 initiation
$ geth --identity "Node2" --datadir node2-datadir init ./genesis.json
$ ENOD1=`geth attach node1-datadir/geth.ipc --exec admin.nodeInfo.enode`
#Node 2
$ geth --datadir ./node2-datadir --networkid 1369 --port 30305 --bootnodes $ENOD1OR$ geth --datadir ./node2-datadir --networkid 1369 --port 30305 --bootnodes "enode://7bea031adf1d26999fa181430e0b40e2e7703c32a7834bfdbf4ca91f94882932d8ddac3aa2b9773bbc68162742a30ef6768cd24db0356bfa0e34c5c5586e9a88@172.26.7.19:30303"
Now you have completed the Etheruem private network node setup
To check the status
$ geth attach node1-datadir/geth.ipc --exec admin.peers$ geth attach node2-datadir/geth.ipc --exec admin.peers$ geth attach node2-datadir/geth.ipc --exec netpeerCountyou will get 1
Note : if you want to create multiple nodes, you can follow as node2 by change the directory path and port if it's the same host.
Initialize IPFS
While we wait for the DAG to be generated, let’s set up IPFS. Start by initializing IPFS and modifying CORS restrictions:
$ ipfs init
$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]'
$ ipfs config --json Gateway.HTTPHeaders.Access-Control-Allow-Origin '["*"]'
$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "POST"]'
Ensure the ports are opened ad access over the public network
5001 and 8080
Now start the daemon in the background:
ipfs daemon &
Now its time to sync the demo app from git
$ git clone https://github.com/dappuniversity/ipfs_image_uploader/
$ cd ipfs_image_uploader <<<< I created some files under this folder
$ npm install -g truffle@4.1.11
Now do the Changes in the following files
1, src/utils/getweb3.jsline 24 : (‘http://xx.xx.xx.xx:8545')2, src/ipfs.jsline 2 : host: ‘xx.xx.xx.xx’, port: 5001, protocol: ‘http’3, src/App.jsline 88 : remove “return” and it should be “this.setState({ ipfsHash: result[0].hash }) “
line 106: http://xx.xx.xx.xx:8080/ipfs4, truffle.json
insert below at line 4
networks: {
development: {
host: “127.0.0.1”,
port: 8545,
network_id: “*” // Match any network id
}
}
Now it's time to compile and start the package.
$ cd ipfs_image_uploader
$ npm install
$ truffle compile
$ truffle migrate --reset
$ npm start
Now you can access the application from the web browser on port 3000.
http://xx.xx.xx.xx:3000
ensure you open port 3000.
Bonus : Script to upload the multiple files from the folder
Link