In my react moralis app I have following imports:
import { Moralis } from 'moralis';
import { useMoralis, useMoralisWeb3Api, useNewMoralisObject, useMoralisCloudFunction, useWeb3ExecuteFunction } from 'react-moralis';
import { contractAbi } from '../abis/abi';
and following component:
const CreateNFT = () => {
const { data, error, fetch, isFetching, isLoading } = useWeb3ExecuteFunction({
abi: contractAbi,
contractAddress: '0x0B41BA45e82d6A4F2e70EC5Bc6ce191798dC29A1',
functionName: "mint",
params: {
_to: user.attributes.ethAddress,
_mintAmount: 1
},
});
return (<div>
{error && <div>{JSON.stringify(error)}</div>}
<button onClick={() => fetch()} disabled={isFetching}>Mint NFT</button>
</div>);
}
In solidity, the mint function looks like this:
function mint(address _to, uint256 _mintAmount) public {
uint256 supply = totalSupply();
require(!paused);
require(_mintAmount > 0);
require(_mintAmount <= maxMintAmount);
require(supply + _mintAmount <= maxSupply);
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(_to, supply + i);
}
}
This returns an error, but the errorโs array is empty. What could be the reason?