Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

Developing Business Blockchain Applications on Hyperledger

Workshop on developing business Blockchain applications
on Hyperledger using a virtual server on Google cloud platform

Developing Business Blockchain Applications on Hyperledger

  1. 1. Thanachart Numnonda, thanachart@imcinstitute.clockchain App on Hyperledger Developing Business Blockchain Applications on Hyperledger May 2018 Dr.Thanachart Numnonda IMC Institute thanachart@imcinstitute.com
  2. 2. Thanachart Numnonda, thanachart@imcinstitute.clockchain App on Hyperledger Launch an Ubuntu virtual server Using Google Cloud Platform (You can skip this part if you already have an Ubuntu server)
  3. 3. Thanachart Numnonda, thanachart@imcinstitute.clockchain App on Hyperledger Launch Google Cloud Virtual Server In this lab, we will use a GCP’s compute engine as our server w ● Ubuntu Server 14.04 LTS ● 2 vCPU, 7.5 GB memory ● 50 GB SSD
  4. 4. Thanachart Numnonda, thanachart@imcinstitute.clockchain App on Hyperledger cloud.google.com
  5. 5. Thanachart Numnonda, thanachart@imcinstitute.clockchain App on Hyperledger Create Google Cloud Project
  6. 6. Thanachart Numnonda, thanachart@imcinstitute.clockchain App on Hyperledger
  7. 7. Thanachart Numnonda, thanachart@imcinstitute.clockchain App on Hyperledger Select Compute Engine
  8. 8. Thanachart Numnonda, thanachart@imcinstitute.clockchain App on Hyperledger Select Create Instance
  9. 9. Thanachart Numnonda, thanachart@imcinstitute.clockchain App on Hyperledger Create an instance with the following configuration
  10. 10. Thanachart Numnonda, thanachart@imcinstitute.clockchain App on Hyperledger Select boot disk as Ubuntu 14.04 and 50 GB
  11. 11. Thanachart Numnonda, thanachart@imcinstitute.clockchain App on Hyperledger Connect via SSH in browser window
  12. 12. Thanachart Numnonda, thanachart@imcinstitute.clockchain App on Hyperledger Connect to the instance
  13. 13. Thanachart Numnonda, thanachart@imcinstitute.clockchain App on Hyperledger Installing Hyperledger development environment
  14. 14. Installing prerequisites $ curl -O https://hyperledger.github.io/composer/latest/prereqs-ubu $ chmod u+x prereqs-ubuntu.sh $ ./prereqs-ubuntu.sh
  15. 15. Installing the Hyperledger Composer tools $ npm install -g composer-cli $ npm install -g composer-rest-server $ npm install -g generator-hyperledger-composer $ npm install -g yo $ npm install -g composer-playground
  16. 16. Installing Hyperledger Fabric $ mkdir ~/fabric-dev-servers && cd ~/fabric-dev-servers $ curl -O https://raw.githubusercontent.com/hyperledger/composer- tools/master/packages/fabric-dev-servers/fabric-dev-servers.tar.gz $ tar -xvf fabric-dev-servers.tar.gz $ ./downloadFabric.sh
  17. 17. Thanachart Numnonda, thanachart@imcinstitute.clockchain App on Hyperledger Starting Hyperledger-Fabric & Hyperledger composer playground
  18. 18. Starting Hyperledger-Fabric $ ./startFabric.sh $ ./createPeerAdminCard.sh
  19. 19. Viewing running process $ docker ps -a
  20. 20. Starting composer-playground $ composer-playground
  21. 21. Obtain a server’s external IP
  22. 22. Launch web-playground (http://ip-address:8080)
  23. 23. Thanachart Numnonda, thanachart@imcinstitute.clockchain App on Hyperledger Running an example business network
  24. 24. Thanachart Numnonda, thanachart@imcinstitute.clockchain App on Hyperledger
  25. 25. Thanachart Numnonda, thanachart@imcinstitute.clockchain App on Hyperledger
  26. 26. Click Deploy a new business network
  27. 27. Provide basic information and select basic-sample -network (provide the network admin as Admin@hlfv1 )
  28. 28. Provide credentials information (Assign the Enrolment id: admin Enrolment secret : adminpw)
  29. 29. Now the network is defined, click Deploy.
  30. 30. The new business network will be shown, click Connect now
  31. 31. thanachart@imcinstitute.com31 Open another terminal console, Type command docker ps -a, You will see another container is running
  32. 32. thanachart@imcinstitute.com32
  33. 33. thanachart@imcinstitute.com33 Exploring a business network Viewing the following files: ● Model ● Script ● Access control
  34. 34. thanachart@imcinstitute.com34 Basic-sample-network Definition ● Asset ○ SampleAsset ● Participant ○ SampleParticipant ● Transaction ○ SampleTransaction ● Event ○ SampleEvent
  35. 35. thanachart@imcinstitute.com35 Testing the business network definition, Click Test tab
  36. 36. thanachart@imcinstitute.com36 Click Create New Participant
  37. 37. thanachart@imcinstitute.com37 Enter the first participant, the click Create New
  38. 38. thanachart@imcinstitute.com38 Enter the second participant, the click Create New
  39. 39. thanachart@imcinstitute.com39 A list of participants will be shown
  40. 40. thanachart@imcinstitute.com40 All transactions show events
  41. 41. thanachart@imcinstitute.com41 Select SampleAsset, the click Create New Asset
  42. 42. thanachart@imcinstitute.com42 Enter the new asset, the click Create New
  43. 43. thanachart@imcinstitute.com43 A list of assets will be shown
  44. 44. thanachart@imcinstitute.com44 Click Submit Transaction
  45. 45. thanachart@imcinstitute.com45 Enter the transaction information, the click Submit
  46. 46. thanachart@imcinstitute.com46 The asset value is now changed
  47. 47. Thanachart Numnonda, thanachart@imcinstitute.clockchain App on Hyperledger Developing a new business network
  48. 48. thanachart@imcinstitute.com48 my-bank-network Definition ● Asset ○ Account ● Participant ○ Customer ● Transaction ○ AccountTransfer
  49. 49. Click Deploy a new business network
  50. 50. Provide basic information and select empty-business -network (provide the network admin as Admin@hlfv1 )
  51. 51. Provide credentials information (Assign the Enrolment id: admin Enrolment secret : adminpw)
  52. 52. Now the network is defined, click Deploy.
  53. 53. The new business network will be shown, click Connect now
  54. 54. thanachart@imcinstitute.com54
  55. 55. thanachart@imcinstitute.com55 Edit a model file ○ /** ○ * Sample business network definition. ○ */ ○ namespace org.imc.basic ○ asset Account identified by accountId { ○ o String accountId ○ --> Customer owner ○ o Double balance ○ } ○ participant Customer identified by customerId { ○ o String customerId ○ o String firstName ○ o String lastName ○ } ○ transaction AccountTransfer { ○ --> Account from ○ --> Account to ○ o Double amount ○ }
  56. 56. thanachart@imcinstitute.com56 Select Model file, click edit icon
  57. 57. thanachart@imcinstitute.com57
  58. 58. thanachart@imcinstitute.com58 Edit a script file ○ /** ○ * Place a transaction for transfering money ○ * @param {org.imc.basic.AccountTransfer} AccountTransfer ○ * @transaction ○ */ ○ function accountTransfer(accountTransfer) { ○ if (accountTransfer.from.balance < accountTransfer.amount) { ○ throw new Error('Insufficient fund'); ○ } ○ ○ accountTransfer.from.balance -= accountTransfer.amount; ○ accountTransfer.to.balance += accountTransfer.amount; ○ return getAssetRegistry('org.imc.basic.Account') ○ .then(function(assetRegistry) { ○ return assetRegistry.update(accountTransfer.from); ○ }) ○
  59. 59. thanachart@imcinstitute.com59 Edit a script file (cont.) ○ .then(function() { ○ return getAssetRegistry('org.imc.basic.Account'); ○ }) ○ .then(function(assetRegistry) { ○ return assetRegistry.update(accountTransfer.to); ○ }); ○ }
  60. 60. thanachart@imcinstitute.com60 Select Add a file
  61. 61. thanachart@imcinstitute.com61 Choose Script File(.js), the click Add
  62. 62. thanachart@imcinstitute.com62 Deploying the updated business network, Click Deploy change
  63. 63. thanachart@imcinstitute.com63 Click Upgrade
  64. 64. thanachart@imcinstitute.com64 Testing the business network definition, Click Test tab
  65. 65. thanachart@imcinstitute.com65 Click Create New Participant
  66. 66. thanachart@imcinstitute.com66 Enter the first participant, the click Create New
  67. 67. thanachart@imcinstitute.com67 Enter the second participant, the click Create New
  68. 68. thanachart@imcinstitute.com68 A list of participants will be shown
  69. 69. thanachart@imcinstitute.com69 Select Account, the click Create New Asset
  70. 70. thanachart@imcinstitute.com70 Enter the first account, the click Create New
  71. 71. thanachart@imcinstitute.com71 Enter the second account, the click Create New
  72. 72. thanachart@imcinstitute.com72 A list of accounts will be shown
  73. 73. thanachart@imcinstitute.com73 Click Submit Transaction
  74. 74. thanachart@imcinstitute.com74 Enter the transaction information, the click Submit
  75. 75. thanachart@imcinstitute.com75 The account balances are now changed
  76. 76. thanachart@imcinstitute.com76 All transactions show events
  77. 77. Thanachart Numnonda, thanachart@imcinstitute.clockchain App on Hyperledger Generate REST APIs
  78. 78. thanachart@imcinstitute.com78 List all of the business cards $ composer card list
  79. 79. thanachart@imcinstitute.com79 Start the REST server & generate the API $ composer-rest-server Enter the name of the business network card to use: Admin@hlfv1 Specify if you want namespaces in the generated REST API: never use namespaces Specify if you want to use an API key to secure the REST API: No Specify if you want to enable authentication for the REST API using Passport: No Specify if you want to enable event publication over WebSockets: Yes Specify if you want to enable TLS security for the REST API: No
  80. 80. thanachart@imcinstitute.com80
  81. 81. Browse REST APIs (http://ip-address::3000/explorer)
  82. 82. Test the REST APIs
  83. 83. www.facebook.com/imcinstitute
  84. 84. Reference: https://hyperledger.github.io/composer/latest/installing/installing-index.html
  85. 85. Thanachart Numnonda,Big Data as a Service Using Google Cloud Platform Thank you www.imcinstitute.com www.facebook.com/imcinstitute

×