When using require statements in my Smart Contract MM doesnt show the require error

Viewed 27

I have the following function within my smart contract

function setRewardTokenForShareholder(address RWRD) external {
        require(customRewardsAllowed, "Contract: setRewardTokenForShareholder:: Custom Rewards arent allowed");
        
        // Check to ensure we have enough and also that we can 
        uint256 existingBalance = balanceOf(msg.sender);
        require(existingBalance < thresholdForCustomRewards, "You do not have enough tokens to changce your RWRD");

        require(isContract(RWRD), "Contract: setRewardTokenForShareholder:: Address is a wallet, not a contract.");
        require(RWRD != address(this), "Contract: setRewardTokenForShareholder:: Cannot set reward token as this token due to Router limitations.");
        require(!distributor.isBlacklistedRwrdToken(RWRD), "Contract: setRewardTokenForShareholder:: Reward Token is blacklisted from being used as rewards.");

        distributor.setNewRewardForShareholder(msg.sender, RWRD);
    }

What I'm trying to do here is do a bunch of checks on the shareholder to ensure they have enough tokens, the contract they want to set as their custom reward isn't blacklisted and is valid. However, when I fail one of the requirements, MetaMask says "We were not able to estimate gas..." and not the custom require error message.

Is there anything I'm doing wrong? I would much rather the error message I've defined would be used.

0 Answers
Related