0

Lets say you have this erc20 token already made, what's the safest way to no longer allow the mint and burn functions to work? Is there a better solution than creating a smart contract, updating the token admin to that contract, then using the selfdestruct() function to render that contract useless?

Here's code:

import '@openzeppelin/[email protected]/token/ERC20/ERC20.sol';

contract Token is ERC20 {
  address public admin;

  constructor(string memory name, string memory symbol) ERC20(name, symbol) {
    admin = msg.sender;
  }

  function updateAdmin(address updateadmin) external {
    require(msg.sender == admin, 'only admin');
    admin = updateadmin;
  }

  function mint(address to, uint amount) external {
    require(msg.sender == admin, 'fail, admin only');
    _mint(to, amount);
  }

  function burn(address owner, uint amount) external {
    require(msg.sender == admin, 'fail, admin only');
    _burn(owner, amount);
  }

}

1 Answer 1

0

If you're sure you want to revoke admin privileges, you can call updateAdmin() with the zero address, essentially burning that role forever. As you can see on Etherscan, the zero address was often used as a "burn" address.

Keep in mind this is unrecoverable if you do it!

2
  • Thanks! Using "burn" address, there's no implications on any of the functions in ERC20.sol? There are many comments of variables requiring 'cannot be the zero address'. I assume no issue, even if owner was one of those requires, that address still exists. Commented Apr 2, 2022 at 5:46
  • Which opens another thought. If the owner address is still valid after burn, are there any functions the owner address could utilize to manipulate the token (ie: mint more supply and sell it to the market for all the eth in the contract)? Commented Apr 2, 2022 at 5:52

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.