我们在调用合约方法时,都可以传一些参数的,比如转账金额 value。

value 的单位是 wei,这是一个很小的单位,所以一般数值很大。

如果误把 ether 当成 wei 传参,就会报标题中的错误。

 

注意,把 ether 转 wei 需要先把 ether 的值转成字符串。

比如 0.1 ether 转 wei 使用 web3.utils.toWei(this.inputEther.toString(), 'ether')。

反过来 wei 转 ether 使用 web3.utils.fromWei(xx, 'ether')。

 

另外,这里有一个相关的错误,https://www.cnblogs.com/farwish/p/12424066.html

 

Refer:Web3js常见问题

Link:https://www.cnblogs.com/farwish/p/12424108.html

相关文章:

  • 2021-05-30
  • 2021-07-02
  • 2022-01-14
  • 2021-12-12
  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
  • 2021-09-11
猜你喜欢
  • 2021-12-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
  • 2022-12-23
相关资源
相似解决方案