Blockchain across Oracle - Robert van Molken - E-Book

Blockchain across Oracle E-Book

Robert van Molken

0,0
31,19 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

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.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB

Seitenzahl: 678

Veröffentlichungsjahr: 2018

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Blockchain across Oracle

 

 

 

 

 

 

 

 

 

 

 

 

Understand the details and implications of the Blockchain for Oracle developers and customers

 

 

 

 

 

 

 

 

 

 

 

 

Robert van Mölken

 

 

 

 

 

 

 

 

 

 

 

BIRMINGHAM - MUMBAI

Blockchain across Oracle

Copyright © 2018 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

 

Acquisition Editor: Dominic ShakeshaftProject Editor: Kishor RitContent Development Editor: Gary SchwartzTechnical Editor: Saby D'silva, Gaurav Gavas Proofreader: Safis EditingIndexer: Pratik ShirodkarGraphics: Tom ScariaProduction Coordinator: Sandip Tadge

 

First published: November 2018

Production reference: 2211118

 

Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK.

ISBN 978-1-78847-429-0

www.packtpub.com

 
mapt.io

Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.

Why subscribe?

Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals

Improve your learning with Skill Plans built especially for you

Get a free eBook or video every month

Mapt is fully searchable

Copy and paste, print, and bookmark content

Packt.com

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.

At www.packt.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks. 

Contributors

About the author

Robert van Mölken lives in Utrecht, the Netherlands, and he studied Computer Science at the University of Applied Sciences in Utrecht and received his BCS in 2007. He started his professional career as a graphic designer and web developer, but soon shifted his focus to Fusion Middleware. Robert is now a Senior Application Integration Specialist and one of the expertise leads on Integration, Internet of Things, and cloud at AMIS with over 11 years of IT experience.

Robert's transition from building service-oriented business processes using Fusion Middleware 12c, toward connecting the physical world with the world of IoT using Oracle Cloud offerings and open source solutions has helped him become a leader in this emerging technology. His fascination for using the latest technology led to the research of blockchain to replace the currently used B2B and B2C patterns and tooling. Besides this book, Robert is also the co-author of the first Oracle PaaS book, Implementing Oracle Integration Cloud Service, which was published by Packt in 2017.

Robert is also heavily involved in the Oracle developer community. He is an international speaker at conferences, author/blogger on the AMIS Technology blog, the Oracle Technology Network, and participates in OTN ArchBeat Podcasts. Robert is a member of the board of the Dutch Oracle User Group (nlOUG) and organizes meetups. He works closely with several Oracle Product Management teams participating in Beta programs and takes what he learns and applies it to new presentations, blog posts, and community engagement. 

Robert was awarded Oracle ACE (Acknowledged Community Expert) Associate in 2015, Oracle ACE in 2016, and Developer Champion in 2017. As his designations expanded, so have his areas of expertise.

First of all I would like to express my utmost gratitude to my family and friends who supported me in the past one and a half year it took to write this book. It has been an exciting journey with some stressful times that consumed most of my free time, but in the end it was worth it. I also would like to thank the people who helped me over the years to shape my professional career, especially my colleagues at AMIS that gave me the chances to excel in my career. Without you I wouldn't came this far. Lastly, I would like to thank the Product Management team at Oracle responsible for the Blockchain Cloud Service to have given me early access to the software to be able to write the implementation chapters.

About the reviewers

Sven Bernhardt is a Software Architect with over 10 years of experience in planning, designing, implementing, and deploying individual software solutions for different customers from different industries. From a technology perspective, Sven is an Oracle technology expert and has meaningful knowledge about leading open source technologies. He also has significant experience as Technology Coach and Trainer.

Sven works as Senior Solution Architect for OPITZ CONSULTING Deutschland GmbH, a German Oracle Platinum Partner. He's one of the company's lead architects, who follows his passion for designing and building future-oriented, robust enterprise applications based on pioneering technologies and new, innovative concepts. In his role, Sven is involved in diverse projects dealing with challenges in the area of modern software architectures and digital transformation. In this area, he's always looking for solutions where existing and new approaches can be meaningfully combined with each other—since in most of the cases, software projects don't start on a greenfield.

