{"id":196,"date":"2018-02-04T16:30:30","date_gmt":"2018-02-04T16:30:30","guid":{"rendered":"http:\/\/www.legendshub.com\/blog\/?p=196"},"modified":"2020-12-06T13:35:53","modified_gmt":"2020-12-06T13:35:53","slug":"pow-proof-of-work-blockchain-configuration","status":"publish","type":"post","link":"https:\/\/www.legendshub.com\/blog\/2018\/02\/04\/pow-proof-of-work-blockchain-configuration\/","title":{"rendered":"POW (Proof of work) Blockchain Configuration"},"content":{"rendered":"\n<!-- Quick Adsense WordPress Plugin: http:\/\/quickadsense.com\/ -->\n<div class=\"2c935cf620b701aabbb7cc90bbf4023c\" data-index=\"1\" style=\"float: none; margin:0px 0 0px 0; text-align:center;\">\n<script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\r\n<script>\r\n  (adsbygoogle = window.adsbygoogle || []).push({\r\n    google_ad_client: \"ca-pub-5554449970657557\",\r\n    enable_page_level_ads: true\r\n  });\r\n<\/script>\n<\/div>\n<p>This Blog provide the detailed steps of configuration and build of POW(Proof of work) Private Blockchain on<\/p>\n<p>docker containers.<\/p>\n<div id=\"attachment_200\" style=\"width: 310px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.legendshub.com\/blog\/wp-content\/uploads\/2018\/02\/Blockchain.jpg\"><img aria-describedby=\"caption-attachment-200\" loading=\"lazy\" class=\"wp-image-200 size-medium\" src=\"http:\/\/www.legendshub.com\/blog\/wp-content\/uploads\/2018\/02\/Blockchain-300x154.jpg\" alt=\"POW\" width=\"300\" height=\"154\" srcset=\"https:\/\/www.legendshub.com\/blog\/wp-content\/uploads\/2018\/02\/Blockchain-300x154.jpg 300w, https:\/\/www.legendshub.com\/blog\/wp-content\/uploads\/2018\/02\/Blockchain-768x395.jpg 768w, https:\/\/www.legendshub.com\/blog\/wp-content\/uploads\/2018\/02\/Blockchain-1024x526.jpg 1024w, https:\/\/www.legendshub.com\/blog\/wp-content\/uploads\/2018\/02\/Blockchain.jpg 2048w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-200\" class=\"wp-caption-text\">Blockchain POW(Proof of work)<\/p><\/div>\n<h5>&nbsp;Prerequisites:<\/h5>\n<p>Docker package should be installed on the host machine.<\/p>\n<h4>Steps for Configuration and build:<\/h4>\n<ol>\n<li><strong><strong> Following docker file is being used to build docker image and eventually building the containers for Blockchain.<\/strong><\/strong><\/li>\n<\/ol>\n<p><strong>&nbsp;<\/strong><\/p>\n<p style=\"text-align: left; padding-left: 60px;\"><em>FROM ubuntu<\/em><br \/>\n<em>MAINTAINER &lt;name and email id of the maintainer\u201d Deloitte&gt;<\/em><br \/>\n<em>RUN apt-get update &amp;&amp; apt-get upgrade -q -y<\/em><br \/>\n<em>RUN apt-get install -q -y git curl software-properties-common vim<\/em><br \/>\n<em>RUN add-apt-repository ppa:ethereum\/ethereum<\/em><br \/>\n<em>RUN add-apt-repository ppa:ethereum\/ethereum-dev<\/em><br \/>\n<em>RUN apt-get update<\/em><br \/>\n<em>RUN apt-get install -q -y geth<\/em><br \/>\n<em>ADD ethereum \/home\/ubuntu\/ethereum<\/em><br \/>\n<em>WORKDIR \/home\/ubuntu\/ethereum<\/em><br \/>\n<em>VOLUME [&#8220;\/home\/ubuntu\/ethereum\/ethdata&#8221;]<\/em><br \/>\n<em>EXPOSE &lt;variable port &#8220;8545&#8221;&gt;<\/em><br \/>\n<em>EXPOSE &lt;Variable port &#8220;30303&#8221;&gt;<\/em><\/p>\n<p><strong>&nbsp;<\/strong><\/p>\n<ol start=\"2\">\n<li><strong> Create a volume\/s depending on the number of containers to be created.<\/strong><\/li>\n<\/ol>\n<p><strong>&nbsp;<\/strong><\/p>\n<p style=\"padding-left: 30px;\"><em>docker volume create [OPTIONS] [VOLUME]<\/em><br \/>\n<em>docker volume create test<\/em><\/p>\n<p style=\"padding-left: 30px;\"><em>&nbsp;<\/em><\/p>\n<ol start=\"3\">\n<li><strong> Create an image using the docker file created in Step 1.<\/strong><\/li>\n<\/ol>\n<p><strong>&nbsp;<\/strong><\/p>\n<p style=\"padding-left: 30px;\"><em> docker build [OPTIONS] PATH | URL | &#8211;<\/em><br \/>\n<em>docker build -t ethereum-docker<\/em><\/p>\n<p><em>&nbsp;<\/em><\/p>\n<p>Verify if the image has been setup using<\/p>\n<p style=\"padding-left: 30px;\"><em>docker image<\/em><\/p>\n<p>This will give a list of all the images created.<\/p>\n<p><em>&nbsp;<\/em><\/p>\n<p><strong>&nbsp;<\/strong><\/p>\n<ol start=\"4\">\n<li><strong> Create the containers using the image. <\/strong><\/li>\n<\/ol>\n<p><strong>&nbsp;<\/strong><\/p>\n<p style=\"padding-left: 30px;\"><em>docker run -d -it &#8211;net=host -v &lt;volume path&gt;:&lt;mount directory in container&gt; &#8211;name &lt;container name&gt; &lt;image name&gt;<\/em><br \/>\n<em>docker run -d -it &#8211;net=host -v hello:\/data &#8211;name etherum1 test \/bin\/bash<\/em><\/p>\n<p><em>&nbsp;<\/em><\/p>\n<p>Use \u201cdocker ps\u201d to check the containers that have been created.<\/p>\n<p>Enter the container created using following command.<\/p>\n<p style=\"padding-left: 30px;\"><em>docker exec \u2013it &lt;container Id&gt; bash<\/em><\/p>\n<ol start=\"5\">\n<li><strong> Create a custom genesis file. <\/strong><\/li>\n<\/ol>\n<p><strong>&nbsp;<\/strong>&nbsp;Make a genesis file. A sample genesis file has been added below.<\/p>\n<p style=\"padding-left: 30px;\"><em>&nbsp;{ <\/em><br \/>\n&#8220;config&#8221;: {<br \/>\n&#8220;chainId&#8221;: 15,<br \/>\n&#8220;homesteadBlock&#8221;: 0,<br \/>\n&#8220;eip155Block&#8221;: 0,<br \/>\n&#8220;eip158Block&#8221;: 0<br \/>\n},<br \/>\n&#8220;nonce&#8221;: &#8220;0x0000000000000042&#8221;,<br \/>\n&#8220;timestamp&#8221;: &#8220;0x00&#8221;,<br \/>\n&#8220;parentHash&#8221;: &#8220;0x0000000000000000000000000000000000000000000000000000000000000000&#8221;,<br \/>\n&#8220;extraData&#8221;: &#8220;0x00&#8221;,<br \/>\n&#8220;gasLimit&#8221;: &#8220;0x8000000&#8221;,<br \/>\n&#8220;difficulty&#8221;: &#8220;0x400&#8221;,<br \/>\n&#8220;mixhash&#8221;: &#8220;0x0000000000000000000000000000000000000000000000000000000000000000&#8221;,<br \/>\n&#8220;coinbase&#8221;: &#8220;0x3333333333333333333333333333333333333333&#8221;,<br \/>\n&#8220;alloc&#8221;: {<br \/>\n}<br \/>\n}<\/p>\n<!-- Quick Adsense WordPress Plugin: http:\/\/quickadsense.com\/ -->\n<div class=\"2c935cf620b701aabbb7cc90bbf4023c\" data-index=\"3\" style=\"float: none; margin:0px 0 0px 0; text-align:center;\">\n<script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\r\n<script>\r\n  (adsbygoogle = window.adsbygoogle || []).push({\r\n    google_ad_client: \"ca-pub-5554449970657557\",\r\n    enable_page_level_ads: true\r\n  });\r\n<\/script>\n<\/div>\n\n<p>Initialize then geth using private genesis file with unique data directory.<\/p>\n<p><em> geth init &lt;name of genesis file&gt; &#8211;datadir=&#8221;.\/&lt;name of data directory&gt;&#8221;<\/em><br \/>\n<em>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; geth init private-genesis.json &#8211;datadir=&#8221;.\/ethdata1&#8243;<\/em><\/p>\n<p><em>&nbsp;<\/em><\/p>\n<ol start=\"6\">\n<li><strong> Start Geth and enter the console.<\/strong><\/li>\n<\/ol>\n<p style=\"padding-left: 30px;\"><em>geth &#8211;datadir=.\/ethdata &#8211;rpccorsdomain &#8220;http:\/\/localhost:3000&#8221; &#8211;port &lt;genericport&gt; &#8211;rpc &#8211;rpcapi eth,net,web3,personal &#8211;rpcaddr &#8220;0.0.0.0&#8221; &#8211;rpcport &lt;genericport&gt; &#8211;nodiscover &#8211;maxpeers 2 &#8211;fast &#8211;cache=1024 console 2&gt;&gt; .\/Logs\/GethLog.log<\/em><br \/>\n<em>geth &#8211;datadir=.\/&lt;datadirectory&gt; &#8211;rpccorsdomain &#8220;http:\/\/localhost:3000\u201d &#8211;port 54259 &#8211;rpc &#8211;rpcapi eth,net,web3,personal &#8211;rpcaddr &#8220;0.0.0.0&#8221; &#8211;rpcport 8545 &#8211;nodiscover &#8211;maxpeers 2 &#8211;fast &#8211;cache=1024 console 2&gt;&gt; .\/Logs\/GethLog.log<\/em><\/p>\n<p><em>&nbsp;<\/em><\/p>\n<ol start=\"7\">\n<li><strong> Create personal account in all the nodes.<\/strong><\/li>\n<\/ol>\n<p>personal.newAccount()<\/p>\n<p>Add and confirm the passphrase.<\/p>\n<p>Save the unique allocation id to use it for further configuration.<\/p>\n<ol start=\"8\">\n<li><strong> Edit the genesis file to add the allocation id and balance block.<\/strong><\/li>\n<\/ol>\n<p><strong>&nbsp;<\/strong><\/p>\n<p>The allocation id of all the accounts has to be added to all the genesis files of all the nodes.<\/p>\n<p>This will be required for the peering of the nodes.<\/p>\n<p><em>&nbsp;<\/em><\/p>\n<p style=\"padding-left: 30px;\"><em>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8220;alloc&#8221;: {<br \/>\n&#8220;&lt;allocid1&gt;&#8221;:<br \/>\n{&#8220;balance&#8221;: &#8220;20000000000000000000&#8221;},<br \/>\n&#8220;&lt;allocid2&gt;&#8221;:<br \/>\n{&#8220;balance&#8221;: &#8220;20000000000000000000&#8221;},<br \/>\n&#8220;&lt;allocid3&gt;&#8221;:<br \/>\n{&#8220;balance&#8221;: &#8220;20000000000000000000&#8221;}<br \/>\n}<\/em><\/p>\n<p><em>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/em><\/p>\n<ol start=\"9\">\n<li><strong> Node Peering for communication.<\/strong><\/li>\n<\/ol>\n<p><strong>&nbsp;<\/strong><\/p>\n<p>For node peering and to create a private cluster. All the nodes created should be able to listen to each other. Start the geth console to get the enode for respective node.<\/p>\n<p>Run the following command on both nodes.<\/p>\n<p><strong>&nbsp;<\/strong><\/p>\n<p style=\"padding-left: 30px;\"><em>admin.nodeInfo.enode<\/em><\/p>\n<p>The sample output of this command will be the following for an instance.<\/p>\n<p style=\"padding-left: 30px;\"><em>&#8220;enode:\/\/f9de2985c4f927acf024b10363ec61e9ba4dc4bed42f39db58bcea104c1ffccdad108e55190a5127e03cd60117c8f4eb8e8a6fb2f88c8c6a1f215fee4f766012@[::]:54259\u201d<\/em><\/p>\n<p>Add the nodes as peers to each other by logging into each node and running the following command with the enode &nbsp;of all the other nodes.<\/p>\n<p><em>admin.addPeer(enodeUrlOfFirstInstance)<\/em><\/p>\n<p style=\"padding-left: 30px;\"><em>admin.addPeer(&#8220;enode:\/\/cfd7b9282857faad76200cee973c0601e8519223f27f7813f3f28b472eea60ebeabe81422ec53b02192744d14f17bbbd5fcd9ece189ce4c8b0d10f61cd005738@[::]:3011&#8221;) <\/em><\/p>\n<p>Reinitialize geth on all nodes.<\/p>\n<p>Add allocation id for every node in genesis file and replicate the genesis file across the cluster.<\/p>\n\n<!-- Quick Adsense WordPress Plugin: http:\/\/quickadsense.com\/ -->\n<div class=\"2c935cf620b701aabbb7cc90bbf4023c\" data-index=\"2\" style=\"float: none; margin:0px 0 0px 0; text-align:center;\">\n<script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\r\n<script>\r\n  (adsbygoogle = window.adsbygoogle || []).push({\r\n    google_ad_client: \"ca-pub-5554449970657557\",\r\n    enable_page_level_ads: true\r\n  });\r\n<\/script>\n<\/div>\n\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\">This Blog provide the detailed steps of configuration and build of POW(Proof of work) Private Blockchain on docker containers. &nbsp;Prerequisites: Docker package should be installed on the host machine. Steps for Configuration and build: Following docker file is being used to build docker image and eventually building the containers for Blockchain. &nbsp; FROM ubuntu MAINTAINER &lt;name and email id of&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"btn btn-default\" href=\"https:\/\/www.legendshub.com\/blog\/2018\/02\/04\/pow-proof-of-work-blockchain-configuration\/\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":200,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[31],"tags":[],"_links":{"self":[{"href":"https:\/\/www.legendshub.com\/blog\/wp-json\/wp\/v2\/posts\/196"}],"collection":[{"href":"https:\/\/www.legendshub.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.legendshub.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.legendshub.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.legendshub.com\/blog\/wp-json\/wp\/v2\/comments?post=196"}],"version-history":[{"count":7,"href":"https:\/\/www.legendshub.com\/blog\/wp-json\/wp\/v2\/posts\/196\/revisions"}],"predecessor-version":[{"id":688,"href":"https:\/\/www.legendshub.com\/blog\/wp-json\/wp\/v2\/posts\/196\/revisions\/688"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.legendshub.com\/blog\/wp-json\/wp\/v2\/media\/200"}],"wp:attachment":[{"href":"https:\/\/www.legendshub.com\/blog\/wp-json\/wp\/v2\/media?parent=196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.legendshub.com\/blog\/wp-json\/wp\/v2\/categories?post=196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.legendshub.com\/blog\/wp-json\/wp\/v2\/tags?post=196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}