可使用JavaScript API来获取以太坊帐户余额,例如在JavaScript代码中:web
web3.fromWei(web3.eth.getBalance(web3.eth.coinbase));
若是你在geth控制台里,能够将web3.eth
使用其eth
别名代替:区块链
> web3.fromWei(eth.getBalance(eth.coinbase));
在合约中更简单,Solidity为每一个address
对象都提供了一个balance
属性,它返回以wei
为单位的帐户余额。例如:ui
contract ownerbalancereturner { address owner; function ownerbalancereturner() public { owner = msg.sender; } function getOwnerBalance() constant returns (uint) { return owner.balance; } }
推荐两个以太坊相关的实战教程:spa
更多的内容能够访问博客:3d
http://blog.hubwiz.com/2018/01/10/how-to-check-ethereum-balance/code