github.com/osdi23p228/fabric@v0.0.0-20221218062954-77808885f5db/docs/source/commands/peerchaincode.md (about)

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