forked from donatedTunic1290/certification-network
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCLI Commands
109 lines (99 loc) · 7.17 KB
/
CLI Commands
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Network Setup
1. Pre-setup
a. Generate Crypto Materials
>> cryptogen generate --config=./crypto-config.yaml
b. Generate Channel Artifacts
>> configtxgen -profile OrdererGenesis -channelID upgrad-sys-channel -outputBlock ./channel-artifacts/genesis.block
>> configtxgen -profile CertificationChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID certificationchannel
>> configtxgen -profile CertificationChannel -outputAnchorPeersUpdate ./channel-artifacts/iitMSPanchors.tx -channelID certificationchannel -asOrg iitMSP
>> configtxgen -profile CertificationChannel -outputAnchorPeersUpdate ./channel-artifacts/mhrdMSPanchors.tx -channelID certificationchannel -asOrg mhrdMSP
>> configtxgen -profile CertificationChannel -outputAnchorPeersUpdate ./channel-artifacts/upgradMSPanchors.tx -channelID certificationchannel -asOrg upgradMSP
2. Docker Network Setup
a. Start Docker Network
>> docker-compose -f ./docker-compose.yml up -d
3. Fabric Network Setup
a. SSH Into CLI Container
>> docker exec -it cli /bin/bash
b. Create Channel
>> CORE_PEER_LOCALMSPID="iitMSP"
>> CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/iit.certification-network.com/users/[email protected]/msp
>> CORE_PEER_ADDRESS=peer0.iit.certification-network.com:7051
>> peer channel create -o orderer.certification-network.com:7050 -c certificationchannel -f ./channel-artifacts/channel.tx
c. Join Peer 0 - IIT
>> peer channel join -b certificationchannel.block
d. Join Peer 1 - IIT
>> CORE_PEER_ADDRESS=peer1.iit.certification-network.com:8051
>> peer channel join -b certificationchannel.block
e. Join Peer 0 - MHRD
>> CORE_PEER_LOCALMSPID="mhrdMSP"
>> CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/mhrd.certification-network.com/users/[email protected]/msp
>> CORE_PEER_ADDRESS=peer0.mhrd.certification-network.com:9051
>> peer channel join -b certificationchannel.block
f. Join Peer 1 - MHRD
>> CORE_PEER_ADDRESS=peer1.mhrd.certification-network.com:10051
>> peer channel join -b certificationchannel.block
g. Join Peer 0 - UPGRAD
>> CORE_PEER_LOCALMSPID="upgradMSP"
>> CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/upgrad.certification-network.com/users/[email protected]/msp
>> CORE_PEER_ADDRESS=peer0.upgrad.certification-network.com:11051
>> peer channel join -b certificationchannel.block
h. Join Peer 1 - UPGRAD
>> CORE_PEER_ADDRESS=peer1.upgrad.certification-network.com:12051
>> peer channel join -b certificationchannel.block
i. Update Anchor Peer for IIT
>> CORE_PEER_LOCALMSPID="iitMSP"
>> CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/iit.certification-network.com/users/[email protected]/msp
>> CORE_PEER_ADDRESS=peer0.iit.certification-network.com:7051
>> peer channel update -o orderer.certification-network.com:7050 -c certificationchannel -f ./channel-artifacts/iitMSPanchors.tx
j. Update Anchor Peer for MHRD
>> CORE_PEER_LOCALMSPID="mhrdMSP"
>> CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/mhrd.certification-network.com/users/[email protected]/msp
>> CORE_PEER_ADDRESS=peer0.mhrd.certification-network.com:9051
>> peer channel update -o orderer.certification-network.com:7050 -c certificationchannel -f ./channel-artifacts/mhrdMSPanchors.tx
k. Update Anchor Peer for UPGRAD
>> CORE_PEER_LOCALMSPID="upgradMSP"
>> CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/upgrad.certification-network.com/users/[email protected]/msp
>> CORE_PEER_ADDRESS=peer0.upgrad.certification-network.com:11051
>> peer channel update -o orderer.certification-network.com:7050 -c certificationchannel -f ./channel-artifacts/upgradMSPanchors.tx
# Install & Instantiate Chaincode
1. Run Chaincode in Dev Mode
a. SSH Into Chaincode Container
>> docker exec -it chaincode /bin/bash
b. Run Chaincode Node App In Dev Mode
>> npm run start-dev
2. Install Chaincode
a. SSH Into CLI Container
>> docker exec -it cli /bin/bash
b. Install Chaincode on Peer 0 - IIT
>> CORE_PEER_LOCALMSPID="iitMSP"
>> CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/iit.certification-network.com/users/[email protected]/msp
>> CORE_PEER_ADDRESS=peer0.iit.certification-network.com:7051
>> peer chaincode install -n certnet -v 1.1 -l node -p /opt/gopath/src/github.com/hyperledger/fabric/peer/chaincode/
c. Install Chaincode on Peer 0 - MHRD
>> CORE_PEER_LOCALMSPID="mhrdMSP"
>> CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/mhrd.certification-network.com/users/[email protected]/msp
>> CORE_PEER_ADDRESS=peer0.mhrd.certification-network.com:9051
>> peer chaincode install -n certnet -v 1.1 -l node -p /opt/gopath/src/github.com/hyperledger/fabric/peer/chaincode/
d. Install Chaincode on Peer 0 - UPGRAD
>> CORE_PEER_LOCALMSPID="upgradMSP"
>> CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/upgrad.certification-network.com/users/[email protected]/msp
>> CORE_PEER_ADDRESS=peer0.upgrad.certification-network.com:11051
>> peer chaincode install -n certnet -v 1.1 -l node -p /opt/gopath/src/github.com/hyperledger/fabric/peer/chaincode/
3. Instantiate Chaincode
a. SSH Into CLI Container
>> docker exec -it cli /bin/bash
b. Instantiate Chaincode on Channel Using Peer 0 - IIT
>> CORE_PEER_LOCALMSPID="iitMSP"
>> CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/iit.certification-network.com/users/[email protected]/msp
>> CORE_PEER_ADDRESS=peer0.iit.certification-network.com:7051
>> peer chaincode instantiate -o orderer.certification-network.com:7050 -C certificationchannel -n certnet -l node -v 1.1 -c '{"Args":["org.certification-network.certnet:instantiate"]}' -P "OR ('iitMSP.member','mhrdMSP.member','upgradMSP.member')"
4. View Container Logs
a. Start Peer 0 - IIT Container Logs
>> docker logs -f peer0.iit.certification-network.com
5. Test Chaincode
a. SSH Into Peer 0 - IIT
>> docker exec -it peer0.iit.certification-network.com /bin/bash
b. Invoke Create Student Function
>> peer chaincode invoke -o orderer.certification-network.com:7050 -C certificationchannel -n certnet -c '{"Args":["org.certification-network.certnet:createStudent","0001","Aakash Bansal","[email protected]"]}'
c. Invoke Get Student Function
>> peer chaincode invoke -o orderer.certification-network.com:7050 -C certificationchannel -n certnet -c '{"Args":["org.certification-network.certnet:getStudent","0001"]}'