Hyperledger Fabric Deploy
中文教程
Supported features
- channel create
- channel updateAnchorPeer
- channel join
- channel update (Update BatchTimeout, BatchSize)
- chaincode install
- chaincode instantiate
- chaincode upgrade
- chaincode invoke
- chaincode query
- organization join (Add organization dynamically, supported system channel)
- organization delete (Delete organization dynamically, supported system channel)
- organization update (Dynamically modify organization certificate, supported system channel)
- channel consensus (Switch consensus algorithm, supported solo, kafka, etcdraft)
Launch test network
git clone https://github.com/yakumioto/hlf-deploy.git && \
cd hlf-deploy/test-network && \
./hlfn.sh up
The demo includes the following steps.
- Create network
- Create channel
- Update anchor peer
- Join channel
- Install go chaincode
- Instantiate go chaincode
- Query go chaincode
- Invoke go chaincode
- Add Org3 to mychannel
- Modify Org3's certificate
- Remove Org3 from mychannel
- Upgrade from solo consensus to etcdraft consensus
- Invoke and query chaincode to ensure that the consensus upgrade is successful
- Install java chaincode
- Upgrade java chaincode
- Invoke java chaincode
- Query java chaincode
Here is an example of the output
Remove test network
./hlfn.sh down
Deploying the network manually
First download the hlf-deploy
binary and yakumioto/hlf-tools:latest
mirror
curl -L -o ../bin/hlf-deploy https://github.com/yakumioto/hlf-deploy/releases/download/v0.1.0/hlf-deploy
docker pull yakumioto/hlf-tools:latest
Start network
Go to the test-network directory
docker-compose up -d
Create Channel
../bin/hlf-deploy channel create --configFile config.yaml \
--channelTxFile channel-artifacts/channel.tx \
--channelName mychannel \
--ordererOrgName OrdererOrg \
Org1 Org2
Update Anchor Peer
../bin/hlf-deploy channel updateAnchorPeer --configFile config.yaml \
--anchorPeerTxFile channel-artifacts/Org1MSPanchors.tx \
--channelName mychannel \
--ordererOrgName OrdererOrg \
Org1
../bin/hlf-deploy channel updateAnchorPeer --configFile config.yaml \
--anchorPeerTxFile channel-artifacts/Org2MSPanchors.tx \
--channelName mychannel \
--ordererOrgName OrdererOrg \
Org2
Join Channel
../bin/hlf-deploy channel join --configFile config.yaml \
--channelName mychannel \
Org1 Org2
Install Chaincode
../bin/hlf-deploy chaincode install --configFile config.yaml \
--goPath chaincode \
--chaincodePath example_02 \
--chaincodeName mycc \
--chaincodeVersion v1.0 \
Org1 Org2
Instantiate Chaincode
chaincodePolicy
: Set which organization signatures are required (currently only members are supported)
chaincodePolicyNOutOf
: Set how many organization endorsement signatures are checked to return true
../bin/hlf-deploy chaincode instantiate --configFile config.yaml \
--channelName mychannel \
--orgName Org1 \
--chaincodePolicy Org1MSP,Org2MSP \
--chaincodePolicyNOutOf 2 \
--chaincodePath example_02 \
--chaincodeName mycc \
--chaincodeVersion v1.0 \
a 100 b 200
Update Chaincode
hlf-deploy chaincode upgrade --configFile config.yaml \
--channelName mychannel \
--orgName Org1 \
--chaincodePolicy Org1MSP,Org2MSP \
--chaincodePolicyNOutOf 2 \
--chaincodePath example_02 \
--chaincodeName mycc \
--chaincodeVersion v2.0 \
a 100 b 200
Query Chaincode
../bin/hlf-deploy chaincode query --configFile config.yaml \
--channelName mychannel \
--orgName Org1 \
--chaincodeName mycc \
query a
../bin/hlf-deploy chaincode query --configFile config.yaml \
--channelName mychannel \
--orgName Org1 \
--chaincodeName mycc \
query b
Invoke Chaincode
../bin/hlf-deploy chaincode invoke --configFile config.yaml \
--channelName mychannel \
--orgName Org1 \
--endorsementOrgsName Org1,Org2 \
--chaincodeName mycc \
invoke a b 50
Add Org3 organization dynamically
../bin/hlf-deploy organization join --configFile config.yaml \
--channelName mychannel \
--ordererOrgName OrdererOrg \
--orgConfig channel-artifacts/org3.json \
--orgName Org3MSP \
--rpcAddress localhost:1234 \
Org1 Org2
Update Org3 organization dynamically
../bin/hlf-deploy organization update --configFile config.yaml \
--channelName mychannel \
--ordererOrgName OrdererOrg \
--orgConfig channel-artifacts/modify-org3.json \
--orgName Org3MSP \
--rpcAddress localhost:1234 \
Org3
Delete Org3 organization dynamically
../bin/hlf-deploy organization delete --configFile config.yaml \
--channelName mychannel \
--ordererOrgName OrdererOrg \
--orgName Org3MSP \
--rpcAddress localhost:1234 \
Org1 Org2