'Error: Nothing saved to memory card' & 'Invalid JSON RPC response: “Unauthorized”' on using Rarible Lazy Mint Plugin

Using Rarible Plugin to lazy mint an NFT on Rinkeby Testnet. But getting errors like:
Error: Nothing saved to memory card
Error: Invalid JSON RPC response: “Unauthorized”

await Moralis.start({
    serverUrl: "MORALIS_SERVER_URL",
    appId: "MORALIS_APP_ID",
    masterKey: "MORALIS_MASTER_KEY",
});
await Moralis.initPlugins();

const customEnable = async () => {
      const web3Provider = new Web3.providers.HttpProvider("RINKEBY_SPEEDY_NODE");
      const web3 = new Web3(web3Provider);
      return web3;
};
Moralis.setEnableWeb3(customEnable);
await Moralis.enableWeb3();
await Moralis.Plugins.rarible.lazyMint({
      chain: "rinkeby",
      userAddress: "USER_ADDR",
      tokenType: "ERC1155",
      tokenUri: "/ipfs/HASH",
      supply: 1,
      royaltiesAmount: 5,
});

This happens when the payload provided is invalid.

  chain: "rinkeby",
      userAddress: "USER_ADDR",
      tokenType: "ERC1155",
      tokenUri: "/ipfs/HASH",
      supply: 1,
      royaltiesAmount: 5,

Is your Metamask on Rinkeby?
Is the userAddress the same one you have selected on Metamask?

Check all these details and try again.

Hi dani.
Thank you for your reply.
This code is written in server side. So we can’t authenticate via metamask.
I have used Moralis speedy node to create the web3 provider.
Even I have tried to add the wallet to the provider using private key. Still getting the same error.
USER_ADDR is same as the wallet address that i have added with the private key.

await Moralis.start({
    serverUrl: "MORALIS_SERVER_URL",
    appId: "MORALIS_APP_ID",
    masterKey: "MORALIS_MASTER_KEY",
});
await Moralis.initPlugins();

const customEnable = async () => {
      const web3Provider = new Web3.providers.HttpProvider("RINKEBY_SPEEDY_NODE");
      const web3 = new Web3(web3Provider);
      const account = await web3.eth.accounts.privateKeyToAccount(PRIVATE_KEY);
      await web3.eth.accounts.wallet.add(account);
      return web3;
};
Moralis.setEnableWeb3(customEnable);
await Moralis.enableWeb3();
await Moralis.Plugins.rarible.lazyMint({
      chain: "rinkeby",
      userAddress: "USER_ADDR",
      tokenType: "ERC1155",
      tokenUri: "/ipfs/HASH",
      supply: 1,
      royaltiesAmount: 5,
});

Still getting
Error: Nothing saved to memory card
Error: Invalid JSON RPC response: “Unauthorized”

I just tried by manually calling the endpoint and works fine (nodejs)

const axios = require('axios');
const APP_ID = '';
const SERVER_URL = '';

const getLazyMintPayload = async () => {

  const { data } = await axios.post(`${SERVER_URL}/functions/rarible_lazyMint`, {
    chain: "rinkeby",
    userAddress: "",
    tokenType: "ERC1155",
    tokenUri: "/ipfs/HASH",
    supply: 1,
    royaltiesAmount: 5,
})
 console.log(data.result.data);
};

getLazyMintPayload();

In your code you use USER_ADDR but does not seem to be defined.

EDIT: you can also add disableTriggers: true as 2nd argument when calling lazyMint().

const r = await Moralis.Rarible.lazyMint({...}, {disableTriggers: true});
console.log(r)

Hi dani,
Thank you for your reply.
I tried both the approaches that u have mentioned and the error has gone.
and I got the same response in both case as follows:

{
  message: {
    tokenId: '98209046969230315483122249123458747682746130542237275099632349717984509427748',
    tokenURI: '/ipfs/QmRSg8rqH3V2VkkV72355fDNkP8d7Z31SbnNzcDYT2TbRV',
    creators: [ [Object] ],
    royalties: [ [Object] ],
    supply: 1
  },
  types: {
    EIP712Domain: [ [Object], [Object], [Object], [Object] ],
    Mint1155: [ [Object], [Object], [Object], [Object], [Object] ],
    Part: [ [Object], [Object] ]
  },
  domain: {
    name: 'Mint1155',
    version: '1',
    chainId: 4,
    verifyingContract: '0x1AF7A7555263F275433c6Bb0b8FdCD231F89B1D7'
  },
  primaryType: 'Mint1155'
}
{
  name: 'callPluginEndpoint',
  pluginName: 'rarible',
  endpoint: 'postLazyMint',
  params: {
    chain: 'rinkeby',
    tokenUri: '/ipfs/QmRSg8rqH3V2VkkV72355fDNkP8d7Z31SbnNzcDYT2TbRV',
    creators: [ [Object] ],
    royalties: [ [Object] ],
    supply: 1,
    tokenType: 'ERC1155',
    tokenId: '98209046969230315483122249123458747682746130542237275099632349717984509427748'
  },
  useSavedResponse: true,
  savedResponseAs: 'signature',
  savedResponseAt: [ 'result' ],
  shouldAwait: true,
  shouldReturnResponse: true
}

