Tools, FAQ, Tutorials:
"peer chaincode invoke" on BYFN
How to run "peer chaincode invoke" to invoke the transaction on the chaincode instance?
✍: FYIcenter.com
After a chaincode in properly installed on all peers
and instantiated on the channel,
you can run the "peer chaincode invoke" to invoke the transaction on
the chaincode instance.
1. Verify instantiated chaincode:
$ docker exec -it cli bash bash-4.4# echo $CORE_PEER_ADDRESS peer0.org1.example.com:7051 bash-4.4# peer chaincode list -C mychannel --instantiated Get instantiated chaincodes on channel mychannel: Name: mycc, Version: 2.0, Path: github.com/chaincode/chaincode_example02/go/, \ Escc: escc, Vscc: vscc
2. Query chaincode instance properties:
bash-4.4# peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}' 100 bash-4.4# peer chaincode query -C mychannel -n mycc -c '{"Args":["query","b"]}' 200
3. Invoke chaincode instance to transfer 10 from property "a" to "b":
bash-4.4# peer chaincode invoke -o orderer.example.com:7050 --tls true \ --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto\ /ordererOrganizations/example.com/orderers/orderer.example.com/msp\ /tlscacerts/tlsca.example.com-cert.pem -C mychannel -n mycc \ --peerAddresses peer0.org1.example.com:9051 --tlsRootCertFiles \ /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations\ /org1.example.com/peers/peer0.org1.example.com/tls/ca.crt \ --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles \ /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations\ /org2.example.com/peers/peer0.org2.example.com/tls/ca.crt \ -c '{"Args":["invoke","a","b","10"]}' [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. \ result: status:200
4. Query chaincode instance properties again:
bash-4.4# peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}' 90 bash-4.4# peer chaincode query -C mychannel -n mycc -c '{"Args":["query","b"]}' 210
The transfer transaction was done correctly!
Â
⇒ View Channel Blockchain and Download Blocks
⇠Remove Older Versions Chaincode Containers
⇑ BYFN (Build Your First Network)
⇑⇑ Hyperledger Tutorials
2020-08-13, 889👍, 0💬
Popular Posts:
How to add an API to an API product for internal testing on the Publisher Portal of an Azure API Man...
What is the "__init__()" class method? The "__init__()" class method is a special method that will b...
How to use "json-to-xml" Azure API Policy Statement? The "json-to-xml" Policy Statement allows you t...
How to use the "find-and-replace" Policy Statement for an Azure API service operation? The "find-and...
FYIcenter JSON Validator and Formatter is an online tool that checks for syntax errors of JSON text ...