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: README.md
+38-4Lines changed: 38 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,7 +72,7 @@ In this case, however, you should use generated `fablo-docker.sh` instead of `fa
72
72
### init
73
73
74
74
```bash
75
-
fablo init [node] [rest] [dev]
75
+
fablo init [node] [rest] [dev] [gateway]
76
76
```
77
77
78
78
Creates simple network config file in current dir.
@@ -82,6 +82,7 @@ Fablo `init` command takes three parameters (the order does not matter):
82
82
* Option `node` makes Fablo to generate a sample Node.js chaincode as well.
83
83
* Option `rest` enables simple REST API with [Fablo REST](https://github.com/fablo-io/fablo-rest) as standalone Docker container.
84
84
* Option `dev` enables running peers in dev mode (so the hot reload for chaincode is possible).
85
+
* Option `gateway` makes Fablo generate a sample Node.js server that connects to the gateway.
85
86
86
87
Sample command:
87
88
@@ -263,6 +264,8 @@ This feature allows hot reload of chaincode code and speeds up the development a
263
264
Fablo will run peers in dev mode when `global.peerDevMode` is set to `true`.
264
265
Note: in this case TLS has to be disabled, otherwise config validation fails.
265
266
267
+
#### For Node.js Chaincode:
268
+
266
269
The simplest way of trying Fablo with dev mode is as follows:
267
270
268
271
1. Execute `fablo init node dev`.
@@ -277,7 +280,7 @@ The simplest way of trying Fablo with dev mode is as follows:
277
280
```
278
281
Now, when you update the chaincode source code, it will be automatically refreshed on Hyperledger Fabric Network.
279
282
280
-
Our sample chaincode definition contains some scripts forrunning chaincodeindev mode:
283
+
The relevant scripts in`package.json` look like:
281
284
282
285
```json
283
286
"scripts": {
@@ -287,13 +290,44 @@ Our sample chaincode definition contains some scripts for running chaincode in d
287
290
...
288
291
},
289
292
```
290
-
291
-
Worth considering:
293
+
**Worth considering for Node.js chaincode:**
292
294
* If you want chaincode to be running on multiple peers, you need to start it multiple times, specifying different `--peer.address`
293
295
* In case of errors ensure you have the same `--chaincode-id-name` as `CC_PACKAGE_ID`in Fablo output.
294
296
295
297
Feel free to update this scripts to adjust it to your chaincode definition.
296
298
299
+
300
+
#### For Java Chaincode:
301
+
302
+
To run Java chaincode in dev mode:
303
+
304
+
1. Make sure your Fablo config has `global.peerDevMode` set to `true` and TLS disabled.
305
+
306
+
2. Start the network with `fablo up`.
307
+
308
+
3. Build and run the Java chaincode locally. As a sample you may use the chaincode from the Fablo source code from the `samples/chaincodes/java-chaincode` directory. Ensure a proper relative path is provided in Fablo config.
309
+
```bash
310
+
cd samples/chaincodes/java-chaincode
311
+
./run-dev.sh
312
+
```
313
+
314
+
The `run-dev.sh` script will:
315
+
- Build the chaincode using Gradle's shadowJar task
316
+
- Automatically detect the peer's IP address from the Docker container
317
+
- Start the chaincode with debug logging enabled
318
+
- Connect to the peer at port 7051
319
+
320
+
For local development and review:
321
+
- The chaincode will run with the name `simple-asset:1.0`
322
+
- Debug level logging is enabled via `CORE_CHAINCODE_LOGLEVEL=debug`
323
+
- You can modify the Java code and rebuild/restart to see changes
324
+
- The peer connection is automatically configured using the Docker container's IP
325
+
326
+
**Worth considering for Java chaincode:**
327
+
- If you want the chaincode running on multiple peers, start multiple instances with different `CORE_PEER_ADDRESS` values
328
+
- Ensure `CORE_CHAINCODE_ID_NAME` matches the chaincode name and version in your Fablo config (for instance `chaincode1:0.0.1`)
329
+
- The Java chaincode uses Gradle's ShadowJar plugin to package all dependencies into a single JAR file
0 commit comments