Proxy contract won't mint after setting value for a mapping

Through the above link you can find the link to the project, the main contract is LuckyElephantClub.sol file, when I set the value of a mapping through the proxy smart contract the contract reverts the minting transaction.

I had optimised the contract before deployment.

Please can anyone help me with this.

This sounds like an issue with the implementation logic. What error are you getting? Did you call the initializer when deploying the proxy?

Thanks for replying, yes I did call the initializer while deploying the smart contract.

    function initialize() initializer public {
        __ERC721A_init("Lucky Elephant Club", "LEC");
        __Ownable_init();
        __DefaultOperatorFilterer_init();
        __ERC2981_init();
        __ERC721ANameable_init();
        __UUPSUpgradeable_init();

        saleMode = 1;
    }

I think the mappings in the main smart contract are the problem, because whenever I set the value for a particular mapping and proceed to execute the minting function, it gets reverted, for example the airdrop function.

I am using the older version of the erc721a upgradeable smart contract which uses the openzeppelin smart contracts as parents.

Here is the link for the main smart contract. You can take a look at the airdrop function at line 377 which is one of the mint functions.

The smart contract was crossing the 24kb limit hence I had it optimized before deploying.

Ensure the initial values for your mappings are set correctly. What specific revert message do you see?

There is no message with the reverted transaction, as you can see in the attached image.

I have implemented functions in the smart contract through which I am setting the values for the mappings after the deployment.

For example when testing the airdrop function, I am first setting the maxSupply using the function below.

    function setMaxMintAndSupply(uint256 _saleMode, uint256 __maxSupply, uint256 __maxMintPerAddress) public onlyOwner {
        require(__maxSupply >= _minted[_saleMode], "__maxSupply must be greater than or equal to current __minted for the saleMode");
        require(__maxMintPerAddress <= __maxSupply, "__maxMintPerAddress must be smaller than or equal to __maxSupply");
        _maxSupply[_saleMode] = __maxSupply;
        _maxMintPerAddress[_saleMode] = __maxMintPerAddress;
    }

And then executing the airdrop function, but it fails and reverts.

    function airdrop(address[] calldata _recipients, uint256 _amount) public onlyOwner {
        require(_minted[saleMode] + _recipients.length * _amount <= _maxSupply[saleMode], "Exceeds sale mode max supply");
        for (uint256 i = 0; i < _recipients.length; i++) {
            _safeMint(_recipients[i], _amount);
            _minted[saleMode] += _amount;
        }
    }

Are you sure your proxy is using the correct implementation address and is the owner set correctly?

Can you link the transactions? Hard to help out without all the information.

Okay, sending it shortly.

Hey guys I found the fix, but thanks for replying to my questions.

1 Like

Can you share the fix? If another user runs into the same problem later, that would be useful.