Hey guys, Iāve been building my first dApp with Moralis and React and right now Iām stuck on my minting function. Iāve been reading the forum but I could not find a solution, and trust me I tried a lot of stuff. Iām attaching my code, my solidity contract, my abi, my nft object Iām trying to mint and the error Iām getting, so you can have all the information needed⦠Really hope ope someone can help me out!! Cheers
Solidity Contract:
contract ZimCollectables is ERC721URIStorage {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
constructor() ERC721('ZimCollectables', 'ZCOL') {}
function mintToken(address recipient, string memory tokenURI) public returns (uint256) {
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_safeMint(recipient, newItemId);
_setTokenURI(newItemId, tokenURI);
return newItemId;
}
}
NFT object to be minted (nft):
{
"id": "30",
"title": "Happy Corgi",
"photo": "https://cdn.pixabay.com/photo/2019/08/19/07/45/dog-4415649_1280.jpg",
"price": "1750",
"category": "pet",
}
ABI:
const abi = {
inputs: [
{
internalType: 'address',
name: 'recipient',
type: 'address',
},
{
internalType: 'string',
name: 'tokenURI',
type: 'string',
},
],
name: 'mintToken',
outputs: [
{
internalType: 'uint256',
name: '',
type: 'uint256',
},
],
stateMutability: 'nonpayable',
type: 'function',
};
Minting Function:
const MintNFT = async nft => {
const options = {
contractAddress: contractAddress,
functionName: 'mintToken',
abi: abi,
params: {
recipient: user.attributes.ethAddress,
tokenURI: nft,
},
};
const receipt = await Moralis.executeFunction(options);
console.log(receipt)
};
Error:
PLEASEEE HELPPPP MEEE!