Referring to this link: https://theethereum.wiki/w/index.php/ERC20_Token_Standard

looking at the last contract. (Line 130)

function totalSupply() public constant returns (uint) {
    return _totalSupply  - balances[address(0)];

Why do we use balances[address(0)] here? Is that means we will get the sum of all values in the balances?


1 Answer 1


balances is a mapping of address to how many tokens that address owns.

balances[address(0)] then means how many tokens the address 0 (0x00000000...00) owns.

Although I don't like the practice, some ERC20 tokens consider tokens that are sent to address 0 to be "burned" and thus don't count them in the total. So _totalSupply - balances[address(0)] gives the total number of tokens minus those that have been "burned" by transferring them to address 0.

  • Thanks for the answer. Who will actually send to address(0) then? By mistakes, error in contract or glitches in blockchain?
    – s k
    Mar 14, 2018 at 9:55
  • 3
    The expectation is that people send to address(0) on purpose to burn tokens.
    – user19510
    Mar 14, 2018 at 10:01
  • 2
    And also due to human error, when no data is passed to the function, by default zero address is used.
    – Ayushya
    Mar 14, 2018 at 10:20
  • @smarx why don't you like this practice? I'm implementing it on my token's contract as I will be burning tokens sometimes and want the total in circulation to show. Are there any drawbacks to it?
    – sigmaxf
    May 22, 2018 at 13:32
  • 1
    I don't like special cases. Why are tokens owned by address 0 not counted but tokens owned by address 1 are? I'd prefer an explicit burn() function.
    – user19510
    May 22, 2018 at 14:51

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