本文依赖于上一篇文章创建通道,基于前面的步骤执行安装及部署步骤。
目录
前提条件
启动测试网络
创建通道
链码安装及部署
模拟参数
设置环境变量
智能合约源码安装依赖(GO语言版本)
打包链码
安装链码
在组织1中peer节点安装链码
在组织2中peer节点安装链码
查询组织2中peer节点安装链码的链码包ID
批准智能合约
组织1身份批准智能合约
组织2身份批准智能合约
将链码提交至通道
查询提交的链码
查询组织1提交的链码
查询组织2提交的链码
前提条件
启动测试网络
[root@localhost test-network-myself]# ./network-myself.sh up
创建通道
[root@localhost test-network-myself]# ./network-myself.sh createChannel
链码安装及部署
模拟参数
[root@localhost test-network-myself]# export CHANNEL_NAME="mychannel"
[root@localhost test-network-myself]# export CC_NAME=basic
[root@localhost test-network-myself]# export CC_SRC_PATH=../asset-transfer-basic/chaincode-go
[root@localhost test-network-myself]# export CC_SRC_LANGUAGE=go
[root@localhost test-network-myself]# export CC_VERSION="1.0"
[root@localhost test-network-myself]# export CC_SEQUENCE="1"
[root@localhost test-network-myself]# export CC_INIT_FCN=""
[root@localhost test-network-myself]# export CC_END_POLICY=""
[root@localhost test-network-myself]# export CC_COLL_ConFIG=""
[root@localhost test-network-myself]# export DELAY="3"
[root@localhost test-network-myself]# export MAX_RETRY="5"
[root@localhost test-network-myself]# export VERBOSE="false"
[root@localhost test-network-myself]# export INIT_REQUIRED=""
[root@localhost test-network-myself]# export CC_RUNTIME_LANGUAGE=golang
设置环境变量
[root@localhost test-network-myself]# export FABRIC_CFG_PATH=$PWD/../config/
[root@localhost test-network-myself]# export CORE_PEER_TLS_ENABLED=true
[root@localhost test-network-myself]# export ORDERER_CA=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
[root@localhost test-network-myself]# export PEER0_ORG1_CA=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
[root@localhost test-network-myself]# export PEER0_ORG2_CA=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
[root@localhost test-network-myself]# export PEER0_ORG3_CA=${PWD}/organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt
[root@localhost test-network-myself]# export ORDERER_ADMIN_TLS_SIGN_CERT=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt
[root@localhost test-network-myself]# export ORDERER_ADMIN_TLS_PRIVATE_KEY=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.key
智能合约源码安装依赖(GO语言版本)
[root@localhost test-network-myself]# cd $CC_SRC_PATH
[root@localhost chaincode-go]# GO111MODULE=on go mod vendor
[root@localhost chaincode-go]# cd ../../test-network-myself
[root@localhost test-network-myself]# ./network-myself.sh up
创建通道
[root@localhost test-network-myself]# ./network-myself.sh createChannel
链码安装及部署
模拟参数
[root@localhost test-network-myself]# export CHANNEL_NAME="mychannel"
[root@localhost test-network-myself]# export CC_NAME=basic
[root@localhost test-network-myself]# export CC_SRC_PATH=../asset-transfer-basic/chaincode-go
[root@localhost test-network-myself]# export CC_SRC_LANGUAGE=go
[root@localhost test-network-myself]# export CC_VERSION="1.0"
[root@localhost test-network-myself]# export CC_SEQUENCE="1"
[root@localhost test-network-myself]# export CC_INIT_FCN=""
[root@localhost test-network-myself]# export CC_END_POLICY=""
[root@localhost test-network-myself]# export CC_COLL_ConFIG=""
[root@localhost test-network-myself]# export DELAY="3"
[root@localhost test-network-myself]# export MAX_RETRY="5"
[root@localhost test-network-myself]# export VERBOSE="false"
[root@localhost test-network-myself]# export INIT_REQUIRED=""
[root@localhost test-network-myself]# export CC_RUNTIME_LANGUAGE=golang
设置环境变量
[root@localhost test-network-myself]# export FABRIC_CFG_PATH=$PWD/../config/
[root@localhost test-network-myself]# export CORE_PEER_TLS_ENABLED=true
[root@localhost test-network-myself]# export ORDERER_CA=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
[root@localhost test-network-myself]# export PEER0_ORG1_CA=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
[root@localhost test-network-myself]# export PEER0_ORG2_CA=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
[root@localhost test-network-myself]# export PEER0_ORG3_CA=${PWD}/organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt
[root@localhost test-network-myself]# export ORDERER_ADMIN_TLS_SIGN_CERT=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt
[root@localhost test-network-myself]# export ORDERER_ADMIN_TLS_PRIVATE_KEY=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.key
智能合约源码安装依赖(GO语言版本)
[root@localhost test-network-myself]# cd $CC_SRC_PATH
[root@localhost chaincode-go]# GO111MODULE=on go mod vendor
[root@localhost chaincode-go]# cd ../../test-network-myself
模拟参数
[root@localhost test-network-myself]# export CHANNEL_NAME="mychannel"
[root@localhost test-network-myself]# export CC_NAME=basic
[root@localhost test-network-myself]# export CC_SRC_PATH=../asset-transfer-basic/chaincode-go
[root@localhost test-network-myself]# export CC_SRC_LANGUAGE=go
[root@localhost test-network-myself]# export CC_VERSION="1.0"
[root@localhost test-network-myself]# export CC_SEQUENCE="1"
[root@localhost test-network-myself]# export CC_INIT_FCN=""
[root@localhost test-network-myself]# export CC_END_POLICY=""
[root@localhost test-network-myself]# export CC_COLL_ConFIG=""
[root@localhost test-network-myself]# export DELAY="3"
[root@localhost test-network-myself]# export MAX_RETRY="5"
[root@localhost test-network-myself]# export VERBOSE="false"
[root@localhost test-network-myself]# export INIT_REQUIRED=""
[root@localhost test-network-myself]# export CC_RUNTIME_LANGUAGE=golang
设置环境变量
[root@localhost test-network-myself]# export FABRIC_CFG_PATH=$PWD/../config/
[root@localhost test-network-myself]# export CORE_PEER_TLS_ENABLED=true
[root@localhost test-network-myself]# export ORDERER_CA=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
[root@localhost test-network-myself]# export PEER0_ORG1_CA=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
[root@localhost test-network-myself]# export PEER0_ORG2_CA=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
[root@localhost test-network-myself]# export PEER0_ORG3_CA=${PWD}/organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt
[root@localhost test-network-myself]# export ORDERER_ADMIN_TLS_SIGN_CERT=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt
[root@localhost test-network-myself]# export ORDERER_ADMIN_TLS_PRIVATE_KEY=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.key
智能合约源码安装依赖(GO语言版本)
[root@localhost test-network-myself]# cd $CC_SRC_PATH
[root@localhost chaincode-go]# GO111MODULE=on go mod vendor
[root@localhost chaincode-go]# cd ../../test-network-myself
[root@localhost test-network-myself]# export FABRIC_CFG_PATH=$PWD/../config/
[root@localhost test-network-myself]# export CORE_PEER_TLS_ENABLED=true
[root@localhost test-network-myself]# export ORDERER_CA=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
[root@localhost test-network-myself]# export PEER0_ORG1_CA=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
[root@localhost test-network-myself]# export PEER0_ORG2_CA=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
[root@localhost test-network-myself]# export PEER0_ORG3_CA=${PWD}/organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt
[root@localhost test-network-myself]# export ORDERER_ADMIN_TLS_SIGN_CERT=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt
[root@localhost test-network-myself]# export ORDERER_ADMIN_TLS_PRIVATE_KEY=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.key
智能合约源码安装依赖(GO语言版本)
[root@localhost test-network-myself]# cd $CC_SRC_PATH
[root@localhost chaincode-go]# GO111MODULE=on go mod vendor
[root@localhost chaincode-go]# cd ../../test-network-myself
安装依赖后将出现vendor目录 ,如下图:
打包链码
[root@localhost test-network-myself]# peer lifecycle chaincode package ${CC_NAME}.tar.gz --path ${CC_SRC_PATH} --lang ${CC_RUNTIME_LANGUAGE} --label ${CC_NAME}_${CC_VERSION}
打包完成将生成打包文件,如下图:


