github.com/kaituanwang/hyperledger@v2.0.1+incompatible/docs/source/commands/peerlifecycle.md (about) 1 # peer lifecycle chaincode 2 3 The `peer lifecycle chaincode` subcommand allows administrators to use the 4 Fabric chaincode lifecycle to package a chaincode, install it on your peers, 5 approve a chaincode definition for your organization, and then commit the 6 definition to a channel. The chaincode is ready to be used after the definition 7 has been successfully committed to the channel. For more information, visit 8 [Chaincode for Operators](../chaincode4noah.html). 9 10 *Note: These instructions use the Fabric chaincode lifecycle introduced in the 11 v2.0 release. If you would like to use the old lifecycle to install and 12 instantiate a chaincode, visit the [peer chaincode](peerchaincode.html) command 13 reference.* 14 15 ## Syntax 16 17 The `peer lifecycle chaincode` command has the following subcommands: 18 19 * package 20 * install 21 * queryinstalled 22 * getinstalledpackage 23 * approveformyorg 24 * checkcommitreadiness 25 * commit 26 * querycommitted 27 28 Each peer lifecycle chaincode subcommand is described together with its options in its own 29 section in this topic. 30 31 ## peer lifecycle 32 ``` 33 Perform _lifecycle operations 34 35 Usage: 36 peer lifecycle [command] 37 38 Available Commands: 39 chaincode Perform chaincode operations: package|install|queryinstalled|getinstalledpackage|approveformyorg|checkcommitreadiness|commit|querycommitted 40 41 Flags: 42 -h, --help help for lifecycle 43 44 Use "peer lifecycle [command] --help" for more information about a command. 45 ``` 46 47 48 ## peer lifecycle chaincode 49 ``` 50 Perform chaincode operations: package|install|queryinstalled|getinstalledpackage|approveformyorg|checkcommitreadiness|commit|querycommitted 51 52 Usage: 53 peer lifecycle chaincode [command] 54 55 Available Commands: 56 approveformyorg Approve the chaincode definition for my org. 57 checkcommitreadiness Check whether a chaincode definition is ready to be committed on a channel. 58 commit Commit the chaincode definition on the channel. 59 getinstalledpackage Get an installed chaincode package from a peer. 60 install Install a chaincode. 61 package Package a chaincode 62 querycommitted Query the committed chaincode definitions by channel on a peer. 63 queryinstalled Query the installed chaincodes on a peer. 64 65 Flags: 66 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 67 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 68 --clientauth Use mutual TLS when communicating with the orderer endpoint 69 --connTimeout duration Timeout for client to connect (default 3s) 70 -h, --help help for chaincode 71 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 72 -o, --orderer string Ordering service endpoint 73 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer. 74 --tls Use TLS when communicating with the orderer endpoint 75 76 Use "peer lifecycle chaincode [command] --help" for more information about a command. 77 ``` 78 79 80 ## peer lifecycle chaincode package 81 ``` 82 Package a chaincode and write the package to a file. 83 84 Usage: 85 peer lifecycle chaincode package [outputfile] [flags] 86 87 Flags: 88 --connectionProfile string The fully qualified path to the connection profile that provides the necessary connection information for the network. Note: currently only supported for providing peer connection information 89 -h, --help help for package 90 --label string The package label contains a human-readable description of the package 91 -l, --lang string Language the chaincode is written in (default "golang") 92 -p, --path string Path to the chaincode 93 --peerAddresses stringArray The addresses of the peers to connect to 94 --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 95 96 Global Flags: 97 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 98 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 99 --clientauth Use mutual TLS when communicating with the orderer endpoint 100 --connTimeout duration Timeout for client to connect (default 3s) 101 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 102 -o, --orderer string Ordering service endpoint 103 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer. 104 --tls Use TLS when communicating with the orderer endpoint 105 ``` 106 107 108 ## peer lifecycle chaincode install 109 ``` 110 Install a chaincode on a peer. 111 112 Usage: 113 peer lifecycle chaincode install [flags] 114 115 Flags: 116 --connectionProfile string The fully qualified path to the connection profile that provides the necessary connection information for the network. Note: currently only supported for providing peer connection information 117 -h, --help help for install 118 --peerAddresses stringArray The addresses of the peers to connect to 119 --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 120 121 Global Flags: 122 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 123 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 124 --clientauth Use mutual TLS when communicating with the orderer endpoint 125 --connTimeout duration Timeout for client to connect (default 3s) 126 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 127 -o, --orderer string Ordering service endpoint 128 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer. 129 --tls Use TLS when communicating with the orderer endpoint 130 ``` 131 132 133 ## peer lifecycle chaincode queryinstalled 134 ``` 135 Query the installed chaincodes on a peer. 136 137 Usage: 138 peer lifecycle chaincode queryinstalled [flags] 139 140 Flags: 141 --connectionProfile string The fully qualified path to the connection profile that provides the necessary connection information for the network. Note: currently only supported for providing peer connection information 142 -h, --help help for queryinstalled 143 -O, --output string The output format for query results. Default is human-readable plain-text. json is currently the only supported format. 144 --peerAddresses stringArray The addresses of the peers to connect to 145 --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 146 147 Global Flags: 148 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 149 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 150 --clientauth Use mutual TLS when communicating with the orderer endpoint 151 --connTimeout duration Timeout for client to connect (default 3s) 152 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 153 -o, --orderer string Ordering service endpoint 154 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer. 155 --tls Use TLS when communicating with the orderer endpoint 156 ``` 157 158 159 ## peer lifecycle chaincode getinstalledpackage 160 ``` 161 Get an installed chaincode package from a peer. 162 163 Usage: 164 peer lifecycle chaincode getinstalledpackage [outputfile] [flags] 165 166 Flags: 167 --connectionProfile string The fully qualified path to the connection profile that provides the necessary connection information for the network. Note: currently only supported for providing peer connection information 168 -h, --help help for getinstalledpackage 169 --output-directory string The output directory to use when writing a chaincode install package to disk. Default is the current working directory. 170 --package-id string The identifier of the chaincode install package 171 --peerAddresses stringArray The addresses of the peers to connect to 172 --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 173 174 Global Flags: 175 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 176 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 177 --clientauth Use mutual TLS when communicating with the orderer endpoint 178 --connTimeout duration Timeout for client to connect (default 3s) 179 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 180 -o, --orderer string Ordering service endpoint 181 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer. 182 --tls Use TLS when communicating with the orderer endpoint 183 ``` 184 185 186 ## peer lifecycle chaincode approveformyorg 187 ``` 188 Approve the chaincode definition for my organization. 189 190 Usage: 191 peer lifecycle chaincode approveformyorg [flags] 192 193 Flags: 194 --channel-config-policy string The endorsement policy associated to this chaincode specified as a channel config policy reference 195 -C, --channelID string The channel on which this command should be executed 196 --collections-config string The fully qualified path to the collection JSON file including the file name 197 --connectionProfile string The fully qualified path to the connection profile that provides the necessary connection information for the network. Note: currently only supported for providing peer connection information 198 -E, --endorsement-plugin string The name of the endorsement plugin to be used for this chaincode 199 -h, --help help for approveformyorg 200 --init-required Whether the chaincode requires invoking 'init' 201 -n, --name string Name of the chaincode 202 --package-id string The identifier of the chaincode install package 203 --peerAddresses stringArray The addresses of the peers to connect to 204 --sequence int The sequence number of the chaincode definition for the channel (default 1) 205 --signature-policy string The endorsement policy associated to this chaincode specified as a signature policy 206 --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 207 -V, --validation-plugin string The name of the validation plugin to be used for this chaincode 208 -v, --version string Version of the chaincode 209 --waitForEvent Whether to wait for the event from each peer's deliver filtered service signifying that the transaction has been committed successfully (default true) 210 --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) 211 212 Global Flags: 213 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 214 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 215 --clientauth Use mutual TLS when communicating with the orderer endpoint 216 --connTimeout duration Timeout for client to connect (default 3s) 217 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 218 -o, --orderer string Ordering service endpoint 219 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer. 220 --tls Use TLS when communicating with the orderer endpoint 221 ``` 222 223 224 ## peer lifecycle chaincode checkcommitreadiness 225 ``` 226 Check whether a chaincode definition is ready to be committed on a channel. 227 228 Usage: 229 peer lifecycle chaincode checkcommitreadiness [flags] 230 231 Flags: 232 --channel-config-policy string The endorsement policy associated to this chaincode specified as a channel config policy reference 233 -C, --channelID string The channel on which this command should be executed 234 --collections-config string The fully qualified path to the collection JSON file including the file name 235 --connectionProfile string The fully qualified path to the connection profile that provides the necessary connection information for the network. Note: currently only supported for providing peer connection information 236 -E, --endorsement-plugin string The name of the endorsement plugin to be used for this chaincode 237 -h, --help help for checkcommitreadiness 238 --init-required Whether the chaincode requires invoking 'init' 239 -n, --name string Name of the chaincode 240 -O, --output string The output format for query results. Default is human-readable plain-text. json is currently the only supported format. 241 --peerAddresses stringArray The addresses of the peers to connect to 242 --sequence int The sequence number of the chaincode definition for the channel (default 1) 243 --signature-policy string The endorsement policy associated to this chaincode specified as a signature policy 244 --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 245 -V, --validation-plugin string The name of the validation plugin to be used for this chaincode 246 -v, --version string Version of the chaincode 247 248 Global Flags: 249 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 250 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 251 --clientauth Use mutual TLS when communicating with the orderer endpoint 252 --connTimeout duration Timeout for client to connect (default 3s) 253 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 254 -o, --orderer string Ordering service endpoint 255 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer. 256 --tls Use TLS when communicating with the orderer endpoint 257 ``` 258 259 260 ## peer lifecycle chaincode commit 261 ``` 262 Commit the chaincode definition on the channel. 263 264 Usage: 265 peer lifecycle chaincode commit [flags] 266 267 Flags: 268 --channel-config-policy string The endorsement policy associated to this chaincode specified as a channel config policy reference 269 -C, --channelID string The channel on which this command should be executed 270 --collections-config string The fully qualified path to the collection JSON file including the file name 271 --connectionProfile string The fully qualified path to the connection profile that provides the necessary connection information for the network. Note: currently only supported for providing peer connection information 272 -E, --endorsement-plugin string The name of the endorsement plugin to be used for this chaincode 273 -h, --help help for commit 274 --init-required Whether the chaincode requires invoking 'init' 275 -n, --name string Name of the chaincode 276 --peerAddresses stringArray The addresses of the peers to connect to 277 --sequence int The sequence number of the chaincode definition for the channel (default 1) 278 --signature-policy string The endorsement policy associated to this chaincode specified as a signature policy 279 --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 280 -V, --validation-plugin string The name of the validation plugin to be used for this chaincode 281 -v, --version string Version of the chaincode 282 --waitForEvent Whether to wait for the event from each peer's deliver filtered service signifying that the transaction has been committed successfully (default true) 283 --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) 284 285 Global Flags: 286 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 287 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 288 --clientauth Use mutual TLS when communicating with the orderer endpoint 289 --connTimeout duration Timeout for client to connect (default 3s) 290 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 291 -o, --orderer string Ordering service endpoint 292 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer. 293 --tls Use TLS when communicating with the orderer endpoint 294 ``` 295 296 297 ## peer lifecycle chaincode querycommitted 298 ``` 299 Query the committed chaincode definitions by channel on a peer. Optional: provide a chaincode name to query a specific definition. 300 301 Usage: 302 peer lifecycle chaincode querycommitted [flags] 303 304 Flags: 305 -C, --channelID string The channel on which this command should be executed 306 --connectionProfile string The fully qualified path to the connection profile that provides the necessary connection information for the network. Note: currently only supported for providing peer connection information 307 -h, --help help for querycommitted 308 -n, --name string Name of the chaincode 309 -O, --output string The output format for query results. Default is human-readable plain-text. json is currently the only supported format. 310 --peerAddresses stringArray The addresses of the peers to connect to 311 --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 312 313 Global Flags: 314 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 315 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 316 --clientauth Use mutual TLS when communicating with the orderer endpoint 317 --connTimeout duration Timeout for client to connect (default 3s) 318 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 319 -o, --orderer string Ordering service endpoint 320 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer. 321 --tls Use TLS when communicating with the orderer endpoint 322 ``` 323 324 325 ## Example Usage 326 327 ### peer lifecycle chaincode package example 328 329 A chaincode needs to be packaged before it can be installed on your peers. 330 This example uses the `peer lifecycle chaincode package` command to package 331 a Golang chaincode. 332 333 * Use the `--label` flag to provide a chaincode package label of `myccv1` 334 that your organization will use to identify the package. 335 336 ``` 337 peer lifecycle chaincode package mycc.tar.gz --path github.com/hyperledger/fabric-samples/chaincode/abstore/go/ --lang golang --label myccv1 338 ``` 339 340 ### peer lifecycle chaincode install example 341 342 After the chaincode is packaged, you can use the `peer chaincode install` command 343 to install the chaincode on your peers. 344 345 * Install the `mycc.tar.gz ` package on `peer0.org1.example.com:7051` (the 346 peer defined by `--peerAddresses`). 347 348 ``` 349 peer lifecycle chaincode install mycc.tar.gz --peerAddresses peer0.org1.example.com:7051 350 ``` 351 If successful, the command will return the package identifier. The 352 package ID is the package label combined with a hash of the chaincode 353 package taken by the peer. 354 ``` 355 2019-03-13 13:48:53.691 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:<status:200 payload:"\nEmycc:ebd89878c2bbccf62f68c36072626359376aa83c36435a058d453e8dbfd894cc" > 356 2019-03-13 13:48:53.691 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: mycc:a7ca45a7cc85f1d89c905b775920361ed089a364e12a9b6d55ba75c965ddd6a9 357 ``` 358 359 ### peer lifecycle chaincode queryinstalled example 360 361 You need to use the chaincode package identifier to approve a chaincode 362 definition for your organization. You can find the package ID for the 363 chaincodes you have installed by using the 364 `peer lifecycle chaincode queryinstalled` command: 365 366 ``` 367 peer lifecycle chaincode queryinstalled --peerAddresses peer0.org1.example.com:7051 368 ``` 369 370 A successful command will return the package ID associated with the 371 package label. 372 373 ``` 374 Get installed chaincodes on peer: 375 Package ID: myccv1:a7ca45a7cc85f1d89c905b775920361ed089a364e12a9b6d55ba75c965ddd6a9, Label: myccv1 376 ``` 377 378 ### peer lifecycle chaincode getinstalledpackage example 379 380 You can retrieve an installed chaincode package from a peer using the 381 `peer lifecycle chaincode getinstalledpackage` command. Use the package 382 identifier returned by `queryinstalled`. 383 384 * Use the `--package-id` flag to pass in the chaincode package identifier. Use 385 the `--output-directory` flag to specify where to write the chaincode package. 386 If the output directory is not specified, the chaincode package will be written 387 in the current directory. 388 389 ``` 390 peer lifecycle chaincode getinstalledpackage --package-id myccv1:a7ca45a7cc85f1d89c905b775920361ed089a364e12a9b6d55ba75c965ddd6a9 --output-directory /tmp --peerAddresses peer0.org1.example.com:7051 391 ``` 392 393 394 ### peer lifecycle chaincode approveformyorg example 395 396 Once the chaincode package has been installed on your peers, you can approve 397 a chaincode definition for your organization. The chaincode definition includes 398 the important parameters of chaincode governance, including the chaincode name, 399 version and the endorsement policy. 400 401 Here is an example of the `peer lifecycle chaincode approveformyorg` command, 402 which approves the definition of a chaincode named `mycc` at version `1.0` on 403 channel `mychannel`. 404 405 * Use the `--package-id` flag to pass in the chaincode package identifier. Use 406 the `--signature-policy` flag to define an endorsement policy for the chaincode. 407 Use the `init-required` flag to request the execution of the `Init` 408 function to initialize the chaincode. 409 410 ``` 411 export ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem 412 413 peer lifecycle chaincode approveformyorg -o orderer.example.com:7050 --tls --cafile $ORDERER_CA --channelID mychannel --name mycc --version 1.0 --init-required --package-id myccv1:a7ca45a7cc85f1d89c905b775920361ed089a364e12a9b6d55ba75c965ddd6a9 --sequence 1 --signature-policy "AND ('Org1MSP.peer','Org2MSP.peer')" 414 415 2019-03-18 16:04:09.046 UTC [cli.lifecycle.chaincode] InitCmdFactory -> INFO 001 Retrieved channel (mychannel) orderer endpoint: orderer.example.com:7050 416 2019-03-18 16:04:11.253 UTC [chaincodeCmd] ClientWait -> INFO 002 txid [efba188ca77889cc1c328fc98e0bb12d3ad0abcda3f84da3714471c7c1e6c13c] committed with status (VALID) at peer0.org1.example.com:7051 417 ``` 418 419 * You can also use the `--channel-config-policy` flag use a policy inside 420 the channel configuration as the chaincode endorsement policy. The default 421 endorsement policy is `Channel/Application/Endorsement` 422 423 ``` 424 export ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem 425 426 peer lifecycle chaincode approveformyorg -o orderer.example.com:7050 --tls --cafile $ORDERER_CA --channelID mychannel --name mycc --version 1.0 --init-required --package-id myccv1:a7ca45a7cc85f1d89c905b775920361ed089a364e12a9b6d55ba75c965ddd6a9 --sequence 1 --channel-config-policy Channel/Application/Admins 427 428 2019-03-18 16:04:09.046 UTC [cli.lifecycle.chaincode] InitCmdFactory -> INFO 001 Retrieved channel (mychannel) orderer endpoint: orderer.example.com:7050 429 2019-03-18 16:04:11.253 UTC [chaincodeCmd] ClientWait -> INFO 002 txid [efba188ca77889cc1c328fc98e0bb12d3ad0abcda3f84da3714471c7c1e6c13c] committed with status (VALID) at peer0.org1.example.com:7051 430 ``` 431 432 ### peer lifecycle chaincode checkcommitreadiness example 433 434 You can check whether a chaincode definition is ready to be committed using the 435 `peer lifecycle chaincode checkcommitreadiness` command, which will return 436 successfully if a subsequent commit of the definition is expected to succeed. It 437 also outputs which organizations have approved the chaincode definition. If an 438 organization has approved the chaincode definition specified in the command, the 439 command will return a value of true. You can use this command to learn whether enough 440 channel members have approved a chaincode definition to meet the 441 `Application/Channel/Endorsement` policy (a majority by default) before the 442 definition can be committed to a channel. 443 444 * Here is an example of the `peer lifecycle chaincode checkcommitreadiness` command, 445 which checks a chaincode named `mycc` at version `1.0` on channel `mychannel`. 446 447 ``` 448 export ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem 449 450 peer lifecycle chaincode checkcommitreadiness -o orderer.example.com:7050 --channelID mychannel --tls --cafile $ORDERER_CA --name mycc --version 1.0 --init-required --sequence 1 451 ``` 452 453 If successful, the command will return the organizations that have approved 454 the chaincode definition. 455 456 ``` 457 Chaincode definition for chaincode 'mycc', version '1.0', sequence '1' on channel 458 'mychannel' approval status by org: 459 Org1MSP: true 460 Org2MSP: true 461 ``` 462 463 * You can also use the `--output` flag to have the CLI format the output as 464 JSON. 465 466 ``` 467 export ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem 468 469 peer lifecycle chaincode checkcommitreadiness -o orderer.example.com:7050 --channelID mychannel --tls --cafile $ORDERER_CA --name mycc --version 1.0 --init-required --sequence 1 --output json 470 ``` 471 472 If successful, the command will return a JSON map that shows if an organization 473 has approved the chaincode definition. 474 475 ``` 476 { 477 "Approvals": { 478 "Org1MSP": true, 479 "Org2MSP": true 480 } 481 } 482 ``` 483 484 ### peer lifecycle chaincode commit example 485 486 Once a sufficient number of organizations approve a chaincode definition for 487 their organizations (a majority by default), one organization can commit the 488 definition the channel using the `peer lifecycle chaincode commit` command: 489 490 * This command needs to target the peers of other organizations on the channel 491 to collect their organization endorsement for the definition. 492 493 ``` 494 export ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem 495 496 peer lifecycle chaincode commit -o orderer.example.com:7050 --channelID mychannel --name mycc --version 1.0 --sequence 1 --init-required --tls --cafile $ORDERER_CA --peerAddresses peer0.org1.example.com:7051 --peerAddresses peer0.org2.example.com:9051 497 498 2019-03-18 16:14:27.258 UTC [chaincodeCmd] ClientWait -> INFO 001 txid [b6f657a14689b27d69a50f39590b3949906b5a426f9d7f0dcee557f775e17882] committed with status (VALID) at peer0.org2.example.com:9051 499 2019-03-18 16:14:27.321 UTC [chaincodeCmd] ClientWait -> INFO 002 txid [b6f657a14689b27d69a50f39590b3949906b5a426f9d7f0dcee557f775e17882] committed with status (VALID) at peer0.org1.example.com:7051 500 ``` 501 502 ### peer lifecycle chaincode querycommitted example 503 504 You can query the chaincode definitions that have been committed to a channel by 505 using the `peer lifecycle chaincode querycommitted` command. You can use this 506 command to query the current definition sequence number before upgrading a 507 chaincode. 508 509 * You need to supply the chaincode name and channel name in order to query a 510 specific chaincode definition and the organizations that have approved it. 511 512 ``` 513 export ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem 514 515 peer lifecycle chaincode querycommitted -o orderer.example.com:7050 --channelID mychannel --name mycc --tls --cafile $ORDERER_CA --peerAddresses peer0.org1.example.com:7051 516 517 Committed chaincode definition for chaincode 'mycc' on channel 'mychannel': 518 Version: 1, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc 519 Approvals: [Org1MSP: true, Org2MSP: true] 520 ``` 521 522 * You can also specify just the channel name in order to query all chaincode 523 definitions on that channel. 524 525 ``` 526 export ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem 527 528 peer lifecycle chaincode querycommitted -o orderer.example.com:7050 --channelID mychannel --tls --cafile $ORDERER_CA --peerAddresses peer0.org1.example.com:7051 529 530 Committed chaincode definitions on channel 'mychannel': 531 Name: mycc, Version: 1, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc 532 Name: yourcc, Version: 2, Sequence: 3, Endorsement Plugin: escc, Validation Plugin: vscc 533 ``` 534 535 <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>.