Invoke the Smart Contract

Invoke your smart contract

Issue an insurance

Assume you are in Smart Insurance, you want to open a new insurance for your client Oscar for his goods with serial number '121214'.

In terminal 3

peer chaincode invoke -o node-1:7050 \
--name ${USER}-chaincode --channelID ${USER}-channel \
-c '{"Args":["issue", "Oscar", "SmartInsurace", "121214", "000001"]}' \
--peerAddresses node-1:7051 \
--peerAddresses node-2:7051 \
--peerAddresses node-3:7051

You should see the following output

2021-02-17 11:04:22.768 HKT [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 075 Chaincode invoke successful. result: status:200 

Report to the insurance

Now, assume Oscar's good with the serial number '121214' is broken in an accident and reported to the police. Now you are Jack, a user from the police, and want to confirm Oscar's lost.

In terminal 2,

peer chaincode invoke -o node-1:7050 \
--name ${USER}-chaincode --channelID ${USER}-channel \
-c '{"Args":["report", "121214", "000001"]}' \
--peerAddresses node-1:7051 \
--peerAddresses node-2:7051 \
--peerAddresses node-3:7051

Refund for the insurance

Finally, Oscar reports his loss to Smart Insurance. Now you are Tom, the user from Smart Insurance, and announce that you going to compensate for Oscar's lost.

In terminal 3,

peer chaincode invoke -o node-1:7050 \
--name ${USER}-chaincode --channelID ${USER}-channel \
-c '{"Args":["refund", "121214", "000001"]}' \
--peerAddresses node-1:7051 \
--peerAddresses node-2:7051 \
--peerAddresses node-3:7051

Last updated