hyperledger-fabric2.0 相关命令

目录

fabrci-docker清除环境

生成所需的证书文件,执行完成之后会在当前目录下产生crypto-config文件

根据configtx.yaml 生成创世区块和频道认证文件

生成Orderer服务启动的初始区块(即系统通道的创世区块文件) genesis.block

生成新建应用通道的配置交易(即用于创建应用通道的配置交易文件) channel.tx

生成org1锚节点配置更新文件  Org1MSPanchors.tx

生成org2锚节点配置更新文件 Org2MSPanchors.tx

//同步指定节点(提取指定区块并写入文件)

//创建通道(生成了加入通道所需要的mychannel.block)

//加入通道

//update anchor peers

//打包合约

//安装合约到节点

//验证合约是否安装到节点

//当前组织同意合约定义

//检查合约定义是否满足策略

//提交合约

//查看节点已提交合约

//初始化合约,执行init方法,设置a:100 b:100

//查询a的余额

//做一笔交易,a账户向b账户转移10个知产

//查看区块信息


fabrci-docker清除环境

./byfn.sh down

docker-compose -f docker-compose-cli.yaml down --volumes --remove-orphans

docker volume prune

生成所需的证书文件,执行完成之后会在当前目录下产生crypto-config文件

cryptogen generate --config=./crypto-config.yaml

根据configtx.yaml 生成创世区块和频道认证文件

生成Orderer服务启动的初始区块(即系统通道的创世区块文件) genesis.block

configtxgen -profile SampleMultiNodeEtcdRaft -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block

生成新建应用通道的配置交易(即用于创建应用通道的配置交易文件) channel.tx

configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel

生成org1锚节点配置更新文件  Org1MSPanchors.tx

configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP

生成org2锚节点配置更新文件 Org2MSPanchors.tx

configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP

//同步指定节点(提取指定区块并写入文件)

peer channel fetch 0 mychannel.block -o orderer.example.com:7050 -c mychannel --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem

//创建通道(生成了加入通道所需要的mychannel.block)

peer channel create -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/channel.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem

//加入通道

peer channel join -b mychannel.block

//update anchor peers

peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org1MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem

//打包合约

peer lifecycle chaincode package mycc.tar.gz --path github.com/hyperledger/fabric-samples/chaincode/abstore/go/ --lang golang --label mycc_1

//安装合约到节点

peer lifecycle chaincode install mycc.tar.gz

//验证合约是否安装到节点

peer lifecycle chaincode queryinstalled

//当前组织审批合约 //谁代表组织?里面的机制是什么 需要研究审批的流程是什么

peer lifecycle chaincode approveformyorg --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name mycc --version 1 --init-required --package-id mycc_1:4622fb602aa60c6368716a70474dc9d9ba2776200f70eccca07a4df4360eaff3 --sequence 1 —waitForEvent

//检查合约定义是否满足策略#检查指定的链码是否可以向通道提交 (不同合约进来之后也可以满足策略?)

peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name mycc --version 1 --sequence 2 --output json --init-required

//提交合约(是不是有可能有两个合约在跑,修改同一份数据??)

peer lifecycle chaincode commit -o orderer.example.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name mycc --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt --version 1 --sequence 1 --init-required

//查看节点已提交合约

peer lifecycle chaincode querycommitted --channelID mychannel --name mycc

//初始化合约,执行init方法,设置a:100 b:100

peer chaincode invoke -o orderer.example.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n mycc --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt --isInit -c '{"Args":["Init","a","100","b","100"]}'

//查询a的余额

peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'

//做一笔交易,a账户向b账户转移10个知产(chaincode 代码(a b 账目转移逻辑修改后测试一下)

peer chaincode invoke -o orderer.example.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n mycc --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c '{"Args":["invoke","a","b","10"]}'

//查看区块信息 cli客户端的权限??

peer channel getinfo -c mychannel

org==》channel==》chaincode的相互关系

用户的权限和身份认证的流程

发布了21 篇原创文章 · 获赞 10 · 访问量 5492

猜你喜欢

转载自blog.csdn.net/tank_ft/article/details/105254813