...by Daniel Szego
quote
"Simplicity is the ultimate sophistication."
Leonardo da Vinci

Friday, December 29, 2017

Azure Blockchain walkthrough - Setting up Ethereum Consortium Blockchain

Azure Blockchain platform have some pretty cool solutions to create consortium blockchain solutions. In this walkthrough we are going to demonstrate one step by step guideline for creating, configuring a consortium network and develop and deploy the first applications on top. 

1. Choosing the necessary Azure Blockchain template: Azure Blockchain has many different templates. Two of them are important for Ethereum consortium blockchains: with the help of "Ethereum Consortium Blockchain" you can create a consortium infrastructure up to 12 nodes in one configuration step. With "Consortium Leader" or "Consortium Member", there is the possibility to do the same configuration step-by-step, with other words dynamically if a new member joins.   

Figure 1. Azure Ethereum templates

2.  Configuring the template: After the necessary template have been chosen it has to be configured. Apart from the usual Azure parameters like resource group and administrator accounts, the structure of the network has to be set, like the number and size of the mining and translation nodes. or the number of consortium members. The last tab provides the possibility to configure the Ethereum specific settings, like the network ID or a custom genesis block.    


Figure 2. Configuring the Ethereum Consortium Blockchain

3. Creation finished: If the network creation finished, the most important parameters are to be found in the result page:
- Admin-site: a general page about the status of the network, including a faucet as well to distribute some pre-allocated ether.
- RPC-Endpoint: is an important parameter for communicating with the consortium blockchain for example from Truffle or Metamask.
- SSH Info: is important for logging in into the environment and configuring parameters, like most typical for unlocking the coinbase account.

Figure 3. important parameters for accessing the consortium blockchain

4. Unlocking the coinbase account: It might cause difficulties in the future so it is not a bad idea to explicitly unlock the coinbase account. With the help of ssh and the ssh command of the previous configuration window, you can attach to the first node of the ethereum consortium network (note that usually the first node is the transaction node, if it is confidently different, you can log in into further nodes with using -p 3001 3002 ... parameters).

If you logged in, you can use: 

  geth attach  -- to attach to a running geth instance

  personal.unlockAccount(eth.coinbase) -- unlocking the coinbase account, the default unlock time is 5 minutes.

 eth.coinbase -- getting the address of the coinbase account

 personal.unlockAccount('address', 'passphrase', 'duration')  -- unlocking the account for a longer time period. If you use 0 as duration, the account will be locked forever. 

5. Configuring Metamask: Based on the Ethereum-RPC-Endpoint, Metamask can be configured with changing from the Main Network to a custom RPC. With the help of the admin page faucet and newly generated accounts, the pre-allocated ether can be further allocated and the network basic network functionality can be tested.


Figure 4. Metamask configuration

6. Deploying contract: If Metamask set up you can directly or indirectly deploy contracts with the help of remix by selecting "Injected Web3" or "Web3 Provider" at the environment. "Injected Web3" deploys the contract with the help of the configured Metamask account.


Figure 5. Remix configuration


7. Configuring Truffle for the consortium network: if you want to deploy to the new Azure consortium network, make sure that you configured the new network in the truffle.js configuration file. You can get the host name as the Ethereum-RPC-Endpoint from the output window, and you can get the network_id from the initial configuration. You can deploy on your consortium network for instance with the truffle migrate --network azureNetwork command.


Figure 6. Truffle configuration