Cannot get state in Hyperledger fabric correctly? - hyperledger-fabric

Problem:
I have developed a Hyperledger fabric network and after that, I install a chain code in there. This is my Initialize ledger methods looks like.
async initLedger(stub, args) {
console.info("============= START : Initialize Ledger ===========");
let drivers = [];
drivers.push({
nic: "123",
firstName: "Saman",
lastName: "Frenando",
status: "Not verified",
licenceNo: "1234"
});
drivers.push({
nic: "124",
firstName: "Janith",
lastName: "Bentharaarachchi",
status: "Not verified",
licenceNo: "1235"
});
for (let i = 0; i < drivers.length; i++) {
drivers[i].docType = "driver";
console.log(drivers[i].nic);
await stub.putState(
drivers[i].nic,
Buffer.from(JSON.stringify(drivers[i]))
);
console.info("Added <--> ", drivers[i]);
}
console.info("============= END : Initialize Ledger ===========");
}
This is how I am retrieving those data.
async selectNthDriver(stub, args) {
if (args.length != 1) {
throw new Error(
"Incorrect number of arguments. Expecting NIC ex: 123"
);
}
let nic = args[0];
console.log(`nic: ${nic}`);
let driverAsBytes = await stub.getState(nic);
console.log("hi"+driverAsBytes);
if (!driverAsBytes || driverAsBytes.toString().length <= 0) {
throw new Error("Driver with NIC" + nic + " does not exist");
}
console.log(driverAsBytes.toString());
return driverAsBytes;
}
When I am Issuing this command on peer it successfully initializes the ledger.
peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C myc -n mycc -c '{"Args":["initLedger"]}'
By Issuing the following command when I try to retrieve a driver it leaves me an error by saying this.
Error: endorsement failure during invoke. response: status:500 message:"transaction returned with failure: Error: Driver with NIC123 does not exist"
peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C myc -n mycc -c '{"Args":["selectNthDriver","123"]}
This is the chaincode logs.
2019-05-09T05:18:51.184Z info [lib/handler.js]
info: [myc-09f261c4] Calling chaincode Init() succeeded.
Sending COMPLETED message back to peer
{"timestamp":"2019-05-09T05:18:51.184Z"} { fcn: 'initLedger', params:
[] }
============= START : Initialize Ledger =========== 123 Added <--> { nic: '123', firstName: 'Saman', lastName: 'Fernando', status:
'Not verified', licenceNo: '1234', docType: 'driver' } 124 Added
<--> { nic: '124', firstName: 'Janith', lastName:
'Bentharaarachchi', status: 'Not verified', licenceNo: '1235',
docType: 'driver' }
============= END : Initialize Ledger =========== { fcn: 'selectNthDriver', params: [ '123' ] } nic: 123 hi
Error: Driver with NIC123 does not exist
at selectNthDriver (/usr/local/src/mycc.js:494:13)
at
at process._tickCallback (internal/process/next_tick.js:188:7) 2019-05-09T05:43:42.430Z error [lib/handler.js]
error: [myc-e7aef847] Calling chaincode Invoke() returned
error response [Error: Driver with NIC123 does not exist].
Sending ERROR message back to peer
{"timestamp":"2019-05-09T05:43:42.430Z"}
And when I go to the CouchDB through browser It is not showing the data I initialized. It only shows this data.
{
"_id": "mycc",
"_rev": "1-5c5ecfec35f65ec74cbe52a52be96048",
"~version": "\u0000CgMBBwA=",
"_attachments": {
"valueBytes": {
"content_type": "application/octet-stream",
"revpos": 1,
"digest": "md5-SkPMcpW++nrvo5v00rCdRQ==",
"length": 424,
"stub": true
}
}
}
Can someone help me to find where am I doing wrong? Thank you.

