...by Daniel Szego
quote
"On a long enough timeline we will all become Satoshi Nakamoto.."
Daniel Szego

Tuesday, October 2, 2018

Fabric composer tips and tricks - call external web service


Integrating external data with a blockchain platform is sometimes pretty much tricky. One way of doing it is with an external service called Oraclize. As Oraclize has already an integration possibility with Hyperledger Fabric, it still does not have any integration possibilities with Fabric Composer. However, if you want to integrate a relative simple and external data, you can explicitly call an external service from the fabric composer like in the following example:

const webServiceInfo = await request.get({ uri:'https://webserviceurl', json: true});
const intParam = parseInt(webServiceInfo.ParameterInteger);

In the above example, we simply call a get a web service that delivers a json object that has property with the name ParameterInteger. More complicated scenarios can also be imagined, like post query, but generally the it is not proposed to put complex calculation into a smart contract. Another aspect which is important that the delivered result has to be static, otherwise the endorsement peers get different information, so they can not really produce valid RW sets, so no valid state can be reached.