简体   繁体   中英

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

I want to create ERC20 token. It must burn 0.5% at every transfer. For example, When someone send 100 tokens from wallet1 to wallet2, wallet 2 must take 99.5 tokens.

You can achiever this by simply having 0.5% of your tokens disappearing into thin air upon transfer:

  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;
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM