The ERC20 token standard specifies balanceof() to return a constant.

function balanceOf(address _owner) constant returns (uint256 balance)

But the balance amount might change or am I getting something wrong here?

2 Answers 2


The constant keyword does not specify what the function returns. A function marked as constant like this one tells you that the function will return a value and will not modify any state variables. A large use for the constant/view keywords is to declare a function that can be called without sending a transaction, i.e. a free "query" of the blockchain.


  • Why would it be wrong not to use constant in balanceof()? The function itself doesn't change any state, it only returns return balances[_owner];
    – sunwarr10r
    Commented Nov 10, 2017 at 14:00
  • It wouldn't be wrong. You're right to have constant there.
    – Malone
    Commented Nov 10, 2017 at 23:06
  • 1
    What is "constant" is the function, which in Solidity refers to a function that doesn't modify the state of the blockchain, just reads values. Not to be confused with a constant variable, whose value can't be changed once declared. Commented Nov 10, 2017 at 23:09

constant on functions is an alias to view, so when executed you can view the contents that function returns

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.