Book Image

Blockchain across Oracle

By : Robert van Molken
Book Image

Blockchain across Oracle

By: Robert van Molken

Overview of this book

Blockchain across Oracle gives you the professional orientation to Blockchain that you need as an Oracle developer in today’s changing world. Written and prepared for you by Oracle Developer Champion Robert van Mölken, this book gets you up to speed with the details of the Blockchain - core concepts, how to implement Oracle’s Blockchain Cloud Service, industry implications for the Blockchain, and how the Blockchain will affect your Oracle customers. Robert van Mölken introduces you to the history and concepts of the Blockchain. You’ll really get to understand the Blockchain inside and out, as an Oracle developer or solution architect. You’ll understand the Blockchain flow, and how the hashes and chains create a new decentralised paradigm for you as an Oracle developer. You’ll gain insights into how the Blockchain affects Oracle developers and customers in this modern and disruptive era. You’ll see how the Blockchain concepts work in this new world where Assets, Transactions, Security, and Privacy, can all be sustained across a decentralized system for your customers. Then you'll find a detailed look at the cutting-edge Oracle middleware solutions. You’ll learn about Hyperledger Fabric, the opensource Blockchain framework used by Oracle as its core, and how to set up your own Oracle Blockchain Network. You’ll design and develop a smart contract, and learn how to run it on the Oracle Blockchain Cloud Service. The final part of the book looks at how the Blockchain will affect your customers across various industry sectors. By studying industry trends in the financial services sector, healthcare industry, and the transport industry, you’ll discover how the options and possibilities for you and your clients are being transformed by the Blockchain across Oracle. You’ll complete this professional orientation by looking at Blockchain trends and future directions.
Table of Contents (24 chapters)
Title Page
Packt Upsell
Contributors
Preface
3
Blockchain 101 - Assets, Transactions, and Hashes
4
Blockchain 101 - Blocks, Chains, and Consensus
Index

Preface

Since you are reading this book, I will assume that you are interested in learning more about blockchain technology in the context of using it in an Oracle environment. In this book, I will try my best to provide you with this knowledge. This book will guide you through the concepts and terminology behind blockchain and how these affect Oracle developers and customers. The chapters in this book examine real-world use cases for several major industries. Apart from these informative chapters, this book also provides a sample implementation of setting up and running a private blockchain on the Oracle cloud.

When speaking about blockchain, we mean a distributed (key-value) database that enables a group of entities to share a unified digital ledger and conduct transactions rapidly and safely with each other without having to go through a central authority. Each entity controls its assets via a private key and independently verifies all transactions. Blockchains have no single point of failure, so entities can appear, disappear, or malfunction without affecting the group as a whole.

Before taking a deep dive into blockchain, we'll begin with a presentation of the broad history of blockchain and where it came from.

History of Blockchain

Originally, blockchain was conceived as the underlying technology for Bitcoin by Satoshi Nakamoto (an alias for the unknown inventor(s)?) in October 2008. This was not the first time; however, the idea of cryptographically securing a chain of data blocks had been described. There were multiple publications throughout the 1990s by several authors, sometimes in parallel. In the late 1990s and at beginning of 2000, the first publications arose which talked about a decentralized digital currency and a theory of cryptographically secured chains. Two important names generally acknowledged for inventing the intellectual precursors of the technology are Wei Dai and Nick Szabo.

It wasn't until 2008, however, when these concepts resulted in the creation of the first blockchain. It was accomplished in the publication of the white paper Bitcoin: A Peer-to-Peer Electronics Cash System, by Satoshi Nakamoto, which can still be obtained at http://www.bitcoin.org/bitcoin.pdf. This white paper describes the concept behind the underlying technology that eventually became the blockchain.

Just three months after the publication of the white paper, the code for Bitcoin was released in a freely available, open source format, on January 9, 2009.

