SlideShare une entreprise Scribd logo
1  sur  171
Télécharger pour lire hors ligne
@horeaporutiu IBM Developer
Horea Porutiu
Developer Advocate, IBM
October 2018
Hyperledger Fabric Workshop
Slides
IBM Developer@horeaporutiu
@pluralsight
• Available on Twitter after talk
• http://slideshare.net/HoreaPorutiu
Agenda
1. Fabric High Level Idea
2. Actors in Fabric Network
3. Channels
4. Chaincode
5. Endorsement Policy
6. Transaction Flow
7. Demo
8. Inspect Chaincode
IBM Developer@horeaporutiu
@pluralsight
Hyperledger Fabric
IBM Developer@horeaporutiu https://www.pinterest.com/pin/215469163401716164/
Hyperledger vs. Ethereum Throughput
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• Approximate throughput - Ethereum: 1,000 / minute
Hyperledger vs. Ethereum Throughput
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• Approximate throughput - Ethereum: 1,000 / minute
• Approximate throughput - Hyperlegder: 500,000 /
minute
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
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
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
Concepts
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• NOT central database
Concepts
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• NOT central database
• Data is distributed
Concepts
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• NOT central database
• Data is distributed
• If you make a mistake, you need to have another
transaction to fix it.
Concepts
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• NOT central database
• Data is distributed
• If you make a mistake, you need to have another
transaction to fix it.
•No ‘delete’ operation in Hyperledger
Concepts
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• NOT central database
• Data is distributed
• If you make a mistake, you need to have another
transaction to fix it.
•No ‘delete’ operation in Hyperledger
• Cannot change ledger
Concepts Part 2
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• If you replay all events in the ledger, you get the
‘current state’
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
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
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
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)
Concepts Part 3
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric
• Main use case - Party A doesn’t trust Party B
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
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
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
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
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
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
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
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)
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/
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
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.
@horeaporutiu IBM Developer
• Every operation inside Hyperledger must be
cryptographically signed with certificate
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
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
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
Actors - Certificate Authority
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
Actors - Certificate Authority Part 2
@horeaporutiu IBM Developer
• CA (Certificate Authority) follows best crypto standards
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
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
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
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
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
Actors - Certificate Authority Part 3
@horeaporutiu IBM Developer
• Fabric CA can be chained
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
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
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
Actors - Peer
@horeaporutiu IBM Developer
• Main working horse
Actors - Peer
@horeaporutiu IBM Developer
• Main working horse
• Where ledger / blockchain is stored
Actors - Peer
@horeaporutiu IBM Developer
• Main working horse
• Where ledger / blockchain is stored
• Need more than 1 peer
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
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)
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
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
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
Actors - Ordering Service
@horeaporutiu IBM Developer
• Heart of consensus algorithm
Actors - Ordering Service
@horeaporutiu IBM Developer
• Heart of consensus algorithm
• Provide order of operation
Actors - Ordering Service
@horeaporutiu IBM Developer
• Heart of consensus algorithm
• Provide order of operation
• Before being committed to ledger, must pass thru
ordering service
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
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
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
Actors - Ordering Service Part 2
@horeaporutiu IBM Developer
• Only 1 instance? Solo orderer - use only in test /
development
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
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
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
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
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
Channels
@horeaporutiu IBM Developer
• Main way of data isolation
Channels
@horeaporutiu IBM Developer
• Main way of data isolation
• Separate instance of Hyperledger Fabric
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
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
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
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
Channels Part 2
@horeaporutiu IBM Developer
• Before you join channel, you must create channel
Channels Part 2
@horeaporutiu IBM Developer
• Before you join channel, you must create channel
• Genesis block, says which parties are allowed to join
channel
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
Chaincode
@horeaporutiu IBM Developer
• Chaincode = smart contract
Chaincode
@horeaporutiu IBM Developer
• Chaincode = smart contract
• How you read and update ledger
Chaincode
@horeaporutiu IBM Developer
• Chaincode = smart contract
• How you read and update ledger
• SDK makes transactions and executes chaincode
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
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
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
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
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
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
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
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
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
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
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?
Endorsement Policy
@horeaporutiu IBM Developer
• This is consensus mechanism of Fabric
Endorsement Policy
@horeaporutiu IBM Developer
• This is consensus mechanism of Fabric
• Operation must be verified before we update the ledger
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
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
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
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
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.
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
Recap
@horeaporutiu IBM Developer
• Inside 1 channel, can have as many chain codes as you want
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:
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
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
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
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
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
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
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
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
Break
@horeaporutiu IBM Developer
12 minute break
Approaches for development
@horeaporutiu IBM Developer
Cloud
• Run docker
containers (peer,
orderer, certificate
authority, couchDb)
Local
Approaches for development
@horeaporutiu IBM Developer
Cloud
• Run docker
containers (peer,
orderer, certificate
authority, couchDb)
Local
• Inviting other orgs,
viewing blocks is hard
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
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
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
Our approach
@horeaporutiu IBM Developer
Cloud - via the IBM
Blockchain Platform
@horeaporutiu IBM Developer
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
Hyperledger Fabric SDK Overview
IBM Developer@horeaporutiu
Blockchain
network - 1 org
Certificate Authority
Orderer
Peer
(Local)
Node.js app +
Fabric SDK
Node.js app +
Fabric SDK
IBM Developer@horeaporutiu
Blockchain
network - 1 org
Certificate Authority
Orderer
Peer
(Local)
1. Enrollment - Register
admin with Certificate Auth
Hyperledger Fabric SDK Overview
Chaincode
Database
Blockchain
network - 1 org
Certificate AuthorityCertificate Authority
Orderer
Peer
Chaincode
Database
1.
Enrollment
IBM Developer@horeaporutiu
• Enrollment - process of generating keys and
certificates from the Certificate Authority
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
Hyperledger Fabric SDK - Enrollment
Node.js app +
Fabric SDK
IBM Developer@horeaporutiu
Blockchain
network - 1 org
Certificate Authority
(Local)
1.
1. Enrollment - Register
admin with Certificate Auth
Certificate Authority
Orderer
Peer
Chaincode
Database
Node.js app +
Fabric SDK
IBM Developer@horeaporutiu
Blockchain
network - 1 org
Certificate Authority
Orderer
(Local)
1. Enrollment - Register
admin with Certificate Auth
2. Register users
🔑
Hyperledger Fabric SDK - Enrollment
Peer
Chaincode
Database
Blockchain
network - 1 org
Certificate Authority
Orderer
Peer
Chaincode
Database
Blockchain
network - 1 org
Certificate AuthorityCertificate Authority
Orderer
Peer
Chaincode
Database
2.
1.
Hyperledger Fabric SDK - Transaction
Node.js app +
Fabric SDK
IBM Developer@horeaporutiu
Blockchain
network - 1 org
Certificate Authority
Orderer
(Local)
1. Enrollment - Register
admin with Certificate Auth
2. Register users
3. Send transaction to peer
🔑
Peer
Chaincode
Database
Blockchain
network - 1 org
Certificate Authority
Orderer
Peer
Chaincode
Database
Blockchain
network - 1 org
Certificate AuthorityCertificate Authority
Orderer
Peer
Chaincode
Database
3.
2.
1.
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.
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);
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
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
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
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.
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’;
}
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
🔑
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
🔑
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
🔑
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
🔑
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.
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.
🔑
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
🔑
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
🔑
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
Demo
IBM Developer@horeaporutiu
Problem
IBM Developer@horeaporutiu
1 in 10 people fall ill
every year from eating
contaminated food -
World Health
Organization
Use Case - IBM Food Trust
IBM Developer@horeaporutiu
• One of the first solutions in-production using blockchain
IBM Developer@horeaporutiu
• One of the first solutions in-production using blockchain
• Smarter, safer, more sustainable food supply chain
Use Case - IBM Food Trust
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
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
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
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
@horeaporutiu IBM Developer
@horeaporutiu IBM Developer
What if we find out
that all products
from Grandma’s
Farm are
contaminated?
Food Contamination - Grandma’s Farm
IBM Developer@horeaporutiu https://tenor.com/view/michael-scott-no-nogod-please-gif-5739001
@horeaporutiu IBM Developer
@horeaporutiu IBM Developer
Hyperledger Fabric v. Composer
• Original project
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/composerhttps://www.hyperledger.org/projects/fabric
• 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
• 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
• 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
• 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
• 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
• 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
• 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
• 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
Links
IBM Developer@horeaporutiu
• https://github.com/IBM/car-auction-network-fabric-
node-sdk
•https://hyperledger-fabric.readthedocs.io/en/
release-1.2/txflow.html
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
Hopefully you will feel like this after
IBM Developer@horeaporutiu https://www.pinterest.com/pin/427630927097492361
@horeaporutiu IBM Developer
Questions?
http://www.freeiconspng.com/img/5437
@horeaporutiu IBM Developer
@horeaporutiu IBM Developer
@horeaporutiu IBM Developer
@horeaporutiu IBM Developer
@horeaporutiu IBM Developer
IBM Blockchain Platform UI
IBM Developer@horeaporutiu

