Giter Club home page Giter Club logo

todo-list-fabricv1's Introduction

OBSOLETE: This code pattern is obsolete

This repository will not be updated. We will keep the repository available for folks interested in some of the technical details.

Read this in other languages: **.

Implementing Common Transactions on IBM Blockchain - Hyperledger Fabric V1

This project is focused on helping a developer to migrate from Hyperledger Fabric V.6 to V1. It shows how to perform traditional data store transactions on IBM Blockchain. This surfaces as a web-based, to-do list application, allowing browse, read, edit, add, and delete (BREAD) operations.

The to-do list application presented here is designed to help developers understand how common transactions needed by business processes can be adapted to use Blockchain. Blockchain != Bitcoin. It might be said that Bitcoin is the first Blockchain application. As a distributed ledger, the distinct characteristics such as decentralization, consensus, and encryption have broad-reaching implications to many business verticals including finance, transportation, health care, and others.

Application Communication Workflow

To-do login screen

  • User will interact with the Todos client application, in their browser.
  • When the user performs any action, the client application calls the server application API where the registered admin interacts with the Hyperledger Blockchain Network.
  • Reading or writing the ledger is known as a proposal. This proposal is built by Todos Server (via the SDK) and then sent to a blockchain peer.
  • The peer will communicate to its Todos chaincode container. The chaincode will run/simulate the transaction. If there are no issues it will endorse the transaction and send it back to our Todos application.
  • Todos (via the SDK) will then send the endorsed proposal to the ordering service. The orderer will package many proposals from the whole network into a block. Then it will broadcast the new block to peers in the network.
  • Finally the peer will validate the block and write it to its ledger. The transaction has now taken effect and any subsequent reads will reflect this change.

Prerequisite

  • Go - most recent version
  • Docker - v1.13 or higher
  • Docker Compose - v1.8 or higher
  • Node.js & npm - node v6.2.0 - v6.10.0 (v7+ not supported); npm comes with your node installation.
  • nvm - if you want to use the nvm install command to retrieve a node version

Steps

  1. Download the docker images and get the code for hyperledger fabric V1 node sdk
  2. Edit the configuration
  3. Start your network
  4. Use the Node SDK
  5. Run the todo list fabric server
  6. Run the todo list fabric client
  7. Using the todo list application

1. Download the docker images and get the code for hyperledger fabric V1 node sdk

download-dockerimages.sh contains the code for downloading the docker images required to setup the network for running Hyperledger Fabric V1.

From your workspace, make the shell script an executable:

chmod +x download-dockerimages.sh

Now run the script. Make sure you have docker running before executing this script. This process will take a few minutes so be patient:

./download-dockerimages.sh

Once the script has completed, you should see the following in your terminal:

===> List out hyperledger docker images
hyperledger/fabric-ca          latest               35311d8617b4        3 weeks ago         240 MB
hyperledger/fabric-ca          x86_64-1.0.0-alpha   35311d8617b4        3 weeks ago         240 MB
hyperledger/fabric-couchdb     latest               f3ce31e25872        3 weeks ago         1.51 GB
hyperledger/fabric-couchdb     x86_64-1.0.0-alpha   f3ce31e25872        3 weeks ago         1.51 GB
hyperledger/fabric-kafka       latest               589dad0b93fc        3 weeks ago         1.3 GB
hyperledger/fabric-kafka       x86_64-1.0.0-alpha   589dad0b93fc        3 weeks ago         1.3 GB
hyperledger/fabric-zookeeper   latest               9a51f5be29c1        3 weeks ago         1.31 GB
hyperledger/fabric-zookeeper   x86_64-1.0.0-alpha   9a51f5be29c1        3 weeks ago         1.31 GB
hyperledger/fabric-orderer     latest               5685fd77ab7c        3 weeks ago         182 MB
hyperledger/fabric-orderer     x86_64-1.0.0-alpha   5685fd77ab7c        3 weeks ago         182 MB
hyperledger/fabric-peer        latest               784c5d41ac1d        3 weeks ago         184 MB
hyperledger/fabric-peer        x86_64-1.0.0-alpha   784c5d41ac1d        3 weeks ago         184 MB
hyperledger/fabric-javaenv     latest               a08f85d8f0a9        3 weeks ago         1.42 GB
hyperledger/fabric-javaenv     x86_64-1.0.0-alpha   a08f85d8f0a9        3 weeks ago         1.42 GB
hyperledger/fabric-ccenv       latest               91792014b61f        3 weeks ago         1.29 GB
hyperledger/fabric-ccenv       x86_64-1.0.0-alpha   91792014b61f        3 weeks ago         1.29 GB

Clone the repo for fabric node sdk:

git clone https://github.com/hyperledger/fabric-sdk-node.git

First, checkout the alpha branch of the fabric-sdk-node repository:

cd fabric-sdk-node
git checkout v1.0.0-alpha

Ensure that you are on the correct branch:

git branch

You should see the following:

Ishans-MacBook-Pro:fabric-sdk-node ishan$ git branch
* (HEAD detached at v1.0.0-alpha)
  master

Now hop back to your workspace directory:

cd ..

From your workspace, move the docker-compose-networksetup.yaml to the test/fixtures folder in the fabric-sdk-node directory:

mv docker-compose-networksetup.yaml fabric-sdk-node/test/fixtures

Still from your workspace, empty the example chaincode source from the fabric-sdk-node directory:

rm -rf fabric-sdk-node/test/fixtures/src/github.com/example_cc/*

Now copy the todo list chaincode to the same folder:

cp todo-list-fabric-server/chaincode/* fabric-sdk-node/test/fixtures/src/github.com/example_cc/

Note: If you want to run your own code on hyperledger fabric V1, just copy the chaincode code in fabric-sdk-node/test/fixtures/src/github.com/example_cc directory.

2. Edit the configuration

Update the config.json and instantiate-chaincode.js files in the fabric-sdk-node directory:

cd fabric-sdk-node/test/integration/e2e

Use an editor to open the config.json and replace all instances of grpcs with grpc.

Use an editor to open instantiate-chaincode.js and replace line 147 with:

args: ['init'],

3. Start your network

docker-compose-networksetup.yaml contains the configuration to setup the network.

Navigate to the test/fixtures folder in the fabric-sdk-node directory and run the docker-compose file:

cd fabric-sdk-node/test/fixtures
docker-compose -f docker-compose-networksetup.yaml up -d

Once complete, issue a docker ps command to view your currently running containers. You should see the following:

CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS                       PORTS                                            NAMES
e61cf829f171        hyperledger/fabric-peer      "peer node start -..."   3 minutes ago       Up 2 minutes           0.0.0.0:7056->7051/tcp, 0.0.0.0:7058->7053/tcp   peer1
0cc1f5ac24da        hyperledger/fabric-peer      "peer node start -..."   3 minutes ago       Up 2 minutes        0.0.0.0:8056->7051/tcp, 0.0.0.0:8058->7053/tcp   peer3
7ab3106e5076        hyperledger/fabric-peer      "peer node start -..."   3 minutes ago       Up 3 minutes        0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp   peer0
2bc5c6606e6c        hyperledger/fabric-peer      "peer node start -..."   3 minutes ago       Up 3 minutes        0.0.0.0:8051->7051/tcp, 0.0.0.0:8053->7053/tcp   peer2
513be1b46467        hyperledger/fabric-ca        "sh -c 'fabric-ca-..."   3 minutes ago       Up 3 minutes        0.0.0.0:8054->7054/tcp                           ca_peerOrg2
741c363ba34a        hyperledger/fabric-orderer   "orderer"                3 minutes ago       Up 3 minutes        0.0.0.0:7050->7050/tcp                           orderer0
abaae883eb13        couchdb                      "tini -- /docker-e..."   3 minutes ago       Up 3 minutes        0.0.0.0:5984->5984/tcp                           couchdb
2c2d51fe88c0        hyperledger/fabric-ca        "sh -c 'fabric-ca-..."   3 minutes ago       Up 3 minutes        0.0.0.0:7054->7054/tcp                           ca_peerOrg1

4. Use the Node SDK

Go back to the root of the fabric-sdk-node directory and add grpc dependency "grpc": "1.1.2" to package.json

Install node modules in your SDK repo.

npm install
npm install -g gulp
# if you get a "permission denied" error, then try with sudo
sudo npm install -g gulp

Finally, build the fabric-ca client:

gulp ca

Remove the key value stores and hfc artifacts that may have cached during previous runs:

rm -rf /tmp/hfc-*
rm -rf ~/.hfc-key-store

Update the chaincode version from v0 to v1 in util.js present in test/unit

module.exports.END2END = {
	channel: 'mychannel',
	chaincodeId: 'end2end',
	chaincodeVersion: 'v1'
};

Create channel

A Hyperledger Fabric channel is a private “subnet” of communication between two or more specific network members, for the purpose of conducting private and confidential transactions. A channel is defined by members (organizations), anchor peers per member, the shared ledger, chaincode application(s) and the ordering service node(s). Each transaction on the network is executed on a channel, where each party must be authenticated and authorized to transact on that channel. Each peer that joins a channel, has its own identity given by a membership services provider (MSP), which authenticates each peer to its channel peers and services.

Now, leverage the SDK test program to create a channel named mychannel. From the fabric-sdk-node directory:

node test/integration/e2e/create-channel.js

Join channel

Pass the genesis block - mychannel.block - to the ordering service and join the peers to your channel:

node test/integration/e2e/join-channel.js

Install chaincode

Install the todo list source code on the peer's filesystems:

node test/integration/e2e/install-chaincode.js

Instantiate chaincode

Spin up the todo list containers:

node test/integration/e2e/instantiate-chaincode.js

5. Run the todo list fabric server

Navigate to the root of the todo-list-fabric-server directory.

Install node modules in your fabric server repo.

npm install

Run the server:

node server.js

Issue a get request to /enrollAdmin endpoint, to the Enroll the admin on chaincode:

You should see the following response:

{
  "message": "Admin Enrolled! "
}

6. Run the todo list fabric client

In a new terminal, navigate to the root of the todo-list-fabric-client/web directory.

In order for the web-based to-do list application to work, it must be run from a web server. This server does not need to be publicly available in order for the application to function.

On Mac, a common approach is to use the built-in PHP installation to run an in-place web server. Run the PHP web server:

php -S localhost:8081

On windows, you can use XAMPP

7. Using the todo list application

Use the link http://localhost:8081 to load the web application in browser. You will be presented with a login screen. The login dialog contains an IBM logo. Alt+Click on that logo to preload data into the blockchain. The only indication that this operation has been completed is a transaction ID in the developer console.

While not extremely verbose, transaction IDs from IBM Blockchain are presented in the developer console of the browser for every change made at the blockchain itself. It may be useful to have the developer console open when you are using the to-do list application.

To-do login screen

There are three accounts created in the default data. In the form of username:password, those accounts are ...

  • krhoyt:abc123
  • abtin:abc123
  • peter:abc123

You can login with any of these accounts to browse, read, edit, add, and delete to-do items.

To-do listing

  • To create a to-do list item, click on the red button labeled "+". Hovering over this button will present the additional button to create a "location".
  • To edit a to-do list item, click on the item you are interested in editing and modify the fields to match your desired values. There is no "save" button as all changes are immediately committed to the blockchain.
  • To delete a to-do list item, move your mouse over any item, and click on the trash can icon.
  • To forward the to-do list item to another person, move your mouse over any item and click on the arrow icon that appears. A list of other users in the system will be presented. Select a name.
  • To logout of the application, click the icon that is a box with an arrow inside of it. This is located in the upper-righthand corner of the screen.
  • Using the above account information, log into the application again using a different account to see to-do items forwarded on to other users in the system.

Additional resources

Following is a list of additional blockchain resources:

Troubleshooting

  • If you see a containerID already exists upon running docker-compose up, then you need to remove the existing container. This command will remove all containers; NOT your images:
docker rm -f $(docker ps -aq)
  • When running create-channel.js, if you see an error stating private key not found, then try clearing your cached key value stores:
rm -rf /tmp/hfc-*
rm -rf ~/.hfc-key-store
  • The developer console in the browser is your key to troubleshooting any problems that may arise while running the client application. The first place to look for errors is in checking the values of the chaincode ID and url in the "/web/script/blockchain.js" file.

References

License

This code pattern is licensed under the Apache Software License, Version 2. Separate third party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 (DCO) and the Apache Software License, Version 2.

Apache Software License (ASL) FAQ

todo-list-fabricv1's People

Contributors

dolph avatar ishangulhane avatar ljbennett62 avatar wwalisa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

todo-list-fabricv1's Issues

ReadMe: instantiate-chaincode.js replace line 147

I am sorry if I miss anything since I am new to this technology. I follow the instruction to replace line 147 in instantiate-chaincode.js but when I open the file, it only has 57 lines of codes. Any idea what I have missed?

5. Run the todo list fabric server

Run the server:

node server.js

when I run this, I got a problem.

[root@localhost todo-list-fabric-server]# node server.js
info: Loaded config file /usr/local/dockerImages/todo-list-fabricV1-master/todo-list-fabric-server/config/toodles_data.json
info: Loaded creds file /usr/local/dockerImages/todo-list-fabricV1-master/todo-list-fabric-server/config/blockchain_creds.json
module.js:597
  return process.dlopen(module, path._makeLong(filename));
                 ^

Error: /usr/local/dockerImages/todo-list-fabricV1-master/todo-list-fabric-server/node_modules/grpc/src/node/extension_binary/grpc_node.node: ELF load command past end of file
    at Error (native)
    at Object.Module._extensions..node (module.js:597:18)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/local/dockerImages/todo-list-fabricV1-master/todo-list-fabric-server/node_modules/grpc/src/node/src/grpc_extension.js:38:15)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)

can someone help me?

ELF load command past end of file

what does this mean? How can I trace it?

Error when running install-chaincode.js

Env:
Go: 1.9.2 windows/amd64
Node: v6.2.0
Docker: 17.09.0-ce
Docker-Compose: 1.16.1

I get the following error when running "node test/integration/e2e/install-chaincode.js".

Prior to executing the .js script, I ran the command to copy all the files to example_cc. [cp todo-list-fabric-server/chaincode/* fabric-sdk-node/test/fixtures/src/github.com/example_cc/]

error: [Peer.js]: GRPC client got an error response from the peer "grpc://localhost:7051". Error: Illegal file detected in payload: "src\github.com\example_cc\account.go"
at C:\Users\pilla\to-do\todo-list-fabricV1\fabric-sdk-node\node_modules\grpc\src\client.js:554:15
error: [Chain.js]: Chain-sendPeersProposal - Promise is rejected: Error: Illegal file detected in payload: "src\github.com\example_cc\account.go"
at C:\Users\pilla\to-do\todo-list-fabricV1\fabric-sdk-node\node_modules\grpc\src\client.js:554:15
error: [Peer.js]: GRPC client got an error response from the peer "grpc://localhost:7056". Error: Illegal file detected in payload: "src\github.com\example_cc\account.go"
at C:\Users\pilla\to-do\todo-list-fabricV1\fabric-sdk-node\node_modules\grpc\src\client.js:554:15
error: [Chain.js]: Chain-sendPeersProposal - Promise is rejected: Error: Illegal file detected in payload: "src\github.com\example_cc\account.go"
at C:\Users\pilla\to-do\todo-list-fabricV1\fabric-sdk-node\node_modules\grpc\src\client.js:554:15
error: [install-chaincode]: install proposal

Adding Couchdb to store data generate through smart contracts and query them

Hi !
I'm trying to add CouchDB to make rich queries through my smart-contract.
I tried to modify the docker-compose-networksetup.yaml but i then have some issues when i want to execute create-channel.js/join-channel.js.

Do you know how to do it ? Is there anything else to change except the docker-compose file ?
Thanks by advance !
:)

Stuck at node test/integration/e2e/create-channel.js

Hello

Have setup till create-channel.js and getting the below error, tried re-installing till this step and unable to find any solution for the below error.
This class requires a CryptoKeyStore to save keys, using the store: {"opts":{"path":"/root/.hfc-key-store"}}
not ok 1 Error: Could not parse enrollment response [{"success":false,"result":null,"errors":[{"code":0,"message":"open /etc/hyperledger/fabric-ca-server-cog/peerOrg1-cert.pem: no such file or directory"}],"messages":[]} ] as JSON due to error [TypeError: Cannot read property 'errors' of undefined] at IncomingMage. (/root/todo-list-fabricV1/fabric-sdk-node/node_modules/fabric-ca-client/lib/FabricCAClientImpl.js:560:14) at emitNone (events.js:91:20) at ImingMessage.emit (events.js:185:7) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._kCallback (internal/process/next_tick.js:98:9)

operator: fail
at: cop.enroll.then.then.then.catch (/root/todo-list-fabricV1/fabric-sdk-node/test/unit/util.js:119:8)
stack: |-

query response is empty when trying to log in

info: Fetching EVERYTHING...
debug: [fcw] Querying Chaincode: account_read()
debug: [fcw] Sending query req chainId=mychannel, chaincodeId=end2end, chaincodeVersion=v1, fcn=account_read, args=[krhoyt, abc123], txId=df379ff15a4a6339c9d581c619bf28cdba6bc478a2264f58da636e3e4ea67fc0
debug: [fcw] Peer 0 len 4
debug: [fcw] Peer 0 type object
debug: [fcw] Query response is empty undefined
debug: Results from query_function invoke_cc:
debug: { parsed: null,
peers_agree: true,
raw_peer_payloads: [ 'null' ] }
debug: null
debug: Query parameters : [object Object]

Can't load data into blockchain

I have a problem when loading the data into blockchain. When I do alt+click I have this message
screenshot_20180228_150024

And I have this loged in the terminal:

debug: Query parameters : [object Object]

info: Invoking function reset_data  with arguments [{"id":"4b56f041-eec7-4247-8ae5-55380e6c9a12","first":"Kevin","last":"Hoyt","name":"krhoyt","password":"abc123"},{"id":"aaad28f4-89c5-453e-bc53-d10905ac94f3","first":"Abtin","last":"Forouzandeh","name":"abtin","password":"abc123"},{"id":"01b5b881-f017-4053-80da-354d2dcf20f7","first":"Peter","last":"Moskovits","name":"peter","password":"abc123"}],[{"id":"281efe43-eb66-4871-9875-bc2f9e200435","account":"4b56f041-eec7-4247-8ae5-55380e6c9a12","name":"Home"},{"id":"e9693fca-ad33-4aa1-9614-4127563e7dd5","account":"4b56f041-eec7-4247-8ae5-55380e6c9a12","name":"Work"},{"id":"99a8e5d9-79b9-4d06-8abe-9f534b74037c","account":"4b56f041-eec7-4247-8ae5-55380e6c9a12","name":"Cave"},{"id":"b5d03c56-78b4-44cf-883b-3696ae07aa9b","account":"4b56f041-eec7-4247-8ae5-55380e6c9a12","name":"Garage"},{"id":"fa48d454-09cf-4216-a17a-07b317648433","account":"4b56f041-eec7-4247-8ae5-55380e6c9a12","name":"TKD"},{"id":"23a91616-78a0-498c-853a-64e979238a0a","account":"4b56f041-eec7-4247-8ae5-55380e6c9a12","name":"Groceries"},{"id":"c4db4872-225f-46f1-915e-c994e8f20aaa","account":"aaad28f4-89c5-453e-bc53-d10905ac94f3","name":"Home"},{"id":"a37c44b8-15b5-4fbf-8c6f-69818fc5bfdc","account":"aaad28f4-89c5-453e-bc53-d10905ac94f3","name":"Work"},{"id":"596402fb-9810-4c74-85fa-d396ccc28dc0","account":"01b5b881-f017-4053-80da-354d2dcf20f7","name":"Home"},{"id":"27a5b073-e8f5-40d2-bf94-744006f6088d","account":"01b5b881-f017-4053-80da-354d2dcf20f7","name":"Work"}],[{"id":"826465cd-4ab7-40a6-8af1-01da16131279","account":"4b56f041-eec7-4247-8ae5-55380e6c9a12","due":1491026400000,"location":"e9693fca-ad33-4aa1-9614-4127563e7dd5","duration":5,"energy":2,"tags":"awesome,journey","notes":"Because Blockchain will revolutionize how you do business.","complete":false,"name":"Chain All The Things","created":1490464725276},{"id":"3c3957e3-076b-4703-9b7a-0490bfd2fd45","account":"4b56f041-eec7-4247-8ae5-55380e6c9a12","due":1490421600000,"location":"281efe43-eb66-4871-9875-bc2f9e200435","duration":1,"energy":2,"tags":"repair","notes":"Because she clogged it with something.","complete":true,"name":"Fix Paige's Toilet","created":1490464681491},{"id":"9069ee37-3d7c-42ae-b861-059d353f4878","account":"aaad28f4-89c5-453e-bc53-d10905ac94f3","due":1491026400000,"location":"a37c44b8-15b5-4fbf-8c6f-69818fc5bfdc","duration":1,"energy":0,"tags":"business","notes":"Because 37 meetings in a week just is not enough.","complete":false,"name":"Schedule More Meetings","created":1490464573737},{"id":"7d2e88af-da34-4fea-8d3c-91faed1f8425","account":"01b5b881-f017-4053-80da-354d2dcf20f7","due":1491026400000,"location":"596402fb-9810-4c74-85fa-d396ccc28dc0","duration":4,"energy":2,"tags":"food,friends,happiness","notes":"Hungarian sponge cake layered with chocolate buttercream and topped with caramel.","complete":false,"name":"Bake Dobos Torte","created":1490464345821}]
debug: [fcw] Invoking Chaincode: reset_data()
TypeError: Cannot read property 'chain' of null
    at Object.invoke_cc.invoke_chaincode (/home/lvndry/Github/todo-list-fabricV1/todo-list-fabric-server/utils/fc_wrangler/invoke_cc.js:37:19)
    at Object.fcw.invoke_chaincode (/home/lvndry/Github/todo-list-fabricV1/todo-list-fabric-server/utils/fc_wrangler/index.js:29:13)
    at Object.toodles_chaincode.invoke_function (/home/lvndry/Github/todo-list-fabricV1/todo-list-fabric-server/utils/toodles_cc_lib.js:23:7)
    at /home/lvndry/Github/todo-list-fabricV1/todo-list-fabric-server/server.js:113:14
    at Layer.handle [as handle_request] (/home/lvndry/Github/todo-list-fabricV1/todo-list-fabric-server/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/lvndry/Github/todo-list-fabricV1/todo-list-fabric-server/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/home/lvndry/Github/todo-list-fabricV1/todo-list-fabric-server/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/home/lvndry/Github/todo-list-fabricV1/todo-list-fabric-server/node_modules/express/lib/router/layer.js:95:5)
    at /home/lvndry/Github/todo-list-fabricV1/todo-list-fabric-server/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/home/lvndry/Github/todo-list-fabricV1/todo-list-fabric-server/node_modules/express/lib/router/index.js:335:12)


can't login todo application

Hi

I setup according to README but can't login todo application.

2017-11-11 22 44 19

~/D/d/t/todo-list-fabric-server ❯❯❯ node server.js
info: Loaded config file /Users/kkyouhei/Developer/docker/todo-list-fabricV1/todo-list-fabric-server/config/toodles_data.json
info: Loaded creds file /Users/kkyouhei/Developer/docker/todo-list-fabricV1/todo-list-fabric-server/config/blockchain_creds.json
info: Returning a new winston logger with default configurations
------------------------------------------ Server Up - localhost:3000 ------------------------------------------
debug: Query parameters : [object Object]

info: Fetching EVERYTHING...
debug: [fcw] Querying Chaincode: account_read()
TypeError: Cannot read property 'chain' of null
    at Object.query_cc.query_chaincode (/Users/kkyouhei/Developer/docker/todo-list-fabricV1/todo-list-fabric-server/utils/fc_wrangler/query_cc.js:23:18)
    at Object.fcw.query_chaincode (/Users/kkyouhei/Developer/docker/todo-list-fabricV1/todo-list-fabric-server/utils/fc_wrangler/index.js:34:12)
    at Object.toodles_chaincode.query_function (/Users/kkyouhei/Developer/docker/todo-list-fabricV1/todo-list-fabric-server/utils/toodles_cc_lib.js:37:7)
    at /Users/kkyouhei/Developer/docker/todo-list-fabricV1/todo-list-fabric-server/server.js:127:15
    at Layer.handle [as handle_request] (/Users/kkyouhei/Developer/docker/todo-list-fabricV1/todo-list-fabric-server/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/kkyouhei/Developer/docker/todo-list-fabricV1/todo-list-fabric-server/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/Users/kkyouhei/Developer/docker/todo-list-fabricV1/todo-list-fabric-server/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/Users/kkyouhei/Developer/docker/todo-list-fabricV1/todo-list-fabric-server/node_modules/express/lib/router/layer.js:95:5)
    at /Users/kkyouhei/Developer/docker/todo-list-fabricV1/todo-list-fabric-server/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/Users/kkyouhei/Developer/docker/todo-list-fabricV1/todo-list-fabric-server/node_modules/express/lib/router/index.js:335:12)

I saw inside couchDB
2017-11-11 22 53 22

Is there a mistake in the procedure I did?

create channel issue

I'm running into an issue when i run this command
node test/integration/e2e/create-channel.js

node version : v8.12.0
npm version : 6.4.1

module.js:550
throw err;
^

Error: Cannot find module '/Users/[email protected]/Client/BlockChain/todo-list-fabricV1/fabric-sdk-node/node_modules/grpc/src/node/extension_binary/grpc_node.node'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object. (/Users/[email protected]/Client/BlockChain/todo-list-fabricV1/fabric-sdk-node/node_modules/grpc/src/node/src/grpc_extension.js:38:15)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)

Error starting peers

When I use docker-compose to start I see this message in all the peers and the orderer.

2017-08-17 17:31:04.548 UTC [main] main -> ERRO 001 Cannot run peer because error when setting up MSP from directory /etc/hyperledger/msp/peer/: err admin 0 is invalid, validation error Could not obtain certification chain, err A CA certificate cannot be used directly by this MSP

I am not able to workout what the message is telling me.

Also, the yaml file just specifies image: couchdb - should this be image: hyperledger-couchdb?

Authentication is not defined

Hi,

After starting up the web server (step 6 in the tutorial), I cannot log in nor load the data by clicking the IBM logo. The following error occurs:

ReferenceError: Authentication is not defined toodles.js:10:5

Logging in the console showed me that toodles.js is being loaded before toodles-authentication.html, so the Authentication class doesn't exist yet when it is requested in toodles.js. Loading toodles.js earlier isn't workable either, since the <toodles-authentication> element wouldn't exist yet.

Any suggestions on how to fix this?

Fail to create a channel

After node test/integration/e2e/create-channel.js, I got the following message:

info: Returning a new winston logger with default configurations
TAP version 13
#

***** End-to-end flow: create channel *****


info: [Client.js]: Failed to load user "admin" from local key value store
info: [FabricCAClientImpl.js]: Successfully constructed Fabric CA client from options - {"protocol":"http","hostname":"localhost","port":7054}
info: [FabricCAClientImpl.js]: Successfully constructed Fabric CA service client: endpoint - {"protocol":"http","hostname":"localhost","port":7054}
info: [crypto_ecdsa_aes]: This class requires a CryptoKeyStore to save keys, using the store: {"opts":{"path":"/Users/velen/.hfc-key-store"}}
not ok 1 Error: Could not parse enrollment response [404 page not found ] as JSON due to error [SyntaxError: Unexpected token pin JSON at position 4] at IncomingMessage.<anonymous> (/Users/velen/Desktop/blockChain/todo-app/fabric-sdk-node/node_modules/[email protected]@fabric-ca-client/lib/FabricCAClientImpl.js:560:14) at emitNone (events.js:91:20) at IncomingMessage.emit (events.js:185:7) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9)
  ---
    operator: fail
    at: cop.enroll.then.then.then.catch (/Users/velen/Desktop/blockChain/todo-app/fabric-sdk-node/test/unit/util.js:119:8)
    stack: |-
      Error: Error: Could not parse enrollment response [404 page not found
      ] as JSON due to error [SyntaxError: Unexpected token p in JSON at position 4]
          at IncomingMessage.<anonymous> (/Users/velen/Desktop/blockChain/todo-app/fabric-sdk-node/node_modules/[email protected]@fabric-ca-client/lib/FabricCAClientImpl.js:560:14)
          at emitNone (events.js:91:20)
          at IncomingMessage.emit (events.js:185:7)
          at endReadableNT (_stream_readable.js:974:12)
          at _combinedTickCallback (internal/process/next_tick.js:74:11)
          at process._tickCallback (internal/process/next_tick.js:98:9)
          at Test.assert [as _assert] (/Users/velen/Desktop/blockChain/todo-app/fabric-sdk-node/node_modules/[email protected]@tape/lib/test.js:225:54)
          at Test.bound [as _assert] (/Users/velen/Desktop/blockChain/todo-app/fabric-sdk-node/node_modules/[email protected]@tape/lib/test.js:77:32)
          at Test.fail (/Users/velen/Desktop/blockChain/todo-app/fabric-sdk-node/node_modules/[email protected]@tape/lib/test.js:318:10)
          at Test.bound [as fail] (/Users/velen/Desktop/blockChain/todo-app/fabric-sdk-node/node_modules/[email protected]@tape/lib/test.js:77:32)
          at cop.enroll.then.then.then.catch (/Users/velen/Desktop/blockChain/todo-app/fabric-sdk-node/test/unit/util.js:119:8)
          at process._tickCallback (internal/process/next_tick.js:103:7)
  ...

1..1
# tests 1
# pass  0
# fail  1

I got this problem Failed to load user "admin" from local key value store

When I run this command:

node test/integration/e2e/create-channel.js

I got this Error Message:

info: [Client.js]: Failed to load user "admin" from local key value store
info: [FabricCAClientImpl.js]: Successfully constructed Fabric CA client from options - {"protocol":"http","hostname":"localhost","port":7054}
info: [FabricCAClientImpl.js]: Successfully constructed Fabric CA service client: endpoint - {"protocol":"http","hostname":"localhost","port":7054}
info: [crypto_ecdsa_aes]: This class requires a CryptoKeyStore to save keys, using the store: {"opts":{"path":"/root/.hfc-key-store"}}
not ok 1 Error: Could not parse enrollment response [404 page not found ] as JSON due to error [SyntaxError: Unexpected token p in JSON at position 4] at IncomingMessage.<anonymous> (/usr/local/dockerImages/fabric-sdk-node/node_modules/fabric-ca-client/lib/FabricCAClientImpl.js:560:14) at emitNone (events.js:91:20) at IncomingMessage.emit (events.js:185:7) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9)
  ---
    operator: fail
    at: cop.enroll.then.then.then.catch (/usr/local/dockerImages/fabric-sdk-node/test/unit/util.js:116:8)
    stack: |-
      Error: Error: Could not parse enrollment response [404 page not found
      ] as JSON due to error [SyntaxError: Unexpected token p in JSON at position 4]
          at IncomingMessage.<anonymous> (/usr/local/dockerImages/fabric-sdk-node/node_modules/fabric-ca-client/lib/FabricCAClientImpl.js:560:14)
          at emitNone (events.js:91:20)
          at IncomingMessage.emit (events.js:185:7)
          at endReadableNT (_stream_readable.js:974:12)
          at _combinedTickCallback (internal/process/next_tick.js:74:11)
          at process._tickCallback (internal/process/next_tick.js:98:9)
          at Test.assert [as _assert] (/usr/local/dockerImages/fabric-sdk-node/node_modules/tape/lib/test.js:224:54)
          at Test.bound [as _assert] (/usr/local/dockerImages/fabric-sdk-node/node_modules/tape/lib/test.js:76:32)
          at Test.fail (/usr/local/dockerImages/fabric-sdk-node/node_modules/tape/lib/test.js:317:10)
          at Test.bound [as fail] (/usr/local/dockerImages/fabric-sdk-node/node_modules/tape/lib/test.js:76:32)
          at cop.enroll.then.then.then.catch (/usr/local/dockerImages/fabric-sdk-node/test/unit/util.js:116:8)
          at process._tickCallback (internal/process/next_tick.js:103:7)
  ...

1..1
# tests 1
# pass  0
# fail  1

I try to analyze the source code. I realize that when I debug in fabric-sdk-node/test/unit/util.js on 104 line:

return cop.enroll({
enrollmentID: username,
enrollmentSecret: password
})

it seems like cop can not invoke its method enroll(req). Because I input console.log("test") in fabric-sdk-node/fabric-ca-client/lib/FabricCAClientImpl.js on 121 line:

/**
* Enroll the member and return an opaque member object.
* @param req Enrollment request
* @param {string} req.enrollmentID The registered ID to use for enrollment
* @param {string} req.enrollmentSecret The secret associated with the enrollment ID
* @returns Promise for an object with "key" for private key and "certificate" for the signed certificate
*/
enroll(req) {
console.log("test");
var self = this;

I restart command:

node test/integration/e2e/create-channel.js

but no "test" on my console. Can somebody help me to sovle this problem? Thanks

[email protected] install: `node-gyp configure build`

I followed the instructions at the command input stage:

node test / integration / e2e / join-channel.js

info: Returning a new winston logger with default configurations
module.js: 471
throw err;
^

Error: Can not find module 'hashtable'
at Function.Module._resolveFilename (module.js: 469: 15)
....

Then I tried to install the hashtable

npm install hashtable

[email protected] install /root/todo-list-fabricV1/fabric-sdk-node/node_modules/hashtable
node-gyp configure build

make: Entering directory '/root/todo-list-fabricV1/fabric-sdk-node/node_modules/hashtable/build'
CXX(target) Release/obj.target/native/src/hashtable.o
make: g++: Command not found
native.target.mk:98: recipe for target 'Release/obj.target/native/src/hashtable.o' failed
make: *** [Release/obj.target/native/src/hashtable.o] Error 127
make: Leaving directory '/root/todo-list-fabricV1/fabric-sdk-node/node_modules/hashtable/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/root/.nvm/versions/node/v6.9.5/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.4.0-112-generic
gyp ERR! command "/root/.nvm/versions/node/v6.9.5/bin/node" "/root/.nvm/versions/node/v6.9.5/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /root/todo-list-fabricV1/fabric-sdk-node/node_modules/hashtable
gyp ERR! node -v v6.9.5
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! Linux 4.4.0-112-generic
npm ERR! argv "/root/.nvm/versions/node/v6.9.5/bin/node" "/root/.nvm/versions/node/v6.9.5/bin/npm" "install" "hashtable"
npm ERR! node v6.9.5
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node-gyp configure build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp configure build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the hashtable package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp configure build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs hashtable
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls hashtable
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /root/todo-list-fabricV1/fabric-sdk-node/npm-debug.log

my mistake

Error: instantiate-chaincode.js

Env:

Go: v1.8.3
Node: v6.10.3
Docker: v17.09.0-ce
Docker-Compose: v1.17.0

Expecation: node test/integration/e2e/instantiate-chaincode.js

Result Error:

RPC client got an error response from the peer "grpc://localhost:7051". Error: Error starting container: Failed to generate platform-specific docker build: Error returned from build: 1 "can't load package: package github.com/example_cc: no buildable Go source files in /chaincode/input/src/github.com/example_cc " at /home/goodfaith/fabric-sdk-node/node_modules/grpc/src/node/src/client.js:434:17

Created the directory /chaincode/input... and copied the src with the rest of the file directory. Got the same error message.

Error:

` Returning a new winston logger with default configurations
TAP version 13

***** End-to-end flow: instantiate chaincode *****
info: [Peer.js]: Peer.const - url: grpc://localhost:7051 options grpc.ssl_target_name_override=peer0, grpc.default_authority=peer0
info: [Peer.js]: Peer.const - url: grpc://localhost:8051 options grpc.ssl_target_name_override=peer2, grpc.default_authority=peer2
info: [crypto_ecdsa_aes]: This class requires a CryptoKeyStore to save keys, using the store: {"opts":{"path":"/home/goodfaith/.hfc-key-store"}}
info: [Client.js]: Successfully loaded user "admin" from local key value store
ok 1 Successfully loaded member from persistence
ok 2 Successfully enrolled user 'admin'
error: [Peer.js]: GRPC client got an error response from the peer "grpc://localhost:8051". Error: Error starting container: Failed to generate platform-specific docker build: Error returned from build: 1 "can't load package: package github.com/example_cc: no buildable Go source files in /chaincode/input/src/github.com/example_cc
"
at /home/goodfaith/fabric-sdk-node/node_modules/grpc/src/node/src/client.js:434:17
error: [Chain.js]: Chain-sendPeersProposal - Promise is rejected: Error: Error starting container: Failed to generate platform-specific docker build: Error returned from build: 1 "can't load package: package github.com/example_cc: no buildable Go source files in /chaincode/input/src/github.com/example_cc
"
at /home/goodfaith/fabric-sdk-node/node_modules/grpc/src/node/src/client.js:434:17
error: [Peer.js]: GRPC client got an error response from the peer "grpc://localhost:7051". Error: Error starting container: Failed to generate platform-specific docker build: Error returned from build: 1 "can't load package: package github.com/example_cc: no buildable Go source files in /chaincode/input/src/github.com/example_cc
"
at /home/goodfaith/fabric-sdk-node/node_modules/grpc/src/node/src/client.js:434:17
error: [Chain.js]: Chain-sendPeersProposal - Promise is rejected: Error: Error starting container: Failed to generate platform-specific docker build: Error returned from build: 1 "can't load package: package github.com/example_cc: no buildable Go source files in /chaincode/input/src/github.com/example_cc
"
at /home/goodfaith/fabric-sdk-node/node_modules/grpc/src/node/src/client.js:434:17
error: [install-chaincode]: instantiate proposal was bad
error: [install-chaincode]: instantiate proposal was bad
not ok 3 Failed to send instantiate Proposal or receive valid response. Response null or status is not 200. exiting...

operator: fail
at: hfc.newDefaultKeyValueStore.then.then.then.then (/home/goodfaith/fabric-sdk-node/input/integration/e2e/instantiate-chaincode.js:228:6)
stack: |-
  Error: Failed to send instantiate Proposal or receive valid response. Response null or status is not 200. exiting...
      at Test.assert [as _assert] (/home/goodfaith/fabric-sdk-node/node_modules/tape/lib/test.js:212:54)
      at Test.bound [as _assert] (/home/goodfaith/fabric-sdk-node/node_modules/tape/lib/test.js:64:32)
      at Test.fail (/home/goodfaith/fabric-sdk-node/node_modules/tape/lib/test.js:277:10)
      at Test.bound [as fail] (/home/goodfaith/fabric-sdk-node/node_modules/tape/lib/test.js:64:32)
      at hfc.newDefaultKeyValueStore.then.then.then.then (/home/goodfaith/fabric-sdk-node/input/integration/e2e/instantiate-chaincode.js:228:6)
      at process._tickCallback (internal/process/next_tick.js:109:7)

...
not ok 4 Error: Failed to send instantiate Proposal or receive valid response. Response null or status is not 200. exiting... at hfc.newDefaultKeyValueStore.then.then.then.then (/home/goodfaith/fabric-sdk-node/input/integration/e2e/instantiate-chaincode.js:229:10) at process._tickCallback (internal/process/next_tick.js:109:7)

operator: fail
at: hfc.newDefaultKeyValueStore.then.then.then.then.then (/home/goodfaith/fabric-sdk-node/input/integration/e2e/instantiate-chaincode.js:246:5)
stack: |-
  Error: Error: Failed to send instantiate Proposal or receive valid response. Response null or status is not 200. exiting...
      at hfc.newDefaultKeyValueStore.then.then.then.then (/home/goodfaith/fabric-sdk-node/input/integration/e2e/instantiate-chaincode.js:229:10)
      at process._tickCallback (internal/process/next_tick.js:109:7)
      at Test.assert [as _assert] (/home/goodfaith/fabric-sdk-node/node_modules/tape/lib/test.js:212:54)
      at Test.bound [as _assert] (/home/goodfaith/fabric-sdk-node/node_modules/tape/lib/test.js:64:32)
      at Test.fail (/home/goodfaith/fabric-sdk-node/node_modules/tape/lib/test.js:277:10)
      at Test.bound [as fail] (/home/goodfaith/fabric-sdk-node/node_modules/tape/lib/test.js:64:32)
      at hfc.newDefaultKeyValueStore.then.then.then.then.then (/home/goodfaith/fabric-sdk-node/input/integration/e2e/instantiate-chaincode.js:246:5)
      at process._tickCallback (internal/process/next_tick.js:109:7)

...
info: [install-chaincode]: Disconnecting the event hub
info: [install-chaincode]: Disconnecting the event hub
not ok 5 Error: Error: Failed to send instantiate Proposal or receive valid response. Response null or status is not 200. exiting... at hfc.newDefaultKeyValueStore.then.then.then.then (/home/goodfaith/fabric-sdk-node/input/integration/e2e/instantiate-chaincode.js:229:10) at process._tickCallback (internal/process/next_tick.js:109:7)

operator: error
expected: |-
  undefined
actual: |-
  [Error: Error: Failed to send instantiate Proposal or receive valid response. Response null or status is not 200. exiting...
at hfc.newDefaultKeyValueStore.then.then.then.then (/home/goodfaith/fabric-sdk-node/input/integration/e2e/instantiate-chaincode.js:229:10)
at process._tickCallback (internal/process/next_tick.js:109:7)]
at: Test.onetime (/home/goodfaith/fabric-sdk-node/node_modules/onetime/index.js:22:12)
stack: |-
  Error: Error: Failed to send instantiate Proposal or receive valid response. Response null or status is not 200. exiting...
      at hfc.newDefaultKeyValueStore.then.then.then.then (/home/goodfaith/fabric-sdk-node/input/integration/e2e/instantiate-chaincode.js:229:10)
      at process._tickCallback (internal/process/next_tick.js:109:7)
      at hfc.newDefaultKeyValueStore.then.then.then.then.then (/home/goodfaith/fabric-sdk-node/input/integration/e2e/instantiate-chaincode.js:247:9)
      at process._tickCallback (internal/process/next_tick.js:109:7)

...

1..5

tests 5

pass 2

fail 3`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.