Will burning a percentage of the amount transferred for an ERC20 token cause issues?

Hello,

For ERC-20, if I override the transfer and transferFrom functions so that it burns a certain pct of the token being transferred, will this cause errors when users try to interact with other contracts that expect to receive a certain amount?

e.g. if a user tries to do a swap of 100 TOKEN for 1 ETH, but my override causes 1% to be burnt and uniswap only receives 99 TOKEN

Here is some example code with only the relevant pieces left in:

    function transfer(address to, uint256 amount)  public override returns (bool) {
        // performing some other logic up here, which is not relevant
        bool _success = super.transfer(to, _txBurn(amount));
        // and more logic down here, which also isn't relevant
        return _success;
    }

    function transferFrom(address from, address to, uint256 amount) public override returns (bool) {            
        // performing some other logic up here, which is not relevant
        bool _success = super.transferFrom(msg.sender, to, _txBurn(amount));
        // and more logic down here, which also isn't relevant
        return _success;
    }

    function _txBurn(uint256 amount) internal returns (uint256) {
        uint256 burnAmount = amount.div(100);
        if (burnAmount > 0) {
            _burn(msg.sender, burnAmount);
            return amount.sub(burnAmount);
        } else {
            return amount;
        }
    }
1 Like

Hi @riley,

Welcome to the community :wave:

:warning: If you create a fee on transfer or deflationary token (burn a percentage on transfer) this can cause issues with use in other contracts such as: https://medium.com/balancer-protocol/incident-with-non-standard-erc20-deflationary-tokens-95a0f6d46dea

You would need to check with each service whether these types of tokens were supported or not.

Also I recommend looking at Points to consider when creating a fungible token (ERC20, ERC777)

1 Like

Thanks @abcoathup! That’s what I expected, just needed some confirmation. Appreciate it

1 Like

Hi @riley,

It doesn’t mean that you can’t do it, but you should make your token holders very aware of the type of token and where it can and can’t be used and that it could have severe consequences when used in a service/protocol that doesn’t support.