1

i have started to work on ethereum project.

i have a customer who owns his own token and he wants to burn some tokens.

i have seen that the smart contract has as an internal _burn function but this is never called and there is no public function for _burn

Now my question.

Is there a way i can upgrade his contract so i can add a public burn function? or is there i way i can execute the never called _burn internal function in other way?

1
  • are you talking about _burn function for ERC20 token, from @OpenZepplin project? Because if your own contract had imported it. Then you can call _burn function without any issue. Feel free to ask questions. I think I might be able to help you here, as I had used the said function more times than I can remember.
    – Sky
    Jan 14 at 10:13

2 Answers 2

1

Contracts are not upgradable on Ethereum, if not explicitly being developed in such a way.

If the token of your customer uses a Proxy pattern then this is possible.

Otherwise you will not be able to make your internal function accessible if it was not accessible before.

A common pattern to burn tokens is to sent them to the zero-address. This also triggers the Transfer event that is associated to burning. This is also the reason why you can see that the zero-address on Etherscan holds quite a large amount of tokens: https://etherscan.io/address/0x0000000000000000000000000000000000000000

3
0

Based on your claim that you have seen internal _burn function. I will assume the function in question is something like this

 /**
 * @dev Destroys `amount` tokens from `account`, reducing the
 * total supply.
 *
 * Emits a {Transfer} event with `to` set to the zero address.
 *
 * Requirements
 *
 * - `account` cannot be the zero address.
 * - `account` must have at least `amount` tokens.
 */
function _burn(address account, uint256 amount) internal {
    require(account != address(0), "ERC20: burn from the zero address");

    _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
    _totalSupply = _totalSupply.sub(amount);
    emit Transfer(account, address(0), amount);
}

The function above is usually found in ERC20.sol contract that is used in conjunction with ERC20Burnable.sol

ERC20Burnable.sol contains a function burn() that will call the _burn() from ERC20.sol

/**
 * @dev Destroys `amount` tokens from the caller.
 *
 * See {ERC20-_burn}.
 */
function burn(uint256 amount) public {
    _burn(_msgSender(), amount);
}

I assume this is the case with the contracts you are looking at the moment. Therefore, there is probably no need to upgrade the contract. But I would need more info to help you here if that is not the case.

6
  • Exactly it looks like you showed. I have the _burn function but there is no public burn function and no such things like ERC20Burnable.sol or similar. My feeling is that there is indeed need to upgrade the contract but when the previous developers didnt use the proxy pattern its probably not possible right? Jan 14 at 10:39
  • True, it will not be possible to simply add ERC20Burnable.sol if they somehow missed it. Could we maybe contact each other over Zoom/Discord or something to see if I might help you clear this up? As it ain't easy to convey everything over the comments.
    – Sky
    Jan 14 at 10:49
  • 1
    Sure lets do it. my discord username is askmeanything#2760 Jan 14 at 11:52
  • Perfect. Just give me a minute. My username is Sky#0677
    – Sky
    Jan 14 at 11:56
  • Allright, I just sent you a friend request. That should be it.
    – Sky
    Jan 14 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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