Cloning Rarible problem

I’m doing a NFT market place similar to Rarible. I’m following the tutorial to clone Rarible but I have a problem minting the NFTs. IPFS upload is fine but the minting is getting the follow issue:


Proxy is connected, Ganache es on, double checked the solidity code and the abi, everything is the same as the tutorial.

This is the JS:

const serverUrl = "";
const appId = "VqIso7CcbXtvDOaEjAdB1RjpWQrMmbin9k3MEAnq";
const TOKEN_CONTRACT_ADDRESS = "0xE3A3CB628206aD4554306badaDEef1657F627197";
Moralis.start({ serverUrl, appId });
let createNewNFT = document.getElementById("fileNewNFT");
let nameNewNFT = document.getElementById("txtItemName");
let descriptionNFT = document.getElementById("txtItemDescription");

createItem = async () => {
    if (createNewNFT.files.lenght == 0) {
        console.log("Select a file");
    } else if (nameNewNFT.value.length == 0) {
        console.log("Give the NFT a name");
    const nftFile = new Moralis.File("nftFile.jpg", createNewNFT.files[0]);
    await nftFile.saveIPFS();

    const nftFilePath = nftFile.ipfs();
    const nftFileHash = nftFile.hash();
    const metadata = {
        name: nameNewNFT.value,
        description: descriptionNFT.value,
        image: nftFilePath,
    const metadataNFT = new Moralis.File("metadata.json", { base64: btoa(JSON.stringify(metadata)) });
    await metadataNFT.saveIPFS();
    const nftFileMetadataFile = metadataNFT.ipfs();
    const nftId = await mintNFT(nftFileMetadataFile);

    const Item = Moralis.Object.extend("Item");
    const item = new Item();
    item.set('name', nameNewNFT.value);
    item.set('description', descriptionNFT.value);
    item.set('nftFilePath', nftFilePath);
    item.set('nftFileHash', nftFileHash);
    item.set('metaFilePath', metadataNFT.ipfs());
    item.set('metaFileHash', metadataNFT.hash());
    item.set('nftId', nftId);
    item.set('nftContractAddress', TOKEN_CONTRACT_ADDRESS);
function loggedOut() {
    console.log("no esta logueado");"../index.html", "_self");
function fadeOut() {
    user = Moralis.User.current();
mintNFT = async (metadataURL) => {
    const receipt = await tokenContract.methods.createItem(metadataURL).send({from: ethereum.selectedAddress});
    return receipt.event.Transfer.returnValues.tokenId;

function clickUploadNDF(){
iniciar = async () => {
    const ethers = Moralis.web3Library;
    window.web3 = await Moralis.enableWeb3();
    window.tokenContract = new ethers.Contract(TOKEN_CONTRACT_ADDRESS, tokenContractAbi);
    if (await Moralis.User.current()) {
    } else { loggedOut(); }
window.onload = iniciar;
document.getElementById("add-photo").onclick = clickUploadNDF;

“metadataURL” seems undefined in your code. try replacing it with “metadataNFT”

This isn’t related to Moralis API.

Consult javascript or Stackoverflow forums.

Hi morpheus, I checked “metadataURL” by printing in console first and is fine. It has the correct structure and for sure is not missing.

Foud that “tokenContract.methods” is undefined. ABI is defined, I can print tokenContract but it seems that doesn’t have methods. The contract and the ABI are the same as the tutorial but I can’t find a solution.