[SOLVED] Moralis Rarible Plugin not working for lazy mint

I’m trying to lazyMint an NFT using the Moralis Rarible Plugin. I have the Plugin installed in my Moralis server but I get this error in my console when trying to lazy mint.

POST https://some numbers.usemoralis.com:2053/server/functions/rarible_postLazyMint 

This is a failed POST request with the status code 400.

The code that I used to lazy mint the NFT is here:

import { MoralisContext, useWeb3Transfer } from "react-moralis";
import { Moralis } from "moralis";
import { useEffect } from "react";
import { useMoralis } from "react-moralis";

export const useMintNft = () => {
    const { enableWeb3, isWeb3Enabled, web3 } = useMoralis();

    useEffect(() => {

        if (!isWeb3Enabled) {
    }, [web3, enableWeb3, isWeb3Enabled]);

    return async function(_owner, _name, _description, _imgData, _supply) {
        const imgFile = new Moralis.File(_imgData.name, _imgData);
        await imgFile.saveIPFS();

        const imgHash = imgFile.hash();


        const metadata = {
            name: _name,
            description: _description,
            image: "/ipfs/" + imgHash
        const metaFile = new Moralis.File("metadata.json", {base64: btoa(JSON.stringify(metadata))});
        await metaFile.saveIPFS();

        const metaDataHash = metaFile.hash();
        let res = await Moralis.Plugins.rarible.lazyMint({
            chain: 'rinkeby',
            userAddress: _owner,
            tokenType: 'ERC721',
            tokenUri: '/ipfs/' + metaDataHash,
            supply: 1,
            royaltiesAmount: 100,
            list: true, // if lazy listing
            listTokenAmount: 1,
            listTokenValue: 10**18, // 1 Eth
            listAssetClass: 'ETH',

        // console.log(res);

I might try the code without having to use it in a hook. But if there’s anything I can do to make this code work then please let me know. Thanks

It seemed you don’t have rarible plugin on the server you’re using. You can check Here to install the plugin.

I already mentioned that I had it installed in my server. Do you think it needs more time to setup installations? It’s already been a day that the plugin has been installed in my computer

if you look in network tab in the browser, do you see any specific error message for that error?

The error code 400 means The server cannot or will not process the request due to something that is perceived to be a client error. Make sure _owner is a valid address

The error code 400 means The server cannot or will not process the request due to something that is perceived to be a client error. Make sure _owner is a valid address

how do make sure it’s a valid address?

You can check normally. It depends on where you got the address from. A user eth address is a valid one

Then I’m sure that I have the correct useraddress. I even copied and pasted my address from Metamask into the function

Try hardcoding all the parameters and see if you get the error

I have done it and the same error occurs

I think it’s a Rarible plugin thing. I tried other APIs and they’re broken too. I tried visiting the Rarible test net and their website doesn’t work. They probably shut down their service for whatever reason. Lack of funding? Cost? Not enough programmers? Broken code? Hackers messing up their stuff?

The testnet site seems to work. As cryptokid said, are you getting any specific error messages if you look inside the response? E.g. incorrect parameter(s) or something more specific for why the request is failing.

I have looked inside the response and it’s difficult to parse especially since the error that Moralis cloud function gives me is “cannot lazy mint token” I have no way to go with this

also their test site might still be working but their nodes for the plugin might not be or the plugins used to make the post requests to the nodes might be outdated and not refreshed for the new node API version. It’s been more than half a year since the plugin had an update for its software

Are you able to give all the options you’re using statically in rarible.lazyMint (e.g. _owner, metaDataHash) as an example? So I can try on my end.

Here this the code I used.

await Moralis.Plugins.rarible.lazyMint({
  chain: 'rinkeby',
  userAddress: '0x7f64041298CC2C045FE5eb0e897ab7b5D4BdB4F3',
  tokenType: 'ERC721',
  tokenUri: '/ipfs/QmWLsBu6nS4ovaHbGAXprD1qEssJu4r5taQfB74sCG51tp',
  supply: 1,
  royaltiesAmount: 5, // 0.05% royalty. Optional

Using your code with my own address I am getting a successful response.

    "success": true,
    "result": {
        "tokenId": "4763751186541760887792473994102991101737838590090169975248428986447131836417",
        "tokenAddress": "0x6ede7F3c26975AAd32a475e1021D8F6F39c89d82"

This is it on Rarible.

Make sure you’re signing from the same userAddress wallet specified there.

Did you make a react app to run your test?
I’m working with react-moralis and I have the plugins installed on my moralis server. I have no idea what is wrong. Could it be my configuration? I enabled Web3 and only mint when a user is logged in.

Oh my gosh. It worked. Sorry for the weird issue on my end. It just had to be the same eth address as the current one I was on. Thx!! <3

1 Like