我正在尝试包括etheruemjs-tx浏览器构建,以使用它在我的浏览器上签名交易。它一直抛出一个错误"Tx不是一个构造器“
const Tx = "https://github.com/ethereumjs/browser-builds/blob/master/dist/ethereumjs-tx/ethereumjs-tx-1.3.3.js";在我的终端上,一切都很好,因为我刚刚使用了
const Tx = require('ethereumjs-tx').Transaction但是因为我不能在我的javascript代码上使用require(),所以我尝试了所有的方法,但是我没有让它工作。在我的浏览器控制台上,单击按钮后,它将转到此行。
const tx = new Tx(txObject,{chain: 'ropsten', hardfork: 'petersburg'})错误是:(索引):368未捕获TypeError: Tx不是构造函数
有关如何在浏览器中使用ethereumjs-tx的帮助将非常感谢。
发布于 2020-11-05 06:14:55
在新版本中,您应该更改:
const Tx = require('ethereumjs-tx')至
const Tx = require('ethereumjs-tx').Transactionhttps://stackoverflow.com/questions/63699798
复制相似问题