0

The uniswapERC20.sol smart contract does not check whether the receiving address is zero or not in the transfer function.

This smart contract also has a burn function

If the user transfers his tokens to address zero(0x) through the burn function, the amount transferred from totalSupply is reduced and the event related to the transfer is emitted with the recipient address zero(0x), but if he transfers some tokens to address zero through the transfer function, the event It is related to transfer emission, but the amount of totalSupply does not decrease.

burn function:

    function _burn(address from, uint value) internal {
        balanceOf[from] = balanceOf[from].sub(value);
        totalSupply = totalSupply.sub(value);
        emit Transfer(from, address(0), value);
    }

transfer function:

    function transfer(address to, uint value) external returns (bool) {
        _transfer(msg.sender, to, value);
        return true;
    }

_transfer function:

    function _transfer(address from, address to, uint value) private {
        balanceOf[from] = balanceOf[from].sub(value);
        balanceOf[to] = balanceOf[to].add(value);
        emit Transfer(from, to, value);
    }

Transfer Event:

    event Transfer(address indexed from, address indexed to, uint value);

Why address zero is not checked in the transfer function?

And when we transfer a number of tokens to address zero with the transfer function, will there be any interference in totalSupply? Because both burn and transfer functions can transfer tokens to zero address(0x), but in one the totalSupply changes but not in the other.

2
  • What is your question? Commented Jan 19, 2023 at 6:30
  • I apologize for the incompleteness of the question corrected Commented Jan 19, 2023 at 6:53

1 Answer 1

0

So the difference between burn and transfer, in this case, is, that in the case of burn the tokens are actually deleted. You can see that owner gets the burn amount subtracted from his balance, whereas, in the case of transfer, the tokens still exist, but are on an unreachable address. That is also why the totalSupply doesn't change in case of transfer.

In general, this doesn't change anything since address(0) or burn address is just an unreachable address, just like many others. Burning ERC20 tokens isn't like burning ether, which you can't just delete. The burn address is, therefore, a burn address meant just for Eth, not the ERC20 tokens. That is also why ERC20 tokens usually don't allow transfers there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.