but I couldn’t verify the tokeninfo in rinkeby net using the below url

https://rinkeby.rarible.com/token/0x1AF7A7555263F275433c6Bb0b8FdCD231F89B1D7:98209046969230315483122249123458747682746130542237275099632349717984509427748

Its showing can’t fetch token info.

This is a message that you should sign using V4 signature standard:https://docs.metamask.io/guide/signing-data.html#sign-typed-data-v4

I am familiar on how to do that using MetaMask but not with Web3. You will have to experiment here I guess.

This is how we do it in the SDK: https://github.com/MoralisWeb3/Moralis-JS-SDK/blob/main/src/MoralisWeb3.js#L457

Keep me posted!

Hi dani,
Thank you for your reply.
I tried to sign the message using web3:

const signature = await web3.eth.accounts.sign(message, "0x" + PRIVATE_KEY);

and I got a message hash and signature as follows:

{
  message: { data: 'Sign message V4', triggers: [ [Object], [Object] ] },
  messageHash: '0x5f35dce98ba4fba25530a026ed80b2cecdaa31091ba4958b99b52ea1d068adad',
  v: '0x1c',
  r: '0x82cf96a4adb1a0bb4e8a7b2328b9327cce13db63716935e5313ae66416b0088d',
  s: '0x6966c24c5bf192c59188a4735dd50b7cf8336c74b9dfd7db669a8f89c793db7f',
  signature: '0x82cf96a4adb1a0bb4e8a7b2328b9327cce13db63716935e5313ae66416b0088d6966c24c5bf192c59188a4735dd50b7cf8336c74b9dfd7db669a8f89c793db7f1c'
}

Could you please help me out what to do next with this signature or message hash.

The next step is described in the array you get back when calling lazy mint (triggers[1])
You have to call the endpoint postLazyMint passing these params:

 params: {
          chain,
          tokenUri,
          creators: merged.message.creators,
          royalties: merged.message.royalties,
          supply: merged.message.supply,
          tokenType: rarible.tokenType,
          tokenId: tokenId,
          signature: undefined,
        },

Not sure the rarible API will like that signature, I remembered I tried months ago and I got an error.
Check it out.

Hi dani,
Thank you for your reply. I tried the postLazyMint method and got an error as below:

Error: Something went wrong
{
  "code": 500003,
  "message": "Cannot lazy mint the token",
  "details": {
    "method": "lazyMint",
    "payload": {
      "tokenId": "98209046969230315483122249123458747682746130542237275099632349717984509427819",
      "creators": [
        {
          "account": "0xd92059cab6d51edace1a97a297cd37681c882adf",
          "value": 10000
        }
      ],
      "royalties": [
        {
          "account": "0xd92059cab6d51edace1a97a297cd37681c882adf",
          "value": "5"
        }
      ],
      "supply": 1,
      "uri": "/ipfs/QmRSg8rqH3V2VkkV72355fDNkP8d7Z31SbnNzcDYT2TbRV",
      "@type": "ERC1155",
      "contract": "0x1AF7A7555263F275433c6Bb0b8FdCD231F89B1D7",
      "signatures": [
        "0x0c0084cdbe6030b7816441ab91cfd9f6720b607d4f693a3e072f4b84d7ca9ea7081c6d275323e8f3338864744de23726514a5db6170678071402ad71962be9a11b"
      ]
    },
    "error": "Request failed with status code 400"
  }
}
1 Like

This is what I meant before, that signature is not correct.
400 is returned by the one inch api and indicates a bad signature.

I tried months ago and I got the same error.

The check to do is:
sign with MetaMask (v4) and compare the signature with the one returned by web3.sign

Most likely they are different. In this case we have to check which sign method (web3 or ether) we can use to get the right signature.