Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/454.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法收缩余额_Javascript_Ethereum_Solidity_Web3_Remix - Fatal编程技术网

Javascript 无法收缩余额

Javascript 无法收缩余额,javascript,ethereum,solidity,web3,remix,Javascript,Ethereum,Solidity,Web3,Remix,我试图检查我的合同中是否有任何资金,并且在混音中使用了稳定功能。 solidity func实际上只是返回这个.balance();这就是我真正需要的 function checkBalance() public view returns (uint) { return this.balance; } 我试图在web3中以编程方式调用这个函数,但在这里我遇到了一些麻烦。我正在使用web3 func eth.getBalance尝试获取合同的当前余额 checkBalance: func

我试图检查我的合同中是否有任何资金,并且在混音中使用了稳定功能。 solidity func实际上只是返回这个.balance();这就是我真正需要的

function checkBalance() public view returns (uint) {
    return this.balance;
}
我试图在web3中以编程方式调用这个函数,但在这里我遇到了一些麻烦。我正在使用web3 func eth.getBalance尝试获取合同的当前余额

checkBalance: function() {
    App.contracts.HackathonDapp.deployed().then(function (instance) {
        return instance.checkBalance.call() 
    }).then(function (balance) {
        return web3.fromWei(web3.eth.getBalance('0xeec918d74c746167564401103096d45bbd494b74'));
    }).then (function (contractBalance) {
        console.log(contractBAlance);
    });
},
但是,当我按下HTML按钮调用此函数时,控制台中出现错误:


如果有人能让我在控制台中获得this.balance()值,那就太棒了。谢谢。

您需要通过回拨:

web3.eth.getBalance('...', function (err, result) { console.log(result); });

这是可行的,但我的控制台中有一个巨大的数字超过了javascript的功能
r{s:1,e:0,c:Array(1)}
,我如何让它显示一个简单的以太量?抱歉,我是超级初学者:p谢谢,返回的是一个
大数字。只需对其调用
.toString()