How do I get the balance of a contract with solidity
?
I know geth
has web3.eth.getBalance()
, but that's to get the contract balance after it has been deployed.
Is there a standard way of doing this, or do I have to have a separate var that uint256
that keeps track of the total balance?
Best Answer
You can do this by calling
address.balance
. To get the contract's balance, just dothis.balance
. Read the docs.Update: As of Solidity ^0.4.24, you need to do:
(Copied from answer by Paul Berg)