0% found this document useful (0 votes)
57 views58 pages

Deploy A Blockchain Web App With Hyperledger Fabric Presentation

The document discusses how to deploy a blockchain web application using Hyperledger Fabric by first providing an overview of key blockchain concepts and the architecture of Hyperledger Fabric, then explaining how to develop smart contracts and client applications that can invoke them to build decentralized applications on Hyperledger Fabric networks.

Uploaded by

Naresh S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views58 pages

Deploy A Blockchain Web App With Hyperledger Fabric Presentation

The document discusses how to deploy a blockchain web application using Hyperledger Fabric by first providing an overview of key blockchain concepts and the architecture of Hyperledger Fabric, then explaining how to develop smart contracts and client applications that can invoke them to build decentralized applications on Hyperledger Fabric networks.

Uploaded by

Naresh S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 58

Deploy a blockchain web-app with

Hyperledger Fabric

Horea Porutiu
Advisory Software Engineer, IBM
July 2019 Blockchain Explained
IBM Blockchain Platform
Blockchain Solutions
Blockchain Composed
Blockchain Architected
Blockchain Explored
Next Steps
By a show of hands…
✋🏼
1. Understands how blockchains work?

2. Know what Hyperledger Fabric is?

3. Developed a smart contract?

4. Developed a dapp?
5. Deployed a network to production?

2
What you will learn

1. Blockchain vocabulary 📖

3
What you will learn

1. Blockchain vocabulary 📖
2. A use-case of blockchain

4
What you will learn

1. Blockchain vocabulary 📖
2. A use-case of blockchain

3. Architecture behind a Hyperledger Fabric solution 🚧

5
What you will learn

1. Blockchain vocabulary 📖
2. A use-case of blockchain

3. Architecture behind a Hyperledger Fabric solution 🚧
4. Difference between the world state and the ledger 📒

6
What you will learn

1. Blockchain vocabulary 📖
2. A use-case of blockchain

3. Architecture behind a Hyperledger Fabric solution 🚧
4. Difference between the world state and the ledger 📒
5. Difference between public and private blockchains
🔓

7
What you will learn

1. Blockchain vocabulary 📖
2. A use-case of blockchain

3. Architecture behind a Hyperledger Fabric solution 🚧
4. Difference between the world state and the ledger 📒
5. Difference between public and private blockchains
🔓
6. How a client application invokes a smart contract
🤝
8
Security: Public vs. private blockchains

Public blockchains
• Bitcoin
• Users treated equally
• Identity is anonymous

9
Security: Public vs. private blockchains

Public blockchains Private blockchains


• Bitcoin • Hyperledger Fabric,
• Users treated equally Quorum
• Identity is anonymous • Network members
known, transactions can
be secret

10
Security: Public vs. private blockchains

Public blockchains Private blockchains


• Bitcoin • Hyperledger Fabric,
• Users treated equally Quorum
• Identity is anonymous • Network members
known, transactions can
be secret
• Identity management (anonymous vs. known)

11
Security: Public vs. private blockchains

Public blockchains Private blockchains


• Bitcoin • Hyperledger Fabric,
• Users treated equally Quorum
• Identity is anonymous • Network members
known, transactions can
be secret
• Identity management (anonymous vs. known)

• Most business use-cases require private, permissioned blockchains


– Network members know who they’re dealing with (KYC)

– Membership is controlled

12
A ledger often consists of two data structures

block • Blockchain
o A linked list of blocks
txn txn txn
o Each block describes a set of transactions
(e.g. the inputs to a smart contract invocation)
Blockchain o Immutable – blocks cannot be tampered

13
A ledger often consists of two data structures

block
• Blockchain
o A linked list of blocks
txn txn txn
o Each block describes a set of transactions
(e.g. the inputs to a smart contract invocation)
Blockchain o Immutable – blocks cannot be tampered

• World State
o An ordinary database (e.g. key/value store)
o Stores the combined outputs of all transactions
World state o CAN delete

14
Block detail (simplified)
Block 15 Block 16 Block 17

Block Hash: Block Hash: Block Hash:


57ec2fda71 87ea2ffe94 44bf2efe32

… Prev Block Hash:


Prev Block Hash: Prev Block Hash: …
d68b2f0a3b 57ec2fda71 87ea2ffe94

Transaction Transaction
Transaction

Transaction
Transaction
Transaction

- New blocks always added to the end

15
Block detail (simplified)
Block 15 Block 16 Block 17

Block Hash: Block Hash: Block Hash:


57ec2fda71 87ea2ffe94 44bf2efe32

… Prev Block Hash:


Prev Block Hash: Prev Block Hash: …
d68b2f0a3b 57ec2fda71 87ea2ffe94

Transaction Transaction
Transaction

Transaction
Transaction
Transaction

- New blocks always added to the end

- Each block header includes a hash of the current block transactions


and the previous block’s transactions