Contenu connexe

Tendances

Tendances (20)

Hyperledger Fabric Application Development 20190618
Hyperledger Fabric Application Development 20190618Hyperledger Fabric Application Development 20190618
Hyperledger Fabric Application Development 20190618
 
Deploy a blockchain web-app with Hyperledger Fabric 1.4 - Concepts & Code
Deploy a blockchain web-app with Hyperledger Fabric 1.4 - Concepts & CodeDeploy a blockchain web-app with Hyperledger Fabric 1.4 - Concepts & Code
Deploy a blockchain web-app with Hyperledger Fabric 1.4 - Concepts & Code
 
Hyperledger
HyperledgerHyperledger
Hyperledger
 
Hyperledger Fabric
Hyperledger FabricHyperledger Fabric
Hyperledger Fabric
 
Developing applications with Hyperledger Fabric SDK
Developing applications with Hyperledger Fabric SDKDeveloping applications with Hyperledger Fabric SDK
Developing applications with Hyperledger Fabric SDK
 
Blockchain workshop IBM CODE Day - Montevideo
Blockchain workshop IBM CODE Day - MontevideoBlockchain workshop IBM CODE Day - Montevideo
Blockchain workshop IBM CODE Day - Montevideo
 
Hyperledger Fabric - Blockchain, sushi and supply chain
Hyperledger Fabric - Blockchain, sushi and supply chain    Hyperledger Fabric - Blockchain, sushi and supply chain
Hyperledger Fabric - Blockchain, sushi and supply chain
 
