Fabric CLI is a command-line interface built using Fabric SDK GO. It provides the following functionality:
Channel:
- Create - Create a channel
- Join - Join a peer to a channel
Query:
- Info - Displays information about the block, including the block height
- Block - Displays the contents of a given block
- Tx - Displays the contents of a transaction within a block
- Channels - Displays all channels for a peer
- Installed - Displays the chaincodes installed on a peer
Chaincode:
- Install - Installs chaincode
- Instantiate - Instantiates chaincode
- Invoke - Invokes chaincode with a transaction proposal and a commit
- Query - Invokes chaincode without a commit
- Info - Retrieves details about the chaincode
Events:
- Listen Block - Listens for block events and displays the block when a new block is created
- Listen TX - Listens for transaction events
- Listen CC - Listens for chaincode events for a specified chaincode
Navigate to folder fabcli:
$ fabcli [options]
To display the available commands/options:
$ fabcli
This example is compatible with the following Hyperledger Fabric commit levels:
- fabric: v1.0.0
- fabric-ca: v1.0.0
$ fabcli channel create --cid mychannel --txfile fixtures/channel/mychannel.tx --config fixtures/config/config_test.yaml
$ fabcli channel join --cid mychannel --peer localhost:7051
$ fabcli channel join --cid mychannel --orgid org1
$ fabcli channel join --cid mychannel
$ fabcli query info --cid mychannel
$ fabcli query block --cid mychannel --num 0
$ fabcli query block --cid mychannel --hash MKUvwa85E7OvITqBZYmf8yn9QIS5eZkal2xLTleK2AA
$ fabcli query block --cid mychannel --num 0 --format json
$ fabcli query tx --cid mychannel --txid 29bd4fd03e657da488acfa8ae1740eebf4a6ee81399bfc501f192cb407d2328c
$ fabcli query channels --peer localhost:7051
$ fabcli query installed --peer localhost:7051
$ fabcli chaincode install --cid=mychannel --peer localhost:7051 --ccp=github.com/user/somecc --ccid=somecc --v v0
$ fabcli chaincode install --cid=mychannel --orgid org1 --ccp=github.com/user/somecc --ccid=somecc --v v0
$ fabcli chaincode install --cid=mychannel --ccp=github.com/user/somecc --ccid=somecc --v v0
$ fabcli chaincode instantiate --cid mychannel --ccp github.com/user/somecc --ccid somecc --v v0 --args='{"Args":["arg1","arg2"]}'
$ fabcli chaincode instantiate --cid mychannel --ccp github.com/user/somecc --ccid somecc --v v0 --args='{"Args":["arg1","arg2"]}' --policy "AND('Org1MSP.member','Org2MSP.member')"
$ fabcli chaincode info --cid mychannel --ccid somecc
$ fabcli chaincode query --ccid=somecc --args='{"Func":"query","Args":["a"]}' --peer localhost:7051,localhost:8051
$ fabcli chaincode invoke --ccid=somecc --args='{"Func":"add","Args":["a","1","11"]}'
$ fabcli chaincode invoke --ccid=somecc --args='{"Func":"add","Args":["a","1","11"]}' --orgid org1
$ fabcli chaincode invoke --ccid=somecc --args='{"Func":"add","Args":["a","1","11"]}' --iterations 5
$ fabcli event listenblock --format json
$ fabcli event listencc --ccid=somecc --event=someevent