16
What is Hyperledger Fabric

📒
• Platform for distributed ledger solutions

17
What is Hyperledger Fabric

📒
• Platform for distributed ledger solutions

• Open Source
– Contributions by hundreds of engineers from tens of organizations

💻‍
‍‍ 💻
💻 ‍‍

18
What is Hyperledger Fabric

📒
• Platform for distributed ledger solutions

• Open Source
– Contributions by hundreds of engineers from tens of organizations

• Features
‍💻‍💻
💻‍
– Smart Contracts (updates the ledger)
– Consensus (synch ledger across network)
– Privacy (channels)

🔒
19
Actors in a blockchain solution

R
Regulator
B2B transactions U
Blockchain
performs
A
oversight
User
Blockchain
Architect

designs
Membership
D Blockchain accesses Services
Blockchain security
certificates
Developer creates
applications
access to data
operates Traditional
Data
Sources
O access to logic
Blockchain
Network Traditional
Operator Processing
Platforms

20
The blockchain developer

Blockchain developers’ primary interests are… Blockchain


Developer
Smart
Application
Contract
f(abc);

21
The blockchain developer

Blockchain developers’ primary interests are… Blockchain


Developer
Smart
Application
Contract
f(abc);

…and how they interact with the ledger and other systems of record:

Traditional Traditional
Ledger Processing Data
Systems
Events Integration

Platforms Sources !

22
Components in a blockchain solution

Ledger …
List of transactions maintained by peers

23
Components in a blockchain solution

Ledger …
List of transactions maintained by peers
Smart
Contract
f(abc); Software running on peer, updates the world state

24
Components in a blockchain solution

Ledger …
List of transactions maintained by peers
Smart
Contract
f(abc); Software running on peer, updates the world state
Peer
Network Network which reaches consensus to add blocks

25
Components in a blockchain solution

Ledger …
List of transactions maintained by peers
Smart
Contract
f(abc); Software running on peer, updates the world state
Peer
Network Network which reaches consensus to add blocks
E T
Membership Authenticates and manages identities on network

26
Components in a blockchain solution

Ledger …
List of transactions maintained by peers
Smart
Contract
f(abc); Software running on peer, updates the world state
Peer
Network Network which reaches consensus to add blocks
E T
Membership Authenticates and manages identities on network
Events ! Emits notifications of operations on network

27
Components in a blockchain solution

Ledger …
List of transactions maintained by peers
Smart
Contract
f(abc); Software running on peer, updates the world state
Peer
Network Network which reaches consensus to add blocks
E T
Membership Authenticates and manages identities on network
Events ! Emits notifications of operations on network
Systems i
Management Enables us to create/monitor blockchain components

28
Components in a blockchain solution

Ledger …
List of transactions maintained by peers
Smart
Contract
f(abc); Software running on peer, updates the world state
Peer
Network Network which reaches consensus to add blocks
E T
Membership Authenticates and manages identities on network
Events ! Emits notifications of operations on network
Systems i
Management Enables us to create/monitor blockchain components
Wallet Securely manages a user’s credentials

29
Components in a blockchain solution

Ledger …
List of transactions maintained by peers
Smart
Contract
f(abc); Software running on peer, updates the world state
Peer
Network Network which reaches consensus to add blocks
E T
Membership Authenticates and manages identities on network
Events ! Emits notifications of operations on network
Systems i
Management Enables us to create/monitor blockchain components
Wallet Securely manages a user’s credentials
Systems
Integration Integrate blockchain with eternal systems

30
Smart Contracts

Smart Contracts contain the business logic deployed to peers

31
Smart Contracts

Smart Contracts contain the business logic deployed to peers

• Interact with the world state through the Fabric shim interface

32
Smart Contracts

Smart Contracts contain the business logic deployed to peers

• Interact with the world state through the Fabric shim interface
• Language support for:

– Golang
– Node.js
– Java

33
Smart Contracts

Smart Contracts contain the business logic deployed to peers

• Interact with the world state through the Fabric shim interface
• Language support for:

– Golang
– Node.js
Admin
– Java Install
Instantiate

Client Invoke() Init() Smart


Application
SDK
Peer Contract

34
Client Application

Client applications use Fabric SDK to:


• Connects over channels to peer and
Client
orderer nodes Application SDK Channels

• Provide public / private keys � ! Events

35
Client Application

Client applications use Fabric SDK to:


• Connects over channels to peer and
Client
orderer nodes Application SDK Channels

• Provide public / private keys � ! Events

Connection Profile � Local MSP

• Network end-points and connection


• Connection Parms
• Credential Store
parameters • Channels
• Organisations
• The gateway to submit transactions to a • Orderers
Connection Profile • Peers
Hyperledger Fabric network • CAs

36
How applications interact with the ledger

develops Client
Blockchain
Application
developer D
SDK
develops submits

