github.com/Hnampk/my-fabric@v0.0.0-20201028083322-75069da399c0/docs/wrappers/peer_chaincode_postscript.md (about)

     1  ## Example Usage
     2  
     3  ### peer chaincode instantiate examples
     4  
     5  Here are some examples of the `peer chaincode instantiate` command, which
     6  instantiates the chaincode named `mycc` at version `1.0` on channel
     7  `mychannel`:
     8  
     9    * Using the `--tls` and `--cafile` global flags to instantiate the chaincode
    10      in a network with TLS enabled:
    11  
    12      ```
    13      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
    14      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')"
    15  
    16      2018-02-22 16:33:53.324 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
    17      2018-02-22 16:33:53.324 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
    18      2018-02-22 16:34:08.698 UTC [main] main -> INFO 003 Exiting.....
    19  
    20      ```
    21  
    22    * Using only the command-specific options to instantiate the chaincode in a
    23      network with TLS disabled:
    24  
    25      ```
    26      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')"
    27  
    28  
    29      2018-02-22 16:34:09.324 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
    30      2018-02-22 16:34:09.324 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
    31      2018-02-22 16:34:24.698 UTC [main] main -> INFO 003 Exiting.....
    32      ```
    33  
    34  ### peer chaincode invoke example
    35  
    36  Here is an example of the `peer chaincode invoke` command:
    37  
    38    * Invoke the chaincode named `mycc` at version `1.0` on channel `mychannel`
    39      on `peer0.org1.example.com:7051` and `peer0.org2.example.com:9051` (the
    40      peers defined by `--peerAddresses`), requesting to move 10 units from
    41      variable `a` to variable `b`:
    42  
    43      ```
    44      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"]}'
    45  
    46      2018-02-22 16:34:27.069 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
    47      2018-02-22 16:34:27.069 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
    48      .
    49      .
    50      .
    51      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" >
    52      2018-02-22 16:34:27.107 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 00b Chaincode invoke successful. result: status:200
    53      2018-02-22 16:34:27.107 UTC [main] main -> INFO 00c Exiting.....
    54  
    55      ```
    56  
    57      Here you can see that the invoke was submitted successfully based on the log
    58      message:
    59  
    60      ```
    61      2018-02-22 16:34:27.107 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 00b Chaincode invoke successful. result: status:200
    62  
    63      ```
    64  
    65      A successful response indicates that the transaction was submitted for ordering
    66      successfully. The transaction will then be added to a block and, finally, validated
    67      or invalidated by each peer on the channel.
    68  
    69  ### peer chaincode list example
    70  
    71  Here are some examples of the `peer chaincode list ` command:
    72  
    73    * Using the `--installed` flag to list the chaincodes installed on a peer.
    74  
    75      ```
    76      peer chaincode list --installed
    77  
    78      Get installed chaincodes on peer:
    79      Name: mycc, Version: 1.0, Path: github.com/hyperledger/fabric-samples/chaincode/abstore/go, Id: 8cc2730fdafd0b28ef734eac12b29df5fc98ad98bdb1b7e0ef96265c3d893d61
    80      2018-02-22 17:07:13.476 UTC [main] main -> INFO 001 Exiting.....
    81      ```
    82  
    83      You can see that the peer has installed a chaincode called `mycc` which is at
    84      version `1.0`.
    85  
    86    * Using the `--instantiated` in combination with the `-C` (channel ID) flag to
    87      list the chaincodes instantiated on a channel.
    88  
    89      ```
    90      peer chaincode list --instantiated -C mychannel
    91  
    92      Get instantiated chaincodes on channel mychannel:
    93      Name: mycc, Version: 1.0, Path: github.com/hyperledger/fabric-samples/chaincode/abstore/go, Escc: escc, Vscc: vscc
    94      2018-02-22 17:07:42.969 UTC [main] main -> INFO 001 Exiting.....
    95  
    96      ```
    97  
    98      You can see that chaincode `mycc` at version `1.0` is instantiated on
    99      channel `mychannel`.
   100  
   101  ### peer chaincode package example
   102  
   103  Here is an example of the `peer chaincode package` command, which
   104  packages the chaincode named `mycc` at version `1.1`, creates the chaincode
   105  deployment spec, signs the package using the local MSP, and outputs it as
   106  `ccpack.out`:
   107  
   108    ```
   109      peer chaincode package ccpack.out -n mycc -p github.com/hyperledger/fabric-samples/chaincode/abstore/go -v 1.1 -s -S
   110      .
   111      .
   112      .
   113      2018-02-22 17:27:01.404 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
   114      2018-02-22 17:27:01.405 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
   115      .
   116      .
   117      .
   118      2018-02-22 17:27:01.879 UTC [chaincodeCmd] chaincodePackage -> DEBU 011 Packaged chaincode into deployment spec of size <3426>, with args = [ccpack.out]
   119      2018-02-22 17:27:01.879 UTC [main] main -> INFO 012 Exiting.....
   120  
   121      ```
   122  
   123  ### peer chaincode query example
   124  
   125  Here is an example of the `peer chaincode query` command, which queries the
   126  peer ledger for the chaincode named `mycc` at version `1.0` for the value of
   127  variable `a`:
   128  
   129    * You can see from the output that variable `a` had a value of 90 at the time of
   130      the query.
   131  
   132      ```
   133      peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
   134  
   135      2018-02-22 16:34:30.816 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
   136      2018-02-22 16:34:30.816 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
   137      Query Result: 90
   138  
   139      ```
   140  
   141  ### peer chaincode signpackage example
   142  
   143  Here is an example of the `peer chaincode signpackage` command, which accepts an
   144  existing signed  package and creates a new one with signature of the local MSP
   145  appended to it.
   146  
   147    ```
   148    peer chaincode signpackage ccwith1sig.pak ccwith2sig.pak
   149    Wrote signed package to ccwith2sig.pak successfully
   150    2018-02-24 19:32:47.189 EST [main] main -> INFO 002 Exiting.....
   151    ```
   152  
   153  ### peer chaincode upgrade example
   154  
   155  Here is an example of the `peer chaincode upgrade` command, which
   156  upgrades the chaincode named `mycc` at version `1.1` on channel
   157  `mychannel` to version `1.2`, which contains a new variable `c`:
   158  
   159    * Using the `--tls` and `--cafile` global flags to upgrade the chaincode
   160      in a network with TLS enabled:
   161  
   162      ```
   163      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
   164      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')"
   165      .
   166      .
   167      .
   168      2018-02-22 18:26:31.433 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
   169      2018-02-22 18:26:31.434 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
   170      2018-02-22 18:26:31.435 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode enabled
   171      2018-02-22 18:26:31.435 UTC [chaincodeCmd] upgrade -> DEBU 006 Get upgrade proposal for chaincode <name:"mycc" version:"1.1" >
   172      .
   173      .
   174      .
   175      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" >
   176      .
   177      .
   178      .
   179      2018-02-22 18:26:46.693 UTC [chaincodeCmd] upgrade -> DEBU 00c Get Signed envelope
   180      2018-02-22 18:26:46.693 UTC [chaincodeCmd] chaincodeUpgrade -> DEBU 00d Send signed envelope to orderer
   181      2018-02-22 18:26:46.908 UTC [main] main -> INFO 00e Exiting.....
   182      ```
   183  
   184    * Using only the command-specific options to upgrade the chaincode in a
   185      network with TLS disabled:
   186  
   187      ```
   188      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')"
   189      .
   190      .
   191      .
   192      2018-02-22 18:28:31.433 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
   193      2018-02-22 18:28:31.434 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
   194      2018-02-22 18:28:31.435 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode enabled
   195      2018-02-22 18:28:31.435 UTC [chaincodeCmd] upgrade -> DEBU 006 Get upgrade proposal for chaincode <name:"mycc" version:"1.1" >
   196      .
   197      .
   198      .
   199      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" >
   200      .
   201      .
   202      .
   203      2018-02-22 18:28:46.693 UTC [chaincodeCmd] upgrade -> DEBU 00c Get Signed envelope
   204      2018-02-22 18:28:46.693 UTC [chaincodeCmd] chaincodeUpgrade -> DEBU 00d Send signed envelope to orderer
   205      2018-02-22 18:28:46.908 UTC [main] main -> INFO 00e Exiting.....
   206      ```
   207  
   208  <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>.