The Bitcoin network itself started on January 3, 2009, when Satoshi Nakamoto used the code to "mine" the first Bitcoins. A few days later, the first transaction took place. In the months that followed, the Bitcoin network gained more and more attention and membership, which led to the first official currency rate on October 5, 2009. At that time, one Bitcoin (or BTC) was worth about $ 0.76 (USD), which was based on an equation that included the electricity cost that a computer node required to generate a Bitcoin. At the time of this writing, June 7, 2018, a Bitcoin is worth about 7,693.50 USD, but its all time high has been 19,783.06 USD. Finally, on February 6, 2010, individuals could buy and sell bitcoins using the newly established dollar currency exchange. In that same year, the market cap exceeded $1 M USD because of increased member participation, and within three years' time, the market cap surpassed $ 1B USD. A more detailed history can be found at http://www.historyofbitcoin.org.

The timeline of the history of Bitcoin and blockchain

Remember, this book is not solely about Bitcoins, but rather about the technology behind it. If we fast forward in time, we will see the rise of many alternative blockchain-based currencies. Because the Bitcoin core code is open source, any knowledgeable individual can start a new coin by changing this code. Thus, you can understand why there are a number of alternative coins, but the one that stands out is Litecoin (https://litecoin.org).

Litecoin is one of the initial cryptocurrencies that followed Bitcoin and was introduced on October 7, 2011. It also is open sourced. It is a fork of the Bitcoin core code, meaning an alteration of the current code (or protocol) to change the rules–released by Charlie Lee, a former Google employee. Litecoin can be viewed as the silver to Bitcoin's gold, as the overall volume is higher and the price is lower. Litecoin is primarily distinguished from Bitcoin by a decreased block generation time (2.5 instead of 10 minutes), an increased maximum number of coins, and a different hashing algorithm. Don't worry if you do not understand these concepts yet, because I will touch on all of them in the upcoming chapters.

Some other honorable mentions include Dash, Zcash, and Ripple. Dash (https://dash.org) defined itself as being the more secretive version of Bitcoin, as it offers greater anonymity by making transactions through its decentralized network almost untraceable. Zcash (z.cash), on the other hand, claims to provide security and/or privacy based on the selective transparency of transactions by making such details as sender, recipient, and amount, private. All of these cryptocurrencies are adaptations of the original Bitcoin core code, or they take the concepts behind this code and create something totally new. Ripple (https://ripple.com), technically a public blockchain, stands out the most as it specifically focuses on banks. It is an interesting example, as though it is a publicly based platform, it is privately controlled through central ownership and the code is closed sourced. This enables banks to settle cross-border payments in real time and at a lower cost.

Once again, we will move forward in time to the year 2015. Starting then, several start-ups appeared that researched the use of the blockchain for very different purposes. One of the most well-known is Ethereum, which is an open source, public blockchain-based platform for distributed computing. One of the distinguishing features of Ethereum are smart contracts. A smart contract is a (scripting) functionality designed to facilitate contractual agreements using a Turing-complete virtual machine. This means that it has conditional branching (for example, "if" and "goto" statements, or a "branch if zero" instruction). Because Ethereum is still a public blockchain, it provides its own cryptocurrency called "Ether" to compensate participants who help perform computations on the platform. In Chapter 5, Blockchain 101 - Security, Privacy, and Smart Contracts, we will go through these agreements in great detail.

Some of the well-known cryptocurrencies and platforms based on blockchain code

Up until this point, I have only discussed public blockchains. After 2015, this changed, as numerous software was made publicly available to run your own private blockchain network. Public blockchains, such as Bitcoin and Ethereum, are terrible when it comes to exchanging information because of the high transaction cost. Private blockchains were introduced to solve the problems related to these costs. Moreover, they are designed to provide more privacy and openness by managing the blockchain user permissions.

Note

A private blockchain performs the following:

  • Ensuring that activity on the blockchain is only visible to chosen participants
  • Introducing control over permissions to manage which transactions are allowed
  • Enabling verification (mining) of transactions without the costs associated with the proof of work (PoW)

There are a couple of private blockchains, some are cloud-based while others run on-premises. There are companies, such as Deloitte's Rubix and Eris Industries' Monax, which sell turnkey solutions for private blockchains directly to businesses. Monax, for example, offers out-of-the-box SDKs for the Finance, Insurance, and Logistics industries. Other companies, such as Microsoft and IBM, offer Blockchain as a Service (BaaS) on their own cloud infrastructure. Both run Hyperledger Fabric (hyperledger.org). Microsoft runs Ethereum as well. Microsoft also offers private blockchain nodes packaged as Azure Quickstart Templates (azure.microsoft.com/en-us/resources/templates/?term=blockchain).

Since 2016, the number of vendors that provide open source software to run your own private blockchain has increased. One that is already mentioned is Hyperledger Fabric. It is part of the umbrella project Hyperledger, which was originally started by the Linux Foundation in early 2016. The project offers multiple open source blockchains and tools from different contributors, each providing different mechanisms and features. The available tools include a composer (package management) and an explorer (analytics). Blockchains within Hyperledger Fabric are built to run on Linux, but they can also run on macOS and Windows, using Docker (docker.com).

A strong competitor of Hyperledger is MultiChain (multichain.com). MultiChain goes the desktop route, deploying a private blockchain on a desktop, even in a Windows environment. It is also open source and allows rapid design, deployment, and operation of private blockchains according to your custom specification. With MultiChain, it is possible to create multiple types of data streams including key-value or identity databases.

For the implementation of our blockchain, we will look more closely at two private blockchains in Chapter 8, Ethereum Versus Hyperledger, and what makes them different from each other.

Major companies such as Visa, Capital One, NASDAQ, and Philips are now investing in the various available blockchain platforms and implementing them in their daily businesses. The following figure shows the highlights in the history of blockchain:

What this book covers

The book's goal is to illustrate the capabilities of the blockchain and show how these can be applied across the Oracle Red Stack. The book will introduce concepts and technologies that will allow you to implement your own blockchain in an Oracle environment. It will not go into the technical details of implementing and setting up your own private blockchain, but it will touch upon the basics. The book also covers five major industries, and it will provide examples of how the blockchain is used for projects in these industries. It will also help guide you as to where more information can be found, as a single volume can't possibly cover every aspect of the technology behind blockchain.

The book has been divided into four parts as follows:

  • Part I covers the implications of the blockchain across industries that use Oracle and serve as high-level overviews of what is to follow. The chapters in Part I are for people who want to learn about the key concepts of the blockchain, how it affects current Oracle projects, and which industries will benefit the most from implementing the blockchain.
  • Part II addresses the core blockchain concepts and terminology in detail. By the time you read through the chapters in Part II, you will have a solid understanding of the technology behind blockchain.
  • Part III covers the use of blockchain as a replacement for tradition cross-organizational (B2B) applications by helping you to set up and run your own consortium/private blockchain.
  • Part IV describes use cases across five major industries. The last chapter of this part will address future industry directions.

The following is a more detailed explanation of each chapter in each of these parts.

Part I: Implications of Blockchain

Chapter 1, An Introduction to the Blockchain, serves as an overview of the ideas and terminology that you'll need to know to work with blockchain, and it also introduces common characteristics of working with blockchain.

Chapter 2, How Blockchain Will Disrupt Your Organization, is an overview of the affects the blockchain can have on your daily workload and the customer projects in which you're involved.

 

Part II: Blockchain Core Concepts and Terminology

Chapter 3, Blockchain 101 - Assets, Transactions, and Hashes, covers the concepts of hashing, blocks, (distributed) blockchains, and the mining process.

Chapter 4, Blockchain 101 - Blocks, Chains, and Consensus, builds on the previous chapter and continues exposing the technical details of different kind of assets, how transactions work, and how consensus is reached among entities in a blockchain.

Chapter 5, Blockchain 101 - Security, Privacy, and Smart Contracts, shows that with blockchain, trust is everything. It also talks about how to know that your assets in a blockchain are secure. In addition to security, it covers how blockchain protects your privacy. Finally, this chapter covers smart contracts for conditional transactions.

Chapter 6, Understanding the Blockchain Data Flowtakes a look at how the discussed technical aspects of blockchain come together. Running through the flow of a few transactions helps to make sense off it all.

Chapter 7, Public Versus Private Blockchains and their Providers, discusses the exact differences between public and private/consortium blockchains. It is important to know that you don't have to build the blockchain yourself—there are plenty of providers.

Part III: Implementing a Permissioned Blockchain

Chapter 8, Ethereum Versus Hyperledger, covers two major private blockchains that you can run yourselves: Ethereum and Hyperledger. Based on the story we have woven so far, you should be ready to implement your own blockchain.This chapter also details the differences between these platforms and discusses which one is more suited to implementing a consortium blockchain.

Chapter 9, Building a Next-Generation Oracle B2B Platform, takes a look at blockchain concepts and reflects on where blockchain can replace certain parts of the Oracle middleware. The chapter proposes an insurance and claim process example and shows how a traditional cross-organizational application can be rebuild using blockchain to overcome current inefficiencies.

Chapter 10, Introducing the Oracle Blockchain Cloud Service, explores Oracle's answer for running a consortium blockchain, which uses Hyperledger Fabric as its core. The chapter answers questions on Oracle's strategy and what they offer as a cloud service on top of Fabric.

 

Chapter 11, Setting Up Your Permissioned Blockchain, will walk you through the steps involved for setting up our own permissioned blockchain for our real-world use-case described in Chapter 9, Building a Next-Generation Oracle B2B Platform, now that we know what the Oracle Blockchain Cloud Service is capable of.

Chapter 12, Designing and Developing Your First Smart Contract, helps you design and develop our first smart contract that we can later deploy and test on the Oracle Blockchain Cloud Service. In the process, we will also set up a development environment.

Chapter 13, Deploying and Testing Your First Smart Contract, enables you to deploy and test our smart contract (developed based on the use-case described in Chapter 9, Building a Next-Generation Oracle B2B Platform) on the Oracle Blockchain Cloud Service and test its functions using the REST proxy.

Chapter 14, Configuring, Extending and Monitoring Your Network, (the last implementation chapter) helps extend our blockchain network we have set up in Chapter 10, Introducing the Oracle Blockchain Cloud Service, by adding an external Hyperledger Fabric participant. This new member organizations will join the existing network and install the same smart contract.

Part IV: Real-World Industry Case Studies

Chapter 15, Blockchain Across the Financial Services Industry, explores real-word use/study cases in the financial services industry. We look at what the impact of blockchain is on this industry, and which day-to-day operations are already being transformed.

Chapter 16, Blockchain Across the Transportation Industry, covers real-world examples in the transportation industry, what is the impact of blockchain, and why is it a viable technology for this industry. We explore how blockchain has transformed freight/fleet tracking and international shipping (supply chain).

Chapter 17, Blockchain Across the Healthcare Industry, provides insights into what types of healthcare use-cases work great when running on a blockchain; think about secure electronic patient records, drug supply chain, fraud detection, and advanced clinical trials.

Chapter 18, Future Industry and Technology Directions, finally, looks at future directions of blockchain across other industries, such as energy and agriculture, and why it have taken longer for these industries to transform. We also look at the future of the blockchain technology itself in the next 5 years.

 

How I have approached this book

The approach I have adopted in this book is worth explaining. If you read the section about the target audience, you’ll note that I'm not only aiming at the developer community, but at a wider customer audience that uses Oracle. To help me do this, I have set up some parameters to help you understand why things have been done a particular way. Note the following:

  1. The book is split into multiple parts: Part I serves as an management overview of the blockchain. Part II goes into greater detail about blockchain core concepts and terminology. Part III addresses how to implement a permissioned blockchain. Finally, Part IV provides practical examples of blockchain implementations across several industries. You can read the parts as you wish in order to get the most value out of the book in the time you have available.
  2. I have dedicated Part III of this book to developers implementing blockchain using the Oracle Blockchain Cloud Service. In this part, we go through the setup and running of a blockchain on the Oracle Cloud in great detail, but the smart contract code can also be deployed on other vendors.
  3. I have tried to build the examples around plausible ideas to which anyone can relate. To achieve this, I have drawn on the idea of implementing a blockchain in projects on which I have previously worked professionally.
  4. I have endeavored to convey the ideas and concepts in a way that places best practice over being a purist.
  5. I have tried not to get caught up in any unnecessary complexities that can arise in order to ensure everybody understands the flow of data within a blockchain. All of the examples should work from your home or work computer without needing to speak with your internet provider or network manager about IP addresses.
  6. The book uses tools that the entire target audience can use and understand—"nice" software and tools are not necessarily used in this book. The software and tools that are discussed represent those that are most popular and commonly used.

Who this book is for

This book seeks to support a broad range of readers, from line-of-business managers to software architects and developers. The first two chapters are especially useful for individuals who want to know what might be the effects of the blockchain on their business. Besides the high-level overview at the start, the book covers technical aspects of the blockchain such as the building blocks of a typical blockchain network.

 

 

 

 

Together, we will explore the impact of adding a blockchain to your current IT architecture. Finally, this book is intended for developers, and I will go through the process of setting up and running your own blockchain on the Oracle Autonomous Cloud Service and extend by connecting to an on-premises blockchain network. The implementation part is mostly done on the cloud service available on the Oracle Cloud, but the smart contract we develop can be deployed on any Hyperledger Fabric blockchain network.

To get the most out of this book

For most parts of the book, you don't need anything beyond what is mentioned in this section. It goes through all of the things that you'll need to implement a blockchain yourself. I have taken the approach of using free services and tools wherever possible. I will explain in greater detail the different tools and services throughout the book, but let's start by introducing what is needed at minimum:

  • For implementing a blockchain smart contract, we will use software from Hyperledger Fabric (https://www.hyperledger.org/projects/fabric).
  • Our blockchain will run on Oracle Autonomous Blockchain Cloud Service, but you can also run the Fabric blockchain on-premises using Docker images. To run on-premises, you need to download and install the pre-requirements (https://hyperledger-fabric.readthedocs.io/en/release-1.1/install.html).
  • Oracle Cloud Account: A trial of the Blockchain Cloud Service will be sufficient for most things (as long as you have try running the blockchain within the trial period).
  • We also make use of Postman (https://www.getpostman.com) as a tool to talk with the APIs supplied by the blockchain software. Postman is a free download.

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub athttps://github.com/packtpublishing/blockchain-across-oracle. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://www.packtpub.com/sites/default/files/downloads/9781788474290_ColorImages.pdf.

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Mount the downloaded WebStorm-10*.dmg disk image file as another disk in your system."

A block of code is set as follows:

func main() {
  err := shim.Start(new(InsuranceChaincode))
  if err != nil {
    fmt.Printf("Error starting chaincode - %s", err)
  }
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

[default]
exten => s,1,Dial(Zap/1|30)
exten => s,2,Voicemail(u100)
exten => s,102,Voicemail(b100)
exten => i,1,Voicemail(s0)

Any command-line input or output is written as follows:

$> curl -sSL https://goo.gl/6wtTN5 | bash -s 1.1.0
$> sudo dpkg -i ~/Downloads/code_*.deb; sudo apt -f install -y

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Select System info from the Administration panel."

Note

Warnings or important notes appear like this.

Note

Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packt.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

 

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packt.com.