Introduction
Problem
Solution
Hyperledger History December 2015 the Linux Foundation announced the creation of the Hyperledger Project February 2016 The founding members of the project were announced In early 2016, the project began accepting proposals for incubation of codebases and other technologies as core elements. 12 July 2017 the project announced its production-ready Hyperledger Fabric 1.0 and it started to gain popularity July 2017 London Stock Exchange Group in a partnership with IBM announced that it will create a Blockchain platform designed for digitally issuing shares of Italian companies. Hyperledger Fabric will form the basis of the platform September 2017 The Royal Bank of Canada (RBC) have started using Hyperledger Fabric for its US - Canada interbank settlements.
What is Hyperledger?
Where are we now?
Benefits of Private Blockchains 1. 100%	Uptime 2. Solves	the	Byzantium	Generals	problem	for	data synchronization 3. The	data	are	Immutable	/	Incorruptible 4. The	algorithm	is	Immutable	/	Incorruptible 5. Traceable
When do you need a blockchain?
When not to use Blockchain 1. The	process	stores	a	lot	of	static	data,	or	the	data	is	quite large 2. Rules	of	transactions	change	frequently 3. The	use	of	external	services	to	gather/store	data
Bitcoin Ethereum Hyperledger Frameworks Cryptocurrency based Yes Yes No Permissioned No No Yes (in general) Pseudo-anonymous Yes No No Auditable Yes Yes Yes Immutable ledger Yes Yes Yes Modularity No No Yes Smart contracts No Yes Yes Consensus protocol PoW PoW Various** Comparing blockchains **Key	Hyperledger consensus	protocols	are	Apache	Kafka	in	Hyperledger Fabric,	PoET in	Hyperledger Sawtooth,	RBFT in	Hyperledger Indy,	Tendermint in	Hyperledger Burrow,	and	Yet	Another	Consensus	(YAC)	in	Hyperledger Iroha.	For more	details,	see	the	Hyperledger	Architecture,	Volume	1 paper.
Other Hyperledger Blockchains HYPERLEDGER Burrow HYPERLEDGER	FABRIC
Other Hyperledger Tools Cello Composer Explorer Quilt Hyperledger Cello:	Implement	Blockchain-as-a-Service	and	contributed	by	IBM.	Baohua Yang	and	Haitao Yue	from	IBM	Research	are	committed	part-time	to	developing	and	maintaining	the	project. Hyperledger Composer:	Blockchain package	management	tooling	contributed	by	IBM.	Composer	is	a user-facing	rapid	prototyping	tooling,	running	on	top	of	Hyperledger Fabric,	which	allows	the	easy management	of	Assets	(data	stored	on	the	blockchain),	Participants	(identity	management,	or	member services)	and	Transactions	(Chaincode,	or	Smart	Contracts	which	operate	on	Assets	on	the	behalf	of	a Participant).	The	resulting	application	can	be	exported	as	a	package	(a	BNA	file)	which	may	be	executed on	a	Hyperledger Fabric	instance,	with	the	support	of	a	Node.js application	(based	on	the	Loopback application	framework)	and	provide	a	REST	interface	to	external	applications. Hyperledger Explorer: Blockchain analytics	tooling	contributed	by	IBM,	Intel,	and	DTCC. Hyperledger Quilt:	Transfer	value	between	and	outside	of	distributed	ledgers.	Uses	the	ILP payments	protocol.
Products Hyperledger Hyperledger Indy Hyperledger Quilt Hyperledger Fabric Hyperledger Composer Hyperledger Explorer Hyperledger Cello Hyperledger Iroha Hyperledger Sawtooth Hyperledger Burrow Frameworks Tools
What is Hyperledger Fabric?
Fabric: Key Points 1. Smart	Contracts:	A	shared	ledger	and	smart	contracts implemented	as	‘chaincode’ 2. Identity	Management:	Privacy	and	permissioning through membership	services	enables	confidentiality. 3. Flexible:	Modular	architecture	and	flexible	hosting	options 4. Efficient	processing:	Practical	Byzantine	Fault	Tolerant.
The Lifecycle of a Smart Contract Client Ordering Service Peers Creates	the Smart Contract	/ Transaction Creates	a Block Accepts	the Block	onto the Blockchain Peers Validates Transaction Client Signs Transaction
SDKs Smart Contracts
Composer Language, Libraries and Frameworks
generator-hyperledger- composer Yeoman skeleton Angular Application Angular Hyperledger	Composer	Components CLI composer-cli REST	Server composer-rest- server Loopback Connector Web	Playground JavaScript	SDK Supported	Runtimes Embedded Node.js Hyperledger Fabric Web Yeoman	generates	a skeleton	Angular	app. This	communicates	with	the	REST	api generated	by	the	Composer	REST	Server. ID	Cards	(connection	profiles	and	credentials)	are used	to	connect	to	the	distributed	ledger. Hyperledger Dapp (Client)
Hyperledger Composer Project Structure
Set-up Open a Terminal from your desktop and move into the hyperledger directory: cd ~/hyperledger/my-network Then type: code . To open your IDE.
README.md Replace all the text in this directory with: # My Commodity Trading Network
package.json Change the text highlighted in Yellow below: "name": "my-network", "version": "0.1.6", "description": "My Commodity Trading network", "networkImage": "https://hyperledger.github.io/composer-sample- networks/packages/basic-sample-network/networkimage.svg", "networkImageanimated": "https://hyperledger.github.io/composer-sample-networks/packages/basic-sample- network/networkimageanimated.svg", "scripts": { "prepublish": "mkdirp ./dist ; composer archive create --sourceType dir -- sourceName . -a ./dist/my-network.bna",
Model File (.cto) A Hyperledger Composer CTO file is composed of the following elements: ● A single namespace. All resource declarations within the file are implicitly in this namespace. ● A set of resource definitions ● Assets ● Transactions ● Participants ● Events. ● Optional import declarations that import resources from other namespaces. CTO Language: https://hyperledger.github.io/composer/reference/cto_language.html
Model File (.cto) /** * Commodity trading network */ namespace org.acme.mynetwork asset Commodity identified by tradingSymbol { o String tradingSymbol o String description o String mainExchange o Double quantity --> Trader owner } participant Trader identified by traderId { o String traderId o String firstName o String lastName } transaction Trade { --> Commodity commodity --> Trader newOwner }
Transaction Processing File (.js) (aka the business logic) Transaction processor functions are automatically invoked by the runtime when transactions are submitted using the BusinessNetworkConnection API. /** * A transaction processor function description * @param {org.example.sampleTransaction} parameter-name A human description of the parameter * @transaction */ Document: https://hyperledger.github.io/composer/reference/js_scripts.html
Logic File (.js) /** * Track the trade of a commodity from one trader to another * @param {org.acme.mynetwork.Trade} trade - the trade to be * processed * @transaction */ function tradeCommodity(trade) { // set the new owner of the commodity trade.commodity.owner = trade.newOwner; return getAssetRegistry('org.acme.mynetwork.Commodity') .then(function (assetRegistry) { // persist the state of the commodity return assetRegistry.update(trade.commodity); }); }
Access Control Langage (acl) Hyperledger Composer differentiates between access control for resources within a business network (business access control) and access control for network administrative changes (network access control). Business access control and network access control are both defined in the access control file (.acl) for a business network. Network access control uses the system namespace, which is implicitly extended by all resources in a business network; and grants or denies access to specific actions as defined below, and is intended to allow for more nuanced access to certain network-level operations. Document: https://hyperledger.github.io/composer/reference/acl_language.html
Permissions (.acl) /** * Access control rules for mynetwork */ rule Default { description: "Allow all participants full access" participant: "ANY" operation: ALL resource: "org.acme.mynetwork.*" action: ALLOW } rule SystemACL { description: "System ACL to permit all access" participant: "org.hyperledger.composer.system.Participant" operation: ALL resource: "org.hyperledger.composer.system.**" action: ALLOW }
Hyperledger Composer Query Language Queries in Hyperledger Composer are written in a bespoke query language. Queries can be written with undefined parameters that must be supplied when running the query. For example, the following query returns all drivers where the age property is greater than the supplied parameter: query Q17 { description: "Select all drivers aged older than PARAM" statement: SELECT org.acme.Driver WHERE (_$ageParam < age) } Document: https://hyperledger.github.io/composer/reference/query-language.html
Queries (.qry) query selectCommoditiesByOwner { description: "Select all commodities based on their owner" statement: SELECT org.acme.mynetwork.Commodity WHERE (owner == _$owner) }
Generate our Business Network Archive (.bna) In the terminal type: npm install When this command is complete, move into the dist directory and deploy the network. cd dist composer network deploy -a my-network.bna -p hlfv1 -i PeerAdmin -s randomString Wait for ‘command succeeded’ (Extra Time: Ping the network) composer network ping -n my-network -p hlfv1 -i admin -s adminpw
Online Playground http://composer-playground.mybluemix.net
Generate the Rest Server In the terminal type: composer-rest-server Answer the following questions: Enter your connection profile name: hlfv1 Enter your business network name: my-network Enter your enrollment ID: admin Enter your enrollment secret: adminpw Do you want namespaces? never use namespaces Enable auth for the REST API using Passport? No Enable event publication over web sockets? Yes Do you want enable TLS security? No Open the following URL: http://localhost:3000/explorer
Generate the App In a NEW terminal type: yo hyperledger-composer Answer the following questions: Type of Application: Angular Connect to a running Business Network? Yes Name of the application? my-app Description of the application: Commodities App Author name: user Author email: user@acme.org License: Apache-2.0 Business network identifier? my-network Connection profile? hlfv1 Enrollment id: admin Enrollment Secret: adminpw New REST API? Connect to an existing REST API REST Server Address?: http://localhost Port number? 3000 Use namespaces? Namespaces are not used
Generate the App After it’s finished, type: cd my-app npm start Open the following URL: http://localhost:4200
SafeBear Blockchain Courses
Many other Crash Courses
Other Certified Courses
Discount YOLKIT2018 safebear.co.uk/courses/ hello@safebear.co.uk 02921	28	0321
Tech Talk - Blockchain presentation

Tech Talk - Blockchain presentation

  • 2.
  • 3.
  • 4.
  • 5.
    Hyperledger History December 2015the Linux Foundation announced the creation of the Hyperledger Project February 2016 The founding members of the project were announced In early 2016, the project began accepting proposals for incubation of codebases and other technologies as core elements. 12 July 2017 the project announced its production-ready Hyperledger Fabric 1.0 and it started to gain popularity July 2017 London Stock Exchange Group in a partnership with IBM announced that it will create a Blockchain platform designed for digitally issuing shares of Italian companies. Hyperledger Fabric will form the basis of the platform September 2017 The Royal Bank of Canada (RBC) have started using Hyperledger Fabric for its US - Canada interbank settlements.
  • 6.
  • 7.
  • 8.
    Benefits of Private Blockchains 1.100% Uptime 2. Solves the Byzantium Generals problem for data synchronization 3. The data are Immutable / Incorruptible 4. The algorithm is Immutable / Incorruptible 5. Traceable
  • 9.
    When do youneed a blockchain?
  • 10.
    When not touse Blockchain 1. The process stores a lot of static data, or the data is quite large 2. Rules of transactions change frequently 3. The use of external services to gather/store data
  • 11.
    Bitcoin Ethereum HyperledgerFrameworks Cryptocurrency based Yes Yes No Permissioned No No Yes (in general) Pseudo-anonymous Yes No No Auditable Yes Yes Yes Immutable ledger Yes Yes Yes Modularity No No Yes Smart contracts No Yes Yes Consensus protocol PoW PoW Various** Comparing blockchains **Key Hyperledger consensus protocols are Apache Kafka in Hyperledger Fabric, PoET in Hyperledger Sawtooth, RBFT in Hyperledger Indy, Tendermint in Hyperledger Burrow, and Yet Another Consensus (YAC) in Hyperledger Iroha. For more details, see the Hyperledger Architecture, Volume 1 paper.
  • 12.
  • 13.
    Other Hyperledger Tools Cello Composer Explorer Quilt Hyperledger Cello: Implement Blockchain-as-a-Service and contributed by IBM. BaohuaYang and Haitao Yue from IBM Research are committed part-time to developing and maintaining the project. Hyperledger Composer: Blockchain package management tooling contributed by IBM. Composer is a user-facing rapid prototyping tooling, running on top of Hyperledger Fabric, which allows the easy management of Assets (data stored on the blockchain), Participants (identity management, or member services) and Transactions (Chaincode, or Smart Contracts which operate on Assets on the behalf of a Participant). The resulting application can be exported as a package (a BNA file) which may be executed on a Hyperledger Fabric instance, with the support of a Node.js application (based on the Loopback application framework) and provide a REST interface to external applications. Hyperledger Explorer: Blockchain analytics tooling contributed by IBM, Intel, and DTCC. Hyperledger Quilt: Transfer value between and outside of distributed ledgers. Uses the ILP payments protocol.
  • 14.
  • 15.
  • 16.
    Fabric: Key Points 1.Smart Contracts: A shared ledger and smart contracts implemented as ‘chaincode’ 2. Identity Management: Privacy and permissioning through membership services enables confidentiality. 3. Flexible: Modular architecture and flexible hosting options 4. Efficient processing: Practical Byzantine Fault Tolerant.
  • 17.
    The Lifecycle ofa Smart Contract Client Ordering Service Peers Creates the Smart Contract / Transaction Creates a Block Accepts the Block onto the Blockchain Peers Validates Transaction Client Signs Transaction
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
    Set-up Open a Terminalfrom your desktop and move into the hyperledger directory: cd ~/hyperledger/my-network Then type: code . To open your IDE.
  • 23.
    README.md Replace all thetext in this directory with: # My Commodity Trading Network
  • 24.
    package.json Change the texthighlighted in Yellow below: "name": "my-network", "version": "0.1.6", "description": "My Commodity Trading network", "networkImage": "https://hyperledger.github.io/composer-sample- networks/packages/basic-sample-network/networkimage.svg", "networkImageanimated": "https://hyperledger.github.io/composer-sample-networks/packages/basic-sample- network/networkimageanimated.svg", "scripts": { "prepublish": "mkdirp ./dist ; composer archive create --sourceType dir -- sourceName . -a ./dist/my-network.bna",
  • 25.
    Model File (.cto) AHyperledger Composer CTO file is composed of the following elements: ● A single namespace. All resource declarations within the file are implicitly in this namespace. ● A set of resource definitions ● Assets ● Transactions ● Participants ● Events. ● Optional import declarations that import resources from other namespaces. CTO Language: https://hyperledger.github.io/composer/reference/cto_language.html
  • 26.
    Model File (.cto) /** *Commodity trading network */ namespace org.acme.mynetwork asset Commodity identified by tradingSymbol { o String tradingSymbol o String description o String mainExchange o Double quantity --> Trader owner } participant Trader identified by traderId { o String traderId o String firstName o String lastName } transaction Trade { --> Commodity commodity --> Trader newOwner }
  • 27.
    Transaction Processing File (.js) (akathe business logic) Transaction processor functions are automatically invoked by the runtime when transactions are submitted using the BusinessNetworkConnection API. /** * A transaction processor function description * @param {org.example.sampleTransaction} parameter-name A human description of the parameter * @transaction */ Document: https://hyperledger.github.io/composer/reference/js_scripts.html
  • 28.
    Logic File (.js)/** * Track the trade of a commodity from one trader to another * @param {org.acme.mynetwork.Trade} trade - the trade to be * processed * @transaction */ function tradeCommodity(trade) { // set the new owner of the commodity trade.commodity.owner = trade.newOwner; return getAssetRegistry('org.acme.mynetwork.Commodity') .then(function (assetRegistry) { // persist the state of the commodity return assetRegistry.update(trade.commodity); }); }
  • 29.
    Access Control Langage (acl) HyperledgerComposer differentiates between access control for resources within a business network (business access control) and access control for network administrative changes (network access control). Business access control and network access control are both defined in the access control file (.acl) for a business network. Network access control uses the system namespace, which is implicitly extended by all resources in a business network; and grants or denies access to specific actions as defined below, and is intended to allow for more nuanced access to certain network-level operations. Document: https://hyperledger.github.io/composer/reference/acl_language.html
  • 30.
    Permissions (.acl) /** * Accesscontrol rules for mynetwork */ rule Default { description: "Allow all participants full access" participant: "ANY" operation: ALL resource: "org.acme.mynetwork.*" action: ALLOW } rule SystemACL { description: "System ACL to permit all access" participant: "org.hyperledger.composer.system.Participant" operation: ALL resource: "org.hyperledger.composer.system.**" action: ALLOW }
  • 31.
    Hyperledger Composer Query Language Queries inHyperledger Composer are written in a bespoke query language. Queries can be written with undefined parameters that must be supplied when running the query. For example, the following query returns all drivers where the age property is greater than the supplied parameter: query Q17 { description: "Select all drivers aged older than PARAM" statement: SELECT org.acme.Driver WHERE (_$ageParam < age) } Document: https://hyperledger.github.io/composer/reference/query-language.html
  • 32.
    Queries (.qry) query selectCommoditiesByOwner{ description: "Select all commodities based on their owner" statement: SELECT org.acme.mynetwork.Commodity WHERE (owner == _$owner) }
  • 33.
    Generate our Business Network Archive(.bna) In the terminal type: npm install When this command is complete, move into the dist directory and deploy the network. cd dist composer network deploy -a my-network.bna -p hlfv1 -i PeerAdmin -s randomString Wait for ‘command succeeded’ (Extra Time: Ping the network) composer network ping -n my-network -p hlfv1 -i admin -s adminpw
  • 34.
  • 35.
    Generate the Rest Server Inthe terminal type: composer-rest-server Answer the following questions: Enter your connection profile name: hlfv1 Enter your business network name: my-network Enter your enrollment ID: admin Enter your enrollment secret: adminpw Do you want namespaces? never use namespaces Enable auth for the REST API using Passport? No Enable event publication over web sockets? Yes Do you want enable TLS security? No Open the following URL: http://localhost:3000/explorer
  • 36.
    Generate the AppIn a NEW terminal type: yo hyperledger-composer Answer the following questions: Type of Application: Angular Connect to a running Business Network? Yes Name of the application? my-app Description of the application: Commodities App Author name: user Author email: user@acme.org License: Apache-2.0 Business network identifier? my-network Connection profile? hlfv1 Enrollment id: admin Enrollment Secret: adminpw New REST API? Connect to an existing REST API REST Server Address?: http://localhost Port number? 3000 Use namespaces? Namespaces are not used
  • 37.
    Generate the App Afterit’s finished, type: cd my-app npm start Open the following URL: http://localhost:4200
  • 38.
  • 39.
  • 40.
  • 41.