Cannot upgrade ERC20

Hi @Mehran_Hafizi,

Welcome to the community :wave:

I noticed a few things about your contract:

You are doing a check on the total supply in the initialize function before any minting, so this will always be zero as you are using the initializer modifier so this function is only ever called once. (similar to a constructor)

You are doing transfer inside your initialize, so this requires that your token contract actually has tokens which it doesn't. I assume you want to do a _mint instead:

_From: https://docs.openzeppelin.com/contracts/3.x/api/token/erc20#IERC20-transfer-address-uint256-_
Moves amount tokens from the caller’s account to recipient .

In your inc function you are doing a transfer which is trying to transfer 200 tokens from the contract (which has zero) to the recipient.

When you add incMore it also does a transfer which fails (which is why it is reverting.

  function  incMore(address recipient) public returns (bool){
       	transfer(recipient,300);
		return true;
    }

I suggest having a look at: Example on how to use ERC20 token in another contract


As an aside, OpenZeppelin Upgrades Plugins for Buidler and Truffle was recently released. You could use either of the plugins to deploy upgradeable contracts: https://docs.openzeppelin.com/upgrades-plugins/1.x/

1 Like