Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
sudipghosh
Active Contributor


Hello Everyone,

Greetings its my first blog Part-1 in this year , I hope everyone doing pretty well. AI and Blockchain are two different technologies but when they go together it just make limitless value addition to business. Yes you heard it right, and in this blog i will explain one use case and how we can develop that use case using SAP Blockchain MultiChain, SAP Conversational AI,SAP Cloud Platform.

Here i am not going to describe about each product, you will get lots of blogs where people have written about these. So lets get into the facts and that is use case and how we will be driving that  use case using Blockchain and AI.

2018 was year of startup many startup got acquired many startup achieved lot of things thats a different story but when this startup comes in my mind first things come in my mind is funding because that's play crucial role and getting fund from Investor is very big deals because in all startup meet people project themselves as very successful but actually they are not. Some of the startup's product suck though try to solve really good problem, In that cases if customer experience is very bad then  there is no point to invest on that startup. But now Question is how this problem can be solved. Answer is Blockchain and AI.

Before getting into the technical facts lets look at the story we have.

Investor A has came up with scheme to fund good startup based on their performance and product, and scheme says startup companies should have enough money to run the pilot version with one or two customer and customer should be satisfied with Product. A Startup company named Bestrun formed by 3 developer and developed a product in HR domain and they are giving pilot run to their customer PW HR Solution. They need fund to expand and make reality so they go for fund option from Investor A. Investor A onboard them in their system as trial and in trial period they also onboard the customer of their product,  for initial fund release they go for customer experience certificate, now this customer experience certificate should be signed by real customer who is using the product in Blockchain and it help Investor to make decision release the fund. This customer experience certificate is totally processed in Blockchain and signed by customer, Bestrun and finally investor after seeing the demo. Now if one of them party among these don't sign then certificate will not be published in Blockchain.

You may have question in your mind, what Blockchain is doing here any one can get customer experience certificate from customer itself and giving it to investor, Now think about a situation if Startup  supply  fake customer experience certificate with fake feedback.



 

