public BigInteger getBalance(String address)
{
/*Web3j web3j */
createEthreumConnection();
EthGetBalance ethGetBalance = null;
try {
ethGetBalance = web.ethGetBalance(address, DefaultBlockParameterName.LATEST).sendAsync().get();
} catch (InterruptedException e) {
logger.error("Interrupted Exception "+e);
} catch (ExecutionException e) {
logger.error("ExecutionException Exception "+e);
}
return ethGetBalance.getBalance();
}我正在使用上面的代码来获得虚空平衡,但是以给定的4555500000格式获取的余额,我想要显示为#en0# balance.For示例比特币提供的balance.For。
发布于 2017-12-05 05:19:31
@Luiz Soares感谢你给我提供了关于魏的价值的线索,但是提供的解决方案没有起作用,me.After,一些挖掘文档,得到了解决方案
( Convert.fromWei(ethGetBalance.getBalance().toString(),Unit.ETHER);
发布于 2017-12-01 12:00:57
你得到了魏的价值
web3.eth.getBalance返回给定地址的当前余额的BigNumber实例(以魏为单位)。https://github.com/ethereum/wiki/wiki/JavaScript-API#returns-33
转换到以太:var value = web3.fromWei('21000000000000', 'ether');
https://github.com/ethereum/wiki/wiki/JavaScript-API#web3fromwei
https://ethereum.stackexchange.com/questions/32208
复制相似问题