Besides his work as a Software Architect in customer projects, Sven is a frequent speaker at numerous IT conferences and an author of blogs as well as articles in diverse magazines. In addition, he's an active member of the Oracle Developer Community and currently has the status of an Oracle ACE.

Arturo Viveros is an outstanding Mexican IT Professional currently based in Oslo, Norway. He is a certified Cloud Integration Architect with over 12 years of experience in the design, development, and delivery of software for a variety of customers and industries. Arturo is also a Developer Champion, Oracle ACE, and a published technology writer both in English and in Spanish; he also strives constantly to be involved with and support developer communities/user groups that focus on technologies such as Oracle, Java, DevOps, cloud, software architecture, open source, and blockchain. In his spare time, Arturo enjoys family life, reading, hiking, traveling, playing guitar, and practicing sports such as tennis, football, and skiing.

 

 

Thanks to Robert and the Packt crew for having me be a part of this awesome project; special thanks to my employer Sysco for supporting this kind of endeavor and particularly to my department manager Jon Petter who is always in my corner. As always, all my efforts are dedicated to my lovely wife Jessica and my beautiful family Luly, Arturo, and Dany.

Packt is searching for authors like you

If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.

Table of Contents

Title Page

Copyright and Credits

Blockchain across Oracle

Packt Upsell

Why subscribe?

Packt.com

Contributors

About the author

About the reviewers

Packt is searching for authors like you

Preface

History of Blockchain

What this book covers

Part I: Implications of Blockchain

Part II: Blockchain Core Concepts and Terminology

Part III: Implementing a Permissioned Blockchain

Part IV: Real-World Industry Case Studies

How I have approached this book

Who this book is for

To get the most out of this book

Download the example code files

Download the color images

Conventions used

Get in touch

Reviews

Part I

An Introduction to the Blockchain

What is a blockchain?

How does a blockchain work?

What is the architecture behind the blockchain?

The data layer

Data model, transactions, and chain structure

Cryptographic protocol, hash functions, and digital signatures

Merkle tree

Participants

The network layer

Peer-to-peer network and broadcast of data

Relay network

Local validation

The consensus layer

Sophisticated consensus mechanisms

Lightweight consensus mechanisms

Permissioned consensus

Sharding consensus

The incentive layer

Rewards distribution and transaction fees

The application layer

Digital ledger

Smart contract

RESTful and command-line APIs

Decentralized applications

Differences between public and private blockchains

How secure and private are blockchains?

What kind of applications can I run on blockchains?

Other decentralized applications

Summary

How Blockchain Will Disrupt Your Organization

Why is blockchain a disruptive technology?

What is Oracle's strategy?

What is the blockchain cloud service?

What are Oracle's competitors doing?

What are the disruptive effects on individuals?

Database administrator

Application integration developer

Frontend developer

Summary

Part II

Blockchain 101 - Assets, Transactions, and Hashes

Assets

Transactions

Managed by a peer-to-peer network

What does a transaction look like?

How can you send a transaction?

Hashes

The types of hash functions used by blockchain

Summary

Blockchain 101 - Blocks, Chains, and Consensus

Blocks

Breaking down blocks

Hashing a block

Chains

Blockchain

Distributed and decentralized

Forks

Orphaned and stale blocks

Soft fork versus hard fork

Sidechains

The underlying mechanism

Consensus

Methods of reaching consensus

Proof-of-work

Practical byzantine fault tolerance

Proof-of-stake

Delegated proof-of-stake

Summary

Blockchain 101 - Security, Privacy, and Smart Contracts

How secure is the blockchain?

Public versus private blockchains

Unexpected security risks

Security starts at the network architecture level

Importance of the consensus protocol

Bugs in the blockchain code

Manage asset security

Difference between hot and cold wallets

Software wallets (desktop and mobile)

Online or web wallets

Physical or paper wallets

Hardware wallets

Access control

Reversibility of transactions

Maintaining privacy on the blockchain

Maintaining today's level of privacy

