How to Set Up a Private Ethereum Blockchain in 20 Minutes
Read step-by-step instructions for how to set up an Ethereum blockchain in less than 20 minutes, written by ArcTouch engineer Nathan Williams.
5 min. read - February 28, 2018
Every year, ArcTouch brings together its employees for a three-day hackathon, where groups set out to prototype an idea using new and emerging technologies. This year, we had many blockchain hackathon projects — and we think this speaks to both the growing interest in blockchain by our staff and the potential for companies to benefit from it.
My group chose to implement an identity verification system built on the blockchain. The idea was to store someone’s proof of age, which a bartender or sales clerk could reference in lieu of a physical ID such as a driver’s license. Since we planned to leverage smart contracts, we opted for an Ethereum blockchain. However, for first-round development, using the public blockchain or even the testnet is not always ideal due to long transaction confirmation times. Instead, we looked at a several options for quickly spinning up a private blockchain.
By far, the easiest approach is to use a cloud service such as Azure to host a private blockchain network. Azure makes the setup particularly easy by providing an Ethereum Blockchain Consortium template, which features a configurable number of both mining and transaction nodes. In three steps, and about 10 minutes, you can set up a fully functioning private blockchain in the cloud (here’s a great Medium post that details this setup).
This particular Azure template however, provides a proof-of-work (PoW) blockchain which, depending on your requirements, may not be the best option for a private blockchain. For example, we opted for a proof-of-authority (PoA) blockchain using Ethereum’s Clique consensus engine that was released last year. This consensus setup works well in a private setting because nodes do not need to compete against each other for the privilege of minting blocks, thus eliminating the processing overhead and energy use that comes with PoW block mining and the ethhash algorithm.
To create our PoA network on Azure, we set up a server instance using the Ubuntu Server 16.04 LTS template to act as our authority node. Since authorities do not require heavy computing resources, we were able to use a smaller virtual machine size (a B1S) with the default options.
Once the virtual machine was provisioned, we set up our authority node using the following steps:
Step 1: Install Ethereum and geth
1
2
3
4
Step 2: Generate the authority account and transaction account
You’ll generate two accounts — the first of which will be the authority account, and the second will be a prefunded account that can be used to send transactions to the network:
1
2
3
4
Be sure to keep track of the password used to create each account!
Step 3: Create the genesis block
Using puppeth, a CLI tool released with geth 1.6, create and export the definition for your genesis block:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Use the first generated account, the authority, as the “sealer” account, and the second account as the pre-funded account. For the network/chain ID, I’d recommend choosing a value below 1000. The value 1337 is used by dev chains, and we found that higher values (such as those generated when choosing “random”) may lead to problems later on.
Step 4: Start your private Ethereum instance
Initialize and start your authority geth instance:
1
2
3
Pass the address of the authority to the unlock parameter, and for rpcaddr, use the Private IP address of your virtual machine as displayed in the Azure console Networking settings.
Be sure to create an Inbound security rule for port 8545 in your network security group to allow you to connect to your authority node using the standard web3.js library, or in our case, Nethereum for use with Xamarin.
Result: A functional Ethereum blockchain
The above process takes about 20 minutes, and results in a fully functional, private PoA Ethereum blockchain in the cloud. This environment is ideal for decentralized application (DApp) proof-of-concept development, and provides fast and free transactions.
You could easily include other virtual machines in the setup to act as dedicated transaction nodes or additional authority nodes for a more representative network. But developing a proof-of-concept is only one step toward developing a full commercial blockchain solution. DApp security is a notoriously complex topic, and deploying to a public testnet for testing real world scenarios and verifying correct operation is critical.
Integrating your blockchain-based back end with a mobile app front end also requires some solid strategy. Blockchain presents a unique user experience challenge, in that transactions may take many minutes to confirm depending on the gas price you are willing to pay.
Here at ArcTouch, we are excited to be a DApp development company, and believe that blockchain will be an important component of tomorrow’s applications for both enterprise and consumers alike.
Wondering how blockchain can help your business?
BlockFirst blockchain development from ArcTouch helps companies transform their business processes through decentralized apps and ledger technology. We offer free consultations — so let’s set up a time to talk:
Article Author:
Subscribe for more insights
Get our newsletter in your inbox.
Contact us.
Let's build something lovable. Together.
We help companies of all sizes build lovable apps, websites, and connected experiences.