I came across the getNative API through which one call chaincode from Hyperledger composer. See here: https://github.com/hyperledger/composer/issues/3120
Can someone please tell me exactly how does this work? Say if I have a very simple chaincode with a getter and setter, can I invoke those from the JS code in composer
To call the Hyperledger Fabric API in a transaction processor function of
composer
, the functiongetNativeAPI
must be called.getNativeAPI
allow users to call directly of the Fabricshim API
which provides the APIs for application developers to implement "Smart Contracts" for the Hyperledger Fabric backend, also known asChaincodes
.Here is a sample example of using
getNativeAPI
in composer which called the Hyperledger Fabric API functiongetHistoryForKey
to returns the history of a specified asset as an iterator. The transaction processor function then stores the returned data in an array.Remember: The
getState
andputState
Hyperledger Fabric API functions will bypass the Hyperledger Composer access control rules.Some resource :
Hope these will help you to understand.
There's Composer chaincode (written in javascript) and Fabric's native chaincode (written in GO). If you want to invoke the chaincode deployed by Composer tools (as a part of a Business Network Definition), you don't need to call native API. You'll need it for low-level calls like getting information on a particular transaction.