How to Check Your Ethereum Account Balance

If you want to start learning Ethereum DApp development right away, you can visit the excellent online interactive tutorial provided by Huizhi.com:

Get account balance using web3

The Ethereum account balance can be obtained using the JavaScript API, for example in the JavaScript code:

web3.fromWei(web3.eth.getBalance(web3.eth.coinbase)); 

If you are in the geth console, you can web3.ethuse its ethalias instead:

> web3.fromWei(eth.getBalance(eth.coinbase)); 

Get the account balance from the contract

Even simpler in a contract, Solidity addressprovides a balanceproperty for each object weithat the account balance in units. E.g:

contract ownerbalancereturner {
    address owner;
    function ownerbalancereturner() public {
        owner = msg.sender; 
    }
    function getOwnerBalance() constant returns (uint) {
        return owner.balance;
    }
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324653131&siteId=291194637