@@ -11,6 +11,8 @@ of the box” - with one exception: we create two channels instead of
11
11
using the default ``testchainid `` channel to show how the single running
12
12
instance can be accessed from multiple channels.
13
13
14
+ All commands are executed from the ``fabric `` folder.
15
+
14
16
Start the orderer
15
17
-----------------
16
18
@@ -34,10 +36,18 @@ MSP. The ``--peer-chaincodedev=true`` puts it in “dev” mode.
34
36
Create channels ch1 and ch2
35
37
---------------------------
36
38
39
+ Generate the transactions for creating the channels using ``configtxgen `` tool.
40
+
41
+ ::
42
+ configtxgen -channelID ch1 -outputCreateChannelTx ch1.tx -profile SampleSingleMSPChannel
43
+ configtxgen -channelID ch2 -outputCreateChannelTx ch2.tx -profile SampleSingleMSPChannel
44
+
45
+ where SampleSingleMSPChannel is a channel profile in ``sampleconfig/configtx.yaml ``
46
+
37
47
::
38
48
39
- peer channel create -o 127.0.0.1:7050 -c ch1
40
- peer channel create -o 127.0.0.1:7050 -c ch2
49
+ peer channel create -o 127.0.0.1:7050 -c ch1 -f ch1.tx
50
+ peer channel create -o 127.0.0.1:7050 -c ch2 -f ch2.tx
41
51
42
52
Above assumes orderer is reachable on ``127.0.0.1:7050 ``. The orderer
43
53
now is tracking channels ch1 and ch2 for the default configuration.
@@ -58,12 +68,23 @@ Start the chaincode
58
68
go build
59
69
CORE_CHAINCODE_LOGLEVEL=debug CORE_PEER_ADDRESS=127.0.0.1:7051 CORE_CHAINCODE_ID_NAME=mycc:0 ./chaincode_example02
60
70
61
- The chaincode is started with peer and chaincode logs showing it got
62
- registered successfully with the peer.
71
+ The chaincode is started with peer and chaincode logs indicating successful registration with the peer.
72
+ Note that at this stage the chaincode is not associated with any channel. This is done in subsequent steps
73
+ using the ``instantiate `` command.
63
74
64
75
Use the chaincode
65
76
-----------------
66
77
78
+ Even though you are in ``--peer-chaincodedev `` mode, you still have to install the chaincode so the life-cycle system
79
+ chaincode can go through its checks normally. This requirement may be removed in future when in ``--peer-chaincodedev ``
80
+ mode.
81
+
82
+ ::
83
+
84
+ peer chaincode install -n mycc -v 0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
85
+
86
+ Once installed, the chaincode is ready to be instantiated.
87
+
67
88
::
68
89
69
90
peer chaincode instantiate -n mycc -v 0 -c '{"Args":["init","a","100","b","200"]}' -o 127.0.0.1:7050 -C ch1
@@ -81,6 +102,8 @@ committed.
81
102
82
103
The above invoke the chaincode over the two channels.
83
104
105
+ Finally, query the chaincode on the two channels.
106
+
84
107
::
85
108
86
109
peer chaincode query -n mycc -c '{"Args":["query","a"]}' -o 127.0.0.1:7050 -C ch1
0 commit comments