0

We can define many things in chaincode "invoke" function.And we can also define many "transaction" in hyperledger composer network.What's more these two concept can change the ledger statement.

If I can use getNativeAPI().invokeChaincode() to call a "transaction in the other network?For example, if I have transaction:

In cto

participant ValifyParticipant identified by valifiedId {
  o String valifiedId
  o String organization
  o Double validRate
  o Double passRate
}

@returns(String)
transaction ValifyTransaction {
  o String detail
  o String valid
  --> ValifyParticipant valifyParticipant
  --> Participant Participant
}

In logic.js:

/**
 * Sample valify manual transaction fuction
 * @param {org.example.com.ValifyTransaction} vct the sample valify manual submit transaction instance.
 * @returns {String}(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string) The string.
 * @transaction
 */
async function ValifyCompoundTransaction(vct) {
  ....
}

How can I call ValifyCompoundTransaction in another network with the function getNativeAPI().invokeChaincode()

I have followed the tutorial:

https://hyperledger.github.io/composer/latest/tutorials/invoke-composer-network

to use getNative().invokechaincode() to execute function which is below:

 const otherNetworkData = await getNativeAPI().invokeChaincode('example-test-network',['getResourceInRegistry','Participant','org.example.com.Participant','1'],'firstchannel');

But failed and get the reason below:

2018-09-21 02:31:00.211 UTC [committer/txvalidator] validateTx -> ERRO 03c VSCCValidateTx for transaction txId = 60730ff6a58440f3a59322ca9590d2eeff933c23b074e73611dfc4ff9b6f8322 returned error: VSCC error: endorsement policy failure, err: signature set did not satisfy policy
2018-09-21 02:31:28.273 UTC [chaincode] HandleTransaction -> ERRO 042 [e2243000] Failed to handle INVOKE_CHAINCODE. error: could not get valid transaction

But When I remove the invokeChaincode() above it works fine

T.Arthur
  • 135
  • 13
  • 1
    you can't do that in Composer, its using its own runtime - for more information on the Hyperledger Fabric API methods that you can call in a transaction processor function, see the Hyperledger Fabric API documentation here -> https://fabric-shim.github.io/master/fabric-shim.ChaincodeStub.html - more info here https://stackoverflow.com/questions/49535602/how-to-use-hyperledger-getnative-api . You can query other business networks registries (as shown here -> https://hyperledger.github.io/composer/latest/tutorials/invoke-composer-network) or.. – Paul O'Mahony Sep 20 '18 at 10:34
  • ..you could use a call-out https://hyperledger.github.io/composer/latest/integrating/call-out to the TP function's REST API endpoint (eg see query transaction processor functions https://hyperledger.github.io/composer/latest/reference/js_scripts ) in that business network, that returns what you show above. – Paul O'Mahony Sep 20 '18 at 10:34
  • I have followed the tutorial: hyperledger.github.io/composer/latest/tutorials/… to use getNative().invokechaincode() to execute function which is below: const otherNetworkData = await getNativeAPI().invokeChaincode('chembeango-token-network',['getResourceInRegistry','Participant','org.example.com.Participant','1'],'firstchannel'); but failed of the reson: VSCCValidateTx for transaction txId = ... returned error: VSCC error: endorsement policy failure, err: signature set did not satisfy policy – T.Arthur Sep 21 '18 at 02:43
  • and error: could not get valid transaction Failed to handle INVOKE_CHAINCODE. error: could not get valid transaction but when I remove the getNativeAPI().invokeChaincode() , the network works fine – T.Arthur Sep 21 '18 at 02:43

0 Answers0