[Ethereum] Why setting balanceOf instead of just using public variable in ERC20 tokens

Architectureerc-20mappingsoliditytokens

Good day,

ERC20 specify the following 2 functions as its most important ones:

function balanceOf(address _owner) constant returns (uint256 balance){}
function transfer(address _to, uint256 _value) returns (bool success){}

But the balanceOf function is nothing more than a fancy way to access the info stored inside a simple mapping array.
Why not just set the balances mapping array to be public and be done with it?

mapping (address=>uint) public balanceOf;

I feel as if I'm missing something here.
As always, your help is appreciated.

Best Answer

The function just defines a way of accessing the mapping array and assumes that you haven't set its modifier to public.

In ether wallets they both seem to work in the same way so no real difference if you just need to see balances.

Related Topic