You should use "query" command for querying a state from the ledger using the peer binary, the invoke command which you have used is for generating a transaction, which is not required for a query operation.
You should just try replacing invoke with query and it should look something like this:
peer chaincode query -o orderer.example.com:7050 -C myc -n mycc -c '{"Args":["selectNthDriver","123"]}
EDIT: Also please check for the following condition in your if statement in the selectNthDriver Method:
if (!driverAsBytes.toString())
Also please console for the same(driverAsBytes.toString()) in the line just before this if statement in your code.

Related

Error while I run a p. benchmark with Hyperledger Caliper: No valid responses from any peers, chaincode registration failed: container exited with 0

I want to run a performance benchmark for the contract (which is writen in typescript) from this repository:https://github.com/AleRapchan/hyperledger-supply-chain
So, I am using Hyperledger Caliper based on this tutorial: https://hyperledger.github.io/caliper/v0.5.0/fabric-tutorial/tutorials-fabric-existing/
to run the performance benchmark and I followed these steps:
Steps followed:
I have clonned this repo as I mentioned before: https://github.com/AleRapchan/hyperledger-supply-chain and, at the same level, I created the caliper-workspace folder as the tutorial said.
I created the channel "mychannel" and deployed the chaincode respectively.
./network.sh up createChannel -ca -s couchdb
./network.sh deployCC -ccn supplychain -ccp ../../chaincode -ccl typescript
I have configured the three caliper files as shown below (myAssetBenchmark.yaml, networkConfig.yaml, readAsset.js) into the caliper-workspace folder.
I have installed the caliper dependencies in the caliper-workspace folder.
npm install --only=prod #hyperledger/caliper-cli#0.5.0
npx caliper bind --caliper-bind-sut fabric:2.2
At the same directory, I run the performance benchmark with the following command:
npx caliper launch manager --caliper-workspace ./ --caliper-networkconfig networks/networkConfig.yaml --caliper-benchconfig benchmarks/myAssetBenchmark.yaml --caliper-flow-only-test
but I got the following errors:
Error 1
error: [Transaction]: Error: No valid responses from any peers. Errors:
peer=peer0.org2.example.com:9051, status=500, message=error in simulation: failed to execute transaction b6cc9ab28537a5539aa0876a823a679a952dee1232540e8efbe1ad01e02ebfbb: could not launch chaincode supplychain_1.0:a38d65123f915a15106ad4d0f8893b0880ed2979ddcc84106b9267f5ee31ddd4: chaincode registration failed: container exited with 0
peer=peer0.org1.example.com:7051, status=500, message=error in simulation: failed to execute transaction b6cc9ab28537a5539aa0876a823a679a952dee1232540e8efbe1ad01e02ebfbb: could not launch chaincode supplychain_1.0:a38d65123f915a15106ad4d0f8893b0880ed2979ddcc84106b9267f5ee31ddd4: chaincode registration failed: container exited with 0
Error 2
error [caliper] [connectors/v2/FabricGateway] Failed to perform submit transaction [createProduct] using arguments [1_0,1234567890,50,Fruit Juices,,2022-06-24T18:25:43.511Z,{},Apple Juice,Etobicoke, ON, Canada,2021-06-24T18:25:43.511Z,$9.00,200,ml], with error: Error: No valid responses from any peers. Errors:
peer=peer0.org2.example.com:9051, status=500, message=error in simulation: failed to execute transaction 5837e5ab8b41016290a3d204f4ffde53bad977e917eb1ae53784623959d4e359: could not launch chaincode supplychain_1.0:a38d65123f915a15106ad4d0f8893b0880ed2979ddcc84106b9267f5ee31ddd4: chaincode registration failed: container exited with 0
peer=peer0.org1.example.com:7051, status=500, message=error in simulation: failed to execute transaction 5837e5ab8b41016290a3d204f4ffde53bad977e917eb1ae53784623959d4e359: could not launch chaincode supplychain_1.0:a38d65123f915a15106ad4d0f8893b0880ed2979ddcc84106b9267f5ee31ddd4: chaincode registration failed: container exited with 0
myAssetBenchmark.yaml
test:
name: basic-contract-benchmark
description: test benchmark
workers:
number: 2
rounds:
- label: readAsset
description: Read asset benchmark
txDuration: 30
rateControl:
type: fixed-load
opts:
transactionLoad: 2
workload:
module: workload/readAsset.js
arguments:
assets: 10
contractId: supplychain
networkConfig.yaml
name: Caliper test
version: "2.0.0"
caliper:
blockchain: fabric
channels:
- channelName: mychannel
contracts:
- id: supplychain
organizations:
- mspid: Org1MSP
identities:
certificates:
- name: 'User1'
clientPrivateKey:
path: '../hyperledger-supply-chain/network/fabric-network/organizations/peerOrganizations/org1.example.com/users/User1#org1.example.com/msp/keystore/46d82eb2dbaed33f941f9a39394bba7b5167d09d116ba563de1675f22b083d3e_sk'
clientSignedCert:
path: '../hyperledger-supply-chain/network/fabric-network/organizations/peerOrganizations/org1.example.com/users/User1#org1.example.com/msp/signcerts/cert.pem'
connectionProfile:
path: '../hyperledger-supply-chain/network/fabric-network/organizations/peerOrganizations/org1.example.com/connection-org1.yaml'
discover: true
readAsset.js
'use strict';
const { WorkloadModuleBase } = require('#hyperledger/caliper-core');
class MyWorkload extends WorkloadModuleBase {
constructor() {
super();
}
async initializeWorkloadModule(workerIndex, totalWorkers, roundIndex, roundArguments, sutAdapter, sutContext) {
await super.initializeWorkloadModule(workerIndex, totalWorkers, roundIndex, roundArguments, sutAdapter, sutContext);
for (let i=0; i<this.roundArguments.assets; i++) {
const id = `${this.workerIndex}_${i}`;
console.log(`Worker ${this.workerIndex}: Creating asset ${id}`);
const request = {
contractId: this.roundArguments.contractId,
contractFunction: 'createProduct',
invokerIdentity: 'User1',
contractArguments: [id, '1234567890', 50, 'Fruit Juices', [],
'2022-06-24T18:25:43.511Z', JSON.stringify({}),'Apple Juice', 'Etobicoke, ON, Canada',
'2021-06-24T18:25:43.511Z','$9.00', 200, 'ml'],
readOnly: false
};
await this.sutAdapter.sendRequests(request);
}
}
async submitTransaction() {
const randomId = Math.floor(Math.random()*this.roundArguments.assets);
const myArgs = {
contractId: this.roundArguments.contractId,
contractFunction: 'readProduct',
invokerIdentity: 'User1',
contractArguments: [`${this.workerIndex}_${randomId}`],
readOnly: true
};
await this.sutAdapter.sendRequests(myArgs);
}
async cleanupWorkloadModule() {
for (let i=0; i<this.roundArguments.assets; i++) {
const assetID = `${this.workerIndex}_${i}`;
console.log(`Worker ${this.workerIndex}: Deleting asset ${assetID}`);
const request = {
contractId: this.roundArguments.contractId,
contractFunction: null,
invokerIdentity: 'User1',
contractArguments: [id],
readOnly: false
};
await this.sutAdapter.sendRequests(request);
}
}
}
function createWorkloadModule() {
return new MyWorkload();
}
module.exports.createWorkloadModule = createWorkloadModule;
PD: I am using WSL2 based engine (Docker Desktop and WSL2).

