fabric命令行
1,生成证书模板文件
cryptogen showtemplate > crypto-config.yaml
2,生成证书
cryptogen generate --config=crypto-config.yaml
configtxgen -profile SampleMultiNodeEtcdRaft -outputBlock ./channel-artifacts/genesis.block -channelID orderer-system-channel
3,创建通道文件
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel
4,锚节点更新文件
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP
5,启动相关容器
docker-compose -f docker-compose-order.yaml up -d
6,进入fabric命令行客户端容器
docker exec -it cli bash
7,通过通道文件创建通道
peer channel create -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/channel.tx
8,加入到通道
peer channel join -b mychannel.block
9,查看加入了哪些通道
peer channel list
10,打包链码 并生成打包文件
peer lifecycle chaincode package transaction.tar.gz --path
/opt/gopath/src/github.com/hyperledger/fabric/peer/chaincode/hua-ccode-transaction --lang java --label transaction16
11,在指定 peer节点上安装链码
peer lifecycle chaincode install transaction.tar.gz --peerAddresses peer0.org1.example.com:7051
12,查询指定 peer节点上已经安装的链码
peer lifecycle chaincode queryinstalled --peerAddresses peer0.org1.example.com:7051
13,从节点上提取已经安装的链码包
peer lifecycle chaincode getinstalledpackage \ --package-id myccv1:a7ca45a7cc85f1d89c905b775920361ed089a364e12a9b6d55ba75c965ddd6a9 \ --output-directory /tmp --peerAddresses peer0.org1.example.com:7051
14,审批链码
peer lifecycle chaincode approveformyorg -o orderer.example.com:7050 --channelID mychannel --name transaction --version 0.0.1
--package-id transaction16:4969cec03b070b6f85e541ceaeb2348bfa281473b73060dd034e2c11942d3a2c --sequence 16
15,检查指定的链码是否可以向通道提交
peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name transaction --version 0.0.1 --sequence 1 --output json
16,指定通道提交链码定义
peer lifecycle chaincode commit -o orderer.example.com:7050 --channelID mychannel --name transaction --version 0.0.1 --sequence 16
17,查询指定通道上已经提交的链码
peer lifecycle chaincode querycommitted --channelID mychannel --name transaction --peerAddresses peer0.org1.example.com:7051
peer lifecycle chaincode package transaction.tar.gz --path /opt/gopath/src/github.com/hyperledger/fabric/peer/chaincode/hua-ccode-transaction --lang java --label transaction18 peer lifecycle chaincode install transaction.tar.gz peer lifecycle chaincode approveformyorg -o orderer.example.com:7050 --channelID mychannel --name transaction --version 0.0.1 --package-id transaction18:4b10dc2e641dfa47d8b06fd4e51299952712f54d3e9b91627be6b4355e1b6ac4 --sequence 17 peer lifecycle chaincode commit -o orderer.example.com:7050 --channelID mychannel --name transaction --version 0.0.1 --sequence 17