[SOLVED] 'Error:Cannot Lazy mint the token' when LazyMinting to ethereum mainet - Rarible plugin

I am using the Rarible plugin and trying to lazymint nfts to mainet instead of rinkeby but I keep getting the following error. ‘Cannot lazymint the token’. Is there more modification I need to do besides changing the chain value?
lazyMint

/** Connect to Moralis server */
const serverUrl = "MyserveId";
const appId = "myappId";
Moralis.start({ serverUrl, appId });
let user = Moralis.User.current();

/** Add from here down */
async function login() {
  if (!user) {
   try {
      user = await Moralis.authenticate({ signingMessage: "Hello World!" })
      initApp();
   } catch(error) {
     console.log(error)
   }
  }
  else{
    Moralis.enableWeb3();
    initApp();
  }
}

function initApp(){
    document.querySelector("#app").style.display = "block";
    document.querySelector("#submit_button").onclick = submit;
}

async function submit(){
    const input = document.querySelector('#input_image');
    let data = input.files[0]
    const imageFile = new Moralis.File(data.name, data)
    await imageFile.saveIPFS();
    let imageHash = imageFile.hash();

    let metadata = {
        name: document.querySelector('#input_name').value,
        description: document.querySelector('#input_description').value,
        image: "/ipfs/" + imageHash
    }
    console.log(metadata);
    const jsonFile = new Moralis.File("metadata.json", {base64 : btoa(JSON.stringify(metadata))});
    await jsonFile.saveIPFS();

    let metadataHash = jsonFile.hash();
    console.log(jsonFile.ipfs())
    let res = await Moralis.Plugins.rarible.lazyMint({
        chain: 'eth',
        userAddress: user.get('ethAddress'),
        tokenType: 'ERC721',
        tokenUri: 'ipfs://' + metadataHash,
        royaltiesAmount: document.querySelector('#royalties').value * 100, // 0.05% royalty. Optional
    })
    // document.querySelector('#royalties').value*100
    console.log(res);
    document.querySelector('#success_message').innerHTML = 
        `NFT minted. <a href="https://rarible.com/token/${res.data.result.tokenAddress}:${res.data.result.tokenId}">View NFT`;
    document.querySelector('#success_message').style.display = "block";
    setTimeout(() => {
        document.querySelector('#success_message').style.display = "none";
    }, 10000)
}

login();

The issue has been solved.
Please update your Rarible plugin to version 0.0.45 and try again.
This is my test:
Screenshot 2021-11-21 at 13.08.33

Please notice that, if you are using Filip’s template, the final returned url will point to Rinkeby, although the token has been minted on Mainnet (just change the url)

`NFT minted. <a href="https://rinkeby.rarible.com/token/${res.data.result.tokenAddress}:${res.data.result.tokenId}">View NFT`;

Its functioning now. Thanks for the heads up Dani :+1:

1 Like