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:
- Considering that at the time of creating the contract, only
balances[owner]
should have the value of_totalSupply
, why are we interested inbalances[address(0)]
in the first place? - Assuming that there's zero value in
balances[address(0)]
anyways, why istotalSupply()
subtracting it every time from_totalSupply
?