Skip to content

Commit

Permalink
[FABN-1183] Update fabtoken tutorial
Browse files Browse the repository at this point in the history
Change-Id: I931b1b18c1c19042bb00d0876601ea5bd660a3f0
Signed-off-by: Wenjian Qiao <[email protected]>
  • Loading branch information
wenjianqiao committed Mar 22, 2019
1 parent 8dc6bc0 commit cc8b4de
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
14 changes: 7 additions & 7 deletions docs/tutorials/fabtoken.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ It demonstrates how to issue, transfer, redeem, and list tokens.

Assume the following objects have been created:

* issuer identity, client (associated to issuer context)
* user1 identity, client1 (associated to user1 context)
* user2 identity, client2 (associated to user1 context)
* issuer, client (associated to issuer context)
* user1, client1 (associated to user1 context)
* user2, client2 (associated to user1 context)
* mychannel

#### Use case 1: issue tokens
Expand All @@ -68,12 +68,12 @@ const tokenclient = client.newTokenClient(mychannel);
// create a request for issue
const txId = client.newTransactionID();
const param1 = {
owner: user1Identity.serialize(),
owner: user1.getIdentity().serialize(),
type: 'USD',
quantity: '500',
};
const param2 = {
owner: user2Identity.serialize(),
owner: user2.getIdentity().serialize(),
type: 'EURO',
quantity: '300',
};
Expand Down Expand Up @@ -115,11 +115,11 @@ user1 wants to transfer 300 to user2. He will transfer the remaining 200 to hims
// After transfer, user2 will have 300 quantity of the token and user1 will have 200 quantity of the token.
const txId = client1.newTransactionID();
const param1 = {
owner: user2Identity.serialize(),
owner: user2.getIdentity().serialize(),
quantity: '300',
};
const param2 = {
owner: user1Identity.serialize(),
owner: user1.getIdentity().serialize(),
quantity: '200',
};
const transferRequest = {
Expand Down
3 changes: 3 additions & 0 deletions docs/tutorials/tutorials.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,8 @@
},
"chaincode-lifecycle": {
"title": "fabric-client: How to install and start your chaincode"
},
"fabtoken": {
"title": "fabric-client: How to perform token operations"
}
}
16 changes: 8 additions & 8 deletions fabric-client/lib/TokenClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ const {HashPrimitives} = require('fabric-common');
*
* @example
* // prerequisites - have created the following objects:
* // client1 (with user1 context), user1Identity
* // client2 (with user2 context), user2Identity
* // user1, client1 (associated to user1 context)
* // user2, client2 (associated to user2 context)
* // mychannel
*
* // create a TokenClient object from client1 (user1)
Expand All @@ -60,11 +60,11 @@ const {HashPrimitives} = require('fabric-common');
* // create a TokenClient object from client2 (user2)
* const tokenClient2 = client2.newTokenClient(mychannel);
*
* // create request to issue tokens
* // create request to issue tokens to user2
* const txId = tokenClient1.newTransactionID();
* const owner = {type: fabprotos.token.TokenOwner_MSP_IDENTIFIER, raw: user2Identity.serialize()};
* const owner = {type: fabprotos.token.TokenOwner_MSP_IDENTIFIER, raw: user2.getIdentity().serialize()};
* const tokenType = 'myTokenType';
* let param = {owner: owner, type: tokenType, quantity: 200};
* let param = {owner: owner, type: tokenType, quantity: '200'};
* let request = {params: [param], txId: txId};
*
* // user1 calls issue method to issue tokens to user2
Expand All @@ -80,7 +80,7 @@ const {HashPrimitives} = require('fabric-common');
* });
*
* // user2 calls redeem method, result.status should be SUCCESS
* param = {quantity: 50};
* param = {quantity: '50'};
* request = {params: [param], txId: txId};
* result = await tokenClient2.redeem(request);
*
Expand All @@ -92,8 +92,8 @@ const {HashPrimitives} = require('fabric-common');
* });
*
* // user2 calls transfer method to transfer the token to user1
* const newOwner = {type: fabprotos.token.TokenOwner_MSP_IDENTIFIER, raw: user1Identity.serialize()};
* param = {owner: newOwner, quantity: 150};
* const newOwner = {type: fabprotos.token.TokenOwner_MSP_IDENTIFIER, raw: user1.getIdentity().serialize()};
* param = {owner: newOwner, quantity: '150'};
* request = {params: [param], tokenId: token.id, txId: txId};
* result = await tokenClient1.transfer(request);
*
Expand Down

0 comments on commit cc8b4de

Please sign in to comment.