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.02 ether
and there is much more in the rinkeby test net in my wallet.

function mint(uint256 quantity_) external payable {
require(isPublicMintEnabled, “mint is not active”);
require(totalSupply() + quantity_ < maxSupply, “exceeded max sup”);
numberMinted(msg.sender) + quantity <= maxPerWallet,
“can not mint this many”
require(msg.value >= mintPrice * quantity_,“not enought eth sent”);
safeMint(msg.sender, quantity);

I tried to change the require statement to

require(msg.value == 0 ether);

and it worked just fine, so my guess is that msg.value is not sending any ether at all. I have been trying to know how to get the mint price to be sent from the msg.sender but I have reached a dead end.
Hope someone to help me if you faced a problem like this.

How do you call that mint function? If you use Moralis.executeFunction then there is a parameter called msgValue where you set that value.

async function handleMint() {
if (window.ethereum) {
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
const contract = new ethers.Contract(
try {
const response = await contract.mint(BigNumber.from(mintAmount), {
value: ethers.utils.parseEther((0.02 * mintAmount).toString()),
console.log("response: ", response);
} catch (err) {
console.log("error: ", err)

you can try with Moralis.executeFunction:


it should work somehow with your code too, I don’t know now exactly what is the problem in that code

you could try to use console.log for that value to see what it is

there is also Moralis.Units that you can use for conversions