Secure multi-party computation

Zero-knowledge proofs

Permissioned blockchain

Making sense of smart contracts

What is a smart contract?

How smart contracts work

Examples of smart contracts

Code example of a smart contract

Summary

Understanding the Blockchain Data Flow

Overview of the blockchain flow

Basic flow of a transaction

Architecture layers

Architectural thoughts and considerations

Submitting transactions

Knowing the data structure

Broadcasting and verifying data

Combining TXs in a block structure

Validating and verifying a block

Summary

Public Versus Permissioned Blockchains and their Providers

What types of blockchain currently exist?

Public blockchains

Advantages

Challenges

Consortium blockchain

Advantages

Challenges

Private blockchains

Advantages

Challenges

Public blockchain providers

Ethereum

NEO

IPFS

Blockstack

Private/consortium blockchain providers

Hyperledger Fabric

Oracle blockchain cloud service

R3/Corda

MultiChain

Summary

Part III

Ethereum Versus Hyperledger

Two leading platform frameworks

Ethereum

Hyperledger fabric

Mode of operation and participation

Ethereum

Hyperledger fabric

Consensus algorithm

Ethereum

Hyperledger fabric

Built-in cryptocurrency

Ethereum

Hyperledger Fabric

Smart contracts

Ethereum

Hyperledger Fabric

How to develop a smart contract

Ethereum 

Hyperledger fabric

Where do your smart contracts run?

Ethereum

Hyperledger Fabric

Summary

Building a Next-Generation Oracle B2B Platform

Introducing the business case

Traditional cross-organizational applications

Introducing Oracle B2B

Introducing Oracle SOA Suite

Implementing the business case on a B2B network

What is the common application architecture?

How do partners interact with each other?

In-depth look at interactions

New accident report

Insurance claim request

Repair order request

Five implementation challenges and/or pitfalls

Reaching a consensus about the interactions

Configuring CPAs can be a redundant activity

Partners need to implement the same business rules

Are all rules implemented?

Room for interpretation

Use of different programming languages

Different approaches to processing and storing data

Offline reconciliation after uncompleted transactions

Blockchain can solve these challenges

How does it solve the traditional B2B challenges?

Taking out the middleman

Messages are distributed to partners in the blockchain

Configuring redundant CPAs is a thing of the past

Solves offline reconciliation between partners

The impact it has on the TTP

Defining interactions is easier and more democratic

One smart contract to rule them all

Data is stored in the same way on each network peer

Implementing the business case on a blockchain

What is the blockchain platform architecture?

Smart contract interactions

In-depth look into interactions

New accident report

Insurance claim request

Repair order request

Blockchain – the next-generation B2B platform

Summary

Introducing the Oracle Blockchain Cloud Service

Why did Oracle pick Hyperledger Fabric?

What component roles does Fabric fulfil?

Membership services

Consensus services

The peer and ordering service architecture

The distributed ledger and world state

Channels for limiting access and visibility

Peer gossip data dissemination protocol

Consensus protocol

Endorsement

Ordering

Validation (commitment)

Chaincode services

Why did Oracle build a managed platform?

What component roles does OBCS fulfill?

Infrastructure and PaaS services

Blockchain nodes and containers

OBCS peer node

OBCS orderer node

OBCS MSP

Data services

OBCS world state and history databases

OBCS – object store integration

Administration services

REST gateway (APIs)

Summary

Setting Up Your Permissioned Blockchain

Summarizing the problem

Introducing the solution

Provisioning the environments

First look at the administrative console

Blockchain Dashboard

Blockchain Network

Blockchain Nodes

Blockchain Channels

Blockchain Chaincodes

Adding the member organizations

Export member organization's certificates

Export member organization's peer nodes

Import certificates of member organizations

Import peer nodes of member organizations

Export orderer settings from founder

Import orderer settings at member organizations

Setting up a private channel

Create a new channel as the founder

Adding member peers to the channel

Summary

Designing and Developing Your First Smart Contract

The proposed application

Model-first design approach

Designing the participants and base assets

Designing the accident assets and transactions

