github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/docs/source/commands/peerchaincode.md (about) 1 <!--- 2 File generated by help_docs.sh. DO NOT EDIT. 3 Please make changes to preamble and postscript wrappers as appropriate. 4 ---> 5 6 # peer chaincode 7 8 The `peer chaincode` command allows administrators to perform chaincode 9 related operations on a peer, such as installing, instantiating, invoking, 10 packaging, querying, and upgrading chaincode. 11 12 ## Syntax 13 14 The `peer chaincode` command has the following subcommands: 15 16 * install 17 * instantiate 18 * invoke 19 * list 20 * package 21 * query 22 * signpackage 23 * upgrade 24 25 The different subcommand options (install, instantiate...) relate to the 26 different chaincode operations that are relevant to a peer. For example, use the 27 `peer chaincode install` subcommand option to install a chaincode on a peer, or 28 the `peer chaincode query` subcommand option to query a chaincode for the 29 current value on a peer's ledger. 30 31 Some subcommands take flag `--ctor`, of which the value must be a JSON string 32 that has either key 'Args' or 'Function' and 'Args'. These keys are 33 case-insensitive. 34 35 If the JSON string only has the Args key, the key value is an array, where the 36 first array element is the target function to call, and the subsequent elements 37 are arguments of the function. If the JSON string has both 'Function' and 38 'Args', the value of Function is the target function to call, and the value of 39 Args is an array of arguments of the function. For instance, 40 `{"Args":["GetAllAssets"]}` is equivalent to 41 `{"Function":"GetAllAssets", "Args":[]}`. 42 43 Each peer chaincode subcommand is described together with its options in its own 44 section in this topic. 45 46 ## Flags 47 48 Each `peer chaincode` subcommand has both a set of flags specific to an 49 individual subcommand, as well as a set of global flags that relate to all 50 `peer chaincode` subcommands. Not all subcommands would use these flags. 51 For instance, the `query` subcommand does not need the `--orderer` flag. 52 53 The individual flags are described with the relevant subcommand. The global 54 flags are 55 56 * `--cafile <string>` 57 58 Path to file containing PEM-encoded trusted certificate(s) for the ordering 59 endpoint 60 61 * `--certfile <string>` 62 63 Path to file containing PEM-encoded X509 public key to use for mutual TLS 64 communication with the orderer endpoint 65 66 * `--keyfile <string>` 67 68 Path to file containing PEM-encoded private key to use for mutual TLS 69 communication with the orderer endpoint 70 71 * `-o` or `--orderer <string>` 72 73 Ordering service endpoint specified as `<hostname or IP address>:<port>` 74 75 * `--ordererTLSHostnameOverride <string>` 76 77 The hostname override to use when validating the TLS connection to the orderer 78 79 * `--tls` 80 81 Use TLS when communicating with the orderer endpoint 82 83 * `--transient <string>` 84 85 Transient map of arguments in JSON encoding 86 87 Flags of type stringArray are to be repeated rather than concatenating their 88 values. For example, you will use `--peerAddresses localhost:9051 89 --peerAddresses localhost:7051` rather than `--peerAddresses "localhost:9051 90 localhost:7051"`. 91 92 ## peer chaincode install 93 ``` 94 Install a chaincode on a peer. This installs a chaincode deployment spec package (if provided) or packages the specified chaincode before subsequently installing it. 95 96 Usage: 97 peer chaincode install [flags] 98 99 Flags: 100 --connectionProfile string Connection profile that provides the necessary connection information for the network. Note: currently only supported for providing peer connection information 101 -c, --ctor string Constructor message for the chaincode in JSON format (default "{}") 102 -h, --help help for install 103 -l, --lang string Language the chaincode is written in (default "golang") 104 -n, --name string Name of the chaincode 105 -p, --path string Path to chaincode 106 --peerAddresses stringArray The addresses of the peers to connect to 107 --tlsRootCertFiles stringArray If TLS is enabled, the paths to the TLS root cert files of the peers to connect to. The order and number of certs specified should match the --peerAddresses flag 108 -v, --version string Version of the chaincode specified in install/instantiate/upgrade commands 109 110 Global Flags: 111 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 112 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 113 --clientauth Use mutual TLS when communicating with the orderer endpoint 114 --connTimeout duration Timeout for client to connect (default 3s) 115 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 116 -o, --orderer string Ordering service endpoint 117 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer 118 --tls Use TLS when communicating with the orderer endpoint 119 --tlsHandshakeTimeShift duration The amount of time to shift backwards for certificate expiration checks during TLS handshakes with the orderer endpoint 120 --transient string Transient map of arguments in JSON encoding 121 ``` 122 123 124 ## peer chaincode instantiate 125 ``` 126 Deploy the specified chaincode to the network. 127 128 Usage: 129 peer chaincode instantiate [flags] 130 131 Flags: 132 -C, --channelID string The channel on which this command should be executed 133 --collections-config string The fully qualified path to the collection JSON file including the file name 134 --connectionProfile string Connection profile that provides the necessary connection information for the network. Note: currently only supported for providing peer connection information 135 -c, --ctor string Constructor message for the chaincode in JSON format (default "{}") 136 -E, --escc string The name of the endorsement system chaincode to be used for this chaincode 137 -h, --help help for instantiate 138 -l, --lang string Language the chaincode is written in (default "golang") 139 -n, --name string Name of the chaincode 140 --peerAddresses stringArray The addresses of the peers to connect to 141 -P, --policy string The endorsement policy associated to this chaincode 142 --tlsRootCertFiles stringArray If TLS is enabled, the paths to the TLS root cert files of the peers to connect to. The order and number of certs specified should match the --peerAddresses flag 143 -v, --version string Version of the chaincode specified in install/instantiate/upgrade commands 144 -V, --vscc string The name of the verification system chaincode to be used for this chaincode 145 146 Global Flags: 147 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 148 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 149 --clientauth Use mutual TLS when communicating with the orderer endpoint 150 --connTimeout duration Timeout for client to connect (default 3s) 151 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 152 -o, --orderer string Ordering service endpoint 153 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer 154 --tls Use TLS when communicating with the orderer endpoint 155 --tlsHandshakeTimeShift duration The amount of time to shift backwards for certificate expiration checks during TLS handshakes with the orderer endpoint 156 --transient string Transient map of arguments in JSON encoding 157 ``` 158 159 160 ## peer chaincode invoke 161 ``` 162 Invoke the specified chaincode. It will try to commit the endorsed transaction to the network. 163 164 Usage: 165 peer chaincode invoke [flags] 166 167 Flags: 168 -C, --channelID string The channel on which this command should be executed 169 --connectionProfile string Connection profile that provides the necessary connection information for the network. Note: currently only supported for providing peer connection information 170 -c, --ctor string Constructor message for the chaincode in JSON format (default "{}") 171 -h, --help help for invoke 172 -I, --isInit Is this invocation for init (useful for supporting legacy chaincodes in the new lifecycle) 173 -n, --name string Name of the chaincode 174 --peerAddresses stringArray The addresses of the peers to connect to 175 --tlsRootCertFiles stringArray If TLS is enabled, the paths to the TLS root cert files of the peers to connect to. The order and number of certs specified should match the --peerAddresses flag 176 --waitForEvent Whether to wait for the event from each peer's deliver filtered service signifying that the 'invoke' transaction has been committed successfully 177 --waitForEventTimeout duration Time to wait for the event from each peer's deliver filtered service signifying that the 'invoke' transaction has been committed successfully (default 30s) 178 179 Global Flags: 180 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 181 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 182 --clientauth Use mutual TLS when communicating with the orderer endpoint 183 --connTimeout duration Timeout for client to connect (default 3s) 184 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 185 -o, --orderer string Ordering service endpoint 186 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer 187 --tls Use TLS when communicating with the orderer endpoint 188 --tlsHandshakeTimeShift duration The amount of time to shift backwards for certificate expiration checks during TLS handshakes with the orderer endpoint 189 --transient string Transient map of arguments in JSON encoding 190 ``` 191 192 193 ## peer chaincode list 194 ``` 195 Get the instantiated chaincodes in the channel if specify channel, or get installed chaincodes on the peer 196 197 Usage: 198 peer chaincode list [flags] 199 200 Flags: 201 -C, --channelID string The channel on which this command should be executed 202 --connectionProfile string Connection profile that provides the necessary connection information for the network. Note: currently only supported for providing peer connection information 203 -h, --help help for list 204 --installed Get the installed chaincodes on a peer 205 --instantiated Get the instantiated chaincodes on a channel 206 --peerAddresses stringArray The addresses of the peers to connect to 207 --tlsRootCertFiles stringArray If TLS is enabled, the paths to the TLS root cert files of the peers to connect to. The order and number of certs specified should match the --peerAddresses flag 208 209 Global Flags: 210 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 211 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 212 --clientauth Use mutual TLS when communicating with the orderer endpoint 213 --connTimeout duration Timeout for client to connect (default 3s) 214 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 215 -o, --orderer string Ordering service endpoint 216 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer 217 --tls Use TLS when communicating with the orderer endpoint 218 --tlsHandshakeTimeShift duration The amount of time to shift backwards for certificate expiration checks during TLS handshakes with the orderer endpoint 219 --transient string Transient map of arguments in JSON encoding 220 ``` 221 222 223 ## peer chaincode package 224 ``` 225 Package a chaincode and write the package to a file. 226 227 Usage: 228 peer chaincode package [outputfile] [flags] 229 230 Flags: 231 -s, --cc-package create CC deployment spec for owner endorsements instead of raw CC deployment spec 232 -c, --ctor string Constructor message for the chaincode in JSON format (default "{}") 233 -h, --help help for package 234 -i, --instantiate-policy string instantiation policy for the chaincode 235 -l, --lang string Language the chaincode is written in (default "golang") 236 -n, --name string Name of the chaincode 237 -p, --path string Path to chaincode 238 -S, --sign if creating CC deployment spec package for owner endorsements, also sign it with local MSP 239 -v, --version string Version of the chaincode specified in install/instantiate/upgrade commands 240 241 Global Flags: 242 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 243 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 244 --clientauth Use mutual TLS when communicating with the orderer endpoint 245 --connTimeout duration Timeout for client to connect (default 3s) 246 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 247 -o, --orderer string Ordering service endpoint 248 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer 249 --tls Use TLS when communicating with the orderer endpoint 250 --tlsHandshakeTimeShift duration The amount of time to shift backwards for certificate expiration checks during TLS handshakes with the orderer endpoint 251 --transient string Transient map of arguments in JSON encoding 252 ``` 253 254 255 ## peer chaincode query 256 ``` 257 Get endorsed result of chaincode function call and print it. It won't generate transaction. 258 259 Usage: 260 peer chaincode query [flags] 261 262 Flags: 263 -C, --channelID string The channel on which this command should be executed 264 --connectionProfile string Connection profile that provides the necessary connection information for the network. Note: currently only supported for providing peer connection information 265 -c, --ctor string Constructor message for the chaincode in JSON format (default "{}") 266 -h, --help help for query 267 -x, --hex If true, output the query value byte array in hexadecimal. Incompatible with --raw 268 -n, --name string Name of the chaincode 269 --peerAddresses stringArray The addresses of the peers to connect to 270 -r, --raw If true, output the query value as raw bytes, otherwise format as a printable string 271 --tlsRootCertFiles stringArray If TLS is enabled, the paths to the TLS root cert files of the peers to connect to. The order and number of certs specified should match the --peerAddresses flag 272 273 Global Flags: 274 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 275 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 276 --clientauth Use mutual TLS when communicating with the orderer endpoint 277 --connTimeout duration Timeout for client to connect (default 3s) 278 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 279 -o, --orderer string Ordering service endpoint 280 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer 281 --tls Use TLS when communicating with the orderer endpoint 282 --tlsHandshakeTimeShift duration The amount of time to shift backwards for certificate expiration checks during TLS handshakes with the orderer endpoint 283 --transient string Transient map of arguments in JSON encoding 284 ``` 285 286 287 ## peer chaincode signpackage 288 ``` 289 Sign the specified chaincode package 290 291 Usage: 292 peer chaincode signpackage [flags] 293 294 Flags: 295 -h, --help help for signpackage 296 297 Global Flags: 298 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 299 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 300 --clientauth Use mutual TLS when communicating with the orderer endpoint 301 --connTimeout duration Timeout for client to connect (default 3s) 302 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 303 -o, --orderer string Ordering service endpoint 304 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer 305 --tls Use TLS when communicating with the orderer endpoint 306 --tlsHandshakeTimeShift duration The amount of time to shift backwards for certificate expiration checks during TLS handshakes with the orderer endpoint 307 --transient string Transient map of arguments in JSON encoding 308 ``` 309 310 311 ## peer chaincode upgrade 312 ``` 313 Upgrade an existing chaincode with the specified one. The new chaincode will immediately replace the existing chaincode upon the transaction committed. 314 315 Usage: 316 peer chaincode upgrade [flags] 317 318 Flags: 319 -C, --channelID string The channel on which this command should be executed 320 --collections-config string The fully qualified path to the collection JSON file including the file name 321 --connectionProfile string Connection profile that provides the necessary connection information for the network. Note: currently only supported for providing peer connection information 322 -c, --ctor string Constructor message for the chaincode in JSON format (default "{}") 323 -E, --escc string The name of the endorsement system chaincode to be used for this chaincode 324 -h, --help help for upgrade 325 -l, --lang string Language the chaincode is written in (default "golang") 326 -n, --name string Name of the chaincode 327 -p, --path string Path to chaincode 328 --peerAddresses stringArray The addresses of the peers to connect to 329 -P, --policy string The endorsement policy associated to this chaincode 330 --tlsRootCertFiles stringArray If TLS is enabled, the paths to the TLS root cert files of the peers to connect to. The order and number of certs specified should match the --peerAddresses flag 331 -v, --version string Version of the chaincode specified in install/instantiate/upgrade commands 332 -V, --vscc string The name of the verification system chaincode to be used for this chaincode 333 334 Global Flags: 335 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 336 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 337 --clientauth Use mutual TLS when communicating with the orderer endpoint 338 --connTimeout duration Timeout for client to connect (default 3s) 339 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 340 -o, --orderer string Ordering service endpoint 341 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer 342 --tls Use TLS when communicating with the orderer endpoint 343 --tlsHandshakeTimeShift duration The amount of time to shift backwards for certificate expiration checks during TLS handshakes with the orderer endpoint 344 --transient string Transient map of arguments in JSON encoding 345 ``` 346 347 ## Example Usage 348 349 ### peer chaincode instantiate examples 350 351 Here are some examples of the `peer chaincode instantiate` command, which 352 instantiates the chaincode named `mycc` at version `1.0` on channel 353 `mychannel`: 354 355 * Using the `--tls` and `--cafile` global flags to instantiate the chaincode 356 in a network with TLS enabled: 357 358 ``` 359 export ORDERER_CA=/opt/gopath/src/github.com/hechain20/hechain/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem 360 peer chaincode instantiate -o orderer.example.com:7050 --tls --cafile $ORDERER_CA -C mychannel -n mycc -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')" 361 362 2018-02-22 16:33:53.324 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc 363 2018-02-22 16:33:53.324 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc 364 2018-02-22 16:34:08.698 UTC [main] main -> INFO 003 Exiting..... 365 366 ``` 367 368 * Using only the command-specific options to instantiate the chaincode in a 369 network with TLS disabled: 370 371 ``` 372 peer chaincode instantiate -o orderer.example.com:7050 -C mychannel -n mycc -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')" 373 374 375 2018-02-22 16:34:09.324 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc 376 2018-02-22 16:34:09.324 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc 377 2018-02-22 16:34:24.698 UTC [main] main -> INFO 003 Exiting..... 378 ``` 379 380 ### peer chaincode invoke example 381 382 Here is an example of the `peer chaincode invoke` command: 383 384 * Invoke the chaincode named `mycc` at version `1.0` on channel `mychannel` 385 on `peer0.org1.example.com:7051` and `peer0.org2.example.com:9051` (the 386 peers defined by `--peerAddresses`), requesting to move 10 units from 387 variable `a` to variable `b`: 388 389 ``` 390 peer chaincode invoke -o orderer.example.com:7050 -C mychannel -n mycc --peerAddresses peer0.org1.example.com:7051 --peerAddresses peer0.org2.example.com:9051 -c '{"Args":["invoke","a","b","10"]}' 391 392 2018-02-22 16:34:27.069 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc 393 2018-02-22 16:34:27.069 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc 394 . 395 . 396 . 397 2018-02-22 16:34:27.106 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> DEBU 00a ESCC invoke result: version:1 response:<status:200 message:"OK" > payload:"\n \237mM\376? [\214\002 \332\204\035\275q\227\2132A\n\204&\2106\037W|\346#\3413\274\022Y\nE\022\024\n\004lscc\022\014\n\n\n\004mycc\022\002\010\003\022-\n\004mycc\022%\n\007\n\001a\022\002\010\003\n\007\n\001b\022\002\010\003\032\007\n\001a\032\00290\032\010\n\001b\032\003210\032\003\010\310\001\"\013\022\004mycc\032\0031.0" endorsement:<endorser:"\n\007Org1MSP\022\262\006-----BEGIN CERTIFICATE-----\nMIICLjCCAdWgAwIBAgIRAJYomxY2cqHA/fbRnH5a/bwwCgYIKoZIzj0EAwIwczEL\nMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBG\ncmFuY2lzY28xGTAXBgNVBAoTEG9yZzEuZXhhbXBsZS5jb20xHDAaBgNVBAMTE2Nh\nLm9yZzEuZXhhbXBsZS5jb20wHhcNMTgwMjIyMTYyODE0WhcNMjgwMjIwMTYyODE0\nWjBwMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMN\nU2FuIEZyYW5jaXNjbzETMBEGA1UECxMKRmFicmljUGVlcjEfMB0GA1UEAxMWcGVl\ncjAub3JnMS5leGFtcGxlLmNvbTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABDEa\nWNNniN3qOCQL89BGWfY39f5V3o1pi//7JFDHATJXtLgJhkK5KosDdHuKLYbCqvge\n46u3AC16MZyJRvKBiw6jTTBLMA4GA1UdDwEB/wQEAwIHgDAMBgNVHRMBAf8EAjAA\nMCsGA1UdIwQkMCKAIN7dJR9dimkFtkus0R5pAOlRz5SA3FB5t8Eaxl9A7lkgMAoG\nCCqGSM49BAMCA0cAMEQCIC2DAsO9QZzQmKi8OOKwcCh9Gd01YmWIN3oVmaCRr8C7\nAiAlQffq2JFlbh6OWURGOko6RckizG8oVOldZG/Xj3C8lA==\n-----END CERTIFICATE-----\n" signature:"0D\002 \022_\342\350\344\231G&\237\n\244\375\302J\220l\302\345\210\335D\250y\253P\0214:\221e\332@\002 \000\254\361\224\247\210\214L\277\370\222\213\217\301\r\341v\227\265\277\336\256^\217\336\005y*\321\023\025\367" > 398 2018-02-22 16:34:27.107 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 00b Chaincode invoke successful. result: status:200 399 2018-02-22 16:34:27.107 UTC [main] main -> INFO 00c Exiting..... 400 401 ``` 402 403 Here you can see that the invoke was submitted successfully based on the log 404 message: 405 406 ``` 407 2018-02-22 16:34:27.107 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 00b Chaincode invoke successful. result: status:200 408 409 ``` 410 411 A successful response indicates that the transaction was submitted for ordering 412 successfully. The transaction will then be added to a block and, finally, validated 413 or invalidated by each peer on the channel. 414 415 Here is an example of how to format the `peer chaincode invoke` command when the chaincode package includes multiple smart contracts. 416 417 * If you are using the [contract-api](https://www.npmjs.com/package/fabric-contract-api), the name you pass to `super("MyContract")` can be used as a prefix. 418 419 ``` 420 peer chaincode invoke -C $CHANNEL_NAME -n $CHAINCODE_NAME -c '{ "Args": ["MyContract:methodName", "{}"] }' 421 422 peer chaincode invoke -C $CHANNEL_NAME -n $CHAINCODE_NAME -c '{ "Args": ["MyOtherContract:methodName", "{}"] }' 423 424 ``` 425 426 427 ### peer chaincode list example 428 429 Here are some examples of the `peer chaincode list ` command: 430 431 * Using the `--installed` flag to list the chaincodes installed on a peer. 432 433 ``` 434 peer chaincode list --installed 435 436 Get installed chaincodes on peer: 437 Name: mycc, Version: 1.0, Path: github.com/hyperledger/fabric-samples/chaincode/abstore/go, Id: 8cc2730fdafd0b28ef734eac12b29df5fc98ad98bdb1b7e0ef96265c3d893d61 438 2018-02-22 17:07:13.476 UTC [main] main -> INFO 001 Exiting..... 439 ``` 440 441 You can see that the peer has installed a chaincode called `mycc` which is at 442 version `1.0`. 443 444 * Using the `--instantiated` in combination with the `-C` (channel ID) flag to 445 list the chaincodes instantiated on a channel. 446 447 ``` 448 peer chaincode list --instantiated -C mychannel 449 450 Get instantiated chaincodes on channel mychannel: 451 Name: mycc, Version: 1.0, Path: github.com/hyperledger/fabric-samples/chaincode/abstore/go, Escc: escc, Vscc: vscc 452 2018-02-22 17:07:42.969 UTC [main] main -> INFO 001 Exiting..... 453 454 ``` 455 456 You can see that chaincode `mycc` at version `1.0` is instantiated on 457 channel `mychannel`. 458 459 ### peer chaincode package example 460 461 Here is an example of the `peer chaincode package` command, which 462 packages the chaincode named `mycc` at version `1.1`, creates the chaincode 463 deployment spec, signs the package using the local MSP, and outputs it as 464 `ccpack.out`: 465 466 ``` 467 peer chaincode package ccpack.out -n mycc -p github.com/hyperledger/fabric-samples/chaincode/abstore/go -v 1.1 -s -S 468 . 469 . 470 . 471 2018-02-22 17:27:01.404 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc 472 2018-02-22 17:27:01.405 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc 473 . 474 . 475 . 476 2018-02-22 17:27:01.879 UTC [chaincodeCmd] chaincodePackage -> DEBU 011 Packaged chaincode into deployment spec of size <3426>, with args = [ccpack.out] 477 2018-02-22 17:27:01.879 UTC [main] main -> INFO 012 Exiting..... 478 479 ``` 480 481 ### peer chaincode query example 482 483 Here is an example of the `peer chaincode query` command, which queries the 484 peer ledger for the chaincode named `mycc` at version `1.0` for the value of 485 variable `a`: 486 487 * You can see from the output that variable `a` had a value of 90 at the time of 488 the query. 489 490 ``` 491 peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}' 492 493 2018-02-22 16:34:30.816 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc 494 2018-02-22 16:34:30.816 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc 495 Query Result: 90 496 497 ``` 498 499 ### peer chaincode signpackage example 500 501 Here is an example of the `peer chaincode signpackage` command, which accepts an 502 existing signed package and creates a new one with signature of the local MSP 503 appended to it. 504 505 ``` 506 peer chaincode signpackage ccwith1sig.pak ccwith2sig.pak 507 Wrote signed package to ccwith2sig.pak successfully 508 2018-02-24 19:32:47.189 EST [main] main -> INFO 002 Exiting..... 509 ``` 510 511 ### peer chaincode upgrade example 512 513 Here is an example of the `peer chaincode upgrade` command, which 514 upgrades the chaincode named `mycc` at version `1.1` on channel 515 `mychannel` to version `1.2`, which contains a new variable `c`: 516 517 * Using the `--tls` and `--cafile` global flags to upgrade the chaincode 518 in a network with TLS enabled: 519 520 ``` 521 export ORDERER_CA=/opt/gopath/src/github.com/hechain20/hechain/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem 522 peer chaincode upgrade -o orderer.example.com:7050 --tls --cafile $ORDERER_CA -C mychannel -n mycc -v 1.2 -c '{"Args":["init","a","100","b","200","c","300"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')" 523 . 524 . 525 . 526 2018-02-22 18:26:31.433 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc 527 2018-02-22 18:26:31.434 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc 528 2018-02-22 18:26:31.435 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode enabled 529 2018-02-22 18:26:31.435 UTC [chaincodeCmd] upgrade -> DEBU 006 Get upgrade proposal for chaincode <name:"mycc" version:"1.1" > 530 . 531 . 532 . 533 2018-02-22 18:26:46.687 UTC [chaincodeCmd] upgrade -> DEBU 009 endorse upgrade proposal, get response <status:200 message:"OK" payload:"\n\004mycc\022\0031.1\032\004escc\"\004vscc*,\022\014\022\n\010\001\022\002\010\000\022\002\010\001\032\r\022\013\n\007Org1MSP\020\003\032\r\022\013\n\007Org2MSP\020\0032f\n \261g(^v\021\220\240\332\251\014\204V\210P\310o\231\271\036\301\022\032\205fC[|=\215\372\223\022 \311b\025?\323N\343\325\032\005\365\236\001XKj\004E\351\007\247\265fu\305j\367\331\275\253\307R\032 \014H#\014\272!#\345\306s\323\371\350\364\006.\000\356\230\353\270\263\215\217\303\256\220i^\277\305\214: \375\200zY\275\203}\375\244\205\035\340\226]l!uE\334\273\214\214\020\303\3474\360\014\234-\006\315B\031\022\010\022\006\010\001\022\002\010\000\032\r\022\013\n\007Org1MSP\020\001" > 534 . 535 . 536 . 537 2018-02-22 18:26:46.693 UTC [chaincodeCmd] upgrade -> DEBU 00c Get Signed envelope 538 2018-02-22 18:26:46.693 UTC [chaincodeCmd] chaincodeUpgrade -> DEBU 00d Send signed envelope to orderer 539 2018-02-22 18:26:46.908 UTC [main] main -> INFO 00e Exiting..... 540 ``` 541 542 * Using only the command-specific options to upgrade the chaincode in a 543 network with TLS disabled: 544 545 ``` 546 peer chaincode upgrade -o orderer.example.com:7050 -C mychannel -n mycc -v 1.2 -c '{"Args":["init","a","100","b","200","c","300"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')" 547 . 548 . 549 . 550 2018-02-22 18:28:31.433 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc 551 2018-02-22 18:28:31.434 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc 552 2018-02-22 18:28:31.435 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode enabled 553 2018-02-22 18:28:31.435 UTC [chaincodeCmd] upgrade -> DEBU 006 Get upgrade proposal for chaincode <name:"mycc" version:"1.1" > 554 . 555 . 556 . 557 2018-02-22 18:28:46.687 UTC [chaincodeCmd] upgrade -> DEBU 009 endorse upgrade proposal, get response <status:200 message:"OK" payload:"\n\004mycc\022\0031.1\032\004escc\"\004vscc*,\022\014\022\n\010\001\022\002\010\000\022\002\010\001\032\r\022\013\n\007Org1MSP\020\003\032\r\022\013\n\007Org2MSP\020\0032f\n \261g(^v\021\220\240\332\251\014\204V\210P\310o\231\271\036\301\022\032\205fC[|=\215\372\223\022 \311b\025?\323N\343\325\032\005\365\236\001XKj\004E\351\007\247\265fu\305j\367\331\275\253\307R\032 \014H#\014\272!#\345\306s\323\371\350\364\006.\000\356\230\353\270\263\215\217\303\256\220i^\277\305\214: \375\200zY\275\203}\375\244\205\035\340\226]l!uE\334\273\214\214\020\303\3474\360\014\234-\006\315B\031\022\010\022\006\010\001\022\002\010\000\032\r\022\013\n\007Org1MSP\020\001" > 558 . 559 . 560 . 561 2018-02-22 18:28:46.693 UTC [chaincodeCmd] upgrade -> DEBU 00c Get Signed envelope 562 2018-02-22 18:28:46.693 UTC [chaincodeCmd] chaincodeUpgrade -> DEBU 00d Send signed envelope to orderer 563 2018-02-22 18:28:46.908 UTC [main] main -> INFO 00e Exiting..... 564 ``` 565 566 <a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.