Hyperledger Fabric super ledger learning [14] Fabcar instance - call chain code through Nodejs command

The Node Npm version corresponding to the Hyperledger Fabric2.X network needs to be upgraded in the future. The default version is too low, and an error will be reported later

insert image description here

Start the Fabcar network

./startFabric.sh javascript

insert image description here

report error

insert image description here

Run the following command to kill the currently running or active container:

docker rm -f $(docker ps -aq)

Clear all cached networks:

docker network prune

Add mapping file

127.0.0.1 peer0.org1.example.com
127.0.0.1 peer0.org2.example.com
127.0.0.1 ca.org2.example.com
127.0.0.1 ca.org1.example.com
127.0.0.1 orderer.example.com
127.0.0.1 peer1.org1.example.com

Enter the javascript directory

cd javascript

Install npm inside this folder

Just install it on first run, after that you can skip
npm to enable the app to connect to channels, submit transactions and wait for notifications using identities, wallets and gateways.

sudo npm install

insert image description here

Execute registration, creation, and query work through the command line

node enrollAdmin.js
node registerUser.js
node query.js

error 2

error: [Channel.js]: Channel:mychannel received discovery error:access denied

 [Channel.js]: Error: Channel:mychannel Discovery error:access denied

Channel.js]: Channel:mychannel received discovery error:access denied

Network]: _initializeInternalChannel: Unable to initialize channel. Attempted to contact 2 Peers. Last error was Error: Channel:mychannel Discovery error:access denied

    at Channel._discover (/home/mxj/go/src/github.com/hyperledger/fabric-samples/fabcar/javascript/node_modules/fabric-client/lib/Channel.js:1254:11)

    at async Channel._initialize (/home/mxj/go/src/github.com/hyperledger/fabric-samples/fabcar/javascript/node_modules/fabric-client/lib/Channel.js:282:32)
    at async Channel.initialize (/home/mxj/go/src/github.com/hyperledger/fabric-samples/fabcar/javascri

Solve the error

Enter the wallet folder, delete all the following two files, and run the following command again
insert image description here

Successfully invoked the chaincode to query the parameters

insert image description here

Guess you like

Origin blog.csdn.net/weixin_42694422/article/details/131030792