Hyperledger community update 20180528
Hyperledger community update 20180528Hyperledger community update 20180528
Hyperledger community update 20180528
 
Blockchain explained FIATA Congress 20180910
Blockchain explained FIATA Congress 20180910Blockchain explained FIATA Congress 20180910
Blockchain explained FIATA Congress 20180910
 
An introduction to blockchain and hyperledger v ru
An introduction to blockchain and hyperledger v ruAn introduction to blockchain and hyperledger v ru
An introduction to blockchain and hyperledger v ru
 
Hyperledger Fabric Update - June 2018
Hyperledger Fabric Update - June 2018Hyperledger Fabric Update - June 2018
Hyperledger Fabric Update - June 2018
 
Hyperledger Fabric in a Nutshell
Hyperledger Fabric in a NutshellHyperledger Fabric in a Nutshell
Hyperledger Fabric in a Nutshell
 
Introduction of Hyperledger Fabric & Composer
Introduction of Hyperledger Fabric & Composer Introduction of Hyperledger Fabric & Composer
Introduction of Hyperledger Fabric & Composer
 
Wwc developing hyperledger applications v4
Wwc  developing hyperledger applications v4Wwc  developing hyperledger applications v4
Wwc developing hyperledger applications v4
 
Anatomy of a hyperledger application
Anatomy of a hyperledger applicationAnatomy of a hyperledger application
Anatomy of a hyperledger application
 
