mp94
mp94

Reputation: 11

Issue about tutorial: Enhance and add queries to a commercial paper smart contract with the IBM Blockchain VS Code extension

I'm following tutorial about adding queries to a commercial paper smart contract with the IBM, and I have a problem with the peer.

I have tried to kill docker images, and start it again, but it was not work for me.

Note that I have completed 1st of three tutorials(Tutorial:Run a commercial paper smart contract with the IBM Blockchain VS Code extension), and I am stuck at the 2nd(Tutorial:Enhance and add queries to a commercial paper smart contract with the IBM Blockchain VS Code extension) at the step Transaction #1. Execute an issue transaction as Isabella@MagnetoCorp ->command: node issue.js

In the picture below you can find an error the was displayed to me after running that command.

Error displayed

Update to the question:

docker ps -a command has been shown below:


CONTAINER ID        IMAGE                                                                                                                                 COMMAND                  CREATED             STATUS              PORTS                                            NAMES
2a3e4e48075e        fabricvscodelocalfabric-peer0.org1.example.com-papercontract-0.0.3-78616bc8781845bda2262df7df0f9b279bbdec017bb93af51d93709f038eda91   "/bin/sh -c 'cd /usr…"   35 minutes ago      Up 35 minutes                                                        fabricvscodelocalfabric-peer0.org1.example.com-papercontract-0.0.3
2f7fabfaddfe        hyperledger/fabric-peer:1.4.1                                                                                                         "peer node start"        36 minutes ago      Up 36 minutes       0.0.0.0:17051-17052->17051-17052/tcp             fabricvscodelocalfabric_peer0.org1.example.com
88f688b6ebba        hyperledger/fabric-couchdb:0.4.15                                                                                                     "tini -- /docker-ent…"   36 minutes ago      Up 36 minutes       4369/tcp, 9100/tcp, 0.0.0.0:17055->5984/tcp      fabricvscodelocalfabric_couchdb
b05de940a8c7        hyperledger/fabric-orderer:1.4.1                                                                                                      "orderer"                36 minutes ago      Up 36 minutes       7050/tcp, 0.0.0.0:17050->17050/tcp               fabricvscodelocalfabric_orderer.example.com
9191eb65ee7a        gliderlabs/logspout                                                                                                                   "/bin/logspout"          36 minutes ago      Up 36 minutes       0.0.0.0:17056->80/tcp                            fabricvscodelocalfabric_logspout
d6309f112d4c        hyperledger/fabric-ca:1.4.1                                                                                                           "sh -c 'fabric-ca-se…"   37 minutes ago      Up 36 minutes       7054/tcp, 0.0.0.0:17054->17054/tcp               fabricvscodelocalfabric_ca.org1.example.com
372f68a944b8        dev-peer0.org1.example.com-papercontract-0-d96abb966a1ed760663cf0a061700a902284832716c55b4cb05eca53054fe011                           "/bin/sh -c 'cd /usr…"   38 minutes ago      Up 38 minutes                                                        dev-peer0.org1.example.com-papercontract-0
6c983d60e48f        hyperledger/fabric-tools                                                                                                              "/bin/bash"              42 minutes ago      Up 42 minutes                                                        cliMagnetoCorp
184e650f2975        hyperledger/fabric-peer                                                                                                               "peer node start"        43 minutes ago      Up 43 minutes       0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp   peer0.org1.example.com
a6cbb904a6ed        hyperledger/fabric-ca                                                                                                                 "sh -c 'fabric-ca-se…"   43 minutes ago      Up 43 minutes       0.0.0.0:7054->7054/tcp                           ca.example.com
041a557654d6        hyperledger/fabric-orderer                                                                                                            "orderer"                43 minutes ago      Up 43 minutes       0.0.0.0:7050->7050/tcp                           orderer.example.com
6b4634079113        hyperledger/fabric-couchdb                                                                                                            "tini -- /docker-ent…"   43 minutes ago      Up 43 minutes       4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp       couchdb

Upvotes: 0

Views: 233

Answers (1)

R Thatcher
R Thatcher

Reputation: 5570

There are 2 changes you need to make to the client applications (issue.js etc) to make them work with LOCAL FABRIC provided by the latest version of the VS Code Extension:

  1. As Paul said in his comment, you need to export the Connection Profile, and then edit the code to use this new JSON file instead of a YAML file.
  2. Use the Wallet from the VS Code extension. You can either Export it and edit issue.js to point to the exported location, or you can just find the original on your file system and point to it directly.

The Wallet can be found at a location like /home/marko/.fabric-vscode/local_fabric_wallet/

In you application code (issue.js) you will need to change the location of the wallet: const wallet = new FileSystemWallet('/home/marko/.fabric-vscode/local_fabric_wallet/');

and the userName: const userName = 'admin';

Whilst you are looking at issue.js I would also check the channel name and the contract name just to make sure. (I guess the channel is still mychannel but the contract name might be papernet-js not papercontract - check in VS Code.)

Additional Background

The Commercial Paper standard tutorial runs on the sample Fabric network "Basic Network". The Basic network uses default network ports 7050, 7051 etc, and a pre-created set of Crypto Material. Early versions of the VS Code extension used the same "Basic Network" so it was easy to run the Commercial Paper tutorial with VS Code.

Later versions of the VS Code extension use a custom Fabric that is generated for each person who uses the VS Code extension. If you want to connect client applications (like issue.js and queryapp.js) to the custom Fabric with these later versions of VS Code it is necessary to export the Connection Profile and the Wallet with the new crypto material. The Custom Fabric uses network ports 17050, 17051 etc so if you look at the original .YAML file and the new .JSON file you can see differences. (You could also check the Wallets and see that they have different crypto material.)

A connection profile can be a .YAML file or a .JSON file - they have the same information, just formatted differently - the line in the client app is slightly different when importing the different file types.

Upvotes: 0

Related Questions