You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: samples/application/ccapi/README.md
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,11 +17,14 @@ The transaction client invocation process, as illustrated in the diagram, consis
17
17
18
18

19
19
20
-
21
20
## User Experience
22
21
23
-
CCAPI is using docker and docker-compose for spinning up all the required components needed to work.
22
+
CCAPI is using docker and docker-compose for spinning up all the required components needed to work.
24
23
25
24
Have a look at the [fpc-docker-compose.yaml](./fpc-docker-compose.yaml) to see how we use different env vars. Most of these environment variables are required by any client application to work and communicate with FPC. If you followed the [cc-tools-demo](../../chaincode/cc-tools-demo/README.md) tutorial, the values should be the same.
26
25
27
-
Start by running `docker-compose -f fpc-docker-compose.yaml up`
26
+
Start by running `docker-compose -f fpc-docker-compose.yaml up` then go to the browser and type `localhost:80` to open the swagger api and start executing functions.
27
+
28
+
## Future work
29
+
30
+
CCAPI have another component for the dashboard frontend application but it's not yet utilized with
Copy file name to clipboardExpand all lines: samples/chaincode/cc-tools-demo/README.md
+49-28Lines changed: 49 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,13 @@
1
1
# CC-Tools-Demo Tutorial
2
2
3
-
This tutorial shows how to build, install and test a Go Chaincode developed using the [CC-Tools]() framework and integrating it with the Fabric Private Chaincode (FPC) framework.
3
+
This tutorial shows how to build, install and test a Go Chaincode developed using the [CC-Tools](https://github.com/hyperledger-labs/cc-tools) framework and integrating it with the Fabric Private Chaincode (FPC) framework.
4
4
5
-
This tutorial illustrates a simple use case where we follow the [cc-tools-demo]() chaincode which is based on standard Fabric and then convert it to an FPC chaincode achieving FPC security capabilities.
5
+
This tutorial illustrates a simple use case where we follow the [cc-tools-demo](https://github.com/hyperledger-labs/cc-tools-demo) chaincode which is based on standard Fabric and then convert it to an FPC chaincode achieving FPC security capabilities.
6
6
7
-
This tutorial is based on the [FPC with CC-Tools integration project]() and all our design choices are explained here in the [design document]().
7
+
This tutorial is based on the [FPC with CC-Tools integration project](https://lf-hyperledger.atlassian.net/wiki/spaces/INTERN/pages/21954957/Hyperledger+Fabric+CC-Tools+Support+for+Fabric+Private+Chaincode) and all our design choices are explained here in the [design document](https://github.com/hyperledger/fabric-private-chaincode/tree/main/docs/design/integrate-with-cc-tools).
8
8
Here are the steps to accomplish this:
9
9
10
-
* Clone and copy the cc-tools-demo chaincode
10
+
* Clone the cc-tools-demo chaincode
11
11
* Modify the chaincode to use FPC
12
12
* Build your FPC CC-tools-demo chaincode
13
13
* Launch a Fabric network
@@ -16,26 +16,32 @@ Here are the steps to accomplish this:
16
16
17
17
## Prerequisites
18
18
19
-
This tutorial presumes that you have installed FPC on your `$GOPATH` as described in the FPC [README.md](../../../README.md#clone-fabric-private-chaincode) and `$FPC_PATH` is set accordingly.
19
+
*This tutorial presumes that you have installed FPC on your `$GOPATH` as described in the FPC [README.md](../../../README.md#clone-fabric-private-chaincode) and `$FPC_PATH` is set accordingly.
20
20
21
-
We also need a working FPC development environment. As described in the "Setup your Development Environment" Section of the FPC [README.md](../../../README.md#setup-your-development-environment), you can use our docker-based dev environment (Option 1) or setup your local development environment (Option 2).
21
+
* We need a working FPC development environment. As described in the "Setup your Development Environment" Section of the FPC [README.md](../../../README.md#setup-your-development-environment), you can use our docker-based dev environment (Option 1) or setup your local development environment (Option 2).
22
22
We recommend using the docker-based development environment and continue this tutorial within the dev container terminal.
23
23
24
-
Moreover, within your FPC development you have already installed the FPC Go Chaincode Support components.
24
+
*Moreover, within your FPC development you have already installed the FPC Go Chaincode Support components.
25
25
See the installation steps in [ecc_go/README.md](../../../ecc_go/README.md#installation).
26
26
27
-
We also assume that you are familiar with Fabric chaincode development in go.
27
+
* We assume that you are familiar with Fabric chaincode development in go.
28
28
Most of the steps in this tutorial follow the normal Fabric chaincode development process, however, there are a few differences that we will highlight here.
29
29
30
-
## Clone and copy the cc-tools-demo chaincode
30
+
* Also, since the tutorial is on the integration between cc-tools and FPC, we expect you to have a grasp knowledge of [cc-tools](https://github.com/hyperledger-labs/cc-tools) framework and that you've at least tried to run the [cc-tools-demo](https://github.com/hyperledger-labs/cc-tools-demo) once by yourself on a Fabric network
31
31
32
-
Clone the [cc-tools-demo]() repository and copy the [chaincode]() folder. Then paste it in the root directory for cc-tools-demo here.
32
+
## Clone the cc-tools-demo chaincode
33
+
34
+
We need to clone the chaincode folder from the [cc-tools-demo](https://github.com/hyperledger-labs/cc-tools-demo) repository here.
cd"$ccToolsDemoPath/chaincode"|| { echo"$ccToolsDemoPath/chaincode does not exist";exit 1; }
40
+
git sparse-checkout set --no-cone chaincode/*
41
+
git checkout
42
+
mv chaincode/*$ccToolsDemoPath
43
+
cd$ccToolsDemoPath
44
+
sudo rm -r $ccToolsDemoPath/chaincode
39
45
```
40
46
41
47
The chaincode code structure is different than normal chaincode as it's using the cc-tools framework.
@@ -115,15 +121,6 @@ func runCCaaS() error {
115
121
116
122
```
117
123
118
-
## Set the needed env vars in the docker-compose file
119
-
120
-
From the code above, we need to set two env variables for the chaincode application to work and use FPC and chaincode-as-a-service (CCAAS). One way to do this is to go to `$FPC_PATH/samples/deployment/test-network/docker-compose.yml` and edit both `ecc.peer0.org1.example.com` and `ecc.peer0.org2.example.com` environment block to have
121
-
```yaml
122
-
- RUN_CCAAS=true
123
-
- FPC_ENABLED=true
124
-
```
125
-
126
-
127
124
## Building FPC Go Chaincode
128
125
129
126
Create a `Makefile` (i.e., `touch $FPC_PATH/samples/chaincode/cc-tools-demo/Makefile`) with the following content:
Please make sure that in the file above the variable `TOP` points to the FPC root directory (i.e., `$FPC_PATH`) as it uses the `$FPC_PATH/ecc_go/build.mk` file.
139
139
140
140
**Note**: In our case, we need to change the build command in the `$FPC_PATH/ecc_go/build.mk` file at the `ecc` target to be `ego-go build $(GOTAGS) -o $(ECC_BINARY)` instead of `ego-go build $(GOTAGS) -o $(ECC_BINARY) main.go`
141
141
142
-
143
142
In `$FPC_PATH/samples/chaincode/cc-tools-demo` directory, to build the chaincode and package it as docker image, execute:
144
143
145
144
```bash
146
145
make
147
146
```
147
+
148
148
Note: this command runs inside the FPC dev environment and not your local host.
149
149
150
150
**Note**: If you faced this error:
151
+
151
152
```bash
152
153
/project/pkg/mod/github.com/hyperledger-labs/cc-tools@v1.0.1/mock/mockstub.go:146:22: cannot use stub (variable of type*MockStub) as shim.ChaincodeStubInterface value in argument to stub.cc.Init: *MockStub does not implement shim.ChaincodeStubInterface (missing method PurgePrivateData)
153
154
```
155
+
154
156
This is because there is a minor difference between the `ChaincodeStubInterface` used in the cc-tools `Mockstub` as it's missing the `PurgePrivateData` method.
155
157
To solve this, run `go mod vendor` in the `$FPC_PATH/samples/chaincode/cc-tools-demo` root directory to download all used packages and go to the file of the error to add the missing method there.
@@ -203,7 +208,19 @@ cd $FPC_PATH/samples/deployment/test-network/fabric-samples/test-network
203
208
./network.sh createChannel -c mychannel
204
209
```
205
210
206
-
Once the network is up and running, we install the simple asset chaincode and the FPC Enclave Registry.
211
+
212
+
### Set the needed env vars in the docker-compose file
213
+
214
+
From the code above, we need to set two env variables for the chaincode application to work and use FPC and chaincode-as-a-service (CCAAS). One way to do this is to go to `$FPC_PATH/samples/deployment/test-network/docker-compose.yml` and edit both `ecc.peer0.org1.example.com` and `ecc.peer0.org2.example.com` environment block to have
215
+
216
+
```yaml
217
+
- RUN_CCAAS=true
218
+
- FPC_ENABLED=true
219
+
```
220
+
221
+
### Install the chaincode
222
+
223
+
Once the network is up and running, we install the cc-tools-demo chaincode and the FPC Enclave Registry.
207
224
We provide a small shell script to make this task a bit easier.
208
225
209
226
```bash
@@ -214,8 +231,6 @@ cd $FPC_PATH/samples/deployment/test-network
214
231
./installFPC.sh
215
232
```
216
233
217
-
Note that the `installFPC.sh` script returns an export statement you need to copy and paste in the terminal.
218
-
This sets environment variables for the package IDs for each chaincode container.
219
234
Continue by running:
220
235
221
236
```bash
@@ -224,7 +239,7 @@ make ercc-ecc-start
224
239
225
240
You should see now four containers running (i.e., `cc-tools-demo.peer0.org1`, `cc-tools-demo.peer0.org2`, `ercc.peer0.org1`, and `ercc.peer0.org2`).
226
241
227
-
### Invoke simple asset
242
+
### Invoke simple getSchema transaction
228
243
229
244
Open a new terminal and connect to the `fpc-development-go-support` container by running
230
245
@@ -270,3 +285,9 @@ export RUN_CCAAS=true
270
285
```
271
286
272
287
Congratulations! You have successfully created an FPC chaincode with go using cc-tools and invoked it using our simple cli.
288
+
289
+
Now you can test all your work again by running the [test](./testTutorial.sh) script
290
+
291
+
## Next Step
292
+
293
+
CC-tools-demo also provides a unique API server called CCAPI that is able to communicate with the peers and execute transactions through a REST API. We integrated this either in the [CCAPI tutorial](../../application/ccapi/)
0 commit comments