Smart emits
Contract !
event
accesses
‘get’, ‘put’,
‘delete’ recorded
Ledger
block
emits
txn txn txn
!
event
World state Blockchain
Peer

37
Sample blockchain use-case: e-voting

38
Components in an e-voting blockchain solution

Ledger …
The ledger containing history of submitted votes

39
Components in an e-voting blockchain solution

Ledger …
The ledger containing history of submitted votes
Smart
voterContract. Registers voters & submits votes
f(abc);

Contract

40
Components in an e-voting blockchain solution

Ledger …
The ledger containing history of submitted votes
Smart
voterContract. Registers voters & submits votes
f(abc);

Contract
Peer
Network The peers which run the voterContract

41
Components in an e-voting blockchain solution

Ledger …
The ledger containing history of submitted votes
Smart
voterContract. Registers voters & submits votes
f(abc);

Contract
Peer
Network The peers which run the voterContract
E T
Membership Public and private key for each registered voter

42
Components in an e-voting blockchain solution

Ledger …
The ledger containing history of submitted votes
Smart
voterContract. Registers voters & submits votes
f(abc);

Contract
Peer
Network The peers which run the voterContract
E T
Membership Public and private key for each registered voter
Events ! Emit events to when a transaction is complete

43
Components in an e-voting blockchain solution

Ledger …
The ledger containing history of submitted votes
Smart
voterContract. Registers voters & submits votes
f(abc);

Contract
Peer
Network The peers which run the voterContract
E T
Membership Public and private key for each registered voter
Events ! Emit events to when a transaction is complete
Systems i
Management VSCode extension to manage nodes & network

44
Components in an e-voting blockchain solution

Ledger …
The ledger containing history of submitted votes
Smart
voterContract. Registers voters & submits votes
f(abc);

Contract
Peer
Network The peers which run the voterContract
E T
Membership Public and private key for each registered voter
Events ! Emit events to when a transaction is complete
Systems i
Management VSCode extension to manage nodes & network
Wallet Stores our voter’s public/private keys and certs

45
Components in an e-voting blockchain solution

Ledger …
The ledger containing history of submitted votes
Smart
voterContract. Registers voters & submits votes
f(abc);

Contract
Peer
Network The peers which run the voterContract
E T
Membership Public and private key for each registered voter
Events ! Emit events to when a transaction is complete
Systems i
Management VSCode extension to manage nodes & network
Wallet Stores our voter’s public/private keys and certs
Systems
Integration An API to validate voter registration (DMV API)

46
App Architecture

47
Concepts and Components

Considerations for the Developer,


Operator and Architect
Working with the ledger example: a change of
ownership transaction

Transaction input - sent from application


Application
invoke(voterContract, castVote,
2020election, 123123123, democrat)

Smart
Contract
f(abc);

txn txn txn

World state

49
Working with the ledger example: a change of
ownership transaction

Transaction input - sent from application


Application
invoke(voterContract, castVote,
2020election, 123123123, democrat)

Smart
Smart contract implementation
Contract
castVote(ctx, args) {
args.democrat.count++
f(abc);

txn txn txn

World state

50
Working with the ledger example: a change of
ownership transaction

Transaction input - sent from application


Application
invoke(voterContract, castVote,
2020election, 123123123, democrat)

Smart
Smart contract implementation
Contract
castVote(ctx, args) {
args.democrat.count++
f(abc);

}
World state: new contents
txn txn txn
democrat.count = 1
World state voterId.castBallot = true

51
Working with the ledger example: a change of
ownership transaction

Transaction input - sent from application


Application
invoke(voterContract, castVote,
2020election, 123123123, democrat)

Smart
Smart contract implementation
Contract
castVote(ctx, args) {
args.democrat.count++
f(abc);

}
World state: new contents
txn txn txn
Democrat.cou
nt = 1
democrat.count = 1
World state voterId.castBallot = true

52
Working with the ledger example: a change of
ownership transaction

Transaction input - sent from application


Application
invoke(voterContract, castVote,
2020election, 123123123, democrat)

Smart
Smart contract implementation
Contract
castVote(ctx, args) {
args.democrat.count++
f(abc);

}
World state: new contents
Democrat.cou txn txn txn
nt = 1 democrat.count = 1
World state voterId.castBallot = true
“Invoke, voterContract,
castVote, 2020election,
123123123, democrat”
53
E-voting Demo

54
What we learned

1. Blockchain vocabulary 📖
2. A use-case of blockchain

3. Architecture behind a Hyperledger Fabric solution 🚧
4. Difference between the world state and the ledger 📒
5. Difference between public and private blockchains
🔓
6. How a client application invokes a smart contract
🤝
55
Contact

Questions⁉️: [email protected]

Twitter: @horeaporutiu

YouTube🎥: horeaporutiu

56
Rate today ’s session

Session page on conference website O’Reilly Events App

You might also like