Blockchain

Blockchain is a distributed ledger that is used to record transactions of a digital asset such as bitcoin. It has been one of the most talked about technologies in the 2010s, continuing to be popular for its tamper-proof design even after bitcoin became notorious for its price vagaries.

Blockchain became a mainstream term since 2014 with applications across several industries being explored – to store data about property exchanges, stops in a supply chain, and even votes for a candidate. I have been following blockchain for many years and finally got some hands-on experience on Ethereum while completing a Pluralsight course.

In this blog, I have listed key blockchain terms / concepts with brief description and also summarised the development environment used:

  • Blockchain is a chain of digital data blocks, with each one containing:
    • Information about transactions such as date, time, amount, price, etc.
    • Unique code called a “hash” that distinguishes a block from another. This is generated by a hashing process.
  • Hashing: an algorithm performed on data to produce an output that can be used to verify that data is not modified, tampered with or corrupted:
    • Length of output always the same.
    • One-way: the hash cannot be converted back into the original key.
    • Digital fingerprint that allows verifying consistency.
  • Obfuscation and Encryption provide data security to blockchain.
  • Key features of Blockchain: Immutable, decentralized, verifiable, increased capacity, better security, faster settlement.
  • Blockchain can be public (like Ethereum) or private (like R3 Corda).
  • Top implementations: Ethereum, Hyperledger Fabric, Ripple, Quorum, R3 Corda.
  • Distributed Applications (DAPPs) architecture using Ethereum: Blockchain encapsulates shared data and logic related to transactions while client is responsible for interface, user credentials and private data.
  • Payment for transactions is made through “gas”.
  • Transactions contain information on recipient, signature, value, gasprice, startgas and message.
  • A consensus mechanism is required to confirm transactions that take place on a blockchain without the need for a third party. Proof of Work and Proof of Stake are the two models currently available to achieve this.
  • Proof of Work is based on cryptography, hence digital coins like Bitcoin and Ethereum are called cryptocurrencies. Cryptography uses mathematical equations that are so difficult that only powerful computers can solve them. No equation is ever the same, meaning that once it is solved, the network knows that the transaction is authentic. Although Proof of Work is an amazing invention, it needs significant amounts of electricity and it is also very limited in the number of transactions it can process at the same time.
  • With Proof of Stake, miners can mine or validate block transactions based on the amount of Bitcoin held by them. This way, instead of utilizing energy to answer Proof of Work puzzles, a miner is limited to mining a percentage of transactions that is reflective of ownership stake.

Development environment:

Ethereum uses a programming language called Solidity, which is an object-oriented language for writing smart contracts. Solidity plugins are available for popular IDEs. I used the following setup:

  • IDE – Eclipse with YAKINDU-Solidity Tools / Visual Studio Code
  • Node.js Package Manager – npm
  • Windows Package Manager – chocolatey (installed from Powershell as administrator)
  • Node.js Windows Build Tool
  • Local ethereum test server and emulator – Ganache / Test RPC
  • Dev & Testing framework – Truffle Suite
  • Crypto wallet & gateway – Metamask
  • My practice code – https://github.com/gsanth/experiment/tree/master/ethereum_experiment

To summarize, Blockchain’s potential as a decentralized form of record-keeping is enormous. From greater user privacy and heightened security to lower processing fees and fewer errors, blockchain technology will continue to see applications across several industries. However, it is easy to get carried away by blockchain’s apparent potential and get into technology overkill. So, it is important to understand the pros and cons of blockchain, and ensure we leverage it for the right use cases.

ProsCons
Decentralized (difficult to tamper)Technology cost for mining
Improved accuracy (no manual effort)Low transactions throughput
Reduced cost (no third party charge)Poor reputation (illicit activities)
Transparent Technology