Failed executing transaction to invoke HyperLedger Fabric function using Kaliedo FabConnect API

I've been using Kaleido's FabConnect API to invoke some transactions from a sample fabric smart contract using this request:
curl -X 'POST'
'https://u0jzrmv8ok-u0nh6n12o1-connect.us0-aws-ws.kaleido.io/transactions?fly-sync=true'
-H 'accept: /'
-H 'Content-Type: application/json'
-d '{
"headers": {
"type": "SendTransaction",
"signer": "user2",
"channel": "ustrades",
"chaincode": "asset_transfer"
},
"func": "GetAllAssets",
"args": [
"string"
],
"init": false
}'
but I get the following error: {
"error": "Failed to submit: error getting channel response for channel [ustrades]: Discovery status Code: (11) UNKNOWN. Description: error received from Discovery Server: failed constructing descriptor for chaincodes:<name:"asset_transfer" > "
}
I've seen a similar problem where the solution offered was to add anchor peer nodes, but how exactly do you do that on Kaleido. Their customer support is slow getting back to me, so I thought I'd ask here.

Error: No valid responses from any peers. Failed to execute transaction could not launch chaincode

I am trying to run the app.js file in the provided asset-transfer-ledger-queries folder with a slight modification.
I made a change to the asset-transfer-ledger-chaincode.js file as shown below:
async CreateAsset(ctx, assetID, color, size, owner, appraisedValue) {
const exists = await this.AssetExists(ctx, assetID);
if (exists) {
throw new Error(`The asset ${assetID} already exists`);
}
// ==== Create asset object and marshal to JSON ====
let asset = {
docType: 'asset',
assetID: assetID,
color: color,
size: size,
owner: owner,
appraisedValue: appraisedValue,
couponID: assetID,
value: color,
expiration: size,
user: sha256(owner),
uuid: uuid.v5(),
redeemed: false
};
basically I just added some properties to the asset object.
After updating the chaincode and running node app.js, I get the following error:
--> Submit Transaction: InitLedger, function creates the initial set of assets on the ledger
2020-12-08T18:22:27.975Z - error: [Transaction]: Error: No valid responses from any peers. Errors:
peer=peer0.org1.example.com:7051, status=500, message=error in simulation: failed to execute transaction 3832a02eeafd57382fb4810bc263d41693764f0d8cb76c27e5613c359b14d42f: could not launch chaincode ledger_1.0:7230409065bcd9da163bc285287935a7d6a3799c99ee59b8a77c93883b607bdb: chaincode registration failed: container exited with 1
peer=peer0.org2.example.com:9051, status=500, message=error in simulation: failed to execute transaction 3832a02eeafd57382fb4810bc263d41693764f0d8cb76c27e5613c359b14d42f: could not launch chaincode ledger_1.0:7230409065bcd9da163bc285287935a7d6a3799c99ee59b8a77c93883b607bdb: chaincode registration failed: container exited with 1
******** initLedger failed :: Error: No valid responses from any peers. Errors:
peer=peer0.org1.example.com:7051, status=500, message=error in simulation: failed to execute transaction 3832a02eeafd57382fb4810bc263d41693764f0d8cb76c27e5613c359b14d42f: could not launch chaincode ledger_1.0:7230409065bcd9da163bc285287935a7d6a3799c99ee59b8a77c93883b607bdb: chaincode registration failed: container exited with 1
peer=peer0.org2.example.com:9051, status=500, message=error in simulation: failed to execute transaction 3832a02eeafd57382fb4810bc263d41693764f0d8cb76c27e5613c359b14d42f: could not launch chaincode ledger_1.0:7230409065bcd9da163bc285287935a7d6a3799c99ee59b8a77c93883b607bdb: chaincode registration failed: container exited with 1
It works fine if I don't make any changes to the chaincode file. Does anyone know what I can do?
I tried to reproduce your situation.
# fabric-samples/test-network
./network.sh down
./network.sh up createChannel -c mychannel -ca
./network.sh deployCC -ccn ledger -ccl javascript
# fabric-samples/asset-transfer-ledger-queries/application-javascript
node -v
# v12.13.1
npm install
node app.js
You can also, see error logs in chaincode container
# check <your_chaincode_container_name>
docker ps -a
# view logs
docker logs <your_chaincode_container_name>
1. Import library [chaincode.js]
#[ERROR CODE] - `node app.js`
--> Submit Transaction: InitLedger, function creates the initial set of assets on the ledger
2020-12-10T00:53:48.061Z - error: [Transaction]: Error: No valid responses from any peers. Errors:
peer=peer0.org2.example.com:9051, status=500, message=error in simulation: transaction returned with failure: ReferenceError: sha256 is not defined
peer=peer0.org1.example.com:7051, status=500, message=error in simulation: transaction returned with failure: ReferenceError: sha256 is not defined
do it
# asset_transfer_ledger_chaincode.js
const {Contract} = require('fabric-contract-api');
const sha256 = require('sha256'); // added
const uuid = require('uuid'); // added
# package.json
"dependencies": {
"fabric-contract-api": "^2.0.0",
"fabric-shim": "^2.0.0", // added ','
"sha256": "^0.2.0", // added
"uuid": "^8.3.2" // added
}
2. Fix wrong module code
#[ERROR CODE] - `node app.js`
--> Submit Transaction: InitLedger, function creates the initial set of assets on the ledger
2020-12-10T01:03:27.583Z - error: [Transaction]: Error: No valid responses from any peers. Errors:
peer=peer0.org1.example.com:7051, status=500, message=error in simulation: failed to execute transaction 62c19fbb84394ba1de399745c46f781078134b84de6b3d73419b9f65c5fa692b: could not launch chaincode ledger_1.0:5303ef138ca9cdb054cd3d814835fffca2706aa0c8e387611b93e4d6d1773742: chaincode registration failed: container exited with 1
peer=peer0.org2.example.com:9051, status=500, message=error in simulation: failed to execute transaction 62c19fbb84394ba1de399745c46f781078134b84de6b3d73419b9f65c5fa692b: could not launch chaincode ledger_1.0:5303ef138ca9cdb054cd3d814835fffca2706aa0c8e387611b93e4d6d1773742: chaincode registration failed: container exited with 1
******** initLedger failed :: Error: No valid responses from any peers. Errors:
peer=peer0.org1.example.com:7051, status=500, message=error in simulation: failed to execute transaction 62c19fbb84394ba1de399745c46f781078134b84de6b3d73419b9f65c5fa692b: could not launch chaincode ledger_1.0:5303ef138ca9cdb054cd3d814835fffca2706aa0c8e387611b93e4d6d1773742: chaincode registration failed: container exited with 1
peer=peer0.org2.example.com:9051, status=500, message=error in simulation: failed to execute transaction 62c19fbb84394ba1de399745c46f781078134b84de6b3d73419b9f65c5fa692b: could not launch chaincode ledger_1.0:5303ef138ca9cdb054cd3d814835fffca2706aa0c8e387611b93e4d6d1773742: chaincode registration failed: container exited with 1
uuid.v4() Create a version 4 (random) UUID
uuid.v5() Create a version 5 (namespace w/ SHA-1) UUID
uuid.v5() requires input parameters
do it
# asset_transfer_ledger_chaincode.js
// ==== Create asset object and marshal to JSON ====
let asset = {
docType: 'asset',
assetID: assetID,
color: color,
size: size,
owner: owner,
appraisedValue: appraisedValue,
couponID: assetID,
value: color,
expiration: size,
user: sha256(owner),
uuid: uuid.v5('Hello, World!', '1b671a64-40d5-491e-99b0-da01ff1f3341'), // modified
redeemed: false
};
3. Result (Solved)
# fabric-samples/asset-transfer-ledger-queries/application-javascript
# node app.js
Loaded the network configuration located at /Users/kmk/Project/src/github.com/hyperledger/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/connection-org1.json
Built a CA Client named ca-org1
Built a file system wallet at /Users/kmk/Project/src/github.com/hyperledger/fabric-samples/asset-transfer-ledger-queries/application-javascript/wallet
Successfully enrolled admin user and imported it into the wallet
Successfully registered and enrolled user appUser and imported it into the wallet
--> Submit Transaction: InitLedger, function creates the initial set of assets on the ledger
*** Result: committed
*** application ending

Can't invoke chaincode from SDK

I can invoke chaincode from my peer by the following command:
peer chaincode invoke -o coreOrderer.dip.com:7050 --tls --cafile /etc/hyperledger/tlsca.dip.com-cert.pem --tlsRootCertFiles /etc/hyperledger/fabric/tls/ca.crt -C dipchannel -n mycc --peerAddresses peer0.core.dip.com:7051 -c '{"Args":["query","a"]}'
And it works, I can see in the peer logs:
Entry chaincode: name:"mycc"
Exit chaincode: name:"mycc" (2ms)
And I can see result of this invoke in my chaincode container.
But when I'm trying to invoke from my code by SDK
req := channel.Request{
ChaincodeID: "mycc",
Fcn: "query",
Args: [][]byte{[]byte("a")},
}
resp, err := client.Execute(req)
I have empty response, and in the peer log I see:
Entry chaincode: name:"cscc"
Exit chaincode: name:"cscc" (1ms)
Entry chaincode: name:"lscc"
Exit chaincode: name:"lscc" (1ms)
Why it is calling "cscc" and "lscc" chaincodes and doesn't call to "mycc" ?
check this below are System Chaincodes
LSCC Lifecycle system chaincode handles lifecycle requests described above. >>> Chaincode lifecycle
CSCC Configuration system chaincode handles channel configuration on the peer side. >>> which helps regulate access control
QSCC Query system chaincode provides ledger query APIs such as getting blocks and transactions.
Note: In particular, install, instantiate and upgrade do not apply to system chaincodes.
System chaincode is used in Hyperledger Fabric to implement a number of system behaviors so that they can be replaced or modified as appropriate by a system integrator.
Unlike a user chaincode, a system chaincode is not installed and instantiated using proposals from SDKs or CLI. It is registered and deployed by the peer at start-up
COMING to your query >>>>
Check whether you are providing identity or not, as it enters into CSCC which is a regulator for ACL
Check below my code snippet
func (setup *FabricSetup) Query() (string, error) {
// Channel client is used to query and execute transactions
clientContext := setup.sdk.ChannelContext(setup.ChannelID, fabsdk.WithUser(setup.OrgAdmin))
client, err := channel.New(clientContext)
setup.client = client
// Prepare arguments
var args []string
args = append(args, "queryRate")
args = append(args, "001")
response, err := setup.client.Query(
channel.Request{
ChaincodeID: setup.ChainCodeID,
Fcn: args[0],
Args: [][]byte{[]byte(args[1])},
},
)
if err != nil {
return "", fmt.Errorf("failed to query: %v", err)
}
return string(response.Payload), nil
}

Cannot invoke a function that change or retrieve function of a chaincode?

Problem:
I have created a Hyperledger fabric network with six organizations 2 peers for each. After running the network I install fabcar chaincode on one peer of each organization and then I instantaited the chaincode using this command.
peer chaincode instantiate -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -n fabcar -l node -v 1.0 -c '{"Args":["init"]}' -C myc -P "AND ('Org2MSP.peer','Org1MSP.peer',Org3MSP.peer','Org4MSP.peer','Org5MSP.peer','Org6MSP.peer')"
Up to this command, everything was successfully happened without giving me an error. After I tried to invoke a function using this command.
peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C myc -n fabcar -c '{"Args":["initLedger"]}
This command leaves this error on the particular peer logs.
2019-05-12 13:38:01.162 UTC [gossip.privdata] StoreBlock -> INFO 191
[myc] Received block [8] from buffer 2019-05-12 13:38:01.213
UTC [vscc] Validate -> ERRO 192 VSCC error:
stateBasedValidator.Validate failed, err validation of endorsement
policy for chaincode fabcar in tx 8:0 failed: signature set did not
satisfy policy 2019-05-12 13:38:01.213 UTC [committer.txvalidator]
validateTx -> ERRO 193 VSCCValidateTx for transaction txId =
a17c0deb20af5a4e0a232fa432ea13e74fca101b63cb697384bbaced80905773
returned error: validation of endorsement policy for chaincode fabcar
in tx 8:0 failed: signature set did not satisfy policy 2019-05-12
13:38:01.258 UTC [committer.txvalidator] Validate -> INFO 194
[myc] Validated block [8] in 96ms 2019-05-12 13:38:01.259 UTC
[valimpl] preprocessProtoBlock -> WARN 195 Channel [trafficfine]:
Block [8] Transaction index [0] TxId
[a17c0deb20af5a4e0a232fa432ea13e74fca101b63cb697384bbaced80905773]
marked as invalid by committer. Reason code
[ENDORSEMENT_POLICY_FAILURE]
This was the logs on the chincode.
fabcar#1.0.0 start /usr/local/src
node fabcar.js "--peer.address" "peer0.org2.example.com:9052"
2019-05-12T13:35:08.951Z info [lib/chaincode.js]
info: Registering with peer peer0.org2.example.com:9052 as chaincode
"fabcar:1.0" {"timestamp":"2019-05-12T13:35:08.951Z"}
2019-05-12T13:35:09.232Z info [lib/handler.js]
info: Successfully registered with peer node. State transferred to
"established" {"timestamp":"2019-05-12T13:35:09.232Z"}
2019-05-12T13:35:09.234Z info [lib/handler.js]
info: Successfully established communication with peer node. State
transferred to "ready" {"timestamp":"2019-05-12T13:35:09.234Z"}
=========== Instantiated fabcar chaincode =========== 2019-05-12T13:35:09.240Z info [lib/handler.js]
info: [myc-8ecdb2a5] Calling chaincode Init() succeeded. Sending
COMPLETED message back to peer
{"timestamp":"2019-05-12T13:35:09.240Z"} { fcn: 'initLedger', params:
[] }
============= START : Initialize Ledger =========== successful { status: 200, message: '', payload: } Added <--> { make:
'Toyota', model: 'Prius', color: 'blue', owner: 'Tomoko',
docType: 'car' } successful { status: 200, message: '', payload:
} Added <--> { make: 'Ford', model: 'Mustang', color:
'red', owner: 'Brad', docType: 'car' } successful { status: 200,
message: '', payload: } Added <--> { make: 'Hyundai',
model: 'Tucson', color: 'green', owner: 'Jin Soo', docType:
'car' } successful { status: 200, message: '', payload: }
Added <--> { make: 'Volkswagen', model: 'Passat', color:
'yellow', owner: 'Max', docType: 'car' } successful { status: 200,
message: '', payload: } Added <--> { make: 'Tesla',
model: 'S', color: 'black', owner: 'Adriana', docType: 'car' }
successful { status: 200, message: '', payload: } Added <-->
{ make: 'Peugeot', model: '205', color: 'purple', owner:
'Michel', docType: 'car' } successful { status: 200, message: '',
payload: } Added <--> { make: 'Chery', model: 'S22L',
color: 'white', owner: 'Aarav', docType: 'car' } successful {
status: 200, message: '', payload: } Added <--> { make:
'Fiat', model: 'Punto', color: 'violet', owner: 'Pari',
docType: 'car' } successful { status: 200, message: '', payload:
} Added <--> { make: 'Tata', model: 'Nano', color:
'indigo', owner: 'Valeria', docType: 'car' } successful { status:
200, message: '', payload: } Added <--> { make: 'Holden',
model: 'Barina', color: 'brown', owner: 'Shotaro', docType:
'car' }
============= END : Initialize Ledger =========== 2019-05-12T13:37:58.998Z info [lib/handler.js]
info: [myc-a17c0deb] Calling chaincode Invoke() succeeded. Sending
COMPLETED message back to peer
{"timestamp":"2019-05-12T13:37:58.998Z"}
I tried a lot to figure out what is wrong with my network. But I was unable to find out. can someone help me to solve this problem? Thank you.
Your endorsement policy is an AND policy so you will need to collect endorsement from all the Organizations defined in your policy. You can use [--peerAddresses] flag in your invoke command to send the transaction to multiple peers in different organizations and get the required signatures required for the policy.

Resources