[solved/closed] Calling Mint Function keeps returning insufficient funds

I am trying to mint on my Fuji testnet contract. When invoking the mint function I keep getting “execution reverted:insufficient funds”. I assume I have to add a line for the 1avax mint amount somewhere in the params?
I added msgValue: Moralis.Units.ETH(1) to params but that didn’t work either. My code is as below:

const { data: mintData, error: mintError, fetch: mintFetch, isFetching: mintFetching, isLoading: mintLoading } = useWeb3ExecuteFunction({
    abi: spotNFTAbiFuji,
    contractAddress: spotNFTContractFuji,
    functionName: "mint",
    params: {
      bg: props.chosenTrait.BackgroundID,
      body: props.chosenTrait.BodyID,
      head: props.chosenTrait.HeadID,
      eyes: props.chosenTrait.EyesID,
      mouth: props.chosenTrait.MouthID,
      headwear: props.chosenTrait.HeadwearID,
         },
     });

Please advice. I didn’t find anything in the docs regarding setting value for sending amoutn to mint function.

Did the metamask display any error while payment conformation?

@johnversus Metamask didn’t even open for transaction like it normally should. Straight away got error.

Did you try adding msgValue: Moralis.Units.ETH(1) as a useWeb3ExecuteFunction param or in your params object?

I’m pretty sure it should be used as a useWeb3ExecuteFunction param.

1 Like

@_Ty yes I added that. Metamask doesnt even open. My console gives me this error: image

@_Ty this is how I’m calling the function:

   if(!checkTraits()) {
     alert("Some of the selected traits are not in your wallet. Ensure all trait-titles are yellow. Click 'My Owned Traits' again to refresh wallet traits.")
   }

   else {
     
     const mintResult = await mintFetch({
       onError: (err)=> alert(JSON.stringify(err.data.message)),
       onSuccess: (data) => console.log(data)
     })   
   }```

Sorry! I was adding msgValue in the wrong place!


    abi: spotNFTAbiFuji,

    contractAddress: spotNFTContractFuji,

    functionName: "mint",

    params: {

      bg: props.chosenTrait.BackgroundID,

      body: props.chosenTrait.BodyID,

      head: props.chosenTrait.HeadID,

      eyes: props.chosenTrait.EyesID,

      mouth: props.chosenTrait.MouthID,

      headwear: props.chosenTrait.HeadwearID

         },

      msgValue: Moralis.Units.ETH(1.0),

     });

This works. I was adding it in function params. Must step away from computer to clear head :stuck_out_tongue:

1 Like

happens to the best of us :laughing:

1 Like