Skip to Content
Author's profile photo Nagesh Caparthy

Step by Step process to create your first Blockchain Project – Hello World

Blockchain…!!! This might be one of the words which is buzzing around in SAP for a long time and many developers and consultants have been waiting to explore this opportunity.  SAP Blockchain as a Service, specifically Hyperledger Fabric is now made available in the cloud foundry trial account for development and testing activities.

Note: Trial accounts or services always comes with limitations.

In this blog, you will learn the following:

  1. Create SAP Cloud Foundry Trial Account
  2. Navigating to your Hypderledger Fabric account
  3. Creating a new instance
  4. Create & Deploy chaincode
  5. Create a Service Key
  6. Read/Write operations using Swagger
  7. Validate your read/write in Hyperledger Explorer

Before you begin, you may want to look at

and have your trail account active.

Once you understand Blockchain, it’s now time to get started with a small example “myfirstblock” in Hyperledger Fabric service.

1. Create SAP Cloud Foundry Trail Account

  • Login to trial account and click on Cloud Foundry trial

  • Select Europe (Frankfurt) and click on ok.

  • Your account should now be created and active for 29 days, click on Go to Space

 

 

2. Navigating to your Hypderledger Fabric account

  • Click on Services and Service Marketplace

  • In the list of services, search for Hyperledger Fabric and click on it

  • Hyperledger Fabric – Overview with all the documentation, support information, and services plan should be listed.

3. Creating a new instance

  • Click on Instances and then click on New Instance.

  • Select Plan dev-beta and click on next(Dev-Beta was active for a limited period and no more active. Request you to select Dev, ignore the error message on pricing and continue with the same steps)

  • Click next on Specify Parameters (optional) and Assign Application (optional). In the confirm, enter “myfirstinstance” and click on Finish

  • The new instance should be created with an option such as Dashboard and Delete Instance under actions. Click on Open Dashboard

  • A new tab opens up, enter your login details; same which was used during your cloud platform registration. Note: Do not use P-Number.

This is a dashboard where you can understand the Node, Peer Status, Fabric Version, Network and Create Channels.

  • Now click on Channels, then click on Create Channels and enter the following details. To know more about the channels, please use the hyperlink above.

  • Click on Create New Instance for the channel which was just created

  • Do not modify the Service Instance name, click on Create.

  • Open the service Instance Channel

4. Create & Deploy a chaincode

  • Click on Deploy Code and select the “sample web.zip”.  The sample code has been shared on the link, however, to make it easy I have attached the sample code to this link. Below are the files which I have zipped as a package.

  • Drag & Drop or Choose the sample web.zip file.

  • Click on Deploy and you should be able to see the success message as below

  • Click on “Test Chaincode” and a new window opens which is known as swagger.

5. Create a Service Key

  • Go back the window Hyperledger Fabric Dashboard and click on Overview and enter the following details under “Service Keys” and click on Create Key

  • Expand the key and copy the “clientId” and “clientSecret” which is required for authorization in Swagger

 

6. Read/Write operations using Swagger

  • Go to Swagger tab and click on Authorize button and enter the clientId, clientSecret and authorize

Once its authorized, close the window.

  • Now that we have the authorization and we are doing the first transaction to the block, we will try a POST operation, click on the POST and then click on Try it out. Enter the details as shown below and click on execute.

  • You should now be able to see the response 201 as shown below

There you go, you have now successfully made your first POST operation to the blockchain.

  • Now let us try to read the same data which was written to the block. Click on Get and then click on Try it out. Enter the ID “101” was used in POST operation and click on execute. You should be able to see the response as shown below.

 

7. Validate your read/write in Hyperledger Explorer

  • To validate the same in a Blockchain, we use the Hyperledger Fabric Explorer. Shift to the other tab “Hyperledger Fabric Dashboard” and click on Explorer.

Here you can identify that we have totally 3 blocks created, 0 is the Genesis Block, 1 is the Chaincode deployed by us and 2 is the successful transaction from swagger.

  • Click on block 2 to get the details

Alright, it’s now time to congratulate you J

#HappyLearning…!!!

Regards,

Nagesh

 

 