Designing the repair assets and transactions

Designing the insurance assets and transactions

Setting up the necessary development tools

Installing cURL

Installing Docker and Docker Compose

Installing the Go programming language

Step 1 – Installing Go

Step 2 – Setting environment paths

Step 3 – Setting up your Go workspace

Downloading platform-specific binaries

Installing Visual Studio Code (IDE)

Programming the smart contract

Setting up a workspace in VSCode

Installing missing Go packages and commands

Programming the actual chaincode

Programming the initial chaincode skeleton

Adding the data model objects

Programming the ReportAccident transaction

Summary

Deploying and Testing Your First Smart Contract

Deploying your smart contract 

Installing chaincode on the founder's peers

Activating the chaincode on a channel

Installing a new version of our chaincode

Installing chaincode on member organizations

Exposing smart contracts using the REST proxy

Exposing chaincode using the Advanced method

Exposing chaincode using the Quick method

Testing a smart contract using a REST client

Installing a client to call the REST proxy's API

Importing and testing chaincode API requests

Available REST proxy APIs

Getting the version of the OBCS API

Overview of chaincode interactions

Setting up all of the required demo assets

Reading asset data to check the current values

Reporting a new accident

Updating the accident report

Issuing a new insurance policy

Requesting a quote for vehicle repairs

Offering a repair quote with estimates

Sending an insurance claim to the driver at fault

Monitoring executed transactions

Summary

Configuring, Extending, and Monitoring Your Network

Extending your blockchain network

Creating a certificate file as a Fabric participant

Importing the certificates file as founder

Adding a member to an existing channel as founder

Adding a member to chaincode endorsers as founder

Adding yourself to the network as a Fabric participant

Retrieving the orderer settings file

Composing the orderer certificate PEM file

Adding the Fabric participant to the network

Configuring your blockchain network

Ordering service

Changing the settings of the ordering service

Changing the configuration of the orderer node

CA node

Peer nodes

Gossip attributes

Election attributes

Event service attributes

Chaincode attributes

Monitoring your blockchain network

Checking the log files of nodes

Things we can/can't monitor from the platform's perspective

Integrating applications using Fabric SDK

Summary

Part IV

Blockchain Across the Financial Services Industry

Impact on financial services

The impact of blockchain on the financial services versus financial markets

International trade finance

Current state and inefficiencies

Cross-border payments

Current state and inefficiencies

Use case – ATM and payment gateway

Cryptocurrency ATM

PayIOTA – Payment gateway

Use case – MonetaGo – bill discounting

Summary

Blockchain Across the Transportation Industry

Impact on transportation and logistics

Freight/fleet tracking

Current state and inefficiencies

Performance contracts

Current state and inefficiencies

Use case – SkyCell (refrigerated air freight)

Use case – TradeLens (shipping solution)

Use case – BiTA (Transport Alliance)

Summary

Blockchain Across the Healthcare Industry

Impact on healthcare

Drug traceability and anti-counterfeiting

Current state and inefficiencies

Cybersecurity and data security 

Current state and inefficiencies

Use case – MedicalChain (health records)

Current state and inefficiencies of health records

Key features of the platform

Dual-blockchain system

Multiple participants and permissions

Data is cryptographically encrypted

Platform services

Use case – Nano Vision (cure development)

Current inefficiencies of medical research

The Nano Sense chip

Nano Cure Chain and marketplace

The AI/ML inference engine

Initial health threat targets

Summary

Future Industry and Technology Directions

Future industry directions

Energy industry

Peer-to-peer trading and microgrids

Current state and inefficiencies

Food and agriculture industry

Current state and inefficiencies

Notable platforms to watch

Agriledger/AgUnity

Foodshed

Provenance

Future technology directions

Lightning Network

Raiden Network

IOTA Tangle network

How do I remain current on blockchain developments?

Summary

Other Books You May Enjoy

Leave a review - let other readers know what you think

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.

A private blockchain performs the following:Ensuring that activity on the blockchain is only visible to chosen participantsIntroducing control over permissions to manage which transactions are allowedEnabling 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 Flow, takes 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:

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.

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.

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.

