[Ethereum] Why do we need to specify constant in the return value


Referring to the constant below:

  function totalSupply() constant returns (uint256 totalSupply);

Best Answer

From Solidity docs:

Functions can be declared constant in which case they promise not to modify the state.

If a function doesn't modify the state of blockchain (simply getters), you should add constant to function definition.

Related Topic