45 调用合约,拿到对象,对象里面,有大的数值,要转换成 ether,用formWei(),不明白

image.png

里面有 amount,是wei单位,要转成ether,用web3.utils.fromWei(_totalInvested, 'ether'),这个函数不知道怎么用?

如果调用合约,拿到的是uint256,就没有问题。

请先 登录 后评论

最佳答案 2021-12-02 08:23

引入web3 之后,进行初始化

var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
// 或
var web3 = new Web3(window.etherum);

然后调用 web3.utils.fromWei(_totalInvested, 'ether'), 就可以了

请先 登录 后评论

其它 0 个回答