Now lets look at Technical Blockchain Implementation Part, Recently MultiChain is available in SAP Cloud Platform Cloud Foundry trial account, you can create the trial node and create the Blockchain. For Startup and Customer we will go with Digital ocean droplets where we can manually install MultiChain and configure the node manually, then we will connect this two node with SAP Cloud Platform Blockchain (Investor firm's node).

 

Use this link to create digital ocean account you will get 100 USD credit which can be used for creating droplets and can be used for two months. Note you have to use below referral link only and need to add Credit/Debit card but it won't charge until you switch to Paid after trial periods.



 

Lets first create MultiChain Node in SAP Cloud Platform Cloud Foundry.

 

Login to Cloud Foundry and navigate to service market place



Open MultiChain and create instance with trial plan





Click on new and choose trial plan



Now if you are specific about your Blockchain Name then fill the chain_name parameter. In this case i specified as "InvestChain"



Click Next and Give instance name and finish



Once Instance will be created you can create service key





click create service key



Click save



Once service key will be created you can have a look at your dashboard



After that once you register for digital ocean using this link , create project and droplets inside that project, (E.G Here i have created MultiChain Demo Nodes)



Click on create button and then Droplets



Choose Ubuntu 16.04



Now you have to generate public - private key pair in order to make ssh login through putty. In order to generate pub-pvt key pair use putty key generator



Now add that public key (E.G here my key name was multichain)



Now give droplets name (Bestrun) and click on create



it will take some time once it ll be created, you will get to know the public IP address for your droplets.



Similar way create a droplet for customer.



Now we have to connect this two nodes to Investor node as peer. Before that we have to install Multichain in both droplets and have to do little bit configuration in order to execute json rpc call as rest api for these two node.

in order to install multichain you can follow this link.

I have used putty to login in droplets.



once it will be installed, go back to Multichain dashboard and note the Node address to connect



Now go to Bestrun node and type multichaind InvestChain@3.121.240.76:7000 -daemon



It will return your node address and ask to grant permission from Investor node address.



Go to sap cp multichain dashboard and grant address



Then go back to Bestrun's node and inside the InvestChain folder edit the multichain.conf file and add rpcallowip = 0.0.0.0/0

 



then execute multichaind InvestChain -daemon to connect the Blockchain.

 



Once we have successful connection automatically configuration will be downloaded into params.dat.

 





Default rpc port is 7999 which need to be used in api call. Similar way you can configure the customer node. After configuring and connecting both node if you have look at SAP CP MultiChain dashboard you will be seeing two nodes are connected as peer.



 

Network setup is completed, now lets have a look at how we can create 3 of 3  multisignature address and confirm the transaction in Blockchain.

Before getting into hands-on lets understand what is Multisignature Transaction.

Public key encryption, also known as asymmetric cryptography, is a key underlying technology of blockchains. Participants in the chain generate their own pairs of private keys and public addresses. They keep the private keys secret, but freely distribute the associated addresses. A blockchain transaction which performs an action for a particular address (e.g. spending its funds) must be signed by the corresponding private key. All participants on the chain can then verify these signatures, using public addresses only, without needing to see each others’ private keys.

Multisignature (“multisig” for short) addresses and transactions broaden this model by creating identities on the chain which are managed collectively by multiple parties. MultiChain uses “m-of-n” bitcoin-style multisignatures, in which a multisig address A is defined as: Given n regular addresses, at least mof the private keys corresponding to those addresses must sign a transaction to perform an action for A.

Some common values of m and n are given below, with practical examples:

  • 1-of-n: Any one of n different parties can approve the transaction. For example, one of three employees can spend some funds, but we want the blockchain to contain a record of who did so.

  • 2-of-2: Each of two separate parties must approve the transaction. For example, two departments in a company must sign off before some data is published on a blockchain on behalf of that company.

  • 2-of-3: Any two out of three parties can approve the transaction. This is commonly used for escrow purposes, where the two counterparties to an agreement engage a third party to act as an arbitrator in the event of dispute.


Reference

 

How do we interact with each node using JSON RPC api call

Lets look at the Customer node for example, If you remember we have written username and password into multichain.conf file, same password we have to use for api call as basic authentication.



In header pass content-type as application/json



we will be using getinfo method to know about the basic details.



It will give response like below



Now lets look at how do we call SAP CP MultiChain API.

From service key section find the url and api key, here apikey you have to pass as header like below.





And it gives response like below.



Now lets get into real business which is multi signature based transaction. In order to create multi sign address first we need to know the public  key for each node. In order to generate public key use  payload for each node.

{"method": "getaddresses", "params":[true]}

You will get below like response.



Investor : 02db8b897cddda8c4cca4bd69201c3dcc6a02fdae2c02d7cd2a5881f0a1653a3bf

Customer : 02a11ee651e5157eeff9e83176cb27b9ba4ba71be4b8e647c919c398fceda7bd58

Bestrun: 020c32fb3ef19b019a2387d278ef7eda111a0017b7d5438a734f2adf4c62c1e73b

Creating Multisign Address

In order to create multisign address we have to execute same payload in each node and then we have to import that multisign address into each node's wallet.

use below payload to create multisign address

{"method": "addmultisigaddress", "params":[3,["02db8b897cddda8c4cca4bd69201c3dcc6a02fdae2c02d7cd2a5881f0a1653a3bf","02a11ee651e5157eeff9e83176cb27b9ba4ba71be4b8e647c919c398fceda7bd58","020c32fb3ef19b019a2387d278ef7eda111a0017b7d5438a734f2adf4c62c1e73b"]]}

You will get Multisign address start with 4 like below

41Ft4HX2sJqLdj59ADzSHddfK2MazX6Vbu41Lw



Now import this multisign address in each node using import address method. Below is the Payload

{"method": "importaddress", "params":["41Ft4HX2sJqLdj59ADzSHddfK2MazX6Vbu41Lw","",false]}

After importing mutisign address now we can create stream from this multisign address. use create method to create stream "customer_feedback". This stream we will create in Bestrun's node. use Below payload.

{"method": "create", "params":["stream","customer_feedback",false]}.

Now we will revoke write permission from  normal address for this stream and grant read write and send permission to Multisign address for this stream.

{"method": "revoke", "params":["1Ni3Mgua3XpZbLmzQicCRvtbmegS132jSmYx7V","customer_feedback.write"]}

After revoking grand write permission to multisign adress using grant method, execute below payload in Bestrun's node.

{"method": "grant", "params":["41Ft4HX2sJqLdj59ADzSHddfK2MazX6Vbu41Lw","customer_feedback.write"]}

also grant send permission to multisign address.

{"method": "grant", "params":["41Ft4HX2sJqLdj59ADzSHddfK2MazX6Vbu41Lw","send"]}

Now Publish the stream from this multisign address using createrawsendfrom method.

{"method": "createrawsendfrom", "params":["41Ft4HX2sJqLdj59ADzSHddfK2MazX6Vbu41Lw",{},[{"for":"customer_feedback","key":"experience_trial","data":"7b22726174696e67223a223130302f313030227d"}],"sign"]}

Here i have converted actual data into hex, my data is {"rating":"100/100"}.

On successful call it will return hex blob like below. If you notice complete field is false that means transaction is still not confirmed.



"hex": "0100000001c5a11fb699403fa0138472572c67f674e58e63cf520c410e160931d0e1cb7d0a00000000b4004730440220266d0a9d275c7f648ec70a8ff111cd16d999972001fdcc6827d317847d1b642902203d61f6155bd8b74f4737f392b3a69c5f69b1a3dfe55d7b3b00271144e286172c014c69532102db8b897cddda8c4cca4bd69201c3dcc6a02fdae2c02d7cd2a5881f0a1653a3bf2102a11ee651e5157eeff9e83176cb27b9ba4ba71be4b8e647c919c398fceda7bd5821020c32fb3ef19b019a2387d278ef7eda111a0017b7d5438a734f2adf4c62c1e73b53aeffffffff020000000000000000421473706b651be74437d0f5db97d0a63cf37de8482c751473706b6b657870657269656e63655f747269616c756a147b22726174696e67223a223130302f313030227d000000000000000017a914094fb32712b2a6fbad0400d4575163fd7e83071e8700000000"

Now Customer would sign this using signrawtransaction method. Switch to customer node and use below payload. Here we have to use the hex which we have got from Bestrun node.

{"method": "signrawtransaction", "params":["0100000001c5a11fb699403fa0138472572c67f674e58e63cf520c410e160931d0e1cb7d0a00000000b4004730440220266d0a9d275c7f648ec70a8ff111cd16d999972001fdcc6827d317847d1b642902203d61f6155bd8b74f4737f392b3a69c5f69b1a3dfe55d7b3b00271144e286172c014c69532102db8b897cddda8c4cca4bd69201c3dcc6a02fdae2c02d7cd2a5881f0a1653a3bf2102a11ee651e5157eeff9e83176cb27b9ba4ba71be4b8e647c919c398fceda7bd5821020c32fb3ef19b019a2387d278ef7eda111a0017b7d5438a734f2adf4c62c1e73b53aeffffffff020000000000000000421473706b651be74437d0f5db97d0a63cf37de8482c751473706b6b657870657269656e63655f747269616c756a147b22726174696e67223a223130302f313030227d000000000000000017a914094fb32712b2a6fbad0400d4575163fd7e83071e8700000000"]}

On successful call it will return another big hex blob which need to be signed from Investor node in order to make transaction confirmed.



"hex": "0100000001c5a11fb699403fa0138472572c67f674e58e63cf520c410e160931d0e1cb7d0a00000000fdfe0000483045022100df4fd6ace72b6fd6a1bd69f96d2bceadb1af7a4f655d362670e7a55c581059a302206c943451c20c841103d0c572f0151aac85952921befe5b595fa27a5ae0cb1230014730440220266d0a9d275c7f648ec70a8ff111cd16d999972001fdcc6827d317847d1b642902203d61f6155bd8b74f4737f392b3a69c5f69b1a3dfe55d7b3b00271144e286172c01004c69532102db8b897cddda8c4cca4bd69201c3dcc6a02fdae2c02d7cd2a5881f0a1653a3bf2102a11ee651e5157eeff9e83176cb27b9ba4ba71be4b8e647c919c398fceda7bd5821020c32fb3ef19b019a2387d278ef7eda111a0017b7d5438a734f2adf4c62c1e73b53aeffffffff020000000000000000421473706b651be74437d0f5db97d0a63cf37de8482c751473706b6b657870657269656e63655f747269616c756a147b22726174696e67223a223130302f313030227d000000000000000017a914094fb32712b2a6fbad0400d4575163fd7e83071e8700000000"

Now execute below payload from investor node.

{"method": "signrawtransaction", "params":["0100000001c5a11fb699403fa0138472572c67f674e58e63cf520c410e160931d0e1cb7d0a00000000fdfe0000483045022100df4fd6ace72b6fd6a1bd69f96d2bceadb1af7a4f655d362670e7a55c581059a302206c943451c20c841103d0c572f0151aac85952921befe5b595fa27a5ae0cb1230014730440220266d0a9d275c7f648ec70a8ff111cd16d999972001fdcc6827d317847d1b642902203d61f6155bd8b74f4737f392b3a69c5f69b1a3dfe55d7b3b00271144e286172c01004c69532102db8b897cddda8c4cca4bd69201c3dcc6a02fdae2c02d7cd2a5881f0a1653a3bf2102a11ee651e5157eeff9e83176cb27b9ba4ba71be4b8e647c919c398fceda7bd5821020c32fb3ef19b019a2387d278ef7eda111a0017b7d5438a734f2adf4c62c1e73b53aeffffffff020000000000000000421473706b651be74437d0f5db97d0a63cf37de8482c751473706b6b657870657269656e63655f747269616c756a147b22726174696e67223a223130302f313030227d000000000000000017a914094fb32712b2a6fbad0400d4575163fd7e83071e8700000000"]}

On successful it will return another hex blob and this time complete field will be true like below.



Now copy this blob and use sendrawtransaction method from any node to publish the verified customer experience.

{"method": "sendrawtransaction", "params":["0100000001c5a11fb699403fa0138472572c67f674e58e63cf520c410e160931d0e1cb7d0a00000000fd460100483045022100ef2a93bba30436fda8786d80b1940d7dca47e37d7f3b989b9f453f2759c0a5da02202599a2352e1cfd09022778bfd20df6b0bbcac645ef87b635274b8daf4cbeba2601483045022100df4fd6ace72b6fd6a1bd69f96d2bceadb1af7a4f655d362670e7a55c581059a302206c943451c20c841103d0c572f0151aac85952921befe5b595fa27a5ae0cb1230014730440220266d0a9d275c7f648ec70a8ff111cd16d999972001fdcc6827d317847d1b642902203d61f6155bd8b74f4737f392b3a69c5f69b1a3dfe55d7b3b00271144e286172c014c69532102db8b897cddda8c4cca4bd69201c3dcc6a02fdae2c02d7cd2a5881f0a1653a3bf2102a11ee651e5157eeff9e83176cb27b9ba4ba71be4b8e647c919c398fceda7bd5821020c32fb3ef19b019a2387d278ef7eda111a0017b7d5438a734f2adf4c62c1e73b53aeffffffff020000000000000000421473706b651be74437d0f5db97d0a63cf37de8482c751473706b6b657870657269656e63655f747269616c756a147b22726174696e67223a223130302f313030227d000000000000000017a914094fb32712b2a6fbad0400d4575163fd7e83071e8700000000"]}

On successful api call customer experience will be published in blockchain. Go to multichain dashboard in SAP CP CF, Look at confirmed stream like below.



 

I hope you have enjoyed this blog, Please share your comments. here is part 2

Regards,

Sudip
8 Comments
Labels in this area