簡體   English   中英

如何創建 ERC20 代幣,轉賬時燒掉 0.5% 的代幣?

[英]How to create ERC20 token with burns 0.5% of tokens on transfer?

我想創建 ERC20 代幣。 它必須在每次轉移時燃燒 0.5%。 例如,當有人從錢包 1 向錢包 2 發送 100 個代幣時,錢包 2 必須取 99.5 個代幣。

你可以通過讓 0.5% 的代幣在轉移時消失在空氣中來實現這一點:

  function transfer(address _to, uint256 _value) public returns (bool success){
    require(balanceOf[msg.sender] >= _value,
      "Tokens transferred must be less or equal to account balance");
    // Remove full balance of sender balance
    balanceOf[msg.sender] -= _value;
    // Add only 99.5 percent of transfer value to receiver balance
    balanceOf[_to] += _value - _value/200;
    emit Transfer(msg.sender, _to, _value);
    return true;
  }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM