When reading the ERC20 Token Standard in the Wiki, I've noticed that in its Sample Fixed Supply Token Contract, the value of balances[address(0)] is subtracted from the contract's total supply to calculate the total supply.

Here's what totalSupply() looks like at the time of writing this question:

function totalSupply() public view returns (uint) {
  return _totalSupply.sub(balances[address(0)]);

To give more context, _totalSupply is created when the contract is instantiated and .sub() is a library function from SafeMath:

contract FixedSupplyToken is ERC20Token {
  using SafeMath for uint;

  mapping(address => uint) balances;
  uint _totalSupply;

  constructor() public {
    decimals = 18;
    _totalSupply = 1000000 * 10**uint(decimals);
    balances[owner] = _totalSupply;

Now there are two things to me that are unclear:

  1. Considering that at the time of creating the contract, only balances[owner] should have the value of _totalSupply, why are we interested in balances[address(0)] in the first place?
  2. Assuming that there's zero value in balances[address(0)] anyways, why is totalSupply() subtracting it every time from _totalSupply?

1 Answer 1


Sending tokens to address(0) is a means of burning tokens.

When calculating the total supply this way, tokens can be removed from existence without ever having to update the internal _tokenSupply field. , which could potentially introduce harmful bugs.

Using ERC-20's transfer function, you can send tokens to any address, including address(0). This contract considers transfering tokens to address(0) to be the same thing as burning tokens. That's because as the balance of address(0) increases, the value returned by the function totalSupply decreases. To the outside world then, the tokens that were sent to address(0) no longer exist.

  • I'm not sure I follow. So totalSupply() is supposed to return the total supply (which is already in _totalSupply. Can you elaborate on why balances[address(0)] is subtracted from it then (to get the total supply we already have even without that subtraction)? Commented Aug 15, 2018 at 9:07
  • 2
    No one knows the private key for 0x0 (the ethereum address), so sending tokens to it is destroying those tokens (so they no longer count to the total supply).
    – JasoonS
    Commented Aug 15, 2018 at 9:09
  • What JasoonS said. This way of calculating the totalSupply is just to let the outside world know that some tokens are no longer in control of anyone anymore, and therefore, burned.
    – Henk
    Commented Aug 15, 2018 at 9:10
  • I appreciate the responsiveness here! I understand that tokens get burned on address(0). I'm sure I'm missing something, but I'm still unsure how one thing relates to the other. Sure sending to that address burns tokens, but we don't send to that address with that code. To me it rather looks like return totalSupply - [whatever_is_in_balances[address(0)]], we don't really touch address(0) anywhere else in that contract. Sorry for being resistant, I hope it makes sense... Commented Aug 15, 2018 at 9:15
  • 1
    Ah! Now I get it. So this is really just for "just in case somebody will actually burn tokens by making transfers to address(0) in the future, we need to make sure those burned tokens are part of the equation". This makes sense now. Thank you for being patient everyone! Commented Aug 15, 2018 at 9:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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