I have an issue with the mint function in the smart contract

This is my mint function, “not enough eth sent” error shows up on minting even though there is enough eth in the wallet.

mint price is: 0.05 ether
and there is much more in the rinkeby test net in my wallet.

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "erc721a/contracts/ERC721A.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

contract STETTE is ERC721A, Ownable, ReentrancyGuard {
uint256 public mintPrice;
uint256 public maxSupply;
uint256 public maxPerWallet;
//uint256 public totalSup;
bool public isPublicMintEnabled;
string internal baseTokenURI;
mapping(address => uint256) public walletMints;
constructor() payable ERC721A("STETTE", "ST") {
    mintPrice = 50000000000000000; //0.05 ETH
    maxSupply = 1000;
    maxPerWallet = 3;
    //totalSup = 0;
}
function setIsPublicMintEnabled(bool _isPublicMintEnabled)
    external
    onlyOwner
{
    isPublicMintEnabled = _isPublicMintEnabled;
}
function setBaseTokenURI(string calldata _baseTokenURI) external onlyOwner {
    baseTokenURI = _baseTokenURI;
}
function tokenURI(uint256 tokenId_)
    public
    view
    override
    returns (string memory)
{
    require(_exists(tokenId_), "Token does not exist!");
    return
        string(
            abi.encodePacked(
                baseTokenURI,
                Strings.toString(tokenId_),
                ".json"
            )
        );
}
function withdraw() external onlyOwner nonReentrant {
    (bool success, ) = msg.sender.call{value: address(this).balance}("");
    require(success, "Transfer failed.");
}
function mint(uint256 quantity_) external payable {
    require(isPublicMintEnabled, "mint is not active");
    require(totalSupply() + quantity_ < maxSupply, "exceeded max sup");
    require(
        _numberMinted(msg.sender) + quantity_ <= maxPerWallet,
        "can not mint this many"
    );
    _safeMint(msg.sender, quantity_);
}
}

hey @Ship
You are not requiring that msg.value is at least mintPrice. So anyone can mint for free

Hey @FreezyEx, Thank you But i use " require(msg.value == quantity_ * mintPrice, 'Wrong mint value.'); " but a still have the same problem

Please attach a screenshot of the error

When I add "uint256 public totalSupply;" I got this error

Hi, welcome to the community! :wave:

It works well for me. I just deployed the contract STETTE, then called the function setIsPublicMintEnabled with the parameter true, and then called the function mint(), there is no errors, so I am not sure why you encountered some errors, so is there a failed transaction hash?