小编Hei*_*erg的帖子

错误:小数部分超过了 EithersJS 中的小数

为什么以下代码会因超过小数而返回小数部分错误?它似乎只在低平衡时触发。

如果我的余额是 0.1 以太币或 BNB,我不会看到错误,但如果我的余额是 0.0001,我会看到此错误

错误:小数部分超过小数

var account = accounts[0]
var yourBalance = await provider.getBalance(account)
var fixedBalance= ethers.FixedNumber.fromValue(yourbalance , 18);
var stakedAmount = (fixedBalance * 0.50).toString();
var finalOutput = ethers.utils.parseUnits(stakedAmount , 18);  //this returns Error: fractional component exceeds decimals
Run Code Online (Sandbox Code Playgroud)

javascript blockchain ethers.js

2
推荐指数
1
解决办法
5038
查看次数

标签 统计

blockchain ×1

ethers.js ×1

javascript ×1