Initialize function is not invoked during deployment of upgradeable contract

This is initialize function of my upgradeable contract

contract MyContract is
     Initializable,
     ERC20PresetMinterPauserUpgradeable,
     OwnableUpgradeable
{
    function initialize(string memory _name, string memory _symbol)
        public
        override
        initializer
    {
        emit ContractInitStarted(_name, _symbol, msg.sender, block.timestamp);
        __ERC20PresetMinterPauser_init(_name, _symbol);
        __Ownable_init_unchained();
        _mint(msg.sender, 500000000 ether);
        emit ContractInitEnded(_name, _symbol, msg.sender, block.timestamp);
    }
}

This is 2_deploy_contracts.js

const MyContract  = artifacts.require("./MyContract .sol");

const { deployProxy } = require("@openzeppelin/truffle-upgrades");

module.exports = async function (deployer) {
  await deployProxy(MyContract , ["MyContract  1.0", "TenX"], { deployer, initializer: "initialize" });
};

npx truffle deploy --network rinkeby

Initialize function is never invoked.
symbol, name and totalSupply are empty

How are you checking symbol, name and totalSupply?

I check in contract data in https://rinkeby.etherscan.io
And by events

And how are you picking the address to which call totalSupply()? Maybe you’re using the implementation instead of the proxy address?

I can see it in my address transaction in etherscan and also during deployment there’s an output with contracts name and address

Perhaps, I should look at AdminUpgradeabilityProxy?

My address: https://rinkeby.etherscan.io/address/0x860fa46f170a87df44d7bb867aa4a5d2813127c1

Last 4 transactions for contracts:

https://rinkeby.etherscan.io/address/0xe97ef53dd413729425317a768a0ba425831c5107 (AdminUpgradeabilityProxy)

https://rinkeby.etherscan.io/address/0x857411020c5e2b540fdd6c5ed0a4faeb678ef280 (ProxyAdmin)

https://rinkeby.etherscan.io/address/0x2e4cd3fd7ed77a278d118b95e4bef5b7079367da (implementation)

Token:

Hi @dmdv,

Etherscan shows your token name, symbol and decimals.

If you verify your implementation contract you can interact via Etherscan.

@abcoathup I don’t understand, this is the token contracts:

And this is AdminUpgradeabilityProxy

1 Like

Hi @dmdv,

With upgradeable contracts, we interact with the proxy and not with the implementation contract, or to put it another way, we use the ABI of the implementation contract to interact with the proxy at the address of the proxy.

The proxy contract on Etherscan shows the name, symbol, decimal etc as I would expect.

I am not sure what the issue is?

1 Like

@abcoathup I followed the instruction you’d posted before and it worked. Thanks.
But the question is still there - why I couldn’t see any events from initialize function

1 Like

Hi @dmdv,

It looks like decoding logs with proxy contracts isn’t supported by Etherscan:

1 Like