Skip to Content

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

  • 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

  • From the overview screen, click on Chaincode from the left pane

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

 

 

To report this post you need to login first.

20 Comments

You must be Logged on to comment or reply to a post.

    1. Gregory Misiorek

      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

      (0) 
  1. 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

    (0) 
    1. Nagesh C R
      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

      (0) 
      1. 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

         

        (0) 
        1. 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

          (0) 
          1. 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

             

            (0) 
            1. 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

               

               

              (0) 
          1. 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

            (0) 
  2. 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

    (0) 
    1. 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

       

      (0) 
      1. 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

        (1) 
  3. 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

    (1) 
    1. Nagesh C R
      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

       

      (0) 

Leave a Reply