本文介绍了在localhost:3000上执行Hyperledger Fabric代码时出错(通过REST)-transactionId的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已尝试执行一个示例,说明在两个帐户之间进行资金转移的情况: https://medium.freecodecamp.org/ultimate-end-to-end-tutorial-to-create-an-application-on-blockchain-using-hyperledger-3a83a80cbc71

I have tried executing a sample case of transfer of money between two accounts while referring to this:https://medium.freecodecamp.org/ultimate-end-to-end-tutorial-to-create-an-application-on-blockchain-using-hyperledger-3a83a80cbc71

我已经执行了所有步骤,从创建.bna和.card到安装它们,启动网络等.创建RESTful API时,我可以在localhost:3000/explore上看到区块链.我还可以添加客户及其关联的帐户详细信息.

I have executed all steps, from creating .bna and .card to installing them, starting the network etc.On creating the RESTful API, I am able to see the blockchain on localhost:3000/explore.I am also able to add customers and their linked account details.

但是,在进行汇款时,默认情况下会生成两个字段:transactionId和timestamp.

However, while performing money transfer, there are two fields that are generated by default : transactionId and timestamp.

此屏幕截图显示了另外两个字段-时间戳和transactionId

正在制造麻烦的是transactionId.它不允许我将其保留为空白,填充任意值或完全删除该字段.

It's the transactionId that is creating trouble.It does not allow me to leave it blank, or fill arbitrary values, or remove the field altogether.

transactionId字段留空时出错

更新

即使写了"transactionId" : true"transactionId" : false,问题仍然存在.

Even after writing "transactionId" : true or "transactionId" : false, the problem persists.

另一个用户遇到了类似的问题.他们通过将npm和node.js设置为非root来修复此问题.就我而言,它已经是非根用户了.它不是超级用户npm和node.js是否可能未正确安装?我在安装过程中收到了一些错误安装过程中出现了npm错误

Another user had encountered a similar problem. They fixed it by making their npm and node.js non-root. In my case, it is already non-root.it is non-rootIs it possible that npm and node.js are not installed properly? I had received a few errors during its installation npm errors during installation

即使删除了transactionIdtimestamp字段,它也无法正常工作

Even after removing transactionId and timestamp fields, it doesn't work

推荐答案

理想情况下,transactionID(在示例中)不应出现在POST操作的 Swagger 示例中.该示例是由 LoopBack到Swagger 转换生成的,该转换是由LoopBack代码(不是Composer)完成的.您需要在JSON中将其删除(而且,时间戳也非常理想,因为Composer会对其进行更新).

The transactionID (in the example) ideally should not appear in the Swagger example for the POST operations. That example is generated by the LoopBack to Swagger conversion that is done by LoopBack code (not Composer). You need to remove it (and the timestamp too ideally, as Composer will update its own) in your JSON.

请参见为什么可以我在Hyperledger Composer REST中提交了带有事务的transactionID 作为答案.此环回/摇摆问题是针对环回创建的-创建的最后一个问题是 https://github.com/strongloop/loopback/issues/3510

see Why can I submit a transactionID with a transaction in hyperledger composer REST? for an answer. This loopback/swagger issue was created against loopback - last issue created was https://github.com/strongloop/loopback/issues/3510

这篇关于在localhost:3000上执行Hyperledger Fabric代码时出错(通过REST)-transactionId的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 00:01