Getting error while deploying OpenZeppelin Wizard contract with UUDP upgradability in Ethereum Remix

Hi,

I am new to smart contract development and solidity. I am using OpenZeppelin Wizard to deploy a smart contract. I am experiencing a problem when using upgradability with UUPS option. Here is my setup in the wizard:

Name: MyToken, Symbol: MTK
Premint: 100000000
Features:
Burnable
Pausable
Permit
Votes
Flash Minting
Snapshots

Access Control:
Roles

Upgradability:
UUPS

When I open it in the Remix, it gives me two warnings.

Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
—>@openzeppelin/contracts-upgradeable@4.3.2/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol:41:43:
|
41 | function
ERC20Permit_init_unchained(string memory name) internal initializer {
| ^^^^^^^^^^^^^^^^^^

Warning: Contract code size exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on mainnet. Consider enabling the optimizer (with a low “runs” value!), turning off revert string, or using libraries.
--> contract-89428c0932.sol:15:1
|
15 | contract MyToken is Initializable, ERC … deable, ERC20FlashMintUpgradeable {
| ^ (Relevant source part starts here and spans across multiple lines).

I was able to resolve the second warning by simple enabling optimization in Compiler Configuration in Solidity Complier at default value (200).

I have tried ignoring the warning and go ahead with deploying the contract. I am able to deploy contract without problem but after deployment when I try to import tokens in Metamask, it shows me 0 Tokens.

Here is more information on the contract info.
Environment: Injected Web3 (I am trying to deploy this contract on Polygon Mumbai Testnet).
Gas Limit: Default (3000000)
Contract: MyToken - contract-89428c0932.sol

Here is the contract code:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

import "@openzeppelin/contracts-upgradeable@4.3.2/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable@4.3.2/token/ERC20/extensions/ERC20BurnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable@4.3.2/token/ERC20/extensions/ERC20SnapshotUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable@4.3.2/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable@4.3.2/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable@4.3.2/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable@4.3.2/token/ERC20/extensions/ERC20VotesUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable@4.3.2/token/ERC20/extensions/ERC20FlashMintUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable@4.3.2/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable@4.3.2/proxy/utils/UUPSUpgradeable.sol";

contract MyToken is Initializable, ERC20Upgradeable, ERC20BurnableUpgradeable, ERC20SnapshotUpgradeable, AccessControlUpgradeable, PausableUpgradeable, ERC20PermitUpgradeable, ERC20VotesUpgradeable, ERC20FlashMintUpgradeable, UUPSUpgradeable {
    bytes32 public constant SNAPSHOT_ROLE = keccak256("SNAPSHOT_ROLE");
    bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
    bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");

    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() initializer {}

    function initialize() initializer public {
        __ERC20_init("MyToken", "MTK");
        __ERC20Burnable_init();
        __ERC20Snapshot_init();
        __AccessControl_init();
        __Pausable_init();
        __ERC20Permit_init("MyToken");
        __ERC20FlashMint_init();
        __UUPSUpgradeable_init();

        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _setupRole(SNAPSHOT_ROLE, msg.sender);
        _setupRole(PAUSER_ROLE, msg.sender);
        _mint(msg.sender, 100000000 * 10 ** decimals());
        _setupRole(UPGRADER_ROLE, msg.sender);
    }

    function snapshot() public onlyRole(SNAPSHOT_ROLE) {
        _snapshot();
    }

    function pause() public onlyRole(PAUSER_ROLE) {
        _pause();
    }

    function unpause() public onlyRole(PAUSER_ROLE) {
        _unpause();
    }

    function _beforeTokenTransfer(address from, address to, uint256 amount)
        internal
        whenNotPaused
        override(ERC20Upgradeable, ERC20SnapshotUpgradeable)
    {
        super._beforeTokenTransfer(from, to, amount);
    }

    function _authorizeUpgrade(address newImplementation)
        internal
        onlyRole(UPGRADER_ROLE)
        override
    {}

    // The following functions are overrides required by Solidity.

    function _afterTokenTransfer(address from, address to, uint256 amount)
        internal
        override(ERC20Upgradeable, ERC20VotesUpgradeable)
    {
        super._afterTokenTransfer(from, to, amount);
    }

    function _mint(address to, uint256 amount)
        internal
        override(ERC20Upgradeable, ERC20VotesUpgradeable)
    {
        super._mint(to, amount);
    }

    function _burn(address account, uint256 amount)
        internal
        override(ERC20Upgradeable, ERC20VotesUpgradeable)
    {
        super._burn(account, amount);
    }
}

If I remove the upgradability (UUPS/Transparency) I can deploy contract without any problem and does not even require optimization. I have searched everywhere on Google and other forums but couldn't found anything. Please help!

Thanks!

Hi, welcome! :wave:

After you deployed your contract, have you called the function initialize()?

And could you please share your contract address?