Initialize function is not invoked during deployment of upgradeable contract

This is initialize function of my upgradeable contract

contract MyContract is
    function initialize(string memory _name, string memory _symbol)
        emit ContractInitStarted(_name, _symbol, msg.sender, block.timestamp);
        __ERC20PresetMinterPauser_init(_name, _symbol);
        _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
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:

Last 4 transactions for contracts: (AdminUpgradeabilityProxy) (ProxyAdmin) (implementation)


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