Assigned Tags

      30 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hi Nagesh,

      It's easy and intuitive enough for anyone to follow and I was able to create the values into the SAP fabric blockchain based on the help file here (with few minor exceptions):

      https://help.sap.com/viewer/81f693ad49a046cba506cc9bd51052d0/BLOCKCHAIN/en-US/31c74c557dc949fd88d07b9c5b278c04.html

      And I believe the beta program is still open for more testers.

      Thank you, gm

      Author's profile photo Nagesh Caparthy
      Nagesh Caparthy
      Blog Post Author

      Hi Gregory,

       

      Thank you for the feedback and happy that it was helpful. I am afraid that the beta program is now closed and if you looking to purchase the cloud accounts you may refer to the below link for pricing:

      https://cloudplatform.sap.com/capabilities/product-info.Hyperledger-Fabric--on-SAP-Cloud-Platform.b9fb18ba-a2dc-485b-ad59-79c30c15ec93.html#capabilitiesPricing

      BR,

      Nagesh

       

       

      Author's profile photo Former Member
      Former Member

      Hi Nagesh,

      sorry to hear that the program is now closed. for those who, who are not gui beholden, there is always the open source route available with a little bit of community support, but again it's outside of SAP ecosystem.

      thank you, gm

      Author's profile photo Prajakta Sambre
      Prajakta Sambre

      Hi,

      When I am trying to deploy the chaincode with package structure exactly as instructed by you, I am getting error-

      File chaincode.yaml not found. Please make sure that the provided ZIP archive has the chaincode.yaml as well as the src directory located at the root level of the archive.

       

      However, when I try to deploy the zipped package provided by you, it works.

      Could you please help with this?

       

      Thanks

      Author's profile photo Nagesh Caparthy
      Nagesh Caparthy
      Blog Post Author

      Hi Prajakta,

      Please ensure the files are structured and saved as in the zip file which I have shared. In case you are copying the code from the help website, ensure the code & file names are accurate. No additional changes were made, so it should work  🙂

      Regards,

      Nagesh

      Author's profile photo Prajakta Sambre
      Prajakta Sambre

      Hi Nagesh,

      Thanks for your response.

      Firstly I deployed the zipped package provided by you on my channel.

      Then, I extracted the code and just changed version in chaincode.yaml file from 13 to 14. Afterwards, I zipped again and tried to deploy using upgrade chaincode. However, it is still showing me the same error-

      File chaincode.yaml not found. Please make sure that the provided ZIP archive has the chaincode.yaml as well as the src directory located at the root level of the archive.

      There is no change in structure of files or naming.

      Can't ascertain the reason behind this error.

       

      Thanks

       

      Author's profile photo Prajakta Sambre
      Prajakta Sambre

      Do you mind sharing which IDE or editor you used for editing .yaml file? It seems SCP is unable to read the chaincode.yaml file whose format may haave changed on my system. I am using Notepad++ and MS Visual Studio..

       

      Thanks

      Author's profile photo Nagesh Caparthy
      Nagesh Caparthy

      Hi Prajakta,

      I am using Atom Editor, it works for both GoLang and YAML files and follow the folder structure, it should work good.

      Regards,

      Nagesh

       

      Author's profile photo Prajakta Sambre
      Prajakta Sambre

      Thanks Nagesh.

      Really value your responses.

      I installed Atom editor and created folder structure as given in development guide. Still, same issue is coming. Is there a possibility that you are using a different compression technique to create zip file? I am creating zip using Windows default- Send to compressed folder option.

      Regards,

      Prajakta

       

       

      Author's profile photo Former Member
      Former Member

      when you are creating the zip file please make sure that the top folder is removed and only the src folder, 2 yaml and one go files are in your zip.

      Author's profile photo Prajakta Sambre
      Prajakta Sambre

      Hi Gregory,

      Thanks for your response.

      I have created zip file with exact folder structure as given in Development guide.

      It seems the chaincode.yaml file is getting corrupted while compression.

      Regards,

      Prajakta

      Author's profile photo Krishnakant Joshi
      Krishnakant Joshi

      Worked as explained. Thank you Nagesh.

      Author's profile photo Guillaume COURREGES
      Guillaume COURREGES

      Very nice blog, thank you Nagesh

       

      Can you please explain how can i create a SAP Cloud Platform destination on top of this blockchain service in order to get access from SAPUI5 ?

       

      Best regards

      Author's profile photo Nagesh Caparthy
      Nagesh Caparthy

      Hi Guillaume,

      For UI5, we can use SAP Neo account, blockchain APIs can be used for this and UI5 program can be developed using WEBIDE and deployed in Neo.

      Regards,

      Nagesh

       

      Author's profile photo Guillaume COURREGES
      Guillaume COURREGES

      Hi Nagesh

       

      As far as i understand, this blockchain api uses OAuth2ClientCredentials authentication.

      I can create a destination on cloud foundry but no webIde is available.

       

      Can you please guide me how to create this destination on neo ?

       

      Regards

      Guillaume

      Author's profile photo Talha Demirci
      Talha Demirci

      Thanks for the blog Nagesh,

       

      i can't access my space in my subaccount. It keeps loading... Do I have to give permission or something else?

       

      Regards,

      Talha Demirci

      Author's profile photo Nagesh Caparthy
      Nagesh Caparthy
      Blog Post Author

      Hi Talha,

       

      If its Trial, no additional permission are required. Try to clear the cookies and try again. It should work.

      Regards,

      Nagesh

       

      Author's profile photo Talha Demirci
      Talha Demirci

      Thanks Nagesh, It's working now!!

      Author's profile photo Pavan Venkat Karthik Pakkurthi
      Pavan Venkat Karthik Pakkurthi

      Hello @nagesh.c.r,

       

      I get the following error on creating channel from the dashboard.

      Http failure response for https://hyperledger-fabric.cfapps.eu10.hana.ondemand.com/dash/nodes/3cac1656-82c1-4c3d-9269-6dd81a8467a1/channels: 409 Conflict

       

      Can you throw some light on solving this.

      Best regards,

      Pavan

      Author's profile photo Siva rama Krishna Pabbraju
      Siva rama Krishna Pabbraju

      Hi Nagesh,

      I have successfully followed your blog and completed all steps. Can you please advise on further steps.

      Regards,

      Siva

      Author's profile photo Nagesh Caparthy
      Nagesh Caparthy
      Blog Post Author

      Excellent, you may take a look at the latest release and plan your developments. SAP also provides options to call APIs from ECC and HANA Systems.

      If you have any specific PoC or Project requirements, let us know we can discuss about it.

      Regards,

      Nagesh

       

       

      Author's profile photo Siva rama Krishna Pabbraju
      Siva rama Krishna Pabbraju

      Hi Nagesh,

      Yeah, I am planning to do a POC to connect to my backend DB(HANA) to Block chain network. If possible can you help me on this.

      Regards,

      Siva

      Author's profile photo Nagesh Caparthy
      Nagesh Caparthy
      Blog Post Author

      Hi Siva,

      Below link should be helpful to you then: https://help.sap.com/viewer/c5bee9180afc4a4e93a0742bb352db11/1.0/en-US/3d17b9c2c38841cd8c56c91342aee048.html

      We can further connect on email as required.

      Regards,

      Nagesh

      Author's profile photo Mohammed zahid
      Mohammed zahid

      Hi,

      I am stuck at one step .

      I had coped the Authkey, and later you mentioned to "Go to the swagger tab and click on AUthorization" where is this swagger tab , can you please tell me

      Author's profile photo Mohammed zahid
      Mohammed zahid

      I am able to perform all the step completely  .

      Thanks for the knowledge

      Author's profile photo Nagesh Caparthy
      Nagesh Caparthy
      Blog Post Author

      Thank you, Mohammed.

      Author's profile photo Mohammed zahid
      Mohammed zahid

      Two things I have to ask

      1. I have being using Neo trail account and using IOT service to build few POC and Demos( running successful thanks for many blogs on this topic ) , Is it possible to enable IOT service in cloud foundry account as well ?  so that I can merge this two - IOT to gather data and Block chain to store data changes ( like any change should trigger as a prof for medic. - again just a poc )
      2. Is there any way to connect the to Hana DB ? tho I did not find the DB in cloud foundry.

       

      Author's profile photo Matt Liotine
      Matt Liotine

      I ran the Hello World test chain code and got Code 200 with a description of "OK" for the GET operation and "Text Written" for the POST operation. In your write-up, you show code 201. Are either of these correct? Also, after each operation, I'm also seeing a Code of 500 with a description of "Failed". What does this mean? Is there any place one can find the definitions of all these codes?

      Also, after running both POST and GET, when reviewing the blocks in the Explore window, it appears that only the Writes have content and the Reads are empty. According to your write-up, I should be seeing both. What does this signify?

      Author's profile photo Hin Kang
      Hin Kang

      For who couldn't find the hyperledger fabric service in your cloud foundary service marketplace,

      please go to the entitlement tab and edit to enable "application runtime, hyperledger fabric (dev, channel)

      Author's profile photo Bhanu Prakash Kandregula
      Bhanu Prakash Kandregula

      Hello Nagesh,

      Thanks for the article, it is great. Is that possible to deploy chain code written in NODE JS in SAP Blockchain platform ? or It will only take GO language ?

      Please advice, thank you.

      Best wishes,

      Bhanu Kandregula