In our previous two articles, we articulated several real-life use cases for Blockchain implementations, and we have also elaborated conceptually how Blockchain differs from current/previous data storage architecture as well as other conceptual benefits of Blockchain as a platform.
In this article, we touch upon the technical components of Blockchain networks and Smart Contracts, and we walk through a technical implementation of a viable Blockchain application using the Microsoft Azure platform.
What is Blockchain?
The blockchain is a shared ledger which stores data differently to typical database platforms and solves several challenges by avoiding double spending and the need for trusted authorities or centralised computing servers. Furthermore, Blockchain as a technology has evolved since the introduction of the Bitcoin Blockchain in 2008 (invented by Satoshi Nakamoto), and are now solving more recognisable business problems other than cryptocurrencies.
In addition to the concepts discussed in the previous article, below are some additional descriptions of Blockchain components before we dive into the technical walk-through:
Blocks – A block is a valid record/transaction in Blockchain that Blockchain can’t be altered or destroyed. It is a digital footprint based on Cryptographic hash which remains in the system as long as the system is alive. Since the Blockchain is decentralised, the blocks are replicated across the network nodes, thus making them immutable and secure.
Cryptographic hash – Cryptographic hash functions are cryptography algorithms that generate hash values for a given piece of data. It ensures authenticity, integrity and security of the data.
Nodes – A node is a computer/server/virtual machine that participates in a Blockchain network. Nodes store all the blocks and transactions generated in the system. A peer-to-peer (P2P) architecture connects nodes of a Blockchain. When a device is attached to the network as a node, all blocks are downloaded and synchronised. Even if one node goes down, the network is not impacted.
Miner Node – Miner nodes create the blocks for processing the transactions. They validate new transactions and add blocks to the Blockchain. Any node can be a miner node since all the blocks in the network are replicated across each node including the miner node; hence a failing of any miner node is not seen as a single point of failure. It is advisable to set high computing machines as miner nodes since mining consumes a lot of power and resources.
How a Blockchain transaction works
A Blockchain transaction should complete a set of pre-cursory activities to ensure the integrity and security. These steps make the network of the Blockchain a unique proposition for a trust computing paradigm.
Let’s look at the Blockchain transaction lifecycle.
- A user initiates a transaction on Blockchain through a “wallet” or on a web3 interface.
- The transaction is validated by the set of computing nodes called miners using Cryptographic hash functions.
- Miner nodes create blocks based on the transaction using crypto economic options like Proof of Work (PoW) or Proof of Stake (PoS)
- The block is synchronised within the other nodes within the Blockchain network.
Types of Blockchain networks
Before setting up a Blockchain, one must determine the type of network required. There are three types of Blockchain Network applications.
Public Blockchain:
- An open (public) network ready for use at any given point in time. Anyone can read the transactions and deploy decentralised apps that use the underlying blocks. No central authority controls the network.
- These Blockchain networks are “fully decentralised”.
- Use case: Ethereum Cryptocurrency Blockchain can be used efficiently for managing payments or running Blockchain apps globally.
Consortium Blockchain:
- A group of nodes controlling the consensus process. The right to read from may be public, but the participation within the Blockchain can be limited to consortium members by using API calls to limit the access and contents of the Blockchain.
- For example, a statutory body or an organisation may implement a regulatory Blockchain application that allows selected organisations to participate in validating the process.
- These Blockchain networks are “Partially decentralised”.
- Use case: Reserve Bank of Australia (RBA) can set up a Blockchain network for processing and controlling specific banking transactions across banks based on statutory compliance requirements. Participating banks implement Blockchain nodes to authenticate transactions in the network.
Private Blockchain:
- Similar to any other centralised database application that is controlled and governed by a company or organisation. They have complete write access and read permissions although the public may be allowed to see specific transactions at the Blockchain network administrator’s discretion.
- These Blockchain networks are “Centralised”.
- Use case: A company can automate its supply chain management using Blockchain technology.
Implementing Blockchain on Azure
Blockchain on Azure is a Blockchain as a service (BaaS) which is an open flexible and scalable platform. Organisations can opt for BaaS to implement solutions on a federated network based on security, performance and operational processes without investing in physical infrastructure.
Azure BaaS provides a perfect ecosystem to design, develop and deploy cloud-based Blockchain applications. Rather than spending hours building out and configuring the infrastructure across organisations, Azure automate these time-consuming pieces to allow us to focus on building out your scenarios and applications. Through the administrator web page, you can configure additional Ethereum accounts to get started with smart contracts, and eventually application development.
Consortium Blockchains can be deployed using:
Ethereum Consortium Leader
- To start a new multi-node Ethereum Consortium network, implement the Ethereum Consortium Leader.
- And a primary network for the other multi-node members to join.
Ethereum Consortium Member
- To join an existing Ethereum Consortium network, deploy the Ethereum Consortium Member.
Private Blockchains can be deployed using
Ethereum Consortium Blockchain
- To create a private network use Ethereum Consortium Blockchain
- Templated to build a private network within minutes on the Azure cloud
Below are links that will allow users to achieve a step by step approach to deploy a Blockchain network on the Azure cloud.
Once deployed you will receive the following details:
- Admin Site: A website you can navigate to showing the status of the nodes on your Ethereum network.
- Ethereum-RPC-Endpoint: An endpoint for connecting to your Ethereum network via an API like Truffle or web3 js.
- Ssh-to-first-tx-node: To interact with your Blockchain, log in using your Secure Shell (SSH) client. I’m currently working on Windows, so I’ll be using Putty (https://www.putty.org/) to log in, but you can use any SSH client to connect the console. On Mac, you can just copy and paste the “ssh” line into your terminal.
Interacting with Your Azure Blockchain Using Geth
Geth is a multipurpose command line tool that runs a full Ethereum node implemented in Go. It offers three interfaces: the command line subcommands and options, a JSON-RPC server and an interactive console.
Steps to connect the Blockchain instance:
- SSH into the Azure server using Putty or Command-line interface
- Use the following command to connect to the Blockchain console
- Loads all the modules below and the command prompt is available
- Examples of geth Command
You can access the network using the Mist Ethereum wallet or any other Ethereum compatible wallet.
Smart Contracts in action
“Smart Contracts: Building Blocks for Digital Free Markets” – Nick Szabo
Smart contracts are set of terms and conditions one must meet to allow for something to happen between parties. It is just code in the form of blocks and is immutable. Smart contracts:
- Are anonymous.
- Are secured using encryption so that they are safe.
- Can’t be lost since they are duplicated into other Blockchain nodes.
- Speed up the business process.
- Save money since there is no need for any third party to validate and go through the contract terms.
- Are accurate since they avoid errors that happen during manual execution of any contracts.
In the above example, the following are the actions captured:
- Mark uses the healthcare consortium network to record his details. The details are persisted in the blockchain through a smart contract. A smart contract can hold all the required variables and attributes.
- Once the smart contract has acquired all the mandatory information and requirements, it is then deployed into the healthcare consortium network. A transaction is initiated for further consultation.
- Healthcare consortium network validates the transaction based on the logic defined in the smart contract. Mark has been detected with some health issues and the contract/health record is automatically sent to Dr John for further analysis and consultation.
- Dr John accesses the record and recommends Dr Anne for specialised treatment. The contract is automatically executed and sent to Dr Anne for further action.
- Dr Anne provides necessary treatment to Mark. The details of the treatment are persisted in the smart contract.
There are various tools to write/deploy a smart contract, however, common tools used are:
- Languages: Solidity
- IDE: Solidity Browser, Ethereum Studio.
- Clients: geth, eth, Ethereum Wallet.
- Api & framework : Embark, truffle, DAPPLE, Meteor, web3.js API, ethereumj, Blockapps
- TEST : TestRpc/ testnet or private network
- Storage : IPFS/ swarm/Storj.
- Dapp Browser: Netmask, Mist.
An example of solidity script can be found below.
Blockchain and Data Analytics
Perhaps the most critical development in information technology is the growth of data analytics and platforms in the Big Data, Machine Learning and Data Visualization space. Analytics/Data lakes can source Blockchain data using federated APIs built on top of Blockchain. Since the provenance and lineage of data is well accomplished, the data from the Blockchain can be helpful in developing a productive data platform for data analytics or machine learning capabilities or AI development.
The following diagram is a simplistic view for integrating data analytics with Blockchain.
Conclusion
Before an organisation starts any of the technology assessments and implementation of a Blockchain, even if just for R&D, consider what a Blockchain would mean for your organisation through potential use cases and process improvement opportunities. Moreover, ensure some of the basic concepts described here and in the second article in the series are understood vis-a-via your identified use cases.
Only then proceed to the technology side of things.
Blockchain has the potential to be a fantastic technology through its federated computing paradigm. But do not lose sight of the process and people aspects associated with this