Deploy A Blockchain Web App With Hyperledger Fabric Presentation
Deploy A Blockchain Web App With Hyperledger Fabric Presentation
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?
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
10
Security: Public vs. private blockchains
11
Security: Public vs. private blockchains
– 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
Transaction Transaction
Transaction
Transaction
Transaction
Transaction
15
Block detail (simplified)
Block 15 Block 16 Block 17
Transaction Transaction
Transaction
Transaction
Transaction
Transaction
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
21
The blockchain developer
…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
31
Smart Contracts
• Interact with the world state through the Fabric shim interface
32
Smart Contracts
• Interact with the world state through the Fabric shim interface
• Language support for:
– Golang
– Node.js
– Java
33
Smart Contracts
• Interact with the world state through the Fabric shim interface
• Language support for:
– Golang
– Node.js
Admin
– Java Install
Instantiate
34
Client Application
35
Client Application
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
Smart
Contract
f(abc);
World state
49
Working with the ledger example: a change of
ownership transaction
Smart
Smart contract implementation
Contract
castVote(ctx, args) {
args.democrat.count++
f(abc);
World state
50
Working with the ledger example: a change of
ownership transaction
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
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
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