(1)TypeError:web3.toHex is not a function
![](https://img-blog.csdnimg.cn/img_convert/ff1e385141b2e229f4d36cd68bcae508.png)
查询toHex方法,在文件夹types下找到
![](https://img-blog.csdnimg.cn/img_convert/3e73b3ef817227fa48bac7cb0f80806c.png)
![](https://img-blog.csdnimg.cn/img_convert/b6a597de9497199b31a9aeeb6ddf32ac.png)
更改方法
web3.toHex(count)
为
web3.utils.toHex(count)
再次运行无报错。
(2)TypeError: Tx is not a constructor
let Tx = require('ethereumjs-tx');
参考:https://stackoverflow.com/questions/63699798/how-to-use-ethereumjs-tx-without-getting-errors-tx-is-not-a-constructor回答的方法,更改源代码如下:
let Tx = require('ethereumjs-tx').Transaction;
再次运行无报错。