The document discusses Hyperledger Fabric and the Hyperledger Fabric SDK. It provides an overview of the Fabric SDK and demonstrates how to use it to interact with a Hyperledger Fabric network, including enrollment, invoking chaincode to read and write to the ledger, and submitting transactions. It also discusses an IBM Food Trust use case for tracking food supply chains using Hyperledger Fabric.
2. Agenda
1. Hyperledger Fabric v.
Composer
2. Approaches for
Development
3. Hyperledger Fabric SDK
overview
4. IBM’s BaaS (blockchain-
as-a-service) Demo
5. Use Case
IBM Developer@horeaporutiu
@pluralsight
4. Hyperledger Fabric v. Composer
• Original project
@horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/composerhttps://www.hyperledger.org/projects/fabric
5. • 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
6. • 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
7. • 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
8. • 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
9. • 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
10. • 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
11. • 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
12. • 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
14. Approaches for development
@horeaporutiu IBM Developer
Cloud
• Run docker
containers (peer,
orderer, certificate
authority, couchDb)
Local
• Inviting other orgs,
viewing blocks is hard
15. 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
16. 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
17. 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
20. 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
21. 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.
25. 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
29. 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.
30. 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);
31. 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
32. 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
33. 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
35. 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’;
}
36. 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
🔑
37. 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
🔑
38. 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
🔑
39. 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
🔑
40. 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.
41. 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.
🔑
42. 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
🔑
43. 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
🔑
44. 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
47. Use Case - IBM Food Trust
IBM Developer@horeaporutiu
• One of the first solutions in-production using blockchain
48. IBM Developer@horeaporutiu
• One of the first solutions in-production using blockchain
• Smarter, safer, more sustainable food supply chain
Use Case - IBM Food Trust
49. 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
50. 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
51. 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
52. 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
58. Hopefully you will feel like this after
IBM Developer@horeaporutiu https://www.pinterest.com/pin/427630927097492361
59. 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
60. Code Patterns
• Hello world Hyperledger Fabric Car Auction -
https://github.com/IBM/car-auction-network-
fabric-node-sdk
@horeaporutiu IBM Code
• Blockchain Bean UI - https://www.ibm.com/
thought-leadership/blockchainbean/index.html
• Blockchain Bean Code -https://github.com/IBM/
blockchainbean