2

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.

  • Also why is the 'unit256 balance' a constant returns ? It might change or am I getting something wrong? – saitam Nov 10 '17 at 13:22
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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