我正在尝试从客户端安装fabcar-chaincode。
In line with我已经启动了Fabric-v1.0并创建了频道, 然后运行enrollAdmin.js和registerUser.js。
我想使用我创建的installchaincode.js安装fabcar。
但发生了以下错误。
error: [client-utils.js]: sendPeersProposal - Promise is rejected: Error: 2 UNKNOWN: chaincode error (status: 500, message: Authorization for INSTALL has been denied (error-Failed verifying that proposal's creator satisfies local MSP principal during channelless check policy with policy [Admins]: [This identity is not an admin]))
Failed to install proposal :: TypeError: Cannot read property 'status' of undefined
有人可以帮我解决如何从客户端安装链码。
我的代码就是这个。
'use strict';
/*
* Copyright IBM Corp All Rights Reserved
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Chaincode query
*/
var Fabric_Client = require('fabric-client');
var path = require('path');
var util = require('util');
var os = require('os');
var fabric_client = new Fabric_Client();
// setup the fabric network
var channel = fabric_client.newChannel('mychannel');
var targets = [];
var peer = fabric_client.newPeer('grpc://localhost:7051');
targets.push(peer);
var member_user = null;
var store_path = path.join(__dirname, 'hfc-key-store');
console.log('Store path:'+store_path);
var tx_id = null;
// create the key value store as defined in the fabric-client/config/default.json 'key-value-store' setting
Fabric_Client.newDefaultKeyValueStore({ path: store_path
}).then((state_store) => {
// assign the store to the fabric client
fabric_client.setStateStore(state_store);
var crypto_suite = Fabric_Client.newCryptoSuite();
// use the same location for the state store (where the users' certificate are kept)
// and the crypto store (where the users' keys are kept)
var crypto_store = Fabric_Client.newCryptoKeyStore({path: store_path});
crypto_suite.setCryptoKeyStore(crypto_store);
fabric_client.setCryptoSuite(crypto_suite);
// get the enrolled user from persistence, this user will sign all requests
return fabric_client.getUserContext('admin', true);
}).then((user_from_store) => {
if (user_from_store && user_from_store.isEnrolled()) {
console.log('Successfully loaded admin from persistence');
member_user = user_from_store;
} else {
throw new Error('Failed to enroll admin.... run enrollAdmin.js');
}
process.env.GOPATH = '/Users/testuser/gopath';
// send proposal to endoser
var request = {
targets: targets,
chaincodePath: 'github.com/fabcar',
chaincodeId : 'fabcar',
chaincodeVersion : '1.0'
}
// send the query proposal to the peer
return fabric_client.installChaincode(request);
}).then((result) => {
console.log("install request has completed, checking results");
// query_responses could have more than one results if there multiple peers were used as targets
var proposal_response = result;
if (proposal_response && proposal_response.response.status === 200) {
console.log("install proposal was good");
} else {
console.log("install proposal was bad");
}
}).catch((err) => {
console.error('Failed to install proposal :: ' + err);
});

答案 0 :(得分:0)
我解决了这个问题。要加载的安装用户不同。