Search code examples
hyperledger-fabrichyperledgerhyperledger-chaincodechaincode

Calling external data on Hyperledger Fabric Chaincode (external data as input in business logic)


Is it possible to invoke external data from the chaincode?

For example, in my business process, the client only releases payment if the work performed is equal to or greater than a certain quantity (i.e. the external data detected). The external data recorded is private data that is recorded in the network.


Solution

  • The chaincode cant make calls to fetch external data, because that external call could potentially be non-deterministic. However "oracle" pattern is useful here.

    • Have a trusted organization(called the oracle) post updates on a smart contract that is deployed to a seperate channel.

    • Only the oracle is allowed to post updates to this smart contract. This would be the external data that you are trying to query.

    • Your chaincode then accesses this data via a inter-channel chaincode query

    Source - Oracle pattern for fabric