I have endeavored to convey the ideas and concepts in a way that places best practice over being a purist.

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.

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:

Log in or register at

www.packt.com

.

Select the

SUPPORT

tab.

Click on

Code Downloads & Errata

.

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."

Warnings or important notes appear like this.
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.

Part I

Implications of the Blockchain

An Introduction to the Blockchain

This chapter serves as an introduction to the blockchain and its underlying technology. It requires minimal technical knowledge. It summarizes the content that you can expect to encounter in the upcoming chapters that go into greater depth. In this chapter, I will explain the blockchain technology is on a more architectural level, rather than describing every detail of each component or layer.

When you ask 10 people what they think the term blockchain means, you might not be surprised to get 10 different and conflicting answers, as use of the term blockchain can be a bit confusing. A lot of people connect it to Bitcoin (https://bitcoin.org/) or other virtual (crypto) currencies. Some people talk about the Ethereum Application Platform (https://ethereum.org), some about smart contracts (executable code), but most of the time, blockchain is explained as a distributed, shared ledger.

In essence, a blockchain is a system of maintaining digitally-distributed ledgers in a way that allows individuals who do not fully trust each other to agree on updates to the shared ledger. Blockchains use peer-to-peer protocols rather than a central authority or third party to distribute and verify transactions between entities. There is no single point of failure, so entities can appear, disappear, or malfunction without affecting the group.

In this chapter, you will learn about the following topics:

What is a blockchain and how does it work?

What is the architecture behind the 

blockchain

 ecosystem?

What are the differences between public and private blockchains?

How secure is a blockchain, and what about an 

individual's 

privacy?

What kind of applications can run on a blockchain?

What is a blockchain?

When talking about blockchains, we always refer to it as a distributed ledger technology (DLT) that established the underlying, open source technology behind Bitcoin. A blockchain is a digital system of recording transactions of assets in a list that is replicated across available nodes in a network, rather than being stored in a central data store, as is the case with traditional databases.

In a distributed ledger such as a blockchain, the data is distributed to all nodes in a trustless manner (meaning without a trusted third party such as VISA, MasterCard, or your bank) using a peer-to-peer protocol in near real time. Each node individually processes and verifies every transaction redundantly, bundles the verified transactions into a block, and broadcasts them to all other nodes in the network. Through a consensus mechanism, the block of transactions is validated by other nodes in which the majority has to approve the block before it becomes final and is added to the blockchain. The blockchain uses a combination of digital signatures and cryptography to prove your identity and authenticity and to enforce read/write and execute permissions (access rights). This makes it possible to permit write access for certain participants and read access to other participants, or even to a wider audience; that is, everybody.

If you loosely compare a blockchain to a traditional database, a blockchain is a system that contains an ordinary database and some extra software that corroborates that submitted records conform to previously agreed-upon rules before adding the new records to the database. This extra software listens and broadcasts new records to all nodes, or peers, participating in the network, ensuring that each peer has the same data in its database. The following diagram is an overview of the capabilities that make up blockchain technology:

The major technologies used by the blockchain are divided into five groups, each representing a different layer in the architecture

Technically, a blockchain is a new method of data storage. It is actually just a file with a predefined data structure (that is, how the data is logically put together). It can be compared with other data structures, such as relational databases (tables, columns, and rows), XML files, comma-separated values (csv), Excel database files, and binary files (images and videos). An analogy that I often use is that blocks in a chain are the same as pages in a book. Each page in a book, just like this one, has a bunch of text structured in paragraphs, and information about its context (also called metadata), such as the chapter number, chapter title, and page number. Similarly, in a blockchain, each block consists of a collection of content, for example, the list of transactions, and a header, which contains technical information about the block, a reference to the previous block, and a digital signature (hash) of the data contained in the block.

A blockchain, where blocks are linked to each other to make a chain, is analogous to pages in a book. Pages use sequential numbering that makes it easy to know their order. If pages were to be pulled out of the book and thrown into a pile, it would be easy to put them back in order. A blockchain, though, is cleverer. The following diagram shows that each block links back to the previous block via the block's fingerprint. The fingerprint is determined by the individual block's content and the fingerprint of the previous block, as demonstrated in the following diagram:

Each block in the chain links back to its previous block, like page numbers in a book

In a book, the ordering of pages is implicitly built on a page whose number is one less; that is, page 13 follows page 12 (13-1), whereas blocks are represented by fingerprints or hashes that are built upon each other. For example, block 3 with hash 8ec6cc0 is determined by hashing its data together with hash 9a59c5f of the previous block. By using a fingerprint that is determined based on the previous one, it can be used for validating the internal consistency of the data.

This scenario is shown in the following screenshot:

Two blocks are linked together by their hashed fingerprints. The fingerprint of block #2 is based on its data and the fingerprint of block #1.

You can check whether the data is consistent within a block by generating the fingerprint yourself and comparing it to the one that is part of the block's header. If someone wants to change the information stored in one of the earlier blocks, they need to regenerate all of the fingerprints from that point until the end of the chain. However, the blockchain will appear to be altered, and it is instantly noticeable by others. Depending on the consensus method used, the creation of these fingerprints can be a very difficult and slow process, which makes it very problematic to rewrite the blockchain. Furthermore, the number of blocks already present in the blockchain can be huge, for example, for Bitcoin (June 3, 2018: 512253 blocks with a size of 156 GB). The following screenshot shows that when changing the data, the hash is also changed and the block becomes invalid:

The data in block #2 is changed, and it generates a different fingerprint than before

How does a blockchain work?

The technology (that is, the architecture, mechanisms, security, and so forth) behind the blockchain can be seen both as the backbone for future accounting and as an engine for a modern message transport system. So how does a blockchain actually work during runtime?

The following diagram shows how blockchain systems must follow a specific flow of actions in order to consistently maintain a distributed ledger of facts (a key-value database with the current state of assets) and a separate history of their updates (distributed transaction log). The transactions that you submit are stored and verified without the involvement of a governing central authority using advanced mathematics and computer science, that is, cryptographic hash functions.

The blockchain not only secures these transactions but also protects their integrity (and anonymity). This demonstrated in the following diagram:

The flow that a transaction follows from submission to being verified by the majority of networks

Now let's take a closer look at the preceding diagram that describes the flow of transactions in a blockchain. When you want to exchange data with someone else on the blockchain, you do this by submitting a transaction in which you propose your changes. A Transaction usually contains the context (action) in which it should be executed and any asset that can be described in digital form, such as currency, contracts, and incident and medical records. The Data structure of proposed changes to an asset can be both structured and unstructured, but often it is represented as JSON (JavaScript Object Notation), which is a human-readable text format for data objects.

A typical blockchain provides client APIs to interact with the transaction, but generally you would use a web application that calls the API with which you would submit your transaction to one of the active nodes (peers) in the network.

Depending on the network's capabilities, the transaction is either locally validated or directly broadcast to all active nodes in the network using the peer-to-peer network (P2P). When locally validated, your transaction is only broadcast after validation, based on a set of network rules. Each node that receives your transaction will, depending on network rules, either verify it instantly or transcribe it into a secure record and place it in a queue of pending transactions. In this case, nodes, in other words, the participating computers or servers in the network, verify whether your transaction is valid based on a set of rules to which the network has agreed.

For example, your transaction can trigger participating nodes to execute business logic (such as a smart contract) and follow the consensus protocol to verify the results. Some consensus protocols require you to pay a transaction fee to get your transaction verified. The amount you pay is part of your transaction, and it determines the time it takes to get verified. Some nodes that create blocks only verify transactions that have a higher reward.

Depending on the rules defined by the network's protocol, validating nodes combine transactions into a block and digitally fingerprint the result so that they can be validated by other nodes in the network. Just like transactions, blocks are broadcast to all active nodes using the peer-to-peer network. When consensus is reached, depending on the network' rules, participating nodes either batch the transactions and store the results as a cryptographically secured, immutable data block, or they take the approved block and append it to their ledger. Consensus protocols may include a reward system for nodes that create a block or require you to pay a transaction fee to distribute the currency to the rightful recipient.

Following the consensus mechanisms and network rules, it may take several blocks until you can be certain that your transaction is verified and not part of an orphaned chain. It is possible for multiple peers to create a block at the same time or just a few seconds apart from each other. This can produce a fork in the chain. Both blocks are initially accepted by the majority of the network, creating two chains. For any block of transactions, however, there is only one way to the genesis block (that is, first created in the chain), and blocks that are part of the smaller chain are eventually rejected.

In the following diagram, you can see that the longest chain survives and that smaller chains are rejected:

The genesis block is shown in green. The main chain is shown in black and the orphaned/rejected chain appears in red.

Those transactions that are part of the rejected block(s) are added back to the pool of queued transactions and will eventually be included in another block. With blockchains that use an incentive model, the reward that someone receives for solving an orphaned block is practically lost.

What is the architecture behind the blockchain?

As I mentioned earlier, the blockchain is not just a distributed database; it includes advanced software and security techniques to create a network of nodes (peers) that are always in sync, where each node validates and verifies transactions and blocks redundantly in order to reach consensus, and it provides a platform to run decentralized applications. To achieve this, the blockchain or digital ledger technology is built upon a layered architecture. In most cases, this contains four or five layers, namely the data layer, network layer, consensus layer, incentive layer, and application layer.

The data layer

At the bottom layer of the stack is the data layer, which deals with the data structure and the physical storage of data in the blockchain.

The following diagram shows the common capabilities that are part of this layer:

The capabilities of the data layer, such as cryptographic protocols, hash functions, digital signatures, and others

The data layer includes capabilities that describe the transaction and data model, the type of participants that can connect and use the blockchain (that is, the permissions model), the structure of the chain and its blocks, and the cryptography and hash functions to secure data and generate digital signatures.

Data model, transactions, and chain structure

The first two capabilities, data model and transactions, are closely related to each other. This is where the data model describes the type of assets available on the network and its data structure. Transactions trigger actions to modify asset data and transact assets between participants. The data model can be very simple and contain just one asset, such as a cryptocurrency like Bitcoin, or a more complex model with multiple assets that can even have relationships between them. The same applies to the transactions available on the network.

An asset(s) can be created or referenced in a transaction, which in essence transfers the asset(s) between two parties who wish to exchange the data, for example, processing a payment between two parties, placing an order on an online store, registering an automobile, tracking diamonds around the world, or sharing your digital identity. More background will be provided on these two capabilities in Chapter 3, Blockchain 101 - Assets, Transactions, and Hashes.

The chain structure is also related to transaction data. It describes the data structure in which individual transactions are combined into a block and how these blocks are chained to each other. The structure is usually different across blockchain platforms, since it is used to run on a specific platform. When comparing blockchains, you will notice that more advanced platforms have more complex structures; that is, they contain more information. For reference, the minimum size of a block on the Bitcoin blockchain is around 100 bytes, whereas the minimum size of a block on the Ethereum blockchain is around 525 bytes. The chain structure also describes the maximum size of a block, how blocks are chained together, and how incentives are paid out to participants. More information will be provided about this capability in Chapter 4, Blockchain 101 - Blocks, Chains, and Consensus.

Cryptographic protocol, hash functions, and digital signatures

These three capabilities—cryptographic protocols, hash functions, and digital signatures—secure and digitally sign the data in the blockchain. A cryptographic protocol performs a security-related function by applying cryptographic methods, and it describes the algorithms such as hash functions should be used. The protocol used by a blockchain usually incorporates at least these aspects:

Entity authentication

Public/private key cryptography

Secured application-level data transport

Fingerprint/signature generation

Data encryption methods

To prove that the data on the blockchain has not been tampered with, transactions, blocks, and participating nodes are signed by generating digital signatures (or fingerprints) on the content of the data using hash functions. A hash function takes any input data and produces an output, which, based on the algorithm in use, has a different fixed length. The output of a hash function is always a string, for example, an SHA256 hash is a 256-bit (32 byte) string of the input data. However, t