如果代币的总余额超过代币的总供应量会怎样?

What happens if the total balance of tokens exceeds the totalSupply of a token?

据我了解,totalSupply 只是一个供参考的数字。
它没有对所有余额的总和施加硬性限制,还是?

示例:

function transfer(address receiver, uint numTokens) public returns (bool) {
  require(numTokens <= balances[msg.sender]);
  balances[msg.sender] = balances[msg.sender] — numTokens;//Remove This
  balances[receiver] = balances[receiver] + numTokens;
  emit Transfer(msg.sender, receiver, numTokens);
  return true;
}

如果我删除减去余额的那一行,代币只会出现在接收方的余额中,但发送方的余额不会改变。
如果发生这种情况,现有的代币总数将比以前更多。是真的吗?
我的理解是否正确,余额映射只是一个余额列表(相当于 C# 字典)?

这对区块链程序员有什么影响需要注意吗?

If I were to remove the line which substracts the balance, the tokens would only appear on the receivers balance, but the senders balance would not change.

没错。

If that happens the total tokens in existance would be more than before.

更正现有代币的总和。

但是 - 代币标准(ERC-20、ERC-721 等)也希望您计算现有代币的总量(通常存储在名为 totalSupply 的 属性 中) .由于您的代码段未更新此 totalSupply,其值将变为不真实。

总供应量主要由 Etherscan 等区块链浏览器用于统计目的(计算代币的最大持有者、他们的所有权百分比等)。

其他系统,例如去中心化交易所或一般的 dapp,当 totalSupply() 输出与实际总供应量不匹配时,可能会出现意外行为。但这完全取决于他们的实施,所以没有统一的答案。