Blockchain - HyperLedger Fabric
Blockchain - HyperLedger FabricBlockchain - HyperLedger Fabric
Blockchain - HyperLedger Fabric
 
Bitmark and Hyperledger Workshop: the Digital Assets and Property
Bitmark and Hyperledger Workshop: the Digital Assets and PropertyBitmark and Hyperledger Workshop: the Digital Assets and Property
Bitmark and Hyperledger Workshop: the Digital Assets and Property
 
First steps with Bitcoin
First steps with BitcoinFirst steps with Bitcoin
First steps with Bitcoin
 
Blockchain Hyperledger Fabric
Blockchain Hyperledger FabricBlockchain Hyperledger Fabric
Blockchain Hyperledger Fabric
 
Hyperledger Fabric & Composer
Hyperledger Fabric & Composer Hyperledger Fabric & Composer
Hyperledger Fabric & Composer
 

Similaire à Hyperleger Fabric Workshop - Denver Blockchain Week

The Unicorn Project and The Five Ideals (Updated Dec 2019)
The Unicorn Project and The Five Ideals (Updated Dec 2019)The Unicorn Project and The Five Ideals (Updated Dec 2019)
The Unicorn Project and The Five Ideals (Updated Dec 2019)
Gene Kim
 
MNSEC 2018 - Observations from the APNIC Community Honeynet Project
MNSEC 2018 -  Observations from the APNIC Community Honeynet Project MNSEC 2018 -  Observations from the APNIC Community Honeynet Project
MNSEC 2018 - Observations from the APNIC Community Honeynet Project
MNCERT
 

Similaire à Hyperleger Fabric Workshop - Denver Blockchain Week (20)

Tools, Tips and Techniques for Developing Real-time Apps. Phil Leggetter
Tools, Tips and Techniques for Developing Real-time Apps. Phil LeggetterTools, Tips and Techniques for Developing Real-time Apps. Phil Leggetter
Tools, Tips and Techniques for Developing Real-time Apps. Phil Leggetter
 
PyConWeb - 2019 Auditing websites & apps for privacy leaks.
PyConWeb - 2019 Auditing websites & apps for privacy leaks.PyConWeb - 2019 Auditing websites & apps for privacy leaks.
PyConWeb - 2019 Auditing websites & apps for privacy leaks.
 
The Unicorn Project and The Five Ideals (Updated Dec 2019)
The Unicorn Project and The Five Ideals (Updated Dec 2019)The Unicorn Project and The Five Ideals (Updated Dec 2019)
The Unicorn Project and The Five Ideals (Updated Dec 2019)
 
Getting up and running with Hyperledger Fabric & Composer (Full Stack)
Getting up and running with Hyperledger Fabric & Composer (Full Stack)Getting up and running with Hyperledger Fabric & Composer (Full Stack)
Getting up and running with Hyperledger Fabric & Composer (Full Stack)
 
Achieving Technical Excellence in Your Software Teams - from Devternity
Achieving Technical Excellence in Your Software Teams - from Devternity Achieving Technical Excellence in Your Software Teams - from Devternity
Achieving Technical Excellence in Your Software Teams - from Devternity
 
Security/Auditing in Puppet
Security/Auditing in PuppetSecurity/Auditing in Puppet
Security/Auditing in Puppet
 
Auditing/Security with Puppet - PuppetConf 2014
Auditing/Security with Puppet - PuppetConf 2014Auditing/Security with Puppet - PuppetConf 2014
Auditing/Security with Puppet - PuppetConf 2014
 
Codemgmt
CodemgmtCodemgmt
Codemgmt
 
HyperLedger LightningTalk BjoernSimon
HyperLedger LightningTalk BjoernSimonHyperLedger LightningTalk BjoernSimon
HyperLedger LightningTalk BjoernSimon
 
HyperLedger Lightning-Talk BjoernSimon
HyperLedger Lightning-Talk BjoernSimonHyperLedger Lightning-Talk BjoernSimon
HyperLedger Lightning-Talk BjoernSimon
 
