Skip to content

Commit cf69392

Browse files
committed
chaincode-setup.md fixes
fix incorrect chaincode signatures in REST API and CLI [ci skip] Change-Id: I9ecbb3c4fe0b82ce1b22a6cf5cc34629e353da3e Signed-off-by: Nick Gaski <[email protected]>
1 parent 019419d commit cf69392

File tree

1 file changed

+19
-25
lines changed

1 file changed

+19
-25
lines changed

docs/Setup/Chaincode-setup.md

+19-25
Original file line numberDiff line numberDiff line change
@@ -275,15 +275,15 @@ POST localhost:7050/registrar
275275

276276
First, send a chaincode deploy transaction, only once, to the validating peer. The CLI connects to the validating peer using the properties defined in the core.yaml file. **Note:** The deploy transaction typically requires a `path` parameter to locate, build, and deploy the chaincode. However, because these instructions are specific to local development mode and the chaincode is deployed manually, the `name` parameter is used instead.
277277
```
278-
peer chaincode deploy -n mycc -c '{"Function":"init", "Args": ["a","100", "b", "200"]}'
278+
peer chaincode deploy -n mycc -c '{Args": ["init", "a","100", "b", "200"]}'
279279
```
280280

281281
Alternatively, you can run the chaincode deploy transaction through the REST API.
282282

283283
**REST Request:**
284284

285285
```
286-
POST host:port/chaincode
286+
POST <host:port>/chaincode
287287
288288
{
289289
"jsonrpc": "2.0",
@@ -294,8 +294,7 @@ POST host:port/chaincode
294294
"name": "mycc"
295295
},
296296
"ctorMsg": {
297-
"function":"init",
298-
"args":["a", "100", "b", "200"]
297+
"args":["init", "a", "100", "b", "200"]
299298
}
300299
},
301300
"id": 1
@@ -317,12 +316,12 @@ POST host:port/chaincode
317316

318317
**Note:** When security is enabled, modify the CLI command and the REST API payload to pass the `enrollmentID` of a logged in user. To log in a registered user through the CLI or the REST API, follow the instructions in the [note on security functionality](#note-on-security-functionality). On the CLI, the `enrollmentID` is passed with the `-u` parameter; in the REST API, the `enrollmentID` is passed with the `secureContext` element. If you are enabling security and privacy on the peer process with environment variables, it is important to include these environment variables in the command when executing all subsequent peer operations (e.g. deploy, invoke, or query).
319318

320-
CORE_SECURITY_ENABLED=true CORE_SECURITY_PRIVACY=true peer chaincode deploy -u jim -n mycc -c '{"Function":"init", "Args": ["a","100", "b", "200"]}'
319+
CORE_SECURITY_ENABLED=true CORE_SECURITY_PRIVACY=true peer chaincode deploy -u jim -n mycc -c '{"Args": ["init", "a","100", "b", "200"]}'
321320

322321
**REST Request:**
323322

324323
```
325-
POST host:port/chaincode
324+
POST <host:port>/chaincode
326325
327326
{
328327
"jsonrpc": "2.0",
@@ -333,8 +332,7 @@ POST host:port/chaincode
333332
"name": "mycc"
334333
},
335334
"ctorMsg": {
336-
"function":"init",
337-
"args":["a", "100", "b", "200"]
335+
"args":["init", "a", "100", "b", "200"]
338336
},
339337
"secureContext": "jim"
340338
},
@@ -344,7 +342,7 @@ POST host:port/chaincode
344342

345343
The deploy transaction initializes the chaincode by executing a target initializing function. Though the example shows "init", the name could be arbitrarily chosen by the chaincode developer. You should see the following output in the chaincode window:
346344
```
347-
2015/11/15 15:19:31 Received INIT(uuid:005dea42-d57f-4983-803e-3232e551bf61), initializing chaincode
345+
<TIMESTAMP_SIGNATURE> Received INIT(uuid:005dea42-d57f-4983-803e-3232e551bf61), initializing chaincode
348346
Aval = 100, Bval = 200
349347
```
350348

@@ -353,15 +351,15 @@ The deploy transaction initializes the chaincode by executing a target initializ
353351
Run the chaincode invoking transaction on the CLI as many times as desired. The `-n` argument should match the value provided in the chaincode window (started in Vagrant terminal 2):
354352

355353
```
356-
peer chaincode invoke -l golang -n mycc -c '{"Function": "invoke", "Args": ["a", "b", "10"]}'
354+
peer chaincode invoke -l golang -n mycc -c '{Args": ["invoke", "a", "b", "10"]}'
357355
```
358356

