# 环境 centos7 并需要docker、docker-compose、go、git
# fabric版本2.2
# 下载相关代码和测试示例地址如下:
https://download.csdn.net/download/loehuang/46720939
# 包含fabric-binaries.tar.gz fabric-samples.tar.gz fabric.tar.gz
# 开始安装fabric
# 创建文件夹
mkdir -p /root/go/src/github.com/hyperledger/
# 拷贝fabric.tar.gz 到 /root/go/src/github.com/hyperledger/
cp ./fabric-download/fabric.tar.gz /root/go/src/github.com/hyperledger/
tar -zxvf fabric.tar.gz
# 将fabric工程切换到2.2分支
cd fabric
git checkout -b relase-2.2 remotes/origin/release-2.2
# 安装fabric-samples.tar.gz
# 将fabric-samples.tar.gz 放到fabric/scripts 文件夹下并解压
tar -zxvf fabric-samples.tar.gz
# 切换samples分支到2.2版本
cd fabric-samples
git checkout -b relase-2.2 remotes/origin/release-2.2
# 安装fabric-binaries.tar.gz
# 将fabric-binaries.tar.gz 放到/fabric/scripts/fabric-samples
# 解压fabric-binaries.tar.gz 得到bin和config文件夹
# 执行安装bootstrap.sh, 需要修改去掉下载sample和binaries过程
# 编辑并且设置AMPLES=false,BINARIES=false
vim bootstrap.sh
# 执行bootstrap.sh 下载docker镜像文件
/root/go/src/github.com/hyperledger/fabric/scripts/bootstrap.sh
# 修改path
export FABRIC_PATH=/root/go/src/github.com/hyperledger/fabric/scripts/fabric-samples
export PATH=$FABRIC_PATH/bin:$PATH
export FABRIC_CFG_PATH=$FABRIC_PATH/config/
# 启动测试环境网络,在 test-network下执行
./network up
./network.sh createChannel
# 部署测试智能合约
./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go
# 执行调用 InitLedger
peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n basic--peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"function":"InitLedger","Args":[]}'
# 调用GetAllAssets
peer chaincode query -C mychannel -n basic -c '{"Args":["GetAllAssets"]}'
# 参考网站
https://hyperledger-fabric.readthedocs.io/en/latest/developapps/smartcontract.html
https://blog.csdn.net/qq_43681877/article/details/107399250
https://blog.csdn.net/shengsikandan/article/details/107656060
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)