Github security bug bounty hunting
Github security   bug bounty huntingGithub security   bug bounty hunting
Github security bug bounty hunting
 
Continuum Analytics and Python
Continuum Analytics and PythonContinuum Analytics and Python
Continuum Analytics and Python
 
MNSEC 2018 - Observations from the APNIC Community Honeynet Project
MNSEC 2018 -  Observations from the APNIC Community Honeynet Project MNSEC 2018 -  Observations from the APNIC Community Honeynet Project
MNSEC 2018 - Observations from the APNIC Community Honeynet Project
 
Defcon Blue Team Village 2020: Purple On My Mind: Cost Effective Automated Ad...
Defcon Blue Team Village 2020: Purple On My Mind: Cost Effective Automated Ad...Defcon Blue Team Village 2020: Purple On My Mind: Cost Effective Automated Ad...
Defcon Blue Team Village 2020: Purple On My Mind: Cost Effective Automated Ad...
 
How to Build an Effective API Security Strategy
How to Build an Effective API Security StrategyHow to Build an Effective API Security Strategy
How to Build an Effective API Security Strategy
 
What is being exposed from IoT Devices
What is being exposed from IoT DevicesWhat is being exposed from IoT Devices
What is being exposed from IoT Devices
 
EMFcamp2022 - What if apps logged into you, instead of you logging into apps?
EMFcamp2022 - What if apps logged into you, instead of you logging into apps?EMFcamp2022 - What if apps logged into you, instead of you logging into apps?
EMFcamp2022 - What if apps logged into you, instead of you logging into apps?
 
Lost and Found Certificates: dealing with residual certificates for pre-owned...
Lost and Found Certificates: dealing with residual certificates for pre-owned...Lost and Found Certificates: dealing with residual certificates for pre-owned...
Lost and Found Certificates: dealing with residual certificates for pre-owned...
 
Wi-Fi Hotspot Attacks
Wi-Fi Hotspot AttacksWi-Fi Hotspot Attacks
Wi-Fi Hotspot Attacks
 
900 keynote abbott
900 keynote abbott900 keynote abbott
900 keynote abbott
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Dernier (20)

Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 

