## 1. 釋義
查詢指定節點上已經安裝的鏈碼,或者查詢指定通道中實例化的鏈碼。
## 2. 使用方法
```
~$ peer chaincode list [flags]
```
## 3. 命令標志
```
-C, --channelID string The channel on which this command should be executed
--connectionProfile string Connection profile that provides the necessary connection information for the network. Note: currently only supported for providing peer connection information
-h, --help help for list
--installed Get the installed chaincodes on a peer
--instantiated Get the instantiated chaincodes on a channel
--peerAddresses stringArray The addresses of the peers to connect to
--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
```
全局標志:
```
--cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint
--certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint
--clientauth Use mutual TLS when communicating with the orderer endpoint
--connTimeout duration Timeout for client to connect (default 3s)
--keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint
-o, --orderer string Ordering service endpoint
--ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer.
--tls Use TLS when communicating with the orderer endpoint
--transient string Transient map of arguments in JSON encoding
```
## 4. 示例代碼
下面的示例代碼使用`--installed`標志列出在當前peer節點上安裝的鏈碼:
```
~$ peer chaincode list --installed
Get installed chaincodes on peer:
Name: mycc, Version: 1.0, Path: github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02, Id: 8cc2730fdafd0b28ef734eac12b29df5fc98ad98bdb1b7e0ef96265c3d893d61
2018-02-22 17:07:13.476 UTC [main] main -> INFO 001 Exiting.....
```
可以看到,節點已經安裝了名為mycc的鏈碼,其版本為1.0。
下面的示例使用`--instantiated`與`-C`(通道ID)的組合來列出指定通道上實例化的鏈碼:
```
~$ peer chaincode list --instantiated -C mychannel
Get instantiated chaincodes on channel mychannel:
Name: mycc, Version: 1.0, Path: github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02, Escc: escc, Vscc: vscc
2018-02-22 17:07:42.969 UTC [main] main -> INFO 001 Exiting.....
```
可以看到,版本為1.0的鏈碼mycc已經在通道mychannel上實例化了。
- Fabric命令手冊
- Peer命令
- peer
- peer node
- peer node start
- peer node status
- peer channel
- peer channel create
- peer channel fetch
- peer channel getinfo
- peer channel join
- peer channel list
- peer channel signconfigtx
- peer channel update
- peer chaincode
- peer chaincode install
- peer chaincode instantiate
- peer chaincode invoke
- peer chaincode list
- peer chaincode package
- peer chaincode query
- peer chaincode signpackage
- peer chaincode upgrade
- peer version
- peer logging
- peer logging getlevel
- peer logging revertlevels
- peer logging setlevel
- Configtxgen命令
- configtxgen
- Configtxlator命令
- configtxlator
- configtxlator start
- configtxlator proto_encode
- configtxlator proto_decode
- configtxlator compute_update
- configtxlator version
- Cryptogen命令
- cryptogen
- cryptogen help
- cryptogen generate
- cryptogen showtemplate
- FabricCA命令
- fabric-ca-client
- fabric-ca-server