opensea-js icon indicating copy to clipboard operation
opensea-js copied to clipboard

{ code: -32603, message: "execution reverted" } when try to buy NFT

Open creed-dev opened this issue 4 years ago • 23 comments

I get an error { code: -32603, message: "execution reverted" } from console when try to buy nft which was put up for sale through the OpenSeaSDK through createSellOrder function. If put it up for sale through the UI, there is no such problem.

Code:

require('dotenv').config();
const opensea = require("opensea-js");
const Network = require("opensea-js").Network;
const OpenSeaSDK = opensea.OpenSeaSDK;
const HDWalletProvider = require("@truffle/hdwallet-provider");
const {WyvernSchemaName} = require('opensea-js/lib/types');

const MNEMONIC = process.env.MNEMONIC;
const NODE_API_KEY = process.env.INFURA_KEY || process.env.ALCHEMY_KEY;
const NFT_CONTRACT_ADDRESS = process.env.NFT_CONTRACT_ADDRESS;
const OWNER_ADDRESS = process.env.OWNER_ADDRESS;
const NETWORK = process.env.NETWORK;
const API_KEY = process.env.API_KEY || ""; // API key is optional but useful if you're doing a high volume of requests.

const provider = new HDWalletProvider({
    mnemonic: MNEMONIC,
    providerOrUrl: "https://" + NETWORK + ".infura.io/v3/" + NODE_API_KEY,
    chainId: 5
});

const seaport = new OpenSeaSDK(
    provider,
    {
        networkName: Network.Goerli
    },
    (arg) => console.log(arg)
);

async function listing(tokenId) {
    try {
        await seaport.createSellOrder({
            asset: {
                tokenId: tokenId,
                tokenAddress: NFT_CONTRACT_ADDRESS,
                schemaName: WyvernSchemaName.ERC721
            },
            startAmount: .001,
            accountAddress: OWNER_ADDRESS
        });

        return "Success!";
    } catch (err) {
        return err;
    }
}

listing("0").then(res => {
    console.log(res);
}).catch(rej => {
    console.log(rej);
});

package.json:

{
  "type": "commonjs",
  "dependencies": {
    "@truffle/hdwallet-provider": "^2.0.15",
    "axios": "^0.27.2",
    "dotenv": "^16.0.2",
    "ethers": "^5.7.1",
    "opensea-js": "^4.0.12",
    "web3": "^1.8.0",
    "wyvern-schemas": "^0.6.15"
  }
}

Node version: v16.17.1

creed-dev avatar Sep 27 '22 12:09 creed-dev

+1 exactly the same error

Smeagolworms4 avatar Sep 28 '22 11:09 Smeagolworms4

+1

carlosbalsas avatar Sep 29 '22 10:09 carlosbalsas

+1

CokeBear666 avatar Sep 29 '22 13:09 CokeBear666

hey - acknowledging the issue, we will look at prioritizing the fix in the next few weeks

cterech avatar Sep 29 '22 13:09 cterech

+1

relipa-dev avatar Sep 30 '22 03:09 relipa-dev

+1

maxtor3569 avatar Oct 05 '22 16:10 maxtor3569

Still receiving this error, any update?

qnft-mjb avatar Oct 05 '22 22:10 qnft-mjb

Not a contributor, but in my working through of trying to solve this I discovered something. This function appears to use wyvern protocol, which is deprecated. Seaport-js package has a function createOrder that should be used to make seaport protocol orders.

qnft-mjb avatar Oct 09 '22 14:10 qnft-mjb

+1 This bug is more than 1 month old, when will there be a fix for this bug?

tantannguyen9x avatar Oct 13 '22 07:10 tantannguyen9x

If not fix, Do you have a workaround to solve the problem?

An example of using createOrder. Because the latter is more complex than createSellOrder.

Smeagolworms4 avatar Oct 13 '22 08:10 Smeagolworms4

To my understanding, createBuyOrder post orders to the wyvern protocol smart contract. This contract is no longer by used by opensea for orders so even if this bug was resolved the orders posted would not appear on opensea(or anywhere?) - opensea is now using the the seaport contract and to interact with that you need to use seaport-js sdk ... And yes sadly it is more complex.

qnft-mjb avatar Oct 14 '22 01:10 qnft-mjb

The method is createShellOrder and not createBuyOrder. (Maybe it's a name mistake in your answer). Do you have an example of using createOrder? However, I did not find the reference to Wyvern on the createSellOrder method.

Smeagolworms4 avatar Oct 14 '22 15:10 Smeagolworms4

Sorry, my issue originated with createBuyOrder and this ticket is for createSellOrder... The error code is the same though...

Again, I am not a contributor and can't confirm this... But the order model you post with this function is designed for wyvern. The create listing/offer api endpoints on Opensea now only accept a seaport order model. Or at least I didn't see any way to successfully list a wyvern order on Opensea.

So to my knowledge, no work around... Ya gotta upgrade 🤷

qnft-mjb avatar Oct 14 '22 16:10 qnft-mjb

Thank you for your answer. On the other hand I have no problem to upgrade because I use openseajs only to make a create sell order. but how do I upgrade with what? do you have an example?

Smeagolworms4 avatar Oct 16 '22 09:10 Smeagolworms4

So there are two issues 0xAskar has posted that have helped me. More discussion on it exists in the comments.

https://github.com/ProjectOpenSea/seaport/discussions/594

https://github.com/ProjectOpenSea/seaport/issues/600

Seaport orders are a little different. If you go Opensea Discord - dev resources channel, there is a video called "seaport workshop" in this they explain the order model.

But you need to use seaport-js (check the readme) to generate and fulfill orders (this will be on chain) - these orders are decoupled from Opensea it's self. Any marketplace can hook up to seaport.

But seaport was developed by OS, they are the main consumer of seaport orders. However they don't list automatically on OS you need write code that first uses seaport-js to produce a signed order, then make a API request (V2 on OS docs) to list the order ( offer = bid, listing = ask) - I don't believe opensea-js ask has a V2 function yet.

Hope this helps.

qnft-mjb avatar Oct 16 '22 12:10 qnft-mjb

Is it still not solved? I even noticed that if I create the order via SDK as usual, this error will appear even on the main OpenSea site.

inartin avatar Oct 18 '22 18:10 inartin

Still not and I haven't been able to find a workaround. Or a fix. +1

Smeagolworms4 avatar Oct 19 '22 09:10 Smeagolworms4

Try this when listing for sale:

  openseaSDK.seaport.createOrder = async (input) => {
    const override = {
      restrictedByZone: false,
      allowPartialFills: false,
    };

    const newInput = { ...input, ...override };

    return await ogCreate.call(openseaSDK.seaport, newInput);
  };

alandotcom avatar Oct 20 '22 03:10 alandotcom

Thank you very mush @alandotcom


const { Seaport } = require('@opensea/seaport-js/lib/seaport');

const oldCreateOrder = Seaport.prototype.createOrder;
Seaport.prototype.createOrder = function (input) {
	return oldCreateOrder.call(this, {
		...input,
		...{
			restrictedByZone: false,
			allowPartialFills: false,
		}
	});
};

Works for me

Smeagolworms4 avatar Oct 20 '22 07:10 Smeagolworms4

Try this when listing for sale:

  openseaSDK.seaport.createOrder = async (input) => {
    const override = {
      restrictedByZone: false,
      allowPartialFills: false,
    };

    const newInput = { ...input, ...override };

    return await ogCreate.call(openseaSDK.seaport, newInput);
  };

This fix the error. Thank you, @alandotcom !

creed-dev avatar Oct 24 '22 07:10 creed-dev