1

The latest Sample Fixed Supply Token Contract in the 30 December 2017 revision of the ERC20 Token Standard has some great improvements that our team was wanting to add to our contract in test. It is now 224 lines long. However, there is one function that spans across lines 126-131 in the FixedSupplyToken contract that makes no sense to us.

    // ------------------------------------------------------------------------
127     // Total supply
128     // ------------------------------------------------------------------------
129     function totalSupply() public constant returns (uint) {
130         return _totalSupply  - balances[address(0)];
131     }

Above this function, there is

uint public _totalSupply;

which provides an automatic getter function for total supply. So I don't see why this function is needed, AND the

- balances[address(0)];

makes no sense to us whatsoever. There would never be a balance to a zero address - correct?

We ask this, because we are afraid that we may be missing something - thanks!

  • 1
    There certainly could be a balance there, if someone transferred tokens there. That's sometimes done to "burn" tokens (reduce the overall supply). – smarx Jan 8 '18 at 21:32
  • @smarx - that's the type of insight we were hoping to receive by asking this question on this exchange. I tested your statement using the JavaScript VM, and it works. Who can control address(0)? I'll also test in truffle and report back. – Thom Ives Jan 8 '18 at 23:17
  • 1
    No one controls address 0. (You'd have to have a private key that mapped to that public address, but no one knows that key.) – smarx Jan 8 '18 at 23:20
  • @smarx - Understood. So once they are sent there, they are truly burned, and one cannot get them back - new tokens would need to be minted to make up for what had been burned if that was so desired - correct? – Thom Ives Jan 8 '18 at 23:23
  • 1
    Yes, typically there's no way to move those tokens, since moving tokens requires the tokens' owner's approval. But I suppose it depends on the contract. – smarx Jan 8 '18 at 23:25

Your Answer

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

Browse other questions tagged or ask your own question.