@@ -9,7 +9,7 @@ through vagrant, make sure you have followed the steps outlined in
9
9
fabric directory within your vagrant environment, execute the ` make peer-docker `
10
10
and ` make orderer-docker ` commands.
11
11
12
- ### Start the network of 2 peers, an orderer, and a CLI
12
+ ### Start the network of 2 peers, an orderer, and a CLI container
13
13
Navigate to the fabric/docs directory in your vagrant environment and start your network:
14
14
``` bash
15
15
docker-compose -f docker-2peer.yml up
@@ -33,7 +33,7 @@ root@ccd3308afc73:/opt/gopath/src/github.com/hyperledger/fabric/peer#
33
33
### Create and join channel from the remote CLI
34
34
From your second terminal, lets create a channel by the name of "myc":
35
35
``` bash
36
- peer channel create -c myc
36
+ peer channel create -c myc -o orderer:5005
37
37
```
38
38
This will generate a genesis block - ` myc.block ` - and place it into the same directory
39
39
from which you issued your ` peer channel create ` command. Now, from the same directory,
@@ -48,43 +48,69 @@ CORE_PEER_ADDRESS=peer1:7051 peer channel join -b myc.block
48
48
From your second terminal, and still within the CLI container, issue the following
49
49
command to install a chaincode named ` mycc ` with a version of ` v0 ` onto ` peer0 ` .
50
50
``` bash
51
- CORE_PEER_ADDRESS=peer0:7051 peer chaincode install -n mycc -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -v v0
51
+ CORE_PEER_ADDRESS=peer0:7051 peer chaincode install \
52
+ -o orderer:5005 \
53
+ -n mycc \
54
+ -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 \
55
+ -v v0
52
56
```
53
57
54
58
### Instantiate the chaincode on the channel from the remote CLI
55
59
Now, still within the cli container in your second terminal, instantiate the chaincode
56
60
` mycc ` with version ` v0 ` onto ` peer0 ` . This instantiation will initialize the chaincode
57
61
with key value pairs of [ "a","100"] and [ "b","200"] .
58
62
``` bash
59
- CORE_PEER_ADDRESS=peer0:7051 peer chaincode instantiate -C myc -n mycc -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -v v0 -c ' {"Args":["init","a","100","b","200"]}'
63
+ CORE_PEER_ADDRESS=peer0:7051 peer chaincode instantiate \
64
+ -o orderer:5005 \
65
+ -C myc \
66
+ -n mycc \
67
+ -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 \
68
+ -c ' {"Args":["init","a","100","b","200"]}' \
69
+ -v v0
60
70
```
61
71
__ Continue operating within your second terminal for the remainder of the commands__
62
72
63
73
### Query for the value of "a" to make sure the chaincode container has successfully started
64
74
Send a query to ` peer0 ` for the value of key ` "a" ` :
65
75
``` bash
66
- CORE_PEER_ADDRESS=peer0:7051 peer chaincode query -C myc -n mycc -v v0 -c ' {"Args":["query","a"]}'
76
+ CORE_PEER_ADDRESS=peer0:7051 peer chaincode query \
77
+ -C myc \
78
+ -n mycc \
79
+ -c ' {"Args":["query","a"]}' \
80
+ -v v0
67
81
```
68
82
This query should return "100".
69
83
70
84
### Invoke to make a state change
71
85
Send an invoke request to ` peer0 ` to move 10 units from "a" to "b":
72
86
``` bash
73
- CORE_PEER_ADDRESS=peer0:7051 peer chaincode invoke -C myc -n mycc -v v0 -c ' {"Args":["invoke","a","b","10"]}'
87
+ CORE_PEER_ADDRESS=peer0:7051 peer chaincode invoke \
88
+ -C myc \
89
+ -n mycc \
90
+ -c ' {"Args":["invoke","a","b","10"]}' \
91
+ -v v0
74
92
```
75
93
76
94
### Query on the second peer
77
95
Issue a query against the key "a" to ` peer1 ` . Recall that ` peer1 ` has successfully
78
96
joined the channel.
79
97
``` bash
80
- CORE_PEER_ADDRESS=peer1:7051 peer chaincode query -C myc -n mycc -v v0 -c ' {"Args":["query","a"]}'
98
+ CORE_PEER_ADDRESS=peer1:7051 peer chaincode query \
99
+ -C myc \
100
+ -n mycc \
101
+ -c ' {"Args":["query","a"]}' \
102
+ -v v0
81
103
```
82
104
This will return an error response because ` peer1 ` does not have the chaincode installed.
83
105
84
106
### Install on the second peer
85
107
Now add the chaincode to ` peer1 ` so that you can successfully perform read/write operations.
86
108
``` bash
87
- CORE_PEER_ADDRESS=peer1:7051 peer chaincode install -n mycc -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -v v0
109
+ CORE_PEER_ADDRESS=peer1:7051 peer chaincode install \
110
+ -o orderer:5005 \
111
+ -n mycc \
112
+ -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 \
113
+ -v v0
88
114
```
89
115
__ Note__ : The initial instantiation applies to all peers in the channel, and is
90
116
affected upon any peer that has the chaincode installed. Therefore, we installed
@@ -97,7 +123,11 @@ chaincode must be installed on any peer receiving endorsement requests for that
97
123
### Query on the second peer
98
124
Now issue the same query request to ` peer1 ` .
99
125
``` bash
100
- CORE_PEER_ADDRESS=peer1:7051 peer chaincode query -C myc -n mycc -v v0 -c ' {"Args":["query","a"]}'
126
+ CORE_PEER_ADDRESS=peer1:7051 peer chaincode query \
127
+ -C myc \
128
+ -n mycc \
129
+ -c ' {"Args":["query","a"]}' \
130
+ -v v0
101
131
```
102
132
Query will now succeed.
103
133
0 commit comments