@horeaporutiu IBM Developer
Horea Porutiu
Developer Advocate, IBM
October 2018
Developing Applications with
Hyperledger Fabric SDK
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
Hyperledger Fabric
IBM Developer@horeaporutiu https://www.pinterest.com/pin/215469163401716164/
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
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
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.
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
Hopefully you will feel like this after
IBM Developer@horeaporutiu https://www.pinterest.com/pin/427630927097492361
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
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
Contact
• Questions: horea.porutiu@ibm.com
• Social: Tweets @horeaporutiu
• Site: https://horeaporutiu.github.io/
• Medium: https://medium.com/@horeaporutiu
@horeaporutiu IBM Developer
@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

Developing applications with Hyperledger Fabric SDK

  • 1.
    @horeaporutiu IBM Developer HoreaPorutiu Developer Advocate, IBM October 2018 Developing Applications with Hyperledger Fabric SDK
  • 2.
    Agenda 1. Hyperledger Fabricv. 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
  • 3.
    Hyperledger Fabric IBM Developer@horeaporutiuhttps://www.pinterest.com/pin/215469163401716164/
  • 4.
    Hyperledger Fabric v.Composer • Original project @horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/composerhttps://www.hyperledger.org/projects/fabric
  • 5.
    • Learn FabricSDK - Node.js, Java • Original project @horeaporutiu IBM Developerhttps://www.hyperledger.org/projects/composerhttps://www.hyperledger.org/projects/fabric Hyperledger Fabric v. Composer
  • 6.
    • Learn FabricSDK - 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 FabricSDK - 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 FabricSDK - 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 FabricSDK - 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 FabricSDK - 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 FabricSDK - 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 FabricSDK - 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
  • 13.
    Approaches for development @horeaporutiuIBM Developer Cloud • Run docker containers (peer, orderer, certificate authority, couchDb) Local
  • 14.
    Approaches for development @horeaporutiuIBM Developer Cloud • Run docker containers (peer, orderer, certificate authority, couchDb) Local • Inviting other orgs, viewing blocks is hard
  • 15.
    Approaches for development @horeaporutiuIBM 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 @horeaporutiuIBM 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 @horeaporutiuIBM 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
  • 18.
    Our approach @horeaporutiu IBMDeveloper Cloud - via the IBM Blockchain Platform
  • 19.
  • 20.
    How do youget 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 @horeaporutiuIBM 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.
  • 22.
    Hyperledger Fabric SDKOverview IBM Developer@horeaporutiu Blockchain network - 1 org Certificate Authority Orderer Peer (Local) Node.js app + Fabric SDK
  • 23.
    Node.js app + FabricSDK 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.
  • 24.
    Enrollment IBM Developer@horeaporutiu • Enrollment- process of generating keys and certificates from the Certificate Authority
  • 25.
    Enrollment IBM Developer@horeaporutiu • Firstgenerate 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
  • 26.
    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
  • 27.
    Node.js app + FabricSDK 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.
  • 28.
    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.
  • 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
  • 34.
    Node.js app + FabricSDK 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.
  • 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 + FabricSDK 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
  • 45.
  • 46.
    Problem IBM Developer@horeaporutiu 1 in10 people fall ill every year from eating contaminated food - World Health Organization
  • 47.
    Use Case -IBM Food Trust IBM Developer@horeaporutiu • One of the first solutions in-production using blockchain
  • 48.
    IBM Developer@horeaporutiu • Oneof the first solutions in-production using blockchain • Smarter, safer, more sustainable food supply chain Use Case - IBM Food Trust
  • 49.
    IBM Developer@horeaporutiu • Oneof 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 • Oneof 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 • Oneof 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 • Oneof 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
  • 53.
  • 54.
    @horeaporutiu IBM Developer Whatif we find out that all products from Grandma’s Farm are contaminated?
  • 55.
    Food Contamination -Grandma’s Farm IBM Developer@horeaporutiu https://tenor.com/view/michael-scott-no-nogod-please-gif-5739001
  • 56.
  • 57.
  • 58.
    Hopefully you willfeel like this after IBM Developer@horeaporutiu https://www.pinterest.com/pin/427630927097492361
  • 59.
    IBM Blockchain StarterPlan 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 • Helloworld 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
  • 61.
    Contact • Questions: horea.porutiu@ibm.com •Social: Tweets @horeaporutiu • Site: https://horeaporutiu.github.io/ • Medium: https://medium.com/@horeaporutiu @horeaporutiu IBM Developer
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
    IBM Blockchain PlatformUI IBM Developer@horeaporutiu