Setting up a private Ethereum blockchain with two nodes

Share Embed Donate


Short Description

How to set up a private Ethereum blockchain with 2 or more nodes using Vmware. https://semanticblocks.wordpress.com/...

Description

Setting up a private Ethereum blockchain with two nodes (or more) and VmWare [FOR TESTING PURPOSES ONLY]

By Eng. Hectór Ugarte

24.03.2016

1. Prerequisites  VmWare Workstation (mine: VMware Workstation 12 Pro).  Ubuntu iso (mine: Ubuntu 15.10) 2. Procedure. A. Create two virtual machines on VmWare, running Ubuntu. Recommended specifications:

B. Set both virtual machines on the same network, for example:

C. Install Geth on both nodes: sudo apt-get install software-properties-common sudo add-apt-repository -y ppa:ethereum/ethereum sudo apt-get update sudo apt-get install ethereum

1 - Setting up a private Ethereum blockchain with two nodes (or more) and VmWare

D. Create a new folder on both virtual machines, called it “Ethereum”, and inside that folder another one, called it “datadir” E. Create a new file inside Ethereum folder, called it “genesis.json” with the next content: { "nonce": "0xdeadbeefdeadbeef", "timestamp": "0x0", "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "extraData": "0x0", "gasLimit": "0x8000000", "difficulty": "0x400", "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", "coinbase": "0x3333333333333333333333333333333333333333", "alloc": { } } F. Now start the geth client on both nodes. geth --genesis --datadir --networkid 12344321 --nodiscover --maxpeers 1 console Where: 1. Use genesis.json as the genesis block. 2. Use datadir folder to put your all the necessary data about the private 3. Use a network id other than ‘1’ to ensure we can’t talk to nodes from the main network – “connections between nodes are valid only if peers have identical protocol version and network id” 4. Disable peer discovery 5. Set a maximum of 1 peers (or more if you want to use more peers) 6. Starts geth in console mode so you can interact with your new blockchain / node For example: sudo geth --genesis="/home/hedugaro/Ethereum/genesis.json" -datadir="/home/hedugaro/Ethereum/datadir" --networkid 12344321 -nodiscover --maxpeers 1 console G. Create Accounts Once geth is up and you get a console, create your own account with the following command:

2 - Setting up a private Ethereum blockchain with two nodes (or more) and VmWare

>personal.newAccount("mypass"); Where “mypass” is your desired password. You get as answer for example: '0xd47eaceb073dc03e3330b4747b1224f146f8d6e7' Repeat this on the other nodes. H. Connect the 2 Nodes as Peers First, find the enode of the first node with the next command: admin.nodeInfo.enode You get as answer: "enode://4e0312fb3eae8b59048afb1a53a3cd4a157db1fb2c8b7175176ffa932e41c2 2c60dd5f7540bbfb7d25b4c443116895360064fe4415734d3da621b29b0a7b6b6e@[::] :30303?discport=0" Instead of [::] , add your ip address to that string, for example: (you can get your ip address with ifconfig command) "enode://4e0312fb3eae8b59048afb1a53a3cd4a157db1fb2c8b7175176ffa932e41c2 2c60dd5f7540bbfb7d25b4c443116895360064fe4415734d3da621b29b0a7b6b6e@172. 16.1.104:30303?discport=0" On the second node, add node one as a peer with the following command: >admin.addPeer("enode://4e0312fb3eae8b59048afb1a53a3cd4a157db1fb2c8b717 5176ffa932e41c22c60dd5f7540bbfb7d25b4c443116895360064fe4415734d3da621b2 [email protected]:30303?discport=0") I.

Check if everything went ok, with the command:

web3.net.peerCount You should get as response 1 Now the two nodes are configured on a private blockchain. At least one node should be mining. J.

To do that:

miner.setEtherbase(eth.accounts[0]) and miner.start() K. It will take around 10 minutes to produce the DAG file (needed for mining) (Dagger-Hashimoto)

3 - Setting up a private Ethereum blockchain with two nodes (or more) and VmWare

L. After the DAG is produced, the mining procedure will start. You can check that the minner account balance is increasing, calling the function getbalance, for example: web3.eth.getBalance("0xc6acbafc19fbcb5ee3af6bf471c0c510e3d9d0c2")

Useful information: Website: https://www.ethereum.org/ Blog: http://blog.ethereum.org/ Homestead documentation: http://www.ethdocs.org/ Reedit: http://www.reddit.com/r/ethereum Forum: https://forum.ethereum.org/

4 - Setting up a private Ethereum blockchain with two nodes (or more) and VmWare

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF