hyperledger-fabric "Writing your first Application" query.js step fails - node.js

Steps "git clone...", "startFabric.sh" and "npm.install" complete with no errors. "node query.js" results in:
Set wallet path, and associate user PeerAdmin with application
error: [Client.js]: Failed to load user "PeerAdmin" from local key value store. Error: TypeError: this is not a typed array.
at Function.from (native)
at importKey (/home/peter/fabric-samples/fabcar/node_modules/fabric-client/lib/impl/CryptoSuite_ECDSA_AES.js:180:26)
at fromString (/home/peter/fabric-samples/fabcar/node_modules/fabric-client/lib/User.js:228:28)
at /home/peter/fabric-samples/fabcar/node_modules/fabric-client/lib/Client.js:968:22
error: [Client.js]: Failed to load an instance of requested user "PeerAdmin" from the state store on this Client instance. Error: TypeError: this is not a typed array.
at Function.from (native)
at importKey (/home/peter/fabric-samples/fabcar/node_modules/fabric-client/lib/impl/CryptoSuite_ECDSA_AES.js:180:26)
at fromString (/home/peter/fabric-samples/fabcar/node_modules/fabric-client/lib/User.js:228:28)
at /home/peter/fabric-samples/fabcar/node_modules/fabric-client/lib/Client.js:968:22
Caught Error [TypeError: this is not a typed array.]
Note: after the git clone step, there is no "chaincode" in fabric-samples/fabcar as stated in the docs, but there is a chaincode/fabcar in fabric-samples. This does not seem to cause a problem.
Note: All steps in "Building Your First Network" complete with no problems.

Hyperledger Fabric 1.0 has been tested against Node.js version >= 6.9 and < 7.x. If you get a similar error, recommend updating the version of Node.js (or use a version manager such as nvm) and re-try. If you have already run npm install with an older version of Node, you should delete the node_modules tree and re-run npm install to be sure you are installing the correct dependencies.

Related

network id specified in truffle config does not match the one returned by network

I'm trying to run a truffle test on ganache-cli and it keeps saying the network ids do not match even though in my truffle-config.js file I specified the id to be 5777 not 4447
Error: The network id specified in the truffle config (4447) does not match the one returned by the network (5777). Ensure that both the network and the provider are properly configured.
at Object.detectAndSetNetworkId (/Users/rbeit/.npm-global/lib/node_modules/truffle/build/webpack:/packages/truffle-core/lib/environment.js:94:1)
at processTicksAndRejections (internal/process/task_queues.js:89:5)
at Object.detect (/Users/rbeit/.npm-global/lib/node_modules/truffle/build/webpack:/packages/truffle-core/lib/environment.js:22:1)
at Object.develop (/Users/rbeit/.npm-global/lib/node_modules/truffle/build/webpack:/packages/truffle-core/lib/environment.js:71:1)
Truffle v5.0.21 (core: 5.0.21)
Node v12.3.1
!Vande Maataram!
You must have cloned the project directly from the github repository (https://github.com/aelshayeb/blockchain) and started compiling and running this .... try this ... just do it.
->npm uninstall truffle -g
->npm install truffle -g (this and the previous ensures running the most current version, now 5.0.4)
->mkdir metacoin
->cd metacoin
->truffle unbox metacoin (try this)
now open the truffle-config.js in the meta coin folder and uncomment the truffle-config.js: "default values".
now you can use:
*truffle compile,
*truffle migrate,
*truffle test;
but, first check the following things:
1. your blockchain network_id is same as reffered in the truffle-config.js.
2. if you run on private net so, check the hostIP and portnumber and network_id before you set start.
Go on Enjoy Coding!!
||Krinavantovishwamaryam||

hyperledger fabric devmode

I am trying to deploy chaincode in devmod on my ubuntu machine. I am following this tutorial.
The issue is when I use this command : CORE_CHAINCODE_LOGLEVEL=debug CORE_PEER_ADDRESS=localhost:7052 npm start
it shows the following error:
2018-09-20T16:27:18.292Z ERROR [lib/handler.js] uncaughtException: The "peer.address" program argument must be set to a legitimate value of <host>:<port>
Full logs can be found here:
https://hastebin.com/arerozesad.sql
I am following this tutorial:
https://hyperledger-fabric.readthedocs.io/en/v1.0.6/peer-chaincode-devmode.html
First, I hope you are using Fabric v1.1 or later as Node.js chaincode is not supported in v1.0.x.
The instructions you listed are for running Go chaincode.
For Node.js chaincode, your command should look like
CORE_CHAINCODE_ID_NAME="mycc:v0" node mycc.js --peer.address grpc://localhost:7052
You should be able to replace node mycc.js with npm start as well.
See https://github.com/hyperledger/fabric-chaincode-node#test-nodejs-chaincode for more information.

(block chain marbles sample) Error: Missing parameter. Must have a username

I am new to block chain and hyperledger-fabric, I am trying to setup Marbles sample application. I followed tutorial
Use Local Hyperledger Network
While executing this command (node enrollAdmin.js) i got following error.
Node version : v6.2.1
Npm Version : 3.9.3
Docker Version: 18.03.1-ce
$ node enrollAdmin.js
Store path:/opt/blockchain/fabric-samples/fabcar/hfc-key-store
Successfully enrolled admin user "admin"
error: [Client.js]: Error: Missing parameter. Must have a username.
at _setUserFromConfig (/opt/blockchain/fabric-samples/fabcar/node_modules/fabric-client/lib/Client.js:1280:27)
at Promise (/opt/blockchain/fabric-samples/fabcar/node_modules/fabric-client/lib/Client.js:1432:11)
at setUserContext (/opt/blockchain/fabric-samples/fabcar/node_modules/fabric-client/lib/Client.js:1413:10)
at promise.then.then.then.then (/opt/blockchain/fabric-samples/fabcar/node_modules/fabric-client/lib/Client.js:1692:17)
Error: Failed to load key or certificate and save to local stores.
at promise.then.then.then.then.then.catch (/opt/blockchain/fabric-samples/fabcar/node_modules/fabric-client/lib/Client.js:1702:19)
Failed to enroll admin: Error: Failed to enroll admin
Could anyone help me to resolve this error?
Thanks in advance.
it got worked when i ran following command
$ sudo node enrollAdmin.js

Event Hub has been Shutdown on Fabric Writing your first Application

I am currently trying to run through the example first application for Hyperledger Fabric here -> http://hyperledger-fabric.readthedocs.io/en/release-1.1/write_first_app.html
I am unable to get past calling node invoke.js
Originally I was getting the same error as this question Error invoking chaincode using Node.js SDK [TypeError: Cannot read property 'getConnectivityState' of undefined]
But after reverting to grpc#1.9.1 I get the following result:
I am able to do everything up to the node query.js method and that returns successfully but can't quite get past this.
Node version: 8.11.1
Docker Version:
fabric client section of package-lock.json
FYI: I am trying to run on Windows 10 mostly using the docker toolbox bash, or a separate git bash CLI.
Last piece of info!
Even though the invoke js command fails with the above error, I can see that the PUT command to couch db does go through and car10 has been successfully added.
If I check the docker logs for peer0.org1.example.com I see the following:
So did it actually work?

Error while updating business network in CLI tutorial

I am following along the Getting Started with Fabric Command Line and have run into a error I don't understand how to resolve. Any ideas?
In the section entitled "Update the deployed business network" an exception is thrown. The terminal output is below. The command used:
composer network update --archiveFile digitalproperty-network#0.0.7.bna --enrollId WebAppAdmin --enrollSecret DJY27pEnl16d
Note that the id is different from the tutorial as the 0.0.7 id was reported during the previous step while creating. The output continued...
Deploying business network from archive digitalproperty-network#0.0.7.bna
Business network definition:
Identifier: digitalproperty-network#0.0.7
Description: Digital Property Network
events.js:160
throw er; // Unhandled 'error' event
^
Error
at ClientDuplexStream._emitStatusIfDone (/home/mnjacobs/.nvm/versions/node/v6.9.5/lib/node_modules/composer-cli/node_modules/grpc/src/node/src/client.js:189:19)
at ClientDuplexStream._readsDone (/home/mnjacobs/.nvm/versions/node/v6.9.5/lib/node_modules/composer-cli/node_modules/grpc/src/node/src/client.js:158:8)
at readCallback (/home/mnjacobs/.nvm/versions/node/v6.9.5/lib/node_modules/composer-cli/node_modules/grpc/src/node/src/client.js:217:12)
I've struggled to get the versions to match the tutorials - they seem inconsistent. Notably, the node (v6.9.5) and nodejs (v6.10.1) versions differ even though node is a symbolic link to nodejs and I notice 6.9.5 is in the stack trace. I'm not sure that difference is relevant to the problem.
Other version information:
Ubuntu 14.04.5
Docker version 17.03.1-ce, build c6d412e (manually installed as auto
install was down level)
docker-compose version 1.12.0-rc2, build 08dc2a4
I've seen exactly that error when Hyperledger Fabric isn't running. If docker ps doesn't show anything, run npm run startHLF in the sample-applications/packages/getting-started directory before trying again.

Resources