【发布时间】:2020-06-04 18:45:34
【问题描述】:
我在 IBM Blockchain Platform 云中部署了一个非常基本的 IBM Blockchain 网络:只有一个对等组织和一个订购者组织。我已经安装并实例化了一个非常基本的合约(只是 CRUD 操作),现在我正在尝试使用模板 Nodejs 客户端应用程序为我的资产提交创建交易;这是我的代码:
'use strict';
const { FileSystemWallet, Gateway } = require('fabric-network');
const fs = require('fs');
const path = require('path');
async function main() {
try {
// Parse the connection profile. This would be the path to the file downloaded
// from the IBM Blockchain Platform operational console.
const ccpPath = path.resolve(__dirname, 'connection.json');
const ccp = JSON.parse(fs.readFileSync(ccpPath, 'utf8'));
// Configure a wallet. This wallet must already be primed with an identity that
// the application can use to interact with the peer node.
const walletPath = path.resolve(__dirname, 'wallet');
const wallet = new FileSystemWallet(walletPath);
// Create a new gateway, and connect to the gateway peer node(s). The identity
// specified must already exist in the specified wallet.
const gateway = new Gateway();
await gateway.connect(ccp, { wallet: wallet, identity: 'orgAdmin' , discovery: {"enabled": true, "asLocalhost":false }});
// Get the network channel that the smart contract is deployed to.
const network = await gateway.getNetwork('erschannel');
// Get the smart contract from the network channel.
const contract = network.getContract('ers_contract');
// Submit the 'createCar' transaction to the smart contract, and wait for it
// to be committed to the ledger.
await contract.submitTransaction('createErsGenHash', 'ersGenHashId_1', 'ersGenHashId_1_value');
console.log('Transaction has been submitted');
await gateway.disconnect();
} catch (error) {
console.error(`Failed to submit transaction: ${error}`);
process.exit(1);
}
}
main();
我已成功注册身份 orgAdmin 并将其下载到我的本地钱包中(至少我做对了!!)。执行上述操作时,出现以下错误:
C:\work\hlf>node invoke.js
2020-06-04T18:34:28.213Z - error: [Network]: _initializeInternalChannel: No peers defined for MSP 'orgAdmin' to discover from
Failed to submit transaction: Error: No peers defined for MSP 'orgAdmin' to discover from
这是我的 connection.json 配置文件(我从 IBM Blockchain Platform 控制台下载的);奇怪的是没有orderer信息:
{
"name": "ORG1MSPprofile",
"description": "Network on IBP v2",
"version": "1.0.0",
"client": {
"organization": "ORG1MSP"
},
"organizations": {
"ORG1MSP": {
"mspid": "ORG1MSP",
"certificateAuthorities": [
"184.172.233.238:31951"
],
"peers": [
"184.172.233.238:30604"
]
}
},
"peers": {
"184.172.233.238:30604": {
"url": "grpcs://184.172.233.238:30604",
"tlsCACerts": {
"pem": "-----BEGIN CERTIFICATE-----\nxxxxxxxxxxx\n-----END CERTIFICATE-----\n"
},
"grpcOptions": {
"ssl-target-name-override": "184.172.233.238"
}
}
},
"certificateAuthorities": {
"184.172.233.238:31951": {
"url": "https://184.172.233.238:31951",
"caName": "ca",
"tlsCACerts": {
"pem": "-----BEGIN CERTIFICATE-----\nxxxxxxxxxxx\n-----END CERTIFICATE-----\n"
}
}
}
}
我怀疑问题在于我如何配置 IBM 云区块链网络。我按照here 的关于构建网络的官方教程进行操作。
【问题讨论】:
标签: hyperledger-fabric ibm-blockchain