Two-Node Setup of a Private Ethereum on AWS with Contract Deployment (Part 1)

By kctam Jul 11, 2017 3:04 PM EST

This story was shared from this site

From time to time I plan to emulate an Ethereum environment. The idea behind is to observe how Ethereum nodes work to each other, and how different accounts interact in transaction and contract deployment. For testing, most contract deployment example nowadays is mainly on testrpc or testnet, but how the contract works among nodes is still new to me.

I deploy this two-node setup on AWS. As I do not use any special features on AWS, it should be applicable to another cloud environment.

My setup is inspired by the work from JJ’s World (link), and after testing this for several times with modification, I document the whole process I have done, and share some experience here about the whole process.

I also use the Voting contract developed by Mahesh Murthy (link). This is a simple contract that best illustrates how a contract works in the chain.

This by no means is a detailed step-by-step guide. I omit certain steps and make reference to some work done by others. For example, the detailed operation of AWS EC2, including launching a new instance with a setup like access key, security group, etc. can be found here (link).

 

There are two parts in this setup.

Part 1: Create a 2-node Ethereum network with private blockchain, and accounts on the two nodes can send ether to each other.

Part 2: Deploy a contract from one node, and both accounts can access and execute functions on this contract.

 

Step 1: Launch two EC2 instances.

 

Use t2.medium (2 vCPU, 4 GB RAM) with default 8G SSD. Pick Ubuntu OS. Make sure that the two nodes are with the same security group, which allows TCP 30303 (or 30000-30999 as I may use more ports on this range). Port 30303 by default is for peering among nodes.

 

 

Experience Sharing I first tried t2.micro as it is the free-tier offer. However, mining was not successful (“DAG” loop without ether reward). I next tried t2.small and mining worked. However, when I deployed contract (see Part 2), the rpc was unstable. Finally, I found t2.medium good enough for my setup.

 

I usually STOP the instance after testing (to save money). Please note that the public IP address of the EC2 instance will be changed after you START it back. This does not have an impact on our setup here as I am using the private IP address of these instances for peering. Private IP address remains even after I STOP/START the instance. In any case if Public IP address is needed, the peering still works, but you may need to change the peering address every time.

 

Step 2: Install geth client on Node 1

 

Access to Node 1 with ssh and proper key. Follow the recommended process (link) for geth installation. Install from PPA is good enough.

Node 1 $ sudo apt-get install software-properties-common $ sudo add-apt-repository -y ppa:ethereum/ethereum $ sudo apt-get update $ sudo apt-get install ethereum

 

and verify it with $ which geth and you will see that geth is installed properly.

 

Step 3: Prepare the Genesis.json

This same Genesis.json is applied to both nodes, as it is to ensure both nodes having the same genesis block. Here is the Genesis.json I used, which is adopted from here (link). I take out the initial allocation as I don’t need to modify the address on this file in each new setup. Each account will gain some ethers once it starts mining.

 

Genesis.json

Facebook Comments


Comments are closed here.

Read previous post:
How to evaluate upcoming ICOs

Media Sources Reddit First of all, where can you find out what is going on in the Blockchain community? Best...

Close