359357
Alternatively, run the chaincode invoking transaction through the REST API.
360358

361359
**REST Request:**
362360

363361
```
364-
POST host:port/chaincode
362+
POST <host:port>/chaincode
365363
366364
{
367365
"jsonrpc": "2.0",
@@ -372,8 +370,7 @@ POST host:port/chaincode
372370
"name":"mycc"
373371
},
374372
"ctorMsg": {
375-
"function":"invoke",
376-
"args":["a", "b", "10"]
373+
"args":["invoke", "a", "b", "10"]
377374
}
378375
},
379376
"id": 3
@@ -400,7 +397,7 @@ POST host:port/chaincode
400397
**REST Request:**
401398

402399
```
403-
POST host:port/chaincode
400+
POST <host:port>/chaincode
404401
405402
{
406403
"jsonrpc": "2.0",
@@ -411,8 +408,7 @@ POST host:port/chaincode
411408
"name":"mycc"
412409
},
413410
"ctorMsg": {
414-
"function":"invoke",
415-
"args":["a", "b", "10"]
411+
"args":["invoke", "a", "b", "10"]
416412
},
417413
"secureContext": "jim"
418414
},
@@ -423,7 +419,7 @@ POST host:port/chaincode
423419
The invoking transaction runs the specified chaincode function name "invoke" with the arguments. This transaction transfers 10 units from A to B. You should see the following output in the chaincode window:
424420

425421
```
426-
2015/11/15 15:39:11 Received RESPONSE. Payload 200, Uuid 075d72a4-4d1f-4a1d-a735-4f6f60d597a9
422+
<TIMESTAMP_SIGNATURE> Received RESPONSE. Payload 200, Uuid 075d72a4-4d1f-4a1d-a735-4f6f60d597a9
427423
Aval = 90, Bval = 210
428424
```
429425

@@ -432,7 +428,7 @@ The invoking transaction runs the specified chaincode function name "invoke" wit
432428
Run a query on the chaincode to retrieve the desired values. The `-n` argument should match the value provided in the chaincode window (started in Vagrant terminal 2):
433429

434430
```
435-
peer chaincode query -l golang -n mycc -c '{"Function": "query", "Args": ["b"]}'
431+
peer chaincode query -l golang -n mycc -c '{"Args": ["query", "b"]}'
436432
```
437433

438434
The response should be similar to the following:
@@ -451,7 +447,7 @@ Alternatively, run the chaincode query transaction through the REST API.
451447

452448
**REST Request:**
453449
```
454-
POST host:port/chaincode
450+
POST <host:port>/chaincode
455451
456452
{
457453
"jsonrpc": "2.0",
@@ -462,8 +458,7 @@ POST host:port/chaincode
462458
"name":"mycc"
463459
},
464460
"ctorMsg": {
465-
"function":"query",
466-
"args":["a"]
461+
"args":["query", "a"]
467462
}
468463
},
469464
"id": 5
@@ -485,12 +480,12 @@ POST host:port/chaincode
485480
**Note:** When security is enabled, modify the CLI command and REST API payload to pass the `enrollmentID` of a logged in user. To log in a registered user through the CLI or the REST API, follow the instructions in the [note on security functionality](#note-on-security-functionality). On the CLI, the `enrollmentID` is passed with the `-u` parameter; in the REST API, the `enrollmentID` is passed with the `secureContext` element. If you are enabling security and privacy on the peer process with environment variables, it is important to include these environment variables in the command when executing all subsequent peer operations (e.g. deploy, invoke, or query).
486481

487482
```
488-
CORE_SECURITY_ENABLED=true CORE_SECURITY_PRIVACY=true peer chaincode query -u jim -l golang -n mycc -c '{"Function": "query", "Args": ["b"]}'
483+
CORE_SECURITY_ENABLED=true CORE_SECURITY_PRIVACY=true peer chaincode query -u jim -l golang -n mycc -c '{Args": ["query", "b"]}'
489484
```
490485

491486
**REST Request:**
492487
```
493-
POST host:port/chaincode
488+
POST <host:port>/chaincode
494489
495490
{
496491
"jsonrpc": "2.0",
@@ -501,8 +496,7 @@ POST host:port/chaincode
501496
"name":"mycc"
502497
},
503498
"ctorMsg": {
504-
"function":"query",
505-
"args":["a"]
499+
"args":["query", "a"]
506500
},
507501
"secureContext": "jim"
508502
},

0 commit comments

Comments
 (0)