DL Fabric Gateway™ User Guide— Section 8
This post is part of the ‘DL Fabric Gateway™ User Guide’ originally published as
This post continues our ongoing discussion regarding invoking chaincode on DL Fabric Gateway™.
Invoking Chaincode on DL Fabric Gateway™
Invocation is the primary method of interaction with chaincode — invocation being another way of saying “call a function from the chaincode”.
IMPORTANT — In order to invoke chaincode, it must be installed on a given channel. This was done in the previous section.
Goal
Invoke chaincode on DL Fabric Gateway™ using the fab_invokeChaincodeAPI:
POST
https://dlfabricnetwork.dltlabs.com/api/1.0/fab_invokeChaincode
Step 1
Open a Command Line Interface (CLI) of your choice (Terminal, cmd, etc.)
Step 2
Install curl (if not already installed): Download links — Linux/Windows
Step 3
Copy and paste the following API Call into your CLI of choice, and tap “enter” on your keyboard
curl -X POST \
‘https://dlfabricnetwork.dltlabs.com/api/1.0/fab_invokeChaincode' \
-H ‘Content-Type: application/json’ \
-H ‘Authorization: AUTH_TOKEN_HERE’ \
-d ‘{
“userName” : “your@email.com”,
“chaincodeName” : “YourChaincode”,
“args” : [“CAR1”, “Acura”, “MDX”, “Black”, “Jovan”],
“functionName” : “createCar”,
“channelName”:”yourchannel”
}’
*Note
a) functionName is the function to be called when invoking chaincode (in this case, createCar, as specified in fabcar.go), and args are the arguments to be passed into the function specified in functionName.
Example:
Which will return a success response:
{
“status”: “success”,
“message”: “Successfully invoked the chaincode.”
“transactionId”: “8bd4ec291e06a1016ab1e561cf6d6e04de604431e95d1af0cedc4da90900c4fd
“
}
b) The transactionId specified in the response is very important, as this is where you will be able to reference a permanent record of the chaincode invocation. When building applications, it is suggested that you store transactionIds (i.e. in a DB) so that they can be referenced in the future.
