【发布时间】:2021-05-30 19:06:58
【问题描述】:
https://github.com/hyperledger/fabric-samples 在director assets-transfer-basic->application-javascript 的文件app.js 中,当我插入服务器代码以侦听端口并尝试调用合约时,它会给出如下错误。 enter image description here
connection.write(data.toString());
console.log('Sent response to client');
connection.end();
console.log('Disconnected the client.');
});
});
server.listen(port, function () {
console.log('server is listening');
});
console.log('\n--> Evaluate Transaction: GetSignedRank, function returns signed rank');
var result = await contract.evaluateTransaction('GetSignedRank', '123');
console.log(result.toString());
//console.log(`*** Result: ${prettyJSONString(result.toString())}`);
} finally {
// Disconnect from the gateway when the application is closing
// This will close all connections to the network
gateway.disconnect();
}
} catch (error) {
console.error(`******** FAILED to run the application: ${error}`);
}
}
问题出在这一行 var result = await contract.evaluateTransaction('GetSignedRank', '123');
【问题讨论】:
-
网络是否已启动并正在运行?您共享的代码不完整。我看不到您创建的任何网关。
-
是的,我刚刚分享了导致错误的行。我通过制作一个单独的 nodejs 文件并调用允许调用 evaluateTransaction 方法的文件 app.js 的副本来解决它。我认为错误在我调用 evaluateTransaction 之前,连接是否已在服务器代码中结束。谢谢您的回复
标签: node.js hyperledger-fabric hyperledger