微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

【教程】如何启动fabric的联盟链?起链十二步解读

不要怕很难只要你肯坚持

第一步

crytogen 组件,为每一个组织生成MSP 所需要的证书与密钥,它与crypto-config.yaml文件

套使用,会在当前目录下自动生成crypto-config目录,里边存放了所有的证书与密钥,为MSP 提供服务;

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

第二步

configtxgen 组件,用于生成通道创世区块或通道交易的配置文件,需要与configtx.yaml文件配套使用。

configtxgen -profile TwoOrgsOrdererGenesis -channelID syschannel -outputBlock ./channel-artifacts/genesis.block

第三步

configtxgen 组件,用于生成通道创世区块或通道交易的配置文件,需要与configtx.yaml文件配套使用。

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

第四步

configtxgen 组件,用于生成通道创世区块或通道交易的配置文件,需要与configtx.yaml文件配套使用。

configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate \

./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP

这里的Org1随时更改为其他的

第五步

使用docker-compose 组件,根据docker-compose-cli.yaml 文件批量启动docker容器;

docker-compose -f docker-compose-cli.yaml up -d

第六步

peer 组件,可用于创建通道、节点加入、链码安装、链码实例化、链码交互等操作;

peer channel create -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/channel.tx

第七步

将peer加入通道

peer channel join -b mychannel.block

export CORE_PEER_ADDRESS=peer1.org1.example.com:7051

peer channel join -b mychannel.block

第八步

更新锚节点

peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx

第九步

安装链码到各节点

peer chaincode install -n mycc -v ${VERSION} -l ${LANGUAGE} -p

${CC_SRC_PATH}

第十步

实例化链码

peer chaincode instantiate -o orderer.example.com:7050 -C mychannel -n

mycc -l golang -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "AND

('Org1MSP.peer','Org2MSP.peer')"

第十一步

链码查询

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

第十二步

链码交易

peer chaincode invoke -o orderer.example.com:7050 -C mychannel -n mycc --peerAddresses peer0.Org1.example.com:7051 --peerAddressespeer0.Org2.example.com:7051 \

-c '{"Args":["invoke","a","b","10"]}'

原文地址:https://www.jb51.cc/wenti/3287185.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