Hyperleger Fabric Workshop - Denver Blockchain Week

  • 1. @horeaporutiu IBM Developer Horea Porutiu Developer Advocate, IBM October 2018 Hyperledger Fabric Workshop
  • 2. Slides IBM Developer@horeaporutiu @pluralsight • Available on Twitter after talk • http://slideshare.net/HoreaPorutiu
  • 3. Agenda 1. Fabric High Level Idea 2. Actors in Fabric Network 3. Channels 4. Chaincode 5. Endorsement Policy 6. Transaction Flow 7. Demo 8. Inspect Chaincode IBM Developer@horeaporutiu @pluralsight
  • 4. Hyperledger Fabric IBM Developer@horeaporutiu https://www.pinterest.com/pin/215469163401716164/
  • 5. Hyperledger vs. Ethereum Throughput @horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric • Approximate throughput - Ethereum: 1,000 / minute
  • 6. Hyperledger vs. Ethereum Throughput @horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric • Approximate throughput - Ethereum: 1,000 / minute • Approximate throughput - Hyperlegder: 500,000 / minute
  • 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
  • 12. Concepts @horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric • NOT central database • Data is distributed • If you make a mistake, you need to have another transaction to fix it.
  • 13. Concepts @horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric • NOT central database • Data is distributed • If you make a mistake, you need to have another transaction to fix it. •No ‘delete’ operation in Hyperledger
  • 14. Concepts @horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/fabric • NOT central database • Data is distributed • If you make a mistake, you need to have another transaction to fix it. •No ‘delete’ operation in Hyperledger • Cannot change ledger
  • 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
  • 47. Actors - Peer @horeaporutiu IBM Developer • Main working horse
  • 48. Actors - Peer @horeaporutiu IBM Developer • Main working horse • Where ledger / blockchain is stored
  • 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
  • 67. Channels @horeaporutiu IBM Developer • Main way of data isolation
  • 68. Channels @horeaporutiu IBM Developer • Main way of data isolation • Separate instance of Hyperledger Fabric
  • 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
  • 73. Channels Part 2 @horeaporutiu IBM Developer • Before you join channel, you must create channel
  • 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
  • 76. Chaincode @horeaporutiu IBM Developer • Chaincode = smart contract
  • 77. Chaincode @horeaporutiu IBM Developer • Chaincode = smart contract • How you read and update ledger
  • 78. Chaincode @horeaporutiu IBM Developer • Chaincode = smart contract • How you read and update ledger • SDK makes transactions and executes chaincode
  • 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?
  • 90. Endorsement Policy @horeaporutiu IBM Developer • This is consensus mechanism of Fabric
  • 91. Endorsement Policy @horeaporutiu IBM Developer • This is consensus mechanism of Fabric • Operation must be verified before we update the ledger
  • 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
  • 98. Recap @horeaporutiu IBM Developer • Inside 1 channel, can have as many chain codes as you want
  • 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
  • 109. Approaches for development @horeaporutiu IBM Developer Cloud • Run docker containers (peer, orderer, certificate authority, couchDb) Local
  • 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
  • 114. Our approach @horeaporutiu IBM Developer Cloud - via the IBM Blockchain Platform
  • 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
  • 117. Hyperledger Fabric SDK Overview IBM Developer@horeaporutiu Blockchain network - 1 org Certificate Authority Orderer Peer (Local) Node.js app + Fabric SDK
  • 118. Node.js app + Fabric SDK IBM Developer@horeaporutiu Blockchain network - 1 org Certificate Authority Orderer Peer (Local) 1. Enrollment - Register admin with Certificate Auth Hyperledger Fabric SDK Overview Chaincode Database Blockchain network - 1 org Certificate AuthorityCertificate Authority Orderer Peer Chaincode Database 1.
  • 119. Enrollment IBM Developer@horeaporutiu • Enrollment - process of generating keys and certificates from the Certificate Authority
  • 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
  • 121. Hyperledger Fabric SDK - Enrollment Node.js app + Fabric SDK IBM Developer@horeaporutiu Blockchain network - 1 org Certificate Authority (Local) 1. 1. Enrollment - Register admin with Certificate Auth Certificate Authority Orderer Peer Chaincode Database
  • 122. Node.js app + Fabric SDK IBM Developer@horeaporutiu Blockchain network - 1 org Certificate Authority Orderer (Local) 1. Enrollment - Register admin with Certificate Auth 2. Register users 🔑 Hyperledger Fabric SDK - Enrollment Peer Chaincode Database Blockchain network - 1 org Certificate Authority Orderer Peer Chaincode Database Blockchain network - 1 org Certificate AuthorityCertificate Authority Orderer Peer Chaincode Database 2. 1.
  • 123. Hyperledger Fabric SDK - Transaction Node.js app + Fabric SDK IBM Developer@horeaporutiu Blockchain network - 1 org Certificate Authority Orderer (Local) 1. Enrollment - Register admin with Certificate Auth 2. Register users 3. Send transaction to peer 🔑 Peer Chaincode Database Blockchain network - 1 org Certificate Authority Orderer Peer Chaincode Database Blockchain network - 1 org Certificate AuthorityCertificate Authority Orderer Peer Chaincode Database 3. 2. 1.
  • 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
  • 129. 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.
  • 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
  • 141. Problem IBM Developer@horeaporutiu 1 in 10 people fall ill every year from eating contaminated food - World Health Organization
  • 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
  • 149. @horeaporutiu IBM Developer What if we find out that all products from Grandma’s Farm are contaminated?
  • 150. Food Contamination - Grandma’s Farm IBM Developer@horeaporutiu https://tenor.com/view/michael-scott-no-nogod-please-gif-5739001
  • 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
  • 171. IBM Blockchain Platform UI IBM Developer@horeaporutiu