首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WEB3.JS问题

WEB3.JS问题
EN

Ethereum用户
提问于 2020-07-18 12:53:04
回答 1查看 61关注 0票数 0

我正在尝试使用“ethereumjs”库,但它不起作用。我收到以下错误消息:“TypeError: Tx不是构造函数”,代码“const= new (TxObject)”。

这是我的代码:

代码语言:javascript
复制
const Tx = require(‘ethereumjs-tx’)

const txObject = {

    nonce: web3.utils.toHex(txCount),

    to: account2,

    value: web3.utils.toHex(web3.utils.toWei('0.3', 'ether')),

    gasLimit: web3.utils.toHex(21000), 

    gasPrice: web3.utils.toHex(web3.utils.toWei('10', 'gwei'))

}

const tx = new Tx(txObject)

谢谢你的帮助

保重

皮埃尔

EN

回答 1

Ethereum用户

发布于 2020-07-18 15:16:44

我是const Tx = require('ethereumjs-tx').Transaction

下面是来自Github存储库的示例:https://github.com/ethereumjs/ethereumjs-tx

票数 0
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/85098

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档