Blockchain technology has been widely adopted because of its unique features of privacy, security, immutability and integrity, among many others. Combining it with modern Web and mobile technologies can bring about a remarkable change in the management and functioning of various civic entities. Effectively implemented, this can save billions of dollars.
A blockchain refers to a chain of records that are interconnected with each other and are highly secure because of the dynamic hash and cryptography implemented at every phase of the transaction. Blockchain technology avoids the possibility of intentional or accidental hacking or cracking of transactions.
Many countries are working on implementing blockchain technologies for their citizen services (e-governance), while it is also being used in e-commerce, corporate applications, agriculture, education, air traffic control, healthcare, telemedicine and many others because of the privacy and security of transactions.
As depicted in Figure 1, the number of blockchain based wallets is increasing very rapidly and gaining huge traction in the domain of cryptocurrency.
The key reasons why blockchain technology is becoming popular in security aware applications are:
- Resilience
- Time reduction
- Reliability
- Unchangeable transactions
- Fraud prevention
- Security
- Transparency
- Collaboration
- Decentralised
The flow of processes in the blockchain environment is shown in Figure 2. Each and every transaction is validated with the implementation of advanced protocols, and cannot be cracked because of the smart contracts integrated in the blockchain network.
Case studies and applications of blockchains
As per reports from Statista, global spending on blockchains moved to around US$ 3 billion in 2019. Blockchain technology is not confined to e-governance or e-commerce, but also advancing in the domain of agriculture. The use of the blockchain in the agriculture segment amounted to a global turnover of over US$ 40 million in 2018.
The United Arab Emirates (UAE) is working on the development of a blockchain based city with fully featured blockchain implementations. Smart Dubai is proposed to be the first city that will be fully powered with blockchain technology. The research reports claim that UAE will save more than US$ 3 billion by deploying the blockchain for multiple sectors.
Krisflyer Singapore Airlines is adopting blockchain technology with the integration of a digital wallet. A loyalty programme and payment have also been integrated with this technology.
Singapore has been very active in the implementation of blockchain technology for multiple applications including education, e-governance, the food industry, healthcare and many others.
In the real estate sector, Averspace is known to be the first portal that is blockchain enabled for the selling and renting of properties. The transactions are deployed in a secured way with digital smart contracts.
Free and open source tools for blockchain programming
A number of platforms and technologies are available for blockchain programming. The key factors to consider when choosing the appropriate platform for blockchain programming include the type of network, the programming language, the consensus protocol, and the platform’s popularity and activity. These factors need to be analysed so that a high performance blockchain application can be developed that is compatible and has a high throughput.
Let’s look at the key features integrated in the prominent platforms for blockchain programming and smart contracts.
Eris (https://erisindustries.com/): This is a powerful and multi-featured platform for blockchain programming. Smart contracts can be written and executed on Eris effectively. The private blockchain networks can be programmed with a higher degree of privacy and security for multiple applications. This platform is popular among blockchain programmers for the automation of smart contracts. The programmed smart contracts are used to analyse and validate the transactions in a secured environment.
HydraChain (https://github.com/HydraChain/hydrachain): HydraChain is used for permissioned distributed ledgers. The key feature of HydraChain is that it is fully compatible with Ethereum Protocol. The primary domain of HydraChain includes consortiums or private chain based setups. In addition, native contracts that can be easily customised and deployed can be programmed using HydraChain.
OpenChain (https://www.openchain.org): OpenChain refers to the free and open source distributed ledger platform. It is used for high-performance scalable applications for organisation and enterprise deployments. The execution speed is much faster than other platforms. OpenChain integrates the client-server architecture, in which there is more reliability and consistency as compared to the traditional peer-to-peer architecture. There is support for multiple signatures in OpenChain which provides multiple keys for authentication and validation.
The key features of OpenChain include:
- No mining charges
- Security using digital signatures
- Multiple layers of control
- Instant validation of transactions
- Immutable
- Transactions audit
- Transparency and validation control
Ethereum (https://www.ethereum.org): Ethereum is a free and open source platform for blockchain programming. It can be used for writing and deploying any type of decentralised applications, and can be used on multiple platforms with high security levels and flexibility.
Smart contracts can be programmed and deployed using Ethereum. This platform is generally used for public blockchains. The support programming languages in Ethereum include Go, Python and C++.
Hyperledger (https://www.hyperledger.org): This is another open source platform for advanced applications of blockchain technology. It is used widely for enterprise applications and for working with private blockchain networks. The Python programming language is used for working with Hyperledger, which is integrating a number of projects for blockchain programming with distributed ledgers. These projects include Hyperledger Besu, Hyperledger Burrow, Hyperledger Fabric, Hyperledger Indy, Hyperledger Iroha and Hyperledger Sawtooth. There is a rich set of tools in Hyperledger including Avalon, Caliper, Cello and Explorer. These tools are used for monitoring and programming with the assorted dimensions of the blockchain network under development.
Scope for implementation in real-world Web and mobile applications
To program real-world applications with blockchain technology, there are many programming languages that are used including Python, JavaScript, Java, PHP, Go, etc.
Programming with blockchain uses the base of cryptography hash functions which are required to encrypt the blocks and the transactions. In addition, programming the smart contracts also integrates the cryptography libraries so that the overall communication and data processing in the blockchain are fully secured.
The following scripts form the foundations of blockchain programming for Web or mobile applications in multiple domains, for which the transactions must to be implemented in secured scenarios.
Block creation and activation: Shown below is the code snippet for writing a block in the blockchain environment for Web or mobile applications in which multiple transactions or processes are expected.
const SHA256 = require(“crypto-js/sha256”); class SecuredBlock { constructor(BlockIndex, CurrentTime, DataBlock, PreviousHashValue = ‘’) { this.BlockIndex = BlockIndex; this.PreviousHashValue = PreviousHashValue; this.CurrentTime = CurrentTime; this.DataBlock = DataBlock; this.hash = this.calculateHash(); } calculateHash() { return SHA256(this.BlockIndex + this.PreviousHashValue + this.CurrentTime + JSON.stringify(this.DataBlock)).toString(); } }
The library of cryptography hash functions is invoked so that the dynamic hash can be generated for the blocks in the blockchain application. crypto-js can be used for the implementation of hash functions. The constructor declared in the class is used to initialise the values and these can be further called in the program. The hash of the block and transaction is processed with JSON to have the retrieved hash in the string.
Blockchain creation: The creation of a blockchain is required so that the blocks can participate in a secured environment and to validate transactions after successful authentication.
class SecuredBlockchain { // Genesis Block (The First Block of Blockchain) constructor() { this.chain = [this.createGenesisSecuredBlock()]; } createGenesisSecuredBlock() { return new SecuredBlock(0, “01/01/2020”, “Genesis SecuredBlock”, “0”); } // Inserting Blocks getLatestSecuredBlock() { return this.chain[this.chain.length - 1]; } addSecuredBlock(newSecuredBlock) { newSecuredBlock.PreviousHashValue = this.getLatestSecuredBlock().hash; newSecuredBlock.hash = newSecuredBlock.calculateHash(); this.chain.push(newSecuredBlock); } // Validation and Authentication Process isChainValid() { for (let i = 1; i < this.chain.length; i++) { const currentSecuredBlock = this.chain[i]; const previousSecuredBlock = this.chain[i - 1]; if (currentSecuredBlock.hash !== currentSecuredBlock.calculateHash()) { return false; } if (currentSecuredBlock.PreviousHashValue !== previousSecuredBlock.hash) { return false; } } return true; } }
The genesis block refers to the very first block that was created in any blockchain network. There is no previous hash value of this block, as it is the initial block in the blockchain. After this genesis block, all other blocks are generated and inserted after validation using protocols and smart contracts. Once the blocks get activated in the blockchain, they are validated for further transactions and the transmission of data.
Implementing the blockchain is quite effective for e-governance, for which security and data privacy are very important. Many countries including Singapore, UAE, Japan, Switzerland, Australia and China are working on blockchain implementations for multiple applications. In developing countries like India, where data privacy is a serious matter, government services including Aadhar based citizen identification, biometric data storage, voter information, education data records, health records and many similar domains can be deployed using blockchain to enable high performance and security of data.