Opensea fulfillOrder with Nodejs

Iā€™m trying to make the fulfillOrder command of the OpenSea plugin work in nodejs (without browser) but I keep getting errors. I even tried this old repo but Iā€™m getting a 400 response from the server so I guess things changed on the Moralis server side. The getOrders works as expected and prints out the order.

import Moralis from 'moralis/node.js';

const serverUrl = '';
const appId = '';
const moralisSecret = '';

async function initiate() {
  await Moralis.start({ serverUrl, appId, moralisSecret });

  await Moralis.enableWeb3({
    chainId: 1,
    privateKey: '',
  });

  const order = await Moralis.Plugins.opensea.getOrders({
    network: 'mainnet',
    tokenAddress: '0x3110EF5f612208724CA51F5761A69081809F03B7',
    tokenId: '370',
    orderSide: '1',
    page: 1, // pagination shows 20 orders each page
  });

  await Moralis.Plugins.opensea.fulfillOrder({
    network: 'mainnet',
    userAddress: '',
    order: order.orders[0],
  });
}

initiate();

The error Iā€™m getting:

node_modules\moralis\lib\node\RESTController.js:423
        error = new _ParseError.default(errorJSON.code, errorJSON.error);
                ^                                                                             3

ParseError: [object Object]

It seems like a parse error but thereā€™s little documentation to figure out where the parsing goes wrongā€¦

Any error in the server logs?
You have your own opensea api key?

Opensea plugin may not work now with fulfillOrder even if you use it directly in front end

Yes, I have my own OS API key. I tried the Moralis plugin on testnet as well but there the .getOrders is always returning 0 and manually fetching the orders from the OS API and passing it to .fulfilOrder gives parsing errors.

Today the Moralis server logs show this error for mainnet: Error: {ā€œmessageā€:ā€œsocket hang upā€,ā€œcodeā€:141}

I heard about this ā€œsocket hang upā€ error before, I donā€™t know a fix for it.

Seems like the opensea plugin is a mess at the moment, might try it again once they fix it. For now, Iā€™m using the Seaport SDK even though thatā€™s a bit buggy too.

1 Like