An Introduction to Blockchain Technology

Written by jacqtrain | Published 2017/10/12
Tech Story Tags: blockchain | web3j | ethereum | java | blockchain-technology

TLDRvia the TL;DR App

I’ll admit now, I am a complete newbie to the world of blockchain technology and all that it means. Until today, I had not heard of Ethereum, or Ether, and smart contracts referred only to me checking that the terms of my tenancy agreement included an automatic rolling continuance, and the term Bitcoin could make me draw a blank as my mental block came up.

I attended the workshop today to open my mind to more about the world of technology, rather than allowing myself to be comforted by the bubble of Java I’ve created for myself where the most exciting things I’ve really experienced are the introduction of RX observables and the latest features release to GitLab. I’ve become complacent, and I needed to push myself. So I did.

Today was one of the most uncomfortable days I have had in recent memory. I loathe not understanding things, at least to the point of lagging up to an hour behind the course. Especially if I can see everyone else progressing. After all, that must be me right? I’m not intelligent enough to understand. I know I’m not the only one who thinks like this, so I’m here to tell you right now — STOP. It’s that sneaky little voice that everyone’s been talking about of late.

Relax, take a breath. Everyone learns at a different pace. Now whilst this was unusual for me, it was also a humbling experience. And although I might not have kept up with the rest of the class, I am still happy with the knowledge that I came away with. So here’s a brief overview of blockchain technology, the Bitcoin implementation, and how Ethereum and Solidity can be used to test a simple Java program that utilises the Web3j library, from a very fresh point of view.

**Blockchain Technology**What is it, and why do we need it?

Image courtesy of Blockchain Technologies

A blockchain is a singly LinkedList of block, with each block containing a number of transactions. It provides a decentralised, immutable data store that can be used across a network of users, create assets and act as a shared black book that records all transactions. Each transaction can be easily queried, affording greater transparency and trust to all parties involved.

With the original creator, or creators, being anonymous the true motivations behind blockchain are arguably unknown. However it has proven to be a more than adequate solution to the many issues.

  1. Data that multiple clients (individuals or organisations) have a copy of, which in turn needs consolidating and validating
  2. Sharing inter-organisational data
  3. Digital asset registry
  4. Identity management (e.g. cryptographic identification)
  5. Significant IoT interest (interested parties could pull data from a blockchain)

Enter distributed ledger technology. This is the umbrella term for all technologies of this nature, with blockchain being one implementation. This is made up of three identifying factors:

  1. Smart contracts
  2. Support for public and private networks
  3. Consensus mechanisms

Blockchain Implementations

The most well known implementation of blockchain technology is the Bitcoin. Created in 2008, this was a breakthrough in Blockchain technology and is often referred to as Blockchain 1.0. Bitcoin is a transaction focused implementation that allows for anonymous trading without a consortium, whilst still offering the basic distributed ledger of all transactions.

Other implementations exist, such as Digital Asset Holdings and Ripple, however these have been more financially focused rather than implementations designed with the individual consumer at the forefront. There is also the Hyperledger Project by IBM, but similarly this is geared more towards larger organisations than smaller companies or individuals.

Finally, we have Ethereum.

Ethereum

Ethereum is the next step in the blockchain evolution. Created in 2013, it is considered to be Blockchain 2.0 and allows for the running of arbitrary code to complete computational processes, rather than just record transactions. It is a Turing-complete virtual machine, and is runs as a public blockchain.

Ether is then the fuel of Ethereum, and it is associated with a wallet and address file that is unique to each account. However each user may have multiple accounts, so although one unique account belongs to a single user, it cannot be known how many other IDs link back to that same user.

So if Ether is the currency of Ethereum, how do you obtain it?

Obtaining Ether

There are two methods of obtaining Ether for use with Ethereum. The first is to buy it:

  1. Purchase from another user
  2. Coinbase
  3. BTC Markets

And the second is to mine it.

  1. mainnet => Bitcoin’s main network, requires dedicated GPUs
  2. testnet => quick using your CPU, via a faucet. Kovan, Rinkeby, Ropston. Connection made to Ethereum test networks via Geth or Parity

Smart Contracts

Smart contracts help you exchange money, property, shares, or anything of value in a transparent, conflict-free way while avoiding the services of a middleman. They are a computerised contract that can be affected by data and methods.

  1. Code and data lives on a blockchain at a given address
  2. Transactions call functions and result in a state transition

They feed into the three steps of transactions through Ethereum.

Transactions

There are only three simple steps to an Ethereum transaction; transfer Ether, deploy a smart contract, and to finalised by calling the smart contract. So how about we see this in action?

Web3j

Web3j is a library created by Conor Svensson that offers a lightweight solution to Java and Ethereum integration. It acts an an interpretation layer, using contract models to performs operations, and is able to connect to any provided Ethereum host node.

Example Project on GitHub

In the workshop I attended, I was able to get a very simple example of the Web3j library working with Java and both a local Ethereum node and the Rinkeby test network. I didn’t want to go into too much detail here about how to get hooked up to servers as that alone seven pages of notes and screenshots!

But check out my GitHub page to see the project in action, and for an extensive tutorial. You can give it a try yourself, and read about how to set an account for Infura, connect to a test network, gain Ether from the Rinkeby faucet and viewing the transactions performed in a local Java application in the Rinkeby EtherScanner. As someone who was definitely in over their head, I may have gone overboard on the note taking, but it helped me clarify a few things by getting it down in text and getting my hands dirty with the practical lab. Hopefully it may help someone as lost as I was to start wrapping their head around all this.

Conclusion

Blockchain technology is still a far reaching mystery to me. However I’ve gotten a taste of what it means now and having struggled but triumphed over the initial understanding, I think I may be ready to delve (slowly) into the more complex topics covered by the workshop. In time, I’ll come to understand more and start to see the true power of this new and potentially revolutionary technology.

Wish me luck!


Published by HackerNoon on 2017/10/12