REC20 burning restriction

Hi

I am trying to implemement an ERC20 Token Burnable.
I implemented it but I realized the owner can burn from any address.

Somehow, this is not good for me as I would not want the Fed to destroy the money in my bank account, but I let them destroy the money they printed might they want to do so.

I could not find any implementataion of a brunable token that could only be burned by a few addresses (being account addrss or contract address)

Is there any "standard" for restricting burning ?

Thanks

Bruno Lenski

Hi @BrunoColb,

You can use _burnFrom method in the ERC20Burnable implementation by OpenZeppelin. It checks for the allowance before calling the burn method.

So you suggest I should override the allowance method to make sure the contract can not brun from any address ?
Or something else.
my point is that I do not want to be able to brun token in a user's address : you surely not want me to burn token in your wallet but I should be able to somehow burn some token (of mine or stored in a smartcontract)

If you implement ERC20Burnable the default implementation is:

function burn(uint256 amount) public virtual {
    _burn(_msgSender(), amount);
}

Which means the function is only able to burn tokens from the msg sender (whoever calls the function). So the person calling it will only be able to burn their own tokens.

yes _burn(...) will be able to burn from all accounts, but as long as you do not implement a public function that calls it that way it will not be a problem.

2 Likes