How to Set Up a Private Ethereum Blockchain in 20 Minutes

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.

virtual machine etherium blockchain

Once the virtual machine was provisioned, we set up our authority node using the following steps:

Step 1: Install Ethereum and geth

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

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:

geth --datadir .ethereum/ account new
> Address: {6203bb870bfb79438b827de3d6b0070d4d2a5f7b}
geth --datadir .ethereum/ account new
> Address: {1808adc011f6e970943d3f28f4d285053d9140ac}

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:

puppeth
...
Please specify a network name to administer (no spaces, please)
> clique
...

What would you like to do? (default = stats)
 1. Show network stats
 2. Configure new genesis
 3. Track new remote server
 4. Deploy network components
> 2

Which consensus engine to use? (default = clique)
 1. Ethash - proof-of-work
 2. Clique - proof-of-authority
> 2

How many seconds should blocks take? (default = 15)
> 15

Which accounts are allowed to seal? (mandatory at least one)
> 0x6203bb870bfb79438b827de3d6b0070d4d2a5f7b
> 0x

Which accounts should be pre-funded? (advisable at least one)
> 0x1808adc011f6e970943d3f28f4d285053d9140ac
> 0x

Specify your chain/network ID if you want an explicit one (default = random)
> 42
INFO [02-15|18:24:03] Configured new genesis block
What would you like to do? (default = stats)
 1. Show network stats
 2. Manage existing genesis
 3. Track new remote server
 4. Deploy network components
> 2

 1. Modify existing fork rules
 2. Export genesis configuration
 3. Remove genesis configuration
> 2

Which file to save the genesis into? (default = clique.json)
> genesis.json
INFO [02-15|18:24:22] Exported existing genesis block

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:

geth --datadir .ethereum/ init genesis.json

geth --nodiscover --networkid 42 --datadir .ethereum/ --unlock 0x6203bb870bfb79438b827de3d6b0070d4d2a5f7b --mine --rpc --rpcapi eth,net,web3 --rpcaddr

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.

newtorking etherium blockchain

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.

inbound security etherium blockchain

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 about the distinct opportunities and challenges that blockchain technology and DApp development have to offer 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:

LET’S TALK ABOUT BLOCKCHAIN

The post How to Set Up a Private Ethereum Blockchain in 20 Minutes appeared first on ArcTouch.


How to Set Up a Private Ethereum Blockchain in 20 Minutes posted first on https://thetruthspyblog.blogspot.com

Comments

  1. Blockchain Technologies (blockchaintechnologies.com) Blockchain Technologies is a huge static content website that covers practically every single question you might have about blockchain. Additionally, the site also has a news section where stories from the largest cryptocurrency news blogs are gathered. I added this site to this list of the 27 best cryptocurrency blogs for three main reasons. The first is that the content is absolutely amazing. It is very obvious that the writer spent A LOT of time researching about cryptocurrencies. Secondly, the UI of the website is astonishing. The colors are very well picked, the site charges in the blink of an eye and it is completely responsive. And finally, although the Blockchain Technologies blog has a couple Ads, it is very clear that the main objective of the site is to inform, and not to just make money with visitors.

    ReplyDelete
  2. The upsides of blockchain development are just brushing the surface as the world reveals its capacities. From quality affirmation and savvy contracts to the stock trade and global exchanges, organizations are bouncing on the blockchain passing trend in large numbers. Mobile app development will keep on ascending as new businesses utilize the blockchain innovation to cooperate with clients from a wide range of devices.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. The information you have shared in this blog in remarkable. You can also check this for Blockchain development company to develop ethereum based platfrom.

    ReplyDelete

Post a Comment

Popular posts from this blog

GPS Tracker – GPS Tracking Device

Real Estate App Development: Must Have Features and Cost Estimation

Key Insights into Developing an Educational App Helpful for Students and Teachers