无法使用Hyperledger Composer Javascript API发行身份证 [英] Unable to issue identity card using Hyperledger Composer Javascript API
问题描述
我正在尝试使用Hyperledger Composer的javascript API创建身份证.这是代码:
I am trying to create an identity card using the javascript API of Hyperledger Composer. Here is the code:
const BusinessNetworkConnection = require('composer-
client').BusinessNetworkConnection;
async function identityIssue() {
let businessNetworkConnection = new BusinessNetworkConnection();
try {
await businessNetworkConnection.connect('admin@demoNetwork');
let result = await businessNetworkConnection.issueIdentity('org.acme.demoNetwork.Participant#testUser', 'test');
console.log(`userID = ${result.userID}`);
console.log(`userSecret = ${result.userSecret}`);
await businessNetworkConnection.disconnect();
} catch(error) {
console.log(error);
process.exit(1);
}
}
identityIssue();
我已经有一个参与者testUser
.
尽管代码成功,并且我获得了userID和userSecret,但没有创建卡.
有谁知道如何做到这一点,而不是使用cli?
I already have a participant testUser
.
Although the code succeeds and I get the userID and userSecret, no card is created.
Does anyone have an idea how to do it instead of using the cli?
推荐答案
您尚未导入卡.
例如
async function importCardForIdentity(cardName, identity) {
const metadata = {
userName: identity.userID,
version: 1,
enrollmentSecret: identity.userSecret,
businessNetwork: businessNetworkName
};
const card = new IdCard(metadata, connectionProfile);
await adminConnection.importCard(cardName, card);
}
See also nodejs test hyperledger composer v0.15 fails with Error: Card not found: PeerAdmin@hlfv1 (answer) it has an example too.
导入后,应连接卡以将证书/密钥下载到钱包,例如await businessNetworkConnection.connect(cardName);
After importing, you should connect with your card to download the cert/key to the wallet eg await businessNetworkConnection.connect(cardName);
这篇关于无法使用Hyperledger Composer Javascript API发行身份证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!