This slide deck goes into detail about the main concepts in Hyperledger Fabric - peers, orderer, certificate authority, and channels. We talk about chaincode, and go into details about modeling a network which involves putting cars on an auction. I end with a demo of the IBM Blockchain Platform, and give you links to get a free 1-month trial of the Starter Plan Blockchain service on the IBM Blockchain Platform.
7. Hyperledger vs. Ethereum Throughput
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• Approximate throughput - Ethereum: 1,000 / minute
• No concept of cryptocurrency in Hyperledger
• Approximate throughput - Hyperlegder: 500,000 /
minute
8. Hyperledger vs. Ethereum Throughput
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• Approximate throughput - Ethereum: 1,000 / minute
• No concept of cryptocurrency in Hyperledger
• Approximate throughput - Hyperlegder: 500,000 /
minute
• No cryptocurrency = no mining = more efficient in terms of
electricity
9. Hyperledger vs. Ethereum Throughput
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• Approximate throughput - Ethereum: 1,000 / minute
• No concept of cryptocurrency in Hyperledger
• Enterprise needs high throughput = Hyperledger is made for
enterprise
• Approximate throughput - Hyperlegder: 500,000 /
minute
• No cryptocurrency = no mining = more efficient in terms of
electricity
15. Concepts Part 2
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• If you replay all events in the ledger, you get the
‘current state’
16. Concepts Part 2
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• If you replay all events in the ledger, you get the
‘current state’
• All data is cryptographically signed
17. Concepts Part 2
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• If you replay all events in the ledger, you get the
‘current state’
• All data is cryptographically signed
• No requirements on hardware, network
infrastructure, software, security
18. Concepts Part 2
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• If you replay all events in the ledger, you get the
‘current state’
• All data is cryptographically signed
• No requirements on hardware, network
infrastructure, software, security
• Can be adjusted for any use case
19. Concepts Part 2
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• If you replay all events in the ledger, you get the
‘current state’
• All data is cryptographically signed
• No requirements on hardware, network
infrastructure, software, security
• Can be adjusted for any use case
• Not vulnerable to 51% attack (unlike Bitcoin)
20. Concepts Part 3
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• Main use case - Party A doesn’t trust Party B
21. Concepts Part 3
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• Main use case - Party A doesn’t trust Party B
• Party A records don’t match Party B
22. Concepts Part 3
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• Main use case - Party A doesn’t trust Party B
• Party A records don’t match Party B
• How to resolve? Settlement process (lawyers,
audits) - expensive, time-intensive
23. Concepts Part 3
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• Main use case - Party A doesn’t trust Party B
• Party A records don’t match Party B
• How to resolve? Settlement process (lawyers,
audits) - expensive, time-intensive
• Instead, you can use 3rd party (verification
authority), and send all data to them. Very expensive
24. Concepts Part 3
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• Main use case - Party A doesn’t trust Party B
• Party A records don’t match Party B
• How to resolve? Settlement process (lawyers,
audits) - expensive, time-intensive
• Instead, you can use 3rd party (verification
authority), and send all data to them. Very expensive
• Need to all trust verification authority
25. Concepts Part 3
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• Main use case - Party A doesn’t trust Party B
• Party A records don’t match Party B
• How to resolve? Settlement process (lawyers,
audits) - expensive, time-intensive
• Instead, you can use 3rd party (verification
authority), and send all data to them. Very expensive
• Need to all trust verification authority
• Verification authority run by humans = prone to mistakes
26. Concepts Part 4
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• No bulletproof way to work with two parties that don’t
trust each other
27. Concepts Part 4
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• No bulletproof way to work with two parties that don’t
trust each other
• All info is enforced by Hyperledger - all participants see this
28. Concepts Part 4
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• No bulletproof way to work with two parties that don’t
trust each other
• All info is enforced by Hyperledger - all participants see this
• Not possible for any party to alter data - must pass
through smart contract (chain code)
29. Actors in Hyperledger
@horeaporutiu IBM Developer
•Michael Scott,
a.k.a. the peer
node. The peer,
(M. Scott) runs
the show
(chaincode). The
manager of The
Office.
http://mtncatholic.com/2016/10/06/no-joke-dante-puts-michael-scott-hell/
30. Actors in Hyperledger
@horeaporutiu IBM Developer
•Michael Scott,
a.k.a. the peer
node. The peer,
(M. Scott) runs
the show
(chaincode). The
manager of The
Office.
http://mtncatholic.com/2016/10/06/no-joke-dante-puts-michael-scott-hell/
• Toby, a.k.a the
CA(Certificate
Authority). The
CA hands out
certificates to
members of the
network. The
H.R. of The
Office - hands
out offer letters.
http://theoffice.wikia.com/wiki/Toby_Flenderson
31. Actors in Hyperledger
@horeaporutiu IBM Developer
•Michael Scott,
a.k.a. the peer
node. The peer,
(M. Scott) runs
the show
(chaincode). The
manager of The
Office.
http://mtncatholic.com/2016/10/06/no-joke-dante-puts-michael-scott-hell/
• Toby, a.k.a the
CA(Certificate
Authority). The
CA hands out
certificates to
members of the
network. The
H.R. of The
Office - hands
out offer letters.
http://theoffice.wikia.com/wiki/Toby_Flenderson https://www.dailybreak.com/break/chilis-lifts-ban-on-pam-beesly
• Pam, a.k.a. the
orderer
broadcasts
messages to
peers. As the
receptionist in the
office, she relays
messages to other
employees.
32. @horeaporutiu IBM Developer
• Every operation inside Hyperledger must be
cryptographically signed with certificate
Actors - Certificate Authority
33. @horeaporutiu IBM Developer
• Every operation inside Hyperledger must be
cryptographically signed with certificate
• Doesn’t matter if you just read data, or if you update,
still need to sign with certificate
Actors - Certificate Authority
34. @horeaporutiu IBM Developer
• Every operation inside Hyperledger must be
cryptographically signed with certificate
• Doesn’t matter if you just read data, or if you update,
still need to sign with certificate
• Can generate your own certificates
Actors - Certificate Authority
35. @horeaporutiu IBM Developer
• Every operation inside Hyperledger must be
cryptographically signed with certificate
• Doesn’t matter if you just read data, or if you update,
still need to sign with certificate
• Can generate your own certificates
• CA (if you use out of box) provides X.509 certificates -
same certificate you use to make your website work on
HTTPS
Actors - Certificate Authority
36. Actors - Certificate Authority
@horeaporutiu IBM Developer
• Every operation inside Hyperledger must be
cryptographically signed with certificate
• Doesn’t matter if you just read data, or if you update,
still need to sign with certificate
• Can generate your own certificates
• CA (if you use out of box) provides X.509 certificates -
same certificate you use to make your website work on
HTTPS
• Inside certificate, you can add info to the system -
smart contract can read this, make decision based on
certificate
37. Actors - Certificate Authority Part 2
@horeaporutiu IBM Developer
• CA (Certificate Authority) follows best crypto standards
38. Actors - Certificate Authority Part 2
@horeaporutiu IBM Developer
• CA (Certificate Authority) follows best crypto standards
• Don’t have to use X.509 or Public Key Infrastructure,
but that’s a very advanced topic
39. Actors - Certificate Authority Part 2
@horeaporutiu IBM Developer
• CA (Certificate Authority) follows best crypto standards
• Don’t have to use X.509 or Public Key Infrastructure,
but that’s a very advanced topic
• Enrollment - create accounts, register users, create
attributes
40. Actors - Certificate Authority Part 2
@horeaporutiu IBM Developer
• CA (Certificate Authority) follows best crypto standards
• Don’t have to use X.509 or Public Key Infrastructure,
but that’s a very advanced topic
• Enrollment - create accounts, register users, create
attributes
• Provide user / pass to CA and it gives you certificate ->
can enforce expiration date
41. Actors - Certificate Authority Part 2
@horeaporutiu IBM Developer
• CA (Certificate Authority) follows best crypto standards
• Don’t have to use X.509 or Public Key Infrastructure,
but that’s a very advanced topic
• Enrollment - create accounts, register users, create
attributes
• Provide user / pass to CA and it gives you certificate ->
can enforce expiration date
• Can use OpenSSL
42. Actors - Certificate Authority Part 2
@horeaporutiu IBM Developer
• CA (Certificate Authority) follows best crypto standards
• Don’t have to use X.509 or Public Key Infrastructure,
but that’s a very advanced topic
• Enrollment - create accounts, register users, create
attributes
• Provide user / pass to CA and it gives you certificate ->
can enforce expiration date
• Can use OpenSSL
• CA can be attached to active directory, all users can be
taken from active directory
43. Actors - Certificate Authority Part 3
@horeaporutiu IBM Developer
• Fabric CA can be chained
44. Actors - Certificate Authority Part 3
@horeaporutiu IBM Developer
• Fabric CA can be chained
• For example - you have 1 root CA and more
intermediate CA that trust the root CA
45. Actors - Certificate Authority Part 3
@horeaporutiu IBM Developer
• Fabric CA can be chained
• For example - you have 1 root CA and more
intermediate CA that trust the root CA
• When you use SDK, you sign all requests with certificate
46. Actors - Certificate Authority Part 3
@horeaporutiu IBM Developer
• Fabric CA can be chained
• For example - you have 1 root CA and more
intermediate CA that trust the root CA
• Can track certificate (identity) on the network - see
who invoked transactions
• When you use SDK, you sign all requests with certificate
49. Actors - Peer
@horeaporutiu IBM Developer
• Main working horse
• Where ledger / blockchain is stored
• Need more than 1 peer
50. Actors - Peer
@horeaporutiu IBM Developer
• Main working horse
• Where ledger / blockchain is stored
• Request from SDK is sent to peer
• Need more than 1 peer
51. Actors - Peer
@horeaporutiu IBM Developer
• Main working horse
• Where ledger / blockchain is stored
• Request from SDK is sent to peer
• Need more than 1 peer
• 1 peer can be part of many channels (cover this later)
52. Actors - Peer
@horeaporutiu IBM Developer
• Main working horse
• Where ledger / blockchain is stored
• Request from SDK is sent to peer
• Need more than 1 peer
• 1 peer can be part of many channels (cover this later)
• Endorse then update ledger. Endorsement is heart of system
53. Actors - Peer
@horeaporutiu IBM Developer
• Main working horse
• Where ledger / blockchain is stored
• Request from SDK is sent to peer
• Need more than 1 peer
• 1 peer can be part of many channels (cover this later)
• Endorse then update ledger. Endorsement is heart of system
• Back up of system? Peers find each other and sync
54. Actors - Peer
@horeaporutiu IBM Developer
• Main working horse
• Where ledger / blockchain is stored
• Request from SDK is sent to peer
• Need more than 1 peer
• 1 peer can be part of many channels (cover this later)
• Endorse then update ledger. Endorsement is heart of system
• Back up of system? Peers find each other and sync
• Need to increase throughput? Simple - add more peers
55. Actors - Ordering Service
@horeaporutiu IBM Developer
• Heart of consensus algorithm
56. Actors - Ordering Service
@horeaporutiu IBM Developer
• Heart of consensus algorithm
• Provide order of operation
57. Actors - Ordering Service
@horeaporutiu IBM Developer
• Heart of consensus algorithm
• Provide order of operation
• Before being committed to ledger, must pass thru
ordering service
58. Actors - Ordering Service
@horeaporutiu IBM Developer
• Heart of consensus algorithm
• Provide order of operation
• Creates blocks
• Before being committed to ledger, must pass thru
ordering service
59. Actors - Ordering Service
@horeaporutiu IBM Developer
• Heart of consensus algorithm
• Provide order of operation
• Creates blocks
• Before being committed to ledger, must pass thru
ordering service
• Sends blocks to peers, peers add block to ledger
60. Actors - Ordering Service
@horeaporutiu IBM Developer
• Heart of consensus algorithm
• Provide order of operation
• Creates blocks
• Before being committed to ledger, must pass thru
ordering service
• Sends blocks to peers, peers add block to ledger
• Decides which operation comes before or after another
operation
61. Actors - Ordering Service Part 2
@horeaporutiu IBM Developer
• Only 1 instance? Solo orderer - use only in test /
development
62. Actors - Ordering Service Part 2
@horeaporutiu IBM Developer
• Only 1 instance? Solo orderer - use only in test /
development
• Production? Use multiple instances, use Kafka orderer
63. Actors - Ordering Service Part 2
@horeaporutiu IBM Developer
• Only 1 instance? Solo orderer - use only in test /
development
• Production? Use multiple instances, use Kafka orderer
• Kafka orderer is distributed, can put these in different
data centers in different continents - if one fails, your
network is still running
64. Actors - Ordering Service Part 2
@horeaporutiu IBM Developer
• Only 1 instance? Solo orderer - use only in test /
development
• Production? Use multiple instances, use Kafka orderer
• Must use Kafka for maximum throughput
• Kafka orderer is distributed, can put these in different
data centers in different continents - if one fails, your
network is still running
65. Actors - Ordering Service Part 2
@horeaporutiu IBM Developer
• Only 1 instance? Solo orderer - use only in test /
development
• Production? Use multiple instances, use Kafka orderer
• Throughput also dependent on hardware - can’t use old
laptop for thousands of transactions per second
• Must use Kafka for maximum throughput
• Kafka orderer is distributed, can put these in different
data centers in different continents - if one fails, your
network is still running
66. Actors - Ordering Service Part 2
@horeaporutiu IBM Developer
• Only 1 instance? Solo orderer - use only in test /
development
• Production? Use multiple instances, use Kafka orderer
• Throughput also dependent on hardware - can’t use old
laptop for thousands of transactions per second
• Must use Kafka for maximum throughput
• Must use server for higher throughput
• Kafka orderer is distributed, can put these in different
data centers in different continents - if one fails, your
network is still running
69. Channels
@horeaporutiu IBM Developer
• Main way of data isolation
• Separate instance of Hyperledger Fabric
• One channel doesn’t depend on another channel - they
never exchange data
70. Channels
@horeaporutiu IBM Developer
• Main way of data isolation
• Separate instance of Hyperledger Fabric
• Each channel has different chaincode that is
independent
• One channel doesn’t depend on another channel - they
never exchange data
71. Channels
@horeaporutiu IBM Developer
• Main way of data isolation
• Separate instance of Hyperledger Fabric
• If party A and party B want to communicate in private,
they create their own channel. No way for Party C to
even see that this channel exists
• Each channel has different chaincode that is
independent
• One channel doesn’t depend on another channel - they
never exchange data
72. Channels
@horeaporutiu IBM Developer
• Main way of data isolation
• Separate instance of Hyperledger Fabric
• If party A and party B want to communicate in private,
they create their own channel. No way for Party C to
even see that this channel exists
• Each channel has different chaincode that is
independent
• Peer must be part of channel to do anything - must join
peer to channel
• One channel doesn’t depend on another channel - they
never exchange data
74. Channels Part 2
@horeaporutiu IBM Developer
• Before you join channel, you must create channel
• Genesis block, says which parties are allowed to join
channel
75. Channels Part 2
@horeaporutiu IBM Developer
• Before you join channel, you must create channel
• Genesis block, says which parties are allowed to join
channel
• If you later want to add another party that is not
specified if genesis block, must alter channel
configuration
79. Chaincode
@horeaporutiu IBM Developer
• Chaincode = smart contract
• How you read and update ledger
• Only way to read/update ledger is through chaincode
• SDK makes transactions and executes chaincode
80. Chaincode
@horeaporutiu IBM Developer
• Chaincode = smart contract
• How you read and update ledger
• You use Node.js? Can use any external libraries from
NPM you want in your chaincode
• Only way to read/update ledger is through chaincode
• SDK makes transactions and executes chaincode
81. Chaincode
@horeaporutiu IBM Developer
• Chaincode = smart contract
• How you read and update ledger
• You use Node.js? Can use any external libraries from
NPM you want in your chaincode
• Only way to read/update ledger is through chaincode
• Chaincode must be part of channel
• SDK makes transactions and executes chaincode
82. Chaincode
@horeaporutiu IBM Developer
• Chaincode = smart contract
• How you read and update ledger
• You use Node.js? Can use any external libraries from
NPM you want in your chaincode
• Only way to read/update ledger is through chaincode
• Chaincode must be part of channel
• SDK makes transactions and executes chaincode
• Why? Bc chaincode is responsible with working with
ledger, but ledger is inside a specific channel
83. Chaincode Part 2
@horeaporutiu IBM Developer
• You may have one chaincode that handles everything
(this is what I will demo later) or 5,10,12 separate ones
84. Chaincode Part 2
@horeaporutiu IBM Developer
• You may have one chaincode that handles everything
(this is what I will demo later) or 5,10,12 separate ones
• Must be installed and instantiated
85. Chaincode Part 2
@horeaporutiu IBM Developer
• You may have one chaincode that handles everything
(this is what I will demo later) or 5,10,12 separate ones
• Must be installed and instantiated
• Must install on every peer that is inside of that channel
86. Chaincode Part 2
@horeaporutiu IBM Developer
• You may have one chaincode that handles everything
(this is what I will demo later) or 5,10,12 separate ones
• Must be installed and instantiated
• CC (chaincode) must be part of peer
• Must install on every peer that is inside of that channel
87. Chaincode Part 2
@horeaporutiu IBM Developer
• You may have one chaincode that handles everything
(this is what I will demo later) or 5,10,12 separate ones
• Must be installed and instantiated
• Instantiation starts container of the CC make all
connections and make it ready for use
• CC (chaincode) must be part of peer
• Must install on every peer that is inside of that channel
88. Chaincode Part 2
@horeaporutiu IBM Developer
• You may have one chaincode that handles everything
(this is what I will demo later) or 5,10,12 separate ones
• Must be installed and instantiated
• Instantiation starts container of the CC make all
connections and make it ready for use
• CC (chaincode) must be part of peer
• When you instantiate, you must provide a policy
• Must install on every peer that is inside of that channel
89. Chaincode Part 2
@horeaporutiu IBM Developer
• You may have one chaincode that handles everything
(this is what I will demo later) or 5,10,12 separate ones
• Must be installed and instantiated
• Instantiation starts container of the CC make all
connections and make it ready for use
• CC (chaincode) must be part of peer
• When you instantiate, you must provide a policy
• Must install on every peer that is inside of that channel
• What is policy?
92. Endorsement Policy
@horeaporutiu IBM Developer
• This is consensus mechanism of Fabric
• Operation must be verified before we update the ledger
• Endorsement policy specifies who must validate
93. Endorsement Policy
@horeaporutiu IBM Developer
• This is consensus mechanism of Fabric
• Operation must be verified before we update the ledger
• Example: All peers, majority of peers, ONLY 1 peer (this
is dangerous)
• Endorsement policy specifies who must validate
94. Endorsement Policy
@horeaporutiu IBM Developer
• This is consensus mechanism of Fabric
• Operation must be verified before we update the ledger
• If you have a channel with 10 CC, then every single
chaincode can have a different policy 🙀🙀🙀🙀🙀🙀
• Example: All peers, majority of peers, ONLY 1 peer (this
is dangerous)
• Endorsement policy specifies who must validate
95. Endorsement Policy
@horeaporutiu IBM Developer
• This is consensus mechanism of Fabric
• Operation must be verified before we update the ledger
• If you have a channel with 10 CC, then every single
chaincode can have a different policy 🙀🙀🙀🙀🙀🙀
• Example: All peers, majority of peers, ONLY 1 peer (this
is dangerous)
• When you instantiate, you must provide a policy
• Endorsement policy specifies who must validate
96. Endorsement Policy
@horeaporutiu IBM Developer
• This is consensus mechanism of Fabric
• Operation must be verified before we update the ledger
• If you have a channel with 10 CC, then every single
chaincode can have a different policy 🙀🙀🙀🙀🙀🙀
• Example: All peers, majority of peers, ONLY 1 peer (this
is dangerous)
• When you instantiate, you must provide a policy
• Endorsement policy specifies who must validate
• Example: for business process that is not important -
endorsement policy says only 1 peer must validate.
97. Endorsement Policy
@horeaporutiu IBM Developer
• This is consensus mechanism of Fabric
• Operation must be verified before we update the ledger
• If you have a channel with 10 CC, then every single
chaincode can have a different policy 🙀🙀🙀🙀🙀🙀
• Example: All peers, majority of peers, ONLY 1 peer (this
is dangerous)
• When you instantiate, you must provide a policy
• Endorsement policy specifies who must validate
• Example: for business process that is not important -
endorsement policy says only 1 peer must validate.
• For vital operations (transfer money) ALL peers validate
99. Recap
@horeaporutiu IBM Developer
• Inside 1 channel, can have as many chain codes as you want
• When you make a request you say I want to execute
operation on:
100. Recap
@horeaporutiu IBM Developer
• Inside 1 channel, can have as many chain codes as you want
• When you make a request you say I want to execute
operation on:
1. Channel X
101. Recap
@horeaporutiu IBM Developer
• Inside 1 channel, can have as many chain codes as you want
• When you make a request you say I want to execute
operation on:
1. Channel X
2. Chaincode X
102. Recap
@horeaporutiu IBM Developer
• Inside 1 channel, can have as many chain codes as you want
• When you make a request you say I want to execute
operation on:
1. Channel X
2. Chaincode X
3. With these arguments
103. Recap
@horeaporutiu IBM Developer
• Inside 1 channel, can have as many chain codes as you want
• When you make a request you say I want to execute
operation on:
1. Channel X
2. Chaincode X
3. With these arguments
4. With this certificate
104. Recap in code
@horeaporutiu IBM Developer
var request = {
chaincodeId: ‘carauction’, //name of chaincode to execute
fcn: ‘initLedger’, // which chaincode function to execute
args: [‘’], //array of args for chaincode function
txId: fabric_client.newTransactionID(); //assign new txn id
}
var channel = fabric_client.newChannel(‘defaultchannel’);
return channel.sentTransactionProposal(request);
var fabric_client = require(‘fabric-client);
1
105. Recap in code
@horeaporutiu IBM Developer
var request = {
chaincodeId: ‘carauction’, //name of chaincode to execute
fcn: ‘initLedger’, // which chaincode function to execute
args: [‘’], //array of args for chaincode function
txId: fabric_client.newTransactionID(); //assign new txn id
}
var channel = fabric_client.newChannel(‘defaultchannel’);
return channel.sentTransactionProposal(request);
var fabric_client = require(‘fabric-client);
1
2
106. Recap in code
@horeaporutiu IBM Developer
var request = {
chaincodeId: ‘carauction’, //name of chaincode to execute
fcn: ‘initLedger’, // which chaincode function to execute
args: [‘’], //array of args for chaincode function
txId: fabric_client.newTransactionID(); //assign new txn id
}
var channel = fabric_client.newChannel(‘defaultchannel’);
return channel.sentTransactionProposal(request);
var fabric_client = require(‘fabric-client);
1
2
3
107. Recap in code
@horeaporutiu IBM Developer
var request = {
chaincodeId: ‘carauction’, //name of chaincode to execute
fcn: ‘initLedger’, // which chaincode function to execute
args: [‘’], //array of args for chaincode function
txId: fabric_client.newTransactionID(); //assign new txn id
}
var channel = fabric_client.newChannel(‘defaultchannel’);
return channel.sentTransactionProposal(request);
var fabric_client = require(‘fabric-client);
1
2
3
4
110. Approaches for development
@horeaporutiu IBM Developer
Cloud
• Run docker
containers (peer,
orderer, certificate
authority, couchDb)
Local
• Inviting other orgs,
viewing blocks is hard
111. Approaches for development
@horeaporutiu IBM Developer
Cloud
• Run docker
containers (peer,
orderer, certificate
authority, couchDb)
• Network setup is
done for you
Local
• Inviting other orgs,
viewing blocks is hard
112. Approaches for development
@horeaporutiu IBM Developer
Cloud
• Run docker
containers (peer,
orderer, certificate
authority, couchDb)
• Network setup is
done for you
Local
• Nice interface to view
all blocks
• Inviting other orgs,
viewing blocks is hard
113. Approaches for development
@horeaporutiu IBM Developer
Cloud
• Run docker
containers (peer,
orderer, certificate
authority, couchDb)
• Network setup is
done for you
Local
• Nice interface to view
all blocks
• Easy to invite other
organizations to the
network
• Inviting other orgs,
viewing blocks is hard
116. How do you get started?
@horeaporutiu IBM Developer
• Intro to Hyperledger Node SDK code pattern -
https://github.com/IBM/car-auction-network-
fabric-node-sdk
• Step by step guide on how to connect local
Node.js app to IBM Blockchain Platform
120. Enrollment
IBM Developer@horeaporutiu
• First generate certificate for our admin identity
and use those to register a new client identity
• Enrollment - process of generating keys and
certificates from the Certificate Authority
124. Using Fabric SDK - Invoking Chaincode 1/2
IBM Developer@horeaporutiu
Node.js app +
Fabric SDK
(Local)
3. Send transaction
proposal to peer
var request = {
chaincodeId: ‘carauction’, //name of chaincode to execute
fcn: ‘initLedger’, // which chaincode function to execute
args: [‘’], //array of args for chaincode function
txId: fabric_client.newTransactionID(); //assign new txn id
}
🔑
Peer
Chaincode
Database
3.
125. Using Fabric SDK - Invoking Chaincode 1/2
IBM Developer@horeaporutiu
var request = {
chaincodeId: ‘carauction’, //name of chaincode to execute
fcn: ‘initLedger’, // which chaincode function to execute
args: [‘’], //array of args for chaincode function
txId: fabric_client.newTransactionID(); //assign new txn id
}
var channel = fabric_client.newChannel(‘defaultchannel’);
return channel.sentTransactionProposal(request);
var fabric_client = require(‘fabric-client);
126. Using Fabric SDK - Invoking Chaincode 1/2
IBM Developer@horeaporutiu
Node.js app +
Fabric SDK
(Local)
3. Send transaction
proposal to peer🔑
Peer
Chaincode
Database
3.
• Check endorsement policy - which peers need to
endorse transaction
127. Using Fabric SDK - Invoking Chaincode 1/2
IBM Developer@horeaporutiu
Node.js app +
Fabric SDK
(Local)
3. Send transaction
proposal to peer🔑
Peer
Chaincode
Database
3.
• Check endorsement policy - which peers need to
endorse transaction
• The transaction proposal will go to the peers in the
endorsement policy
128. Using Fabric SDK - Writing to the ledger
IBM Developer@horeaporutiu
let member = {
member.balance = 5000; //set balance of member’s account
member.firstName = ‘Amy’; //set first name of member
member.lastName = ‘Williams’; //set last name of member
member.email = ‘amyWilliams@email.com’; //set email
}
await stub.putState(‘amyWilliams@email.com’,
Buffer.from(JSON.stringify(member)));
• putState takes a key value pair, and writes to the ledger
130. Using Fabric SDK - Reading from the ledger
IBM Developer@horeaporutiu
await stub.getState(‘amyWilliams@email.com’);
• getState reads the member object from the ledger.
Note, this does not create a block on the network.
• This will return:
{
balance: ‘5000’;
firstName: ’Amy’;
lastName: ‘Williams’;
email: ‘amyWilliams@email.com’;
}
131. Using Fabric SDK - Invoking Chaincode 2/2
IBM Developer@horeaporutiu
Node.js app +
Fabric SDK
Peer
(Local)
4. Peers return endorsed
transaction
4.
• Check transaction proposal has not been submitted in
the past and is well formed
🔑
132. Using Fabric SDK - Invoking Chaincode 2/2
IBM Developer@horeaporutiu
Node.js app +
Fabric SDK
Peer
(Local)
4. Peers return endorsed
transaction
4.
• Check transaction proposal has not been submitted in
the past and is well formed
• Check that signature is valid
🔑
133. Using Fabric SDK - Invoking Chaincode 2/2
IBM Developer@horeaporutiu
Node.js app +
Fabric SDK
Peer
(Local)
4. Peers return endorsed
transaction
4.
• Check transaction proposal has not been submitted in
the past and is well formed
• Check that signature is valid
• Take args from chaincode function, and execute function
🔑
134. Using Fabric SDK - Invoking Chaincode 2/2
IBM Developer@horeaporutiu
Node.js app +
Fabric SDK
Peer
(Local)
4. Peers return endorsed
transaction
4.
• Check transaction proposal has not been submitted in
the past and is well formed
• Check that signature is valid
• Take args from chaincode function, and execute function
• Transaction results + enduring peer signature is sent
back to SDK
🔑
135. Node.js app +
Fabric SDK
IBM Developer@horeaporutiu
Blockchain
network - 1 org
Certificate Authority
Orderer
Peer
(Local)
1.
1. Enrollment - Register
admin with Certificate Auth
2. Register application
2.
3. Send (txn)transaction to peer
4. Peers return endorsed txn
Using Fabric SDK - Invoking Chaincode
🔑
Peer
Chaincode
Database
4.
3.
5. App sends endorsed txn to ordering service to add to ledger
5.
136. Using Fabric SDK - Ordering Service
IBM Developer@horeaporutiu
Node.js app +
Fabric SDK
Orderer
(Local)
5. App sends endorsed txn to
ordering service to add to ledger
• App ‘broadcasts’ transaction proposal and response to
the ordering service
5.
🔑
137. Using Fabric SDK - Ordering Service
IBM Developer@horeaporutiu
Node.js app +
Fabric SDK
Orderer
(Local)
5. App sends endorsed txn to
ordering service to add to ledger
• App ‘broadcasts’ transaction proposal and response to
the ordering service
5.
• Order chronologically and create blocks
🔑
138. Using Fabric SDK - Ordering Service
IBM Developer@horeaporutiu
Node.js app +
Fabric SDK
Orderer
(Local)
5. App sends endorsed txn to
ordering service to add to ledger
• App ‘broadcasts’ transaction proposal and response to
the ordering service
5.
• Order chronologically and create blocks
• Order transactions from all channels - order
chronologically by channel and create blocks
🔑
139. Ledger Updated
IBM Developer@horeaporutiu
• Each peer appends block to the channel’s chain,
•For each valid transaction the write sets are committed to
current state database
• Client is notified that transaction has been immutably
appended to the chain
142. Use Case - IBM Food Trust
IBM Developer@horeaporutiu
• One of the first solutions in-production using blockchain
143. IBM Developer@horeaporutiu
• One of the first solutions in-production using blockchain
• Smarter, safer, more sustainable food supply chain
Use Case - IBM Food Trust
144. IBM Developer@horeaporutiu
• One of the first solutions in-production using blockchain
• Smarter, safer, more sustainable food supply chain
• Built on open-source framework - Hyperledger Fabric
Use Case - IBM Food Trust
145. IBM Developer@horeaporutiu
• One of the first solutions in-production using blockchain
• Smarter, safer, more sustainable food supply chain
• Built on open-source framework - Hyperledger Fabric
• How to join: register your organization with the network
Use Case - IBM Food Trust
146. IBM Developer@horeaporutiu
• One of the first solutions in-production using blockchain
• Smarter, safer, more sustainable food supply chain
• Built on open-source framework - Hyperledger Fabric
• How to join: register your organization with the network
• Solution: Trace - allows user to search the origin of a
product by product name, Purchase Order or GTIN
(Global Trade Item Number)
Use Case - IBM Food Trust
147. IBM Developer@horeaporutiu
• One of the first solutions in-production using blockchain
• Smarter, safer, more sustainable food supply chain
• Built on open-source framework - Hyperledger Fabric
• How to join: register your organization with the network
• Solution: Trace - allows user to search the origin of a
product by product name, Purchase Order or GTIN
(Global Trade Item Number)
• Solution: Certificate Manager - upload regulation and
inspection documents (fair-trade, organic, etc.)
Use Case - IBM Food Trust
153. Hyperledger Fabric v. Composer
• Original project
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/composerhttps://www.hyperledger.org/projects/fabric
154. • Learn Fabric SDK -
Node.js, Java
• Original project
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/composerhttps://www.hyperledger.org/projects/fabric
Hyperledger Fabric v. Composer
155. • Learn Fabric SDK -
Node.js, Java
• Original project
@horeaporutiu IBM Developer
• Uses channels to
divide communication
between participants
https://www.hyperledger.org/projects/composerhttps://www.hyperledger.org/projects/fabric
Hyperledger Fabric v. Composer
156. • Learn Fabric SDK -
Node.js, Java
• Original project
@horeaporutiu IBM Developer
• Uses channels to
divide communication
between participants
https://www.hyperledger.org/projects/composerhttps://www.hyperledger.org/projects/fabric
•Status: active
Hyperledger Fabric v. Composer
157. • Learn Fabric SDK -
Node.js, Java
• Original project • Tool for using Fabric
@horeaporutiu IBM Developer
• Uses channels to
divide communication
between participants
https://www.hyperledger.org/projects/composerhttps://www.hyperledger.org/projects/fabric
•Status: active
Hyperledger Fabric v. Composer
158. • Learn Fabric SDK -
Node.js, Java
• Original project
• Easy to generate
REST API
• Tool for using Fabric
@horeaporutiu IBM Developer
• Uses channels to
divide communication
between participants
https://www.hyperledger.org/projects/composerhttps://www.hyperledger.org/projects/fabric
•Status: active
Hyperledger Fabric v. Composer
159. • Learn Fabric SDK -
Node.js, Java
• Original project
• Easy to generate
REST API
• Tool for using Fabric
@horeaporutiu IBM Developer
• Uses channels to
divide communication
between participants
https://www.hyperledger.org/projects/composerhttps://www.hyperledger.org/projects/fabric
•Status: active
• Learn Composer
modeling language
Hyperledger Fabric v. Composer
160. • Learn Fabric SDK -
Node.js, Java
• Original project
• Easy to generate
REST API
• Tool for using Fabric
@horeaporutiu IBM Developer
• Uses channels to
divide communication
between participants
https://www.hyperledger.org/projects/composerhttps://www.hyperledger.org/projects/fabric
•Status: active
• Learn Composer
modeling language
• Test your contracts in
a sandbox, online
Hyperledger Fabric v. Composer
161. • Learn Fabric SDK -
Node.js, Java
• Original project
• Easy to generate
REST API
• Tool for using Fabric
@horeaporutiu IBM Developer
• Uses channels to
divide communication
between participants
https://www.hyperledger.org/projects/composerhttps://www.hyperledger.org/projects/fabric
•Status: active
• Learn Composer
modeling language
• Test your contracts in
a sandbox, online
•Status: incubation
Hyperledger Fabric v. Composer
163. IBM Blockchain Starter Plan
IBM Developer@horeaporutiu
•http://goo.gl/i9WZcH
• Need either business or student
email address, gmail wont work
• Takes a few business days to
process, please be patient
164. Hopefully you will feel like this after
IBM Developer@horeaporutiu https://www.pinterest.com/pin/427630927097492361