OpenSea plugin createBuyOrder triggers undefined

I’m trying to allow a user to place a bid on an NFT on OpenSea. My code is below.

          const bid = await Moralis.Plugins.opensea.createBuyOrder({
            tokenId: i,
            tokenAddress: contractAddress,
            network: 'mainnet',
            amount: userMaxBid,
            userAddress: user.attributes.ethAddress,
          });

It’s successfully initiating MetaMask to sign the transaction, and when it is signed a TypeError is thrown.

TypeError: Cannot read properties of undefined (reading 'triggers')
    at MoralisWeb3.js:957
    at tryCatch (runtime.js:63)
    at Generator.invoke [as _invoke] (runtime.js:293)
    at Generator.next (runtime.js:118)
    at tryCatch (runtime.js:63)
    at maybeInvokeDelegate (runtime.js:356)
    at Generator.invoke [as _invoke] (runtime.js:267)
    at Generator.next (runtime.js:118)
    at asyncGeneratorStep (asyncToGenerator.js:5)
    at _next (asyncToGenerator.js:27)

I have tried entering all inputs as numbers, strings etc and nothing seems to work. I’ve also tried entering the amount in eth, gwei and wei in strng and bigint formats.The fulfillOrder function is working perfectly for me however.

Anyone else got this issue and know how to resolve?

Anyone got any update on this plugin error? Still not resolved.

Update:

Now getting an Unauthorized error response. I have my OS api key pasted into the plugin settings and I know this works as the fulfilOrder endpoint is still working fine.

Error: Something went wrong
{
  "code": 500004,
  "message": "Cannot generate a valid web3 sign payload",
  "details": {
    "method": "signBuyOrder",
    "network": "main",
    "tokenAddress": "0xbc4ca0eda76.....2e118a18a936f13d",
    "tokenId": 1,
    "tokenType": null,
    "startAmount": 0.1,
    "userAddress": "0x43bc534e6f07e7.....265913c54517",
    "error": "API Error 403: Unauthorized."

Now back to the old undefined triggers error. Nothing changed on my end.

Still waiting for any kind of support.

@dani

Hey @anthorner please post the payload you’re sending to the plugin (the object you are sending as argument).

{
            tokenId: i,
            tokenAddress: contractAddress,
            network: 'mainnet',
            amount: userMaxBid,
            userAddress: user.attributes.ethAddress,
}

Hey @dani here’s an example payload I’m sending that returned the error.

{
    "tokenId": 1,
    "tokenAddress": "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d",
    "network": "mainnet",
    "amount": 0.1,
    "userAddress": "redacted",
    "_ApplicationId": "redacted",
    "_ClientVersion": "redacted",
    "_InstallationId": "redacted",
    "_SessionToken": "redacted"
}

Here’s the data I got using { disableTriggers: true }.

{
    "exchange": "0x7be8076f4ea4a4ad08075c2508e481d6c946d12b",
    "maker": "redacted",
    "taker": "0x0000000000000000000000000000000000000000",
    "quantity": "1",
    "makerRelayerFee": "0",
    "takerRelayerFee": "500",
    "makerProtocolFee": "0",
    "takerProtocolFee": "0",
    "makerReferrerFee": "0",
    "waitingForBestCounterOrder": "false",
    "feeMethod": "1",
    "feeRecipient": "0x5b3256965e7c3cf26e11fcaf296dfc8807c01073",
    "side": "0",
    "saleKind": "0",
    "target": "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d",
    "howToCall": "0",
    "calldata": "0x23b872dd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000043bc534e6f07e7c6e766dd344a9e265913c545170000000000000000000000000000000000000000000000000000000000000001",
    "replacementPattern": "0x00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "staticTarget": "0x0000000000000000000000000000000000000000",
    "staticExtradata": "0x",
    "paymentToken": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    "basePrice": "100000000000000000",
    "extra": "0",
    "listingTime": "1641164225",
    "expirationTime": "0",
    "salt": "5899044983866372916133323961583853491341097650514991968321916021733422666074",
    "hash": "0x96c78dd498fe2dfaaf8c62c55900c363a14c586e8c0aa37f160f09ffd78602f1",
    "assetId": "1",
    "assetAddress": "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d",
    "tokenType": "ERC721"
}

Hey @anthorner

This is an example of the payload required by the endpoint:

 await Moralis.Plugins.opensea.createBuyOrder({
  network: 'testnet',
  tokenAddress: '0xdbe8143c3996c87ecd639ebba5d13b84f56855c2',
  tokenId: '0',
  tokenType: 'ERC1155',
  amount: 0.5,
  userAddress: '0x6057b9bA4BAe35B8128685f342a8e1016b77046d',
  paymentTokenAddress: '0xc778417e063141139fce010982780140aa0cd5ab',
});

It seems like you are missing some properties, can you double check?

Our docs: https://github.com/MoralisWeb3/plugindocs/tree/main/opensea%20plugin

Cheers,
Dani

Hey @dani - I have tried several times with just some params and also with all of them. Each get the same result.

Also, tokenType and paymentTokenAddress are passed in by default to OpenSea when those params aren’t passed so that shouldn’t be an issue either.

I have tried again using the full payload posted above.

{
    "tokenId": 1,
    "tokenAddress": "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d",
    "network": "mainnet",
    "amount": 0.1,
    "tokenType": "ERC721",
    "paymentTokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    "userAddress": "redacted",
    "_ApplicationId": "redacted",
    "_ClientVersion": "redacted",
    "_InstallationId": "redacted",
    "_SessionToken": "redacted"
}

I have tried to pass tokenId and amount both as strings & integers but doesn’t seem to make a difference.

Thanks!

Hey @anthorner

The payload correct is the one in our docs.
I was checking the ape you wanna buy and I see a bunch of orders for .01 WETH.

Are these yours?
Asking just to be sure, I am still checking.

Screenshot 2022-01-03 at 15.47.58

Edit:
Can you provide a screenshot of the error message now that you are also sending the tokenType in the payload?

Also remove:

    "_ApplicationId": "redacted",
    "_ClientVersion": "redacted",
    "_InstallationId": "redacted",
    "_SessionToken": "redacted"

Hey @dani thanks for continuing to look into this. Those aren’t my bids.

I’m getting the same error as before, triggers undefined.

TypeError: Cannot read properties of undefined (reading 'triggers')

I think I can reproduce the issue.
Very strange, need to check if something changed in the SDK recently.
Will get back to you.

@anthorner

So I can reproduce and I found the issue:

  • When calling createBuyOrder MetaMask asks to sign a message;
  • The console shows TypeError: Cannot read properties of undefined (reading 'triggers')

I changed the SDK to clearly see what’s the error, and after signing the message the SDK calls a plugin endpoint that returns an error. The error is the following:

This is something new and was not there when I created the plugin.
I checked in the OpenSea SDK project on github and I see a new issue created 18 days ago about this error. Other people seem facing it as well: https://github.com/ProjectOpenSea/opensea-js/issues/305

I will add info in that issue, let’s see what OpenSea responds.

EDIT: I just tried with a new account and I can place buy orders, super strange. Let’s see what they say.

Hey @dani yeah that’s super odd. Thanks for looking into this though. Like some of the comments say on the github issue all my offers are expired so that error message doesn’t make sense. When I’m using opensea-js the createBuyOrder works fine with my wallet address which is really weird!

I’ve updated both moralis & react-moralis to the latest version, updated our moralis server to the latest version but I’m still just getting the undefined triggers error rather than what you posted above? Am I missing something? I have just a simple try catch and logging the error raised.

Also, would we be able to get support for expirationTime within the Moralis plugin?