5.4.3.5 Invoke chaincode API in Key Trust Mode

For DApps in Key Trust Mode, when the off-BSN system invokes the chaincode functions via PCN gateway, it is required to insert the parameters in the request message. The gateway will return the response message from the chaincode.

1. Interface address: https://PCNGatewayAddress/api/fabric/v1/node/reqChainCode

This interface will directly return the response message without waiting for the generation of block. Please use “Get transaction information API” described in section 5.4.3.8 to check the status of a block generated based on transaction ID.

Note: After a user has successfully participated in a DApp service, this participant can view and download the DApp’s configuration parameters which are used for off-BSN systems to connect to this DApp’s chaincodes, including the PCN gateway address and Dapp access keys, as shown below:

image-20200807205609180

2. Call Method: POST

3. Signature Algorithm: required and refer to Section 5.4.3.1

4. Call parameters

No. Field name Field Type Required Remarks
1 Header header Map Y
2 Body body Map Y
3 Signature Value mac String Y
Header
1 user unique ID userCode String Y
2 DApp unique ID appCode String Y
3 User and DApp mapping ID tId String N
Body
1 user name userName String N
random string nonce String Y Use 24 random byte array of the base64 encoding
1 chainCode chainCode String Y
2 function name funcName String Y
3 Call parameters args String[] N
4 Transient data transientData Map N

Example:

{"header":{"userCode":"USER0001202004161009309407413","appCode":"app0001202004161017141233920","tId":""},"mac":"MEQCICJpE1jfeJKtw/ZboVuKSLy2RmmSdkhrEVPGFJhm9IaIAiA/Qqs6RNz0ndSS4/AFSwBj7vC76Py1hXnqO5zMD9pNtA==","body":{"userName":"","nonce":"lgH7Ozfv6npqg9D3pSbq9c6o+rAcpa5D","chainCode":"cc_app0001202004161017141233920_00","funcName":"set","args":["{\"baseKey\":\"test2020048\",\"baseValue\":\"this is string \"}"],"transientData":{}}}

5. Response parameters

No. Field name Field Type Required Remarks
1 Header header Map Y
2 Body body Map Y
3 Signature Value mac String Y
Header
1 Response ID code int Y 0: authentication successful -1: authentication failed
2 Response Message msg String N if code=0 then can be null
Body
1 block information blockInfo blockInfo N If code is not 0, then leave blank
2 chaincode response result ccRes ccRes N If code is not 0, then leave blank
blockInfo
1 Transaction ID txId String Y
2 Block HASH blockHash String N On synchronous mode returns Block HASH
3 status value status Int Y Refer to the detailed transaction status description in 5.4.3.17
ccRes
1 chaincode response status ccCode Int Y 200: Successful500: Failed
2 chaincode response result ccData Str N Actual chaincode response result

Example:

{
  "header": {
    "code": 0,
    "msg": "Transaction Successful"
  },
  "mac": "MEUCIQCBtfO1AfYkoJ2hIlp8CfKK1iuhVEAYkPY8YFRAdvPJlAIgDjSqYgwlORJRyF6KZPU/uC5Fx/DxXxu9VgKwU9+JhjU=",
  "body": {
    "blockInfo": {
      "txId": "a144149150ee615a9d11c68485600f43dc2c3eb2a98d7b36de53a6b99e03c495",
      "blockHash": "",
      "status": 0
    },
    "ccRes": {
      "ccCode": 200,
      "ccData": "SUCCESS"
    }
  }
}
© 2019-2024 Red Date (Hong Kong) Technology Limited. all right reserved,powered by GitbookFile Modify: 2023-02-16 12:22:02

results matching ""

    No results matching ""

    results matching ""

      No results matching ""