Nitesh Thakrar, IT Software Architect,
IBM @niteshpthakrar and Benjamin Fuentes, Software
Architect and Developer, IBM, @benji_fuentes
This workshop will be in 3 stages:
1. A brief presentation on Blockchain and why
Hyperledger
2. A demo use case to explain the architecture and the code behind the demo
3. Finally, the attendees will create their own blockchain application on the cloud. The hands-on
will also invite them to use the appropriate APIs and event update a smart contract.Majority of
the time will be in doing the hands-on (step 3) so that the attendees are able to continue
developing their application after the event.Requirements: Attendees will need to bring their
laptops and be able to connect to wifi.
2. @benji_fuentes @niteshpthakrar#Devoxx #Hyperledger
https://ibm.box.com/v/devoxxUS
For Part 1:
Bluemix account: https://console.ng.bluemix.net/registration
Docker: https://docs.docker.com/engine/installation/#platform-support-
matrix
Docker compose: https://docs.docker.com/compose/install
Postman: https://www.getpostman.com
For Part 2 & 3:
Java JDK 8:
http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-
138363.html
Eclipse: https://www.eclipse.org/downloads
Eclipse Maven plugin: (you can use the one embedded on Eclipse)
Eclipse Gradle plugin: (depending on the version, it can be already
included or https://projects.eclipse.org/projects/tools.buildship)
3. #Devoxx #Hyperledger @benji_fuentes @niteshpthakrar
Agenda
• First part (1H)
Introduction to Blockchain and Hyperledger (30min)
Use Blockchain As a Service on Bluemix Cloud and start a network
locally (30min)
• Pause (15min)
• Second part (45min)
Create a smart contract (in Java or Go)
• Pause (15min)
• Third part (45min)
Develop the client side (HTTP API or JAVA/HFC SDK)
5. #Devoxx #Hyperledger @benji_fuentes @niteshpthakrar
Blockchain - Introduction
A blockchain is a distributed database,
introduced by Bitcoin (2008) on Satoshi Nakamoto’s
white paper, that maintains a continuously-
growing list of data records that each refer
to previous items on this list and is thus
hardened against tampering and revision
Distributed systems answer to a problem called
Byzantine Generals’ Problem described by Leslie
Lamport (1982)
As today, blockchains can be used to write distributed
applications named “smart contract” or “chaincode”
Mesopotamian
ledger
Byzantine Generals’
Problem
6. #Devoxx #Hyperledger @benji_fuentes @niteshpthakrar
Blockchain - Hyperledger
Hyperledger (or Hyperledger project) is a cross-
industry collaborative effort to create blockchain-based
open standard for distributed ledgers for globally
conducted business transactions under the Linux
Foundation
The project aims to create an open-standard,
public, decentralised public ledger based on
blockchain technology to advance worldwide
business transaction processing in terms of cost-
effectiveness, speed and traceability
More than 100 members
Fabric
Sawtooth Lake
7. #Devoxx #Hyperledger @benji_fuentes @niteshpthakrar
Blockchain -
Blockchain as a Service (on Bluemix Cloud)
IBM is the only provider that gives you access to a
permissioned Blockchain as a Service on its catalog of
services
9. #Devoxx #Hyperledger @benji_fuentes @niteshpthakrar
Fabric - Actors
The business user, operating in a business network. This role interacts with the Blockchain using
an application. They are not aware of the Blockchain.
The overall authority in a business network. Specifically, regulators may require broad access to
the ledger’s contents.
The developer of applications and smart contracts that interact with the Blockchain and are used
by Blockchain users.
Defines, creates, manages and monitors the Blockchain network. Each business in the network
has a Blockchain Network operator.
Manages the different types of certificates required to run a permissioned Blockchain.
An existing computer system which may be used by the Blockchain to augment processing. This
system may also need to initiate requests into the Blockchain.
An existing data system which may provide data to influence the behavior of smart contracts.
Blockchain
User
Blockchain
Developer
Certificate
Authority
Blockchain
Regulator
Traditional
Processing
Platform
Traditional
Data
Sources
Blockchain
Network
Operator
U
R
D
O
ü
10. #Devoxx #Hyperledger @benji_fuentes @niteshpthakrar
Fabric - Components
Membership
Smart Contract
Systems
Management
Events
Consensus
Network
Wallet
Ledger Contains the current World State of the ledger and a Blockchain of transaction
invocations
f(abc); Encapsulates business network transactions into logic code. Transaction invocations result in
gets and sets of ledger state
…
E T
A collection of network data and processing peers forming a Blockchain network.
Responsible for maintaining a consistently replicated ledger
Manages identity and transaction certificates, as well as other aspects of permissioned
access
Creates notifications of significant operations on the Blockchain (e.g. a new block), as well as
notifications related to smart contracts. Does not include event distribution.
Provides the ability to create, change and monitor Blockchain components
Securely manages a user’s security credentials
i
Responsible for integrating Blockchain bi-directionally with external systems. Not
part of Blockchain, but used with it.
Systems
Integration
11. #Devoxx #Hyperledger @benji_fuentes @niteshpthakrar
Fabric - Interactions
Protocols :
•SDK : use gRPC to communicate with a blockchain
peer or Certificate Authority. Maintain the user’s key
wallet
•HTTP API : use HTTP (will be deprecated in V1.0)
Functional interaction methods:
•DEPLOY* : to deploy a chaincode
•QUERY : to retrieve data from World State
•INVOKE* : to call a chaincode method creating a
transaction
membership
keys
Consensus
Ledger
Events
Chaincode
state
peer
SDK
ECA, TCA, TLS-CA
API
Blockchain
network
(* Creates a block on the chain)
12. #Devoxx #Hyperledger @benji_fuentes @niteshpthakrar
Fabric - Architecture
1.Blockchain developer codes
Application and Smart Contract
2.He deploys the app on a server
and smart contract on a peer
using DEPLOY
3.A registered user interacts with
the app sending order
(INVOKE) or retrieving
information (QUERY)
throught the smart contract
4.Smart contract can emit an
event susbcribed by the app World/Ledger
State
Blockchain
Genesis
Block
…
Blockchain
developer
Smart
Contrac
t
Invokes/queries
on a smart contract
Develops
Application
D
SDK HTTP
txn txn txn txn txn
Block n
PEER
develops, then deploys
emits
PutState/GetState
U
Blockchain
developer
Interacts
13. #Devoxx #Hyperledger @benji_fuentes @niteshpthakrar
Think distributed and deterministic !!!
Get resources from external systems
peer
Blockchain
network
peer
peer
Ext system
Put resources to external systems
peer
Blockchain
network
peer
peer
Ext system
t1
t3
t2 1 call
1 call
1 call
14. #Devoxx #Hyperledger @benji_fuentes @niteshpthakrar
Next coming on V1.0 (March 2017?)
• Endorsement/consensus model
• Plugging external identity server
• Plugging external State DB
• Historical queries
• HTTP API deprecated, use SDK
• Chaincode upgrades
15. #Devoxx #Hyperledger @benji_fuentes @niteshpthakrar
Fabric V1.0 - Endorsement/Consensus model
Peer role has been split :
• Committer peer : commits
transactions, maintains ledger and state
• Endorsing peer: receives a transaction
proposal for endorsement, responds
granting or denying endorsement
• Ordering peer: approves the inclusion
of transaction blocks into the ledger and
communicates with peer and endorsing
peer nodes
Also a peer can now communicate via
private channels inside the network to
strenghten privacy
Different configuration options
for the ordering service include:
– SOLO
• Single node for development
– Kafka / Zookeeper
• 1:n nodes providing Crash
Fault Tolerance
• Odd number of nodes
recommended
– SBFT (future)
• 1:n nodes providing Byzantine
Fault Tolerance
Ordering-Service
OO
O O
E C
Peer types
oror
16. #Devoxx #Hyperledger @benji_fuentes @niteshpthakrar
Fabric V1.0 - Identity server
New Identity server (COP)
•make as pluggable as possible
•make it decentralized
•default implementation : CloudFlare's
PKI/TLS toolkit
•can be configured to read from an LDAP
server
•Developed in GO
•CLI commands for server and client
17. #Devoxx #Hyperledger @benji_fuentes @niteshpthakrar
Fabric V1.0 - External World State DB
•Key/value database (LevelDB)
•Document JSON database (CouchDB)
•SQL data stores (future?)
• requires schema definition
• difficult to change schema
CouchDB
Chaincode
APIs
LevelDB
Worldstate
18. #Devoxx #Hyperledger @benji_fuentes @niteshpthakrar
Fabric V1.0 - Historical queries
Simple use case :
• Show history of values for an asset X
Rich queries :
• Show value of an asset at a certain point
in time
• Show all assets having same field value
through history (example : owned by a
specific owner)
tt-1t-2
19. #Devoxx #Hyperledger @benji_fuentes @niteshpthakrar
Fabric V1.0 - HTTP deprecated, use SDK
•Do not use HTTP API anymore
•Use SDK over gRPC :
•Java
•NodeJs
•Python
20. #Devoxx #Hyperledger @benji_fuentes @niteshpthakrar
Fabric V1.0 - Chaincode upgrades
• New command UPGRADE to use
instead of redeploying another chaincode
• Chaincode will contain version number
…
Smart
Contrac
t
txn txn txn txn
Smart
Contrac
t
Application
SDK HTTP
UPGRADE
Version N+1Version N
World/Ledger
State