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
Node 24 is the latest LTS release and is used as the runtime in the
fabric-nodeenv Docker image to provide access to the latest features and
performance improvements.
Node 20 is now the minimum supported version since Node 18 is no longer
supported.
Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
Copy file name to clipboardExpand all lines: TUTORIAL.md
+17-19Lines changed: 17 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ The dependencies of `fabric-contract-api` and `fabric-shim` will be required.
15
15
"name": "chaincode",
16
16
"description": "My first exciting chaincode implemented in node.js",
17
17
"engines": {
18
-
"node": ">=18"
18
+
"node": ">=20"
19
19
},
20
20
"scripts": {
21
21
"test": "mocha....."
@@ -33,6 +33,7 @@ The dependencies of `fabric-contract-api` and `fabric-shim` will be required.
33
33
}
34
34
35
35
```
36
+
36
37
Remember to add in any additional business logic, and testing libraries needed
37
38
38
39
Adding `fabric-shim` as a dependency, gives a command `fabric-chaincode-node` that is the script to run for `npm start`.
@@ -45,7 +46,6 @@ Adding `fabric-shim` as a dependency, gives a command `fabric-chaincode-node` th
45
46
},
46
47
```
47
48
48
-
49
49
### 2: How is chaincode deployed?
50
50
51
51
Chaincode is deployed by the peer in response to issuing a number of (usually CLI) commands. For node.js chaincode the location of the chaincode npm project is required (the directory that the package.json is in). This does not need to be an installed project, but has to have all the code, and the package.json.
@@ -54,7 +54,7 @@ A docker image is built for this chaincode, the package.json and code copied in.
54
54
55
55
After the install there is a 'bootstrap' process that starts the chaincode up (more details later). The constructors of the exported Contracts will be run at this point; these constructors are for setting the name and optional setup of the 'error/monitoring functions', (again more later). This instance of the contract will existing whilst this chaincode docker image is up.
56
56
57
-
When chaincode is instantiated or updated, the `init()` function in the chaincode is called. As with the `invoke()` call from the client, a fn name and parameters can be passed. Remember therefore to have specific functions to call on `init()` and `update()` in order to do any data initialisation or migration that might be needed. These two functions have been abstracted away to focus on specific function implementations.
57
+
When chaincode is instantiated or updated, the `init()` function in the chaincode is called. As with the `invoke()` call from the client, a fn name and parameters can be passed. Remember therefore to have specific functions to call on `init()` and `update()` in order to do any data initialisation or migration that might be needed. These two functions have been abstracted away to focus on specific function implementations.
58
58
59
59
It is strongly recommended to use the npm shrinkwrap mechanism so the versions of the modules that are used are fixed.
In Fabric, there is a *stub* api that provides chaincode with functionality.
207
+
In Fabric, there is a _stub_ api that provides chaincode with functionality.
210
208
No functionality has been removed, but a new approach to providing abstractions on this to facilitate programming.
211
209
212
-
*user additions*: additional properties can be added to the object to support for example common handling of the data serialization.
210
+
_user additions_: additional properties can be added to the object to support for example common handling of the data serialization.
213
211
214
212
The context object contains
215
213
216
-
-`ctx.stub`the same stub instance as in earlier versions for compatibility
214
+
-`ctx.stub` the same stub instance as in earlier versions for compatibility
217
215
-`ctx.identity` and instance of the Client Identity object
218
216
219
217
You are at liberty to create a subclass of the Context to provide additional functions, or per-transaction context storage. For example
@@ -249,29 +247,29 @@ class ScenarioContext extends Context {
249
247
250
248
Definitions as per https://www.ietf.org/rfc/rfc2119.txt
251
249
252
-
- All the functions that are present in the prototype of a class that extends *Contract* will be invokable
253
-
- The exports from the node module *MUST* include *contracts* that is an array of constructors (1 or more)
254
-
- Each class *MAY* call in it's constructor pass a name. This is prefixed to each of the function names by an _ (underscore)
255
-
- Each class *MAY* define functions that are executed before and functions that are executed after the invoked function.
250
+
- All the functions that are present in the prototype of a class that extends _Contract_ will be invokable
251
+
- The exports from the node module _MUST_ include _contracts_ that is an array of constructors (1 or more)
252
+
- Each class _MAY_ call in it's constructor pass a name. This is prefixed to each of the function names by an \_ (underscore)
253
+
- Each class _MAY_ define functions that are executed before and functions that are executed after the invoked function.
256
254
- These are part of the same fabric transaction
257
255
- They are scoped per name
258
-
- Each class *MAY* define a function that would be executed if a matching function name does not exist; otherwise a 'no function exists' error will be thrown
256
+
- Each class _MAY_ define a function that would be executed if a matching function name does not exist; otherwise a 'no function exists' error will be thrown
259
257
- If too many parameters are passed, they will be discarded
260
258
- If too few parameters are passed, the remainder will be set to undefined
261
-
- as per node.js language standard
259
+
- as per node.js language standard
262
260
- Having duplicate function names in a single class is an error
263
261
- Any function that is dynamically added will not be registered as an invokable function
264
-
- There is no specific function that is invoked per Fabric's *init* chaincode spi. The instantiate flow can pass function name and parameters; therefore consider
265
-
a dedicated function that will be called for new chaincode deployments, and for upgrade deployments.
262
+
- There is no specific function that is invoked per Fabric's _init_ chaincode spi. The instantiate flow can pass function name and parameters; therefore consider
263
+
a dedicated function that will be called for new chaincode deployments, and for upgrade deployments.
266
264
267
265
## Restrictions on programming in side a Contract function
268
266
269
267
Hyperledger Fabric's consensus algorithm permits the ability to use general purpose languages; rather than a more restrictive language. But the following restrictions apply
270
268
271
269
- Functions should not create random variables, or use any function whose return values are functions of the current time or location of execution
272
-
- i.e. the function will be executed in another context (i.e. peer process). This could potentially be in a different time zone in a different locale.
270
+
- i.e. the function will be executed in another context (i.e. peer process). This could potentially be in a different time zone in a different locale.
273
271
- Functions should be aware that they may read state, and write state. But they are producing a set of changes that will be applied to the state. The implication is that updates to the state
0 commit comments