Giter VIP home page Giter VIP logo

seaport-js's Introduction

Version npm Test CI Code Coverage License Docs Discussions

Seaport.js

Seaport is a new marketplace protocol for safely and efficiently buying and selling NFTs. This is a TypeScript library intended to make interfacing with the contract reasonable and easy.

Synopsis

This is a TypeScript library to help interface with Seaport. It includes various helper methods and constants that makes interfacing with Seaport easier. These include creating orders, fulfilling orders, doing the necessary balance and approval checks, and more. We recommend taking a look at the Seaport docs to get a better understanding of how the Seaport marketplace works.

Installation

We recommend using nvm to manage Node.js versions. Execute nvm use, if you have nvm installed.

Then, in your project, run:

npm install --save @opensea/seaport-js

Getting Started

Instantiate your instance of seaport using your ethers provider:

Examples

Through a browser provider (i.e. Metamask)

import { Seaport } from "@opensea/seaport-js";
import { ethers } from "ethers";

const provider = new ethers.BrowserProvider(window.ethereum);

const seaport = new Seaport(provider);

Through a RPC Provider (i.e. Alchemy)

import { Seaport } from "@opensea/seaport-js";
import { ethers } from "ethers";

const provider = new ethers.JsonRpcProvider(
  "https://<network>.alchemyapi.io/v2/YOUR-API-KEY",
);

const seaport = new Seaport(provider);

With custom signer

import { Seaport } from "@opensea/seaport-js";
import { ethers } from "ethers";

// Provider must be provided to the signer when supplying a custom signer
const provider = new ethers.JsonRpcProvider(
  "https://<network>.alchemyapi.io/v2/YOUR-API-KEY",
);

const signer = new ethers.Wallet("YOUR_PK", provider);

const seaport = new Seaport(signer);

Look at the relevant definitions in seaport.ts in order to see the different functionality this library offers.

Use Cases

Many of the main core flows return use cases. What this means is that if you were to create an order (a la createOrder), the library helps perform the necessary balance and approval checks based on the offer of the order being created. If the offerer requires approvals on one asset contract, the actions field of the use case would contain an approval action that the user should execute first in order for the trade to succeed in the future.

Examples

Listing an ERC-721 for 10 ETH and fulfilling it

const offerer = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266";
const fulfiller = "0x70997970c51812dc3a010c7d01b50e0d17dc79c8";
const { executeAllActions } = await seaport.createOrder(
  {
    offer: [
      {
        itemType: ItemType.ERC721,
        token: "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
        identifier: "1",
      },
    ],
    consideration: [
      {
        amount: ethers.parseEther("10").toString(),
        recipient: offerer,
      },
    ],
  },
  offerer,
);

const order = await executeAllActions();

const { executeAllActions: executeAllFulfillActions } =
  await seaport.fulfillOrder({
    order,
    accountAddress: fulfiller,
  });

const transaction = executeAllFulfillActions();

Making an offer for an ERC-721 for 10 WETH and fulfilling it

const offerer = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266";
const fulfiller = "0x70997970c51812dc3a010c7d01b50e0d17dc79c8";
const { executeAllActions } = await seaport.createOrder(
  {
    offer: [
      {
        amount: parseEther("10").toString(),
        // WETH
        token: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
      },
    ],
    consideration: [
      {
        itemType: ItemType.ERC721,
        token: "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
        identifier: "1",
        recipient: offerer,
      },
    ],
  },
  offerer,
);

const order = await executeAllActions();

const { executeAllActions: executeAllFulfillActions } =
  await seaport.fulfillOrder({
    order,
    accountAddress: fulfiller,
  });

const transaction = executeAllFulfillActions();

Contributing

See the contributing guide for detailed instructions on how to get started with this project.

License

MIT Copyright 2022 Ozone Networks, Inc.

seaport-js's People

Contributors

0xshisui avatar arr00 avatar dependabot[bot] avatar frankisawesome avatar isvidler avatar joshuaschmidt-opensea avatar jtaaa avatar kenlr avatar mi-yu avatar miguelgonzales-wiv avatar montasaurus avatar orenyomtov avatar perpetuum7 avatar renovate[bot] avatar rombrom avatar ryanio avatar slokh avatar sofianeouafir avatar sosoxuc avatar stephankmin avatar sunwrobert avatar tenthirtyone avatar thatisgreat avatar trejgun avatar ximon-x avatar xtools-at avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

seaport-js's Issues

Why public and restricted orders have order type 2?

Hi, no matter how I list NFTs for sale, as private or public orders, the Seaport order type is always 2 on https://testnets.opensea.io, while I expected it to be 0 (public) and 2 (private). At least that's my interpretation of https://github.com/ProjectOpenSea/seaport-js/blob/16c77475a6d61452eae01a3092f2e0c435dfc76d/src/constants.ts#L40_L45.

Can someone explain why it is 2 in both cases and under what circumstances an order type of 0 applies? Thanks!

Multilple Bids for different assets?

Hey

I managed to make via seaportJS a bid on an ERC721 asset (1 <-> 1) and I was wondering if it was possible to make several bids on different assets?

for example:

{
   0.5 WrappedETH -> 1 NFT from contract 0x123..
   0.4 WrappedETH -> 1 NFT from contract 0x456..
   0.6 WrappedETH -> 1 NFT from contract 0x789..
}

If yes, does someone have examples on it?

Thanks :)

My Orders on OpenSea

Hey!
After reading this tweet that was posted on the OpenSea account (https://twitter.com/opensea/status/1570482796271140864) I had some questions.

What listings/offers will be fulfillable on OpenSea? Does this refer to the orders created with the createBuyOrder function in this library?
If it is not referring to these orders, then what listings are being referred to in this tweet?

My use-case would be me having my own dapp where I can create orders using seaport-js for others to fulfill only on my dapp.

Confusion with createOrder params

Hey 👋,

the portion of documentation for making orders is a little confusing

https://github.com/ProjectOpenSea/seaport-js/blob/main/README.md#making-an-offer-for-an-erc-721-for-10-weth-and-fulfilling-it

The params seem to be incorrect, for example the docs suggest us to use createOrder like so, this simply does work

const { executeAllActions } = await seaport.createOrder({
  offer: [
    {
      amount: parseEther("10").toString(),
      // WETH
      token: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    },
  ],
  consideration: [
    {
      itemType: ItemType.ERC721,
      token: "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
      identifier: "1",
      recipient: offerer,
    },
  ],
  accountAddress: offerer,
});

and needs to be rewritten as

const { executeAllActions } = await seaport.createOrder(
  {
    offer: [
      {
        itemType: ItemType.ERC721,
        token: "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
        identifier: "1",
      },
    ],
    consideration: [
      {
        amount: parseEther("10").toString(),
        recipient: offerer,
      },
    ],
  },
  offerer
);

Am I understanding this correctly? Can we update the documentation to be a bit clearer on what is expected?

Gas probleme

Hi,

I am getting this error when trying to buy an order . It seems to struggle with gas:

cannot estimate gas; transaction may fail or may require manual gas limit [ See: https://links.ethers.org/v5-errors-UNPREDICTABLE_GAS_LIMIT ] (reason="execution reverted", method="estimateGas", transaction={"from":"0x9f3752cd801fD513dAD4200aD08EA6b9d149C6Cd","to":"0x00000000006c3852cbEf3e08E8dF289169EdE581","value":{"type":"BigNumber","hex":"0x12795f58d50000"},"data":"0xfb0f3ee1000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000

. I am using truffle/hd wallet. Any idea where it could come from?

UnhandledRejection from isApprovedForAll() call

With Ethers 5.7.0 (JsonRpcProvider), Node 16 and seaport-js 1.0.8, I get a UnhandledRejection when calling seaport.fulfillOrder() on a no longer valid OrderWithCounter, specifically this is the error I get;

Error: call revert exception [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (method="isApprovedForAll(address,address)", data="0x", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.7.0)
      at Logger.makeError (node_modules\@ethersproject\logger\src.ts\index.ts:269:28)
      at Logger.throwError (node_modules\@ethersproject\logger\src.ts\index.ts:281:20)
      at Interface.decodeFunctionResult (node_modules\@ethersproject\abi\src.ts\interface.ts:427:23)
      at Contract.<anonymous> (node_modules\@ethersproject\contracts\src.ts\index.ts:400:44)
      at step (node_modules\@ethersproject\contracts\lib\index.js:48:23)
      at Object.next (node_modules\@ethersproject\contracts\lib\index.js:29:53)
      at fulfilled (node_modules\@ethersproject\contracts\lib\index.js:20:58)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)

Digging around, it appears it's caused by a missing catch in approval.ts

Example in the Readme

Is it correct that opensea.js will be deprecated in the future in favor of this one? If so it would be great to have examples like opensea.js has of things like fulfilling sell orders. Also was there a decision to move from web3 to ethers, or will this also support web3?

The fulfiller does not have the balances needed to fulfill.

Can someone help me understand why I get this error?
I'm trying to buy a nft that's listed on opensea.
The fulfiller is the owner of the nft, correct?
I verified that the owner address is right.
The message sounds like seaport thinks the owner doesn't have that token...

const provider = new ethers.providers.Web3Provider(window.ethereum)
const seaport = new Seaport(provider)
let [account] = await window.ethereum.enable()

const offerer = account // me
const fulfiller = "0x3649b5fA32d367BfAf218354cf5eB7Ab55AE1c46" // the address that owns the token

const { executeAllActions } = await seaport.createOrder(
  {
    offer: [
      {
        amount: ethers.utils.parseEther("0.0019").toString(),
        recipient: fulfiller,
      },
    ],
    consideration: [
      {
        itemType: 2, //ItemType.ERC721,
        token: "0x42921c64797b64499a3ad3a3cdbbfab7bee294fe",
        identifier: "1262",
        recipient: offerer,
      },
    ],
  },
  offerer
)

const order = await executeAllActions()
console.log(order)

const { executeAllActions: executeAllFulfillActions } =
  await seaport.fulfillOrder({
    order,
    accountAddress: account,
  });

const transaction = executeAllFulfillActions();

Can't create sell orders (listings) that reflect on OpenSea

Thanks for this library, it looks very promising (esp. with support of ethers and different networks like Polygon) which are missing in OpenSea.js SDK.

I am trying to use this to create sellorder/listings in bulk for a ERC721 contract. Though the transaction succeeds, there is no sale listing created for the said item on OpenSea.

But if I follow the create Order with fullfill orders (as in sample), the sale is reflected in OpenSea and I can see Transfer of the token between offerrer and fulfiller.

Chain: Polygon Mumbai
Contract: ERC721 - deployed and items minted already

-------------------------- code snippet for brevity --------------------------
const { executeAllActions } = await seaport.createOrder(
{
offer: [
{
itemType: ItemType.ERC721,
token: deployment.address,
identifier: "1",
}
],
consideration: [
{
amount: ethers.utils.parseEther("0.040").toString(),
recipient: offerer,
}
],
}
);
const order: OrderWithCounter = await executeAllActions();

// this part also works well, the token sale is reflected on Open Sea
/*const { executeAllActions: executeFullfillActions} = 
    await seaport.fulfillOrder({
        order,
        accountAddress:fulfiller,
    });
const txn = await executeFullfillActions();
console.log(`transaction hash:${txn.hash}`);*/

// this goes through, I can see the transaction on polygonscan, but the sale listing is not created on OpenSea
const txmethod = await seaport.validate([order]);
await txmethod.buildTransaction()
const tx = await txmethod.transact();
console.log(`Transaction Hash:${tx.hash}`);
await tx.wait();

Difference seaport js Vs Open Sea Js

Hi OpenSea,

I want to do transaction to list NFTs and fufillOrders.

It is not reallly clear to me which library should I use for that. It seems than opensea js does the job, but seaport could do it as well..

Pb, there is no field for the Opensea key in its instance .. what is strange.

Could you please make it a bit clearer.. thanks in advance ?

How to specify which signer to send fulfillOrder function from?

Within the docs is says that the accountAddress is the "optional address from which to fulfill the order from", however, when testing, the transactions are 1. giving "cannot estimate gas" error, 2. attempting to be sent from the offerer address and not the specified fulfiller address.

 const { executeAllActions: executeAllFulfillActions } =
    await seaport.fulfillOrder({
      order,
      accountAddress: fulfiller.address,
    });

  const transaction = executeAllFulfillActions();

This is the code being used (directly from the docs). I can provide more of the code being used if necessary

Error: Invalid order signature

I am manually building and signing an EIP-712 message corresponding to a seaport listing order using the order components (to be precise I am not using seaport-js to do this).

Once signed, I call the create order API endpoint for RINKEBY network and provide the order components + the EIP-712 signature.

I get the following error: 'Invalid order signature'

Could you give me some precisions on:

  • What format / types do you expect for the EIP-712 message? Can you give an example?
  • What format / types do you expect for the API params parameters and signature? Can you give an example?
  • How the API backend verifying the signature? Do you expect a classic EIP-712 signature string?

[question] Should the README example work?

Hi there,

Thanks for creating this library. I'm trying to run the code in the example to just understand how the library and seaport work, however, on running the code in the example as is using an RPC provider (Infura) for Seaport I receive an error back with:

call revert exception 
[ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] 
(method=\"ownerOf(uint256)\", data=\"0x\", errorArgs=null, 
errorName=null, errorSignature=null, reason=null, 
code=CALL_EXCEPTION, version=abi/5.7.0)

I'm assuming that the error has something to do with a call to a contract ownerOf but it doesn't specify which contract (i.e. Seaport or ERC[20/721/1155]). After adding some logging to the seaport-js library distribution and tracing through, I managed to find the failure point at the checking approvals step here.

My understanding is this step should check, if all library defaults are taken, whether the offerer account has given the default Seaport Conduit Key approval permission to transfer the Doodles ERC721, but instead it seems like the contract call fails with a revert.

Unfortunately the RPC provider doesn't have any better but would appreciate any better ideas if you have any. I'm running the example on Goerli network.

Getting Started

Let's say I wanted to build a new marketplace using seaport and seaport-js. Would I need to deploy my own version of the seaport contract or i would rely on the existing one? If I rely on the existing one, would that mean opensea get the 2.5% commission?

It a little unclear if opensea is 100% decoupled from seaport or where the opensea business logic lives.

Updating gas fees for transaction

Hey there! I totally could be missing something, but it doesn't look like there's a way as of now to update the gas fees (priority fee, mainly) for a certain transaction before fulfilling it.

It looks like it's technically built in a bit by allowing updates to payableOverrides to make their way into the getTransactionMethods function, but there's currently no way to update payableOverrides via the .fulfillX methods :)

Is there a downside to allowing users to pass through something like:

seaport.fulfillOrder({
  order,
  accountAddress,
  payableOverrides: {
    gas: '...',
    maxPriorityFeePerGas: '...',
    maxFeePerGas: '...',
  }
})

Support Node >=v14

Most apps that will use seaport-js will be webapp clients. It doesn't make sense to enforce the latest node version when node is not used on the client.

I'm requesting that you downgrade the seaport-js node requirement to 14, ie >=v14.19.1 or just remove this restriction altogether.

The reason I'm asking is because I'm up-taking seaport on my client app which is served by a Node 14 server-- it's turning out to be a challenging upgrade. Since the seaport protocol was just released, it is time sensitive for my app to upgrade before you disable wyvern.

Thanks.

Opensea API wont accept order object created returned from "executeAllActions"

I create a bid on a item via the seaport SDK like this

const { executeAllActions } = await seaport.createOrder(
        {
            offer: [
                {
                    amount: basePrice.toString(),
                    token: WETH,
                }
            ],
            consideration: [item, ...considerationFeeItems],
            endTime: endTime.toString(),
            zone: DEFAULT_ZONE_BY_NETWORK[opensea.Network.Main],
            restrictedByZone: true,
            allowPartialFills: false,
            conduitKey: CROSS_CHAIN_DEFAULT_CONDUIT_KEY,
            counter: 0
        },
        ourAddress
    );
    
const order = await executeAllActions();

Works perfectly fine.

but when I send it to the Opensea API 2.0 I get the error:
Error: API Error 400: Asset does not exist.

Why is that?

This is there reutrn from executeAllActions

{
parameters: {
 offerer: '0x...',
 zone: '0x004c00500000ad104d7dbd00e3ae0a5c00560c00',
 zoneHash: '0x3000000000000000000000000000000000000000000000000000000000000000',
 startTime: '1660557986',
 endTime: '1660644385',
 orderType: 2,
 offer: [ [Object] ],
 consideration: [ [Object], [Object], [Object] ],
 totalOriginalConsiderationItems: 3,
 salt: '0xc532bab0fd9ae9529b4d8cfc9fc2f02e',
 conduitKey: '0x0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f0000',
 counter: 0
},
signature: '0x....'
}

I dont know where the bug here is, with the SDK or with the API or if its all as intended.

Bignumber error on createOrder

Trying to create offer using this js and getting a weird error that comes from
Uncaught (in promise) Error: invalid BigNumber value (argument="value", value=undefined, code=INVALID_ARGUMENT, version=bignumber/5.6.2)

in order.js
lines 151

It did read endAmount succesfully tho, meanwhile they are the same string
image

offerList.push({
itemType: type, //type int 1
token: element[0],//weth contract
identifier: 0, //int
startAmount: "10000000000000000000", //string, tried bignum, tried everything
endAmount: "10000000000000000000", //string, tried bignum, tried everything
})

Issues connecting to provider or signer

Hi,

Whenever I try to connect Seaport to a provider using
const provider = new ethers.providers.Web3Provider(window.ethereum);
I get the error:
either a provider or custom signer with provider must be provided

And if i try to connect using a rpc provider like the example in the docs:
const provider = new ethers.providers.JsonRpcProvider( "https://<network>.alchemyapi.io/v2/YOUR-API-KEY" );
I get the error:
TypeError: provider.getNetwork is not a function
Is this because Seaport can not access ethers?
Calling getNetwork manually works perfectly fine

I am locally shipping seaport and ethers through the browser
Hope someone can help

New OpenSea salt generation breaks getOrderHash, getting "hex data is odd-length" error

Problem

I started getting a hex data is odd-length error when trying to call fulfillOrder on any opensea listings posted within the past ~12 hours. I traced this down to the getOrderHash function, see this line:

orderComponents.salt.slice(2).padStart(64, "0"),

The problem is that new listings on OpenSea will have a salt with length 77, an odd number that isn't remedied by the padStart(64, "0") call here since it is also longer than 64 characters. I also find it odd that there's a slice(2) here, because from what I can see the salt that's passed in through the order object does not start with 0x (which is what I assume this would be trying to remove).

Local workaround

I'm currently working around this issue in my own code by prepending a 0 to the salt string on the order object if it happens to be of odd length, before passing it to the fulfillOrder function in opensea-js.

const order = await openseaSDK.api.getOrder({ side: "ask", ... })
if (order.protocolData.parameters.salt.length % 2) {
  order.protocolData.parameters.salt =
    '0' + order.protocolData.parameters.salt
}
const transactionHash = await openseaSDK.fulfillOrder({ order, ... })

Default provider confusion from the documentation

👋 Hey guys,

I am trying to figure out how to use this library instead of the opensea-js mostly of this library support of bulk purchasing of tokens.

No matter how I try to figure out what providers to use nothing works and documentation suggests to use

const provider = ethers.getDefaultProvider();

Which is seemingly incorrect and doesn't work out of the box, as the library works only with JsonRpcProvider and getDefaultProvider exports BaseProvider that is missing getSigner method.

private provider: providers.JsonRpcProvider;

So trying to understand if I am doing something that I am not supposed to do, or we should really update the docs with more relevant example.

Thanks.

POST /v2/orders/: canceling statement due to statement timeout

Hello OpenSea team!

I am trying to post a seaport order to the new v2 endpoint.

URL: https://api.opensea.io/v2/orders/ethereum/seaport/offers

Data:

{"parameters":{"offerer":"0x2a47583d9604E25f4e1AadF323f8701bB93Cad33","zone":"0x004c00500000ad104d7dbd00e3ae0a5c00560c00","zoneHash":"0x3000000000000000000000000000000000000000000000000000000000000000","startTime":"1655499967","endTime":"1655586366","orderType":2,"offer":[{"itemType":1,"token":"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2","identifierOrCriteria":"0","startAmount":"10000000000000000","endAmount":"10000000000000000"}],"consideration":[{"itemType":2,"token":"0x9c8ff314c9bc7f6e59a9d9225fb22946427edc03","identifierOrCriteria":"0","startAmount":"1","endAmount":"1","recipient":"0x2a47583d9604E25f4e1AadF323f8701bB93Cad33"},{"itemType":1,"token":"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2","identifierOrCriteria":"0","startAmount":"250000000000000","endAmount":"250000000000000","recipient":"0x8de9c5a032463c561423387a9648c5c7bcc5bc90"}],"totalOriginalConsiderationItems":2,"salt":"0xce3dd639ae780510e18108a332850e40","conduitKey":"0x0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f0000","counter":0},"signature":"0xb5...d992"}

Error: errors: [ 'canceling statement due to statement timeout\n' ]

I have successfully fixed the previous errors:

  1. errors: [ 'Invalid order signature' ]
  2. errors: [ 'You provided an invalid order type: OrderType.FULL_OPEN, please set it to be FULL_RESTRICTED or PARTIAL_RESTRICTED' ]

no issues

I was lying and no one helped anyway

Error when calling `cancelOrders`

Hey folks,

With the following code calling cancelOrders():

const seaport = new Seaport(userSigner);
seaport.cancelOrders([orderComponents]);

I'm getting the following error:

Error: invalid address or ENS name (argument="name", value=undefined, code=INVALID_ARGUMENT, version=contracts/5.6.2)

...which is very strange because the following code where I cancel by trying to connect directly to the contract exposed by the Seaport instance also fails with the same error:

  const seaport = new Seaport(userSigner);
  const contract = seaport.contract.connect(userSigner);
  contract.cancel([item.protocolData])
      .then(result => {
            console.log("Result: ", result);
      })
      .catch(err => console.error(err));

Anybody see anything like this?

[bug] bulkCancelOrders is broken

calling

seaport.bulkCancelOrders()

results in error

Screen Shot 2022-06-07 at 08 46 14

because of improper type conversion

here
an empty array is passed

here last item of this empty array is taken which is undefined

and here this undefined is passed to Object.keys which can accept an only object.

I can create PR with a fix. just tell me if defaulting obj to {} in instanceOfOverrides would be appropriate

Support latest node LTS version

receiving this error installing opensea-js version 4.0.0-beta.2 via yarn.

error @opensea/[email protected]: The engine "node" is incompatible with this module. Expected version "16.11.0". Got "16.14.2"

If there aren't compatibility issues, would be nice to support the latest versions of node. 16.15.1 is currently the latest LTS version

Supports Polygon Network?

hello there, I want to know if this project is already supporting polygon network?
Let me explain my situation:
I have a collection of nft on the polygon network and I would like to create a marketplace using the opensea sdk, but I read that opensea-js does not support polygon, I wanted to know if seaport-js supports it, I could not find any information about it

in case that not support polygon, can you recommend me some idea to build my marketnft on my site using opensea below

thanks for advance!

eth_signTypedData_v4 issue while trying createOrder() from non-browser providers.

Hey, there was an error about signing data after migrating to opensea-js V 2.0.0 based on issue ProjectOpenSea/opensea-js#372 .

I'm facing with same issue again after trying to use opensea-js 4.0.1 version to createOrder with hdwallet-provider .
Anyway, all the functions about signing data moved to seaport-js.

/node_modules/@truffle/hdwallet-provider/node_modules/eth-sig-util/dist/index.js:172
        if (results.includes(primaryType) || types[primaryType] === undefined) {
                                                  ^
TypeError: Cannot read properties of undefined (reading 'EIP712Domain')

On opensea-js that issue solved by creating a catch block to handle eth_signTypedData_v4 errors and use it eth_signTypedData instead of it, but I can see that web3.js is no longer used in seaport-js.

export async function signTypedDataAsync(
  web3: Web3,
  message: object,
  signerAddress: string
): Promise<ECSignature> {
  let signature: JsonRpcResponse | undefined;
  try {
    // Using sign typed data V4 works with a stringified message, used by browser providers i.e. Metamask
    signature = await promisify<JsonRpcResponse | undefined>((c) =>
      (web3.currentProvider as AbstractProvider).sendAsync(
        {
          method: "eth_signTypedData_v4",
          params: [signerAddress, JSON.stringify(message)],
          from: signerAddress,
          id: new Date().getTime(),
          // eslint-disable-next-line @typescript-eslint/no-explicit-any
        } as any,
        c
      )
    );
  } catch {
    // Fallback to normal sign typed data for node providers, without using stringified message
    // https://github.com/coinbase/coinbase-wallet-sdk/issues/60
    signature = await promisify<JsonRpcResponse | undefined>((c) =>
      (web3.currentProvider as AbstractProvider).sendAsync(
        {
          method: "eth_signTypedData",
          params: [signerAddress, message],
          from: signerAddress,
          id: new Date().getTime(),
          // eslint-disable-next-line @typescript-eslint/no-explicit-any
        } as any,
        c
      )
    );
  }

When I check code, can see same signing method but it's handled by ethers.js and there's no support for eth_signTypedData.

seaport-js/src/seaport.ts

Lines 344 to 366 in 3d78959

public async signOrder(
orderParameters: OrderParameters,
counter: number,
accountAddress?: string
): Promise<string> {
const signer = this.provider.getSigner(accountAddress);
const domainData = await this._getDomainData();
const orderComponents: OrderComponents = {
...orderParameters,
counter,
};
const signature = await signer._signTypedData(
domainData,
EIP_712_ORDER_TYPE,
orderComponents
);
// Use EIP-2098 compact signatures to save gas. https://eips.ethereum.org/EIPS/eip-2098
return ethers.utils.splitSignature(signature).compact;
}

I'm sure this will be big problem after v1/orders endpoint deprecated. Many developers use node providers to bid faster.

Troubles with front-end integration

Discussed in #90

Originally posted by punpom August 10, 2022
Hello, I try to use seaportJS with front-end, but my transaction is reverted with this error:

(index.ts:261 Uncaught (in promise) Error: call revert exception [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (method="isApprovedForAll(address,address)", data="0x", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.6.4)
    at Logger.makeError (index.ts:261:1)
    at Logger.throwError (index.ts:273:1)
    at Interface.decodeFunctionResult (interface.ts:427:1)
    at Contract.<anonymous> (index.ts:400:1)
    at Generator.next (<anonymous>)
    at fulfilled (index.ts:2:1))

I first tried to create a Seaport instance with Metamask and got the above error, and then with a provider and a private key and also got the above error.

I also tried to do an Approveforall from the NFT contract on Etherscan Goerli but nothing works.

I tried a strong approach, approving the NFT contract with the method "isApprovedForAll(address,address)"
and still the same error.

I already made back-end scripts with nodeJS that work perfectly but impossible to allow compatibility between React and SeaportJS.

I observed that by removing the createOrder function I had no error

Thank you for reading me

Type Error

I get the error
"listings/SeaportEthListing.ts:24:33 - error TS2345: Argument of type 'JsonRpcProvider' is not assignable to parameter of type 'JsonRpcProvider | Signer'."

however the code snippet is very straightforward as in tutorials

import {ethers} from "ethers";
import { Seaport } from "@opensea/seaport-js";


    const provider = new ethers.providers.JsonRpcProvider(
        `https://eth-goerli.g.alchemy.com/v2/${process.env.ALCHEMY_KEY}`
    );
    
       const seaport = new Seaport(provider);
       
       ```
       
  "ethers": "^5.5.4",
    "@opensea/seaport-js": "^1.0.6",
       
       

Rounding error in `mapOrderAmountsFromUnitsToFill`

There is a potential rounding error when calculating offer/consideration amounts in mapOrderAmountsFromUnitsToFill.
 
Consider the following example:

  • Alice creates a partially fillable order, listing 3 of some ERC1155 token for 1ETH each
  • Bob tries to buy 1 of these tokens by calling seaport.fulfillOrder
  • In this scenario, seaport.fulfillOrder will execute fulfillAdvancedOrder on the Seaport contract with a value of 0.9999ETH, resulting in InsufficientEtherSupplied error

Let's examine why this is happening using the following snippets from mapOrderAmountsFromUnitsToFill as reference:

const unitsToFillBasisPoints = unitsToFillBn
    .mul(ONE_HUNDRED_PERCENT_BP)
    .div(maxUnits);

&&

const multiplyBasisPoints = (amount: BigNumberish, basisPoints: BigNumberish) =>
  BigNumber.from(amount)
    .mul(BigNumber.from(basisPoints))
    .div(ONE_HUNDRED_PERCENT_BP);

&&

startAmount: multiplyBasisPoints(
    item.startAmount,
    basisPoints
).toString(),

When Bob executes seaport.fulfillOrder the following calculations are made:

  • unitsToFillBasisPoints = 1 * 10_000 / 3 = 3333.3333333333333333 = 3333 (due to BigNumber truncation)
  • startAmount: 3E18 * 3333 / 10_000 = 0.9999E17 = 0.9999ETH

Because BigNumber does not support decimals, the precision of unitsToFillBasisPoints is off, resulting in a rounding error when calculating the consideration's start and end amounts.

Unknown Account error message

Error: processing response error (body="{\"jsonrpc\":\"2.0\",\"id\":49,\"error\":{\"code\":-32000,\"message\":\"unknown account\"}}
Code:

const provider = new ethers.providers.JsonRpcProvider(customUrl, "mainnet");
const seaport = new Seaport(provider);
const { executeAllActions, actions } = await seaport.createOrder(
      {
        offer: [
          {
            itemType: 2,
            token, 
            identifier: tokenId,
            amount: "1",
            endAmount: "1",
          },
        ],
        consideration: [
          {
            itemType: 0,
            identifier: "0",
            amount: "9250000000000000",
            token: "0x0000000000000000000000000000000000000000",
            endAmount: "9250000000000000",
            recipient: offerer,
          },
          {
            itemType: 0,
            identifier: "0",
            token: "0x0000000000000000000000000000000000000000",
            amount: "250000000000000",
            endAmount: "250000000000000",
            recipient: "0x8De9C5A032463C561423387a9648c5C7BCC5BC90",
          },
          {
            itemType: 0,
            identifier: "0",
            token: "0x0000000000000000000000000000000000000000",
            amount: "500000000000000",
            endAmount: "500000000000000",
            recipient: "0x53fa2013286C57114EfF51D6A27E09e46Acc5f89",
          },
        ],
      },
      offerer
    );

    const order = await executeAllActions();

I think that issues comes from not having the account private key when creating the message.

Is there a way to provide a signer to seaport that can be used to sign. I have an environment where I cannot expect my users to have Meta Mask installed.

"Regular OpenSea sale" via Seaport?

For legal reasons, we - the project I currently work for - want to avoid to be considered as marketplace, but keep all trade on OpenSea and pay the 2.5 % fees. Nevertheless it would be great if users wouldn't have to be redirected to the OpenSea website, but could buy our (Polygon) NFTs listed on OpenSea directly on our own website. Does Seaport - either via OpenSea's Seaport API endpoint or using seaport.js - allow this? And if yes, could anyone point me to some working example code that does this? Thanks a bunch in advance!

I can confirm that the approach described by DEREK-DEV-AFK here works, but AFAICT this would ignore the OpenSea listings, and no fees would be payed to OpenSea at all, right?

TypeError: checkedIdentifierOrCriteria.toLowerCase is not a function

1.environment

    const provider = new ethers.providers.Web3Provider(window.ethereum)
    window.ethereum.enable().then(()=>{
      const signer = provider.getSigner()
      signer.getAddress().then((result)=>{setAddress(result)})
    })
    const seaport = new Seaport(provider);
    let standardCreateOrderInput = {
      startTime: "0",
      offer: [
          {
              itemType: 2,
              token: 'xxx',
              identifier: 9,
          },
      ],
      consideration: [
          {
              amount: utils.parseEther("10").toString(),
              recipient: 'xxx',
          },
      ],
      // 2.5% fee
      fees: [{ recipient: 'xxx', basisPoints: 250 }],
    };
    const { executeAllActions } = await seaport.createOrder(
        standardCreateOrderInput
    );
    const order = await executeAllActions();
    console.log(order)

2.Call Stack

Unhandled Runtime Error
TypeError: checkedIdentifierOrCriteria.toLowerCase is not a function

Call Stack
eval
    node_modules/@opensea/seaport-js/lib/utils/balanceAndApprovalCheck.js (86:0)
Array.find
    <anonymous>
findBalanceAndApproval
    node_modules/@opensea/seaport-js/lib/utils/balanceAndApprovalCheck.js (83:0)
eval
    node_modules/@opensea/seaport-js/lib/utils/balanceAndApprovalCheck.js (149:0)
Array.filter
    <anonymous>
filterBalancesOrApprovals
    node_modules/@opensea/seaport-js/lib/utils/balanceAndApprovalCheck.js (147:0)
getInsufficientBalanceAndApprovalAmounts
    node_modules/@opensea/seaport-js/lib/utils/balanceAndApprovalCheck.js (172:0)
validateOfferBalancesAndApprovals
    node_modules/@opensea/seaport-js/lib/utils/balanceAndApprovalCheck.js (190:0)
Seaport.eval
    node_modules/@opensea/seaport-js/lib/seaport.js (311:0)
step
    node_modules/@opensea/seaport-js/lib/seaport.js (44:0)
Object.eval [as next]
    node_modules/@opensea/seaport-js/lib/seaport.js (25:45)
fulfilled
    node_modules/@opensea/seaport-js/lib/seaport.js (16:42)

Cannot get a proof to confirm the criteria nft

Hello, I can't get a proof to confirm the criteria nft

I am using this code:

Code for generating proof:

import { MerkleTree } from "./merkletree";

const array: string[] = [];

for (let i = 0; i != 10000; i++) {
    array.push(i.toString())
}

const mt = new MerkleTree(array);

console.log(mt.getProof("8789"))

I get this proof:

0x5b64c74267703e9a616ecd7acc49a32f745c76e76c584f51a7c46ec533c9da91
0x6c798822a125d871ff2d0d319689c1d5c63c9fddbbb802c67ee7fe1daba5644c
0xd19fd7fe7560b0c1b6b3481db07749efdfee5c7d619c4ab409b7366062a6ac76
0xd584b08d99a6867b1df28bb102b6eff6b01bc582de5c3ae9070f057bda47a314
0x2d82e989452e782e3c38aac5b5c55b0dc625b79616a15bb38baeead3c02ba103
0xfe781a286b60d208f3c7b02fa9ecd9084a0fc95f584f6a25db4c01f29d21befe
0x8918c9a4b60bf3a4ce47c8aed9f1426f7538b5e5cf68327c29842c10a0470c7d
0x81b21edec49c7af9b35abee92d122ba8321090233df17d78cc3c75cc6d481334
0x3d302e2b18786555160ab21bd6f305411bc73122360a1e662dcd5c64ebafd339
0x7f2532ac08f12a2b75b8bb389b802a1265c53599918f4cd67c0cb3c18f22fe07
0x965b8ba21d5c57c51b67c523063e103e984666afdc901ef2db8c5d19509e2839
0x20f8fed229280aadaebcaefb890dc2688c665919b9d806a32d9087bf90aeba27
0xa47e838b3ef91bbcf32fd6b525fad03c1be84e3f6f659bc5804a6259141902d3
0x8d41dc10f4b775fb64acbb16141b980b1530e99fc45150a2b7856c1c7ac1816f

But if we take this transaction:

We will see this proof:

0x5b64c74267703e9a616ecd7acc49a32f745c76e76c584f51a7c46ec533c9da91
0x6c798822a125d871ff2d0d319689c1d5c63c9fddbbb802c67ee7fe1daba5644c
0xd19fd7fe7560b0c1b6b3481db07749efdfee5c7d619c4ab409b7366062a6ac76
0x5d3cce655488c894798fa51b4c793770b623bf1b42d8fa5553daf5c5e0febbd7
0x3aaf261fac248d2cdce43b7010e3c1d6299748f0aeb03c2c92e69af5a5275860
0x9963edb01b2bb8e9f62d00151d128e059e8a42ae14d92c2bfef88e36e059e3af
0xa62c0b88649f459ef07b711c0fd2fb1776b16ce5faf8a3c53225e7b99e407169
0x947562bc343520fbf32ac9fd9aa5dbf853c391fbd565d501b6b8bb7dd3a16d13
0x1a2f5356781c6b529553cdb6fa922e82ec57b8367e09a5555a12acfcaaeae012
0x9d3594b15d2c041d47ac11ad4741e2ac9351c936422243d10bd8a77ab95fbced
0xef875a1e1cde982baad84c42a0b3cc866e8348e7791c460a514a58cb1ae0c2ed
0x2bd2db404ed82cc14eb74bbee89179f195fe4a0ee75df387fd58ea90db77ad7c
0xb9468791cd584d5f0217ff46d532066df62ba448a9d072f6d59bef36bd737f59
0x1092fc742914e8156b33c24845eaac4ac6874fe353da7ff658025ddfaac40bcc

These proofs only match the first three lines, please tell me how to generate a correct proof
I tried this code, but it doesn't work either

APIs to get the original calldata

The old OpenSea SDK has some APIs to get the original calldata of fulfillOrder/matchOrder methods, which is very useful. But I did not find same APIs in seaport SDK. It seems fulfillOrder/matchOrder methods in seaport SDK returns only actions like:

const { actions } = await seaport.fulfillOrder({
              order,
              accountAddress: fulfiller.address,
 });

The only choice is to run the actions. If we can get the original calldata, it'll be very flexible that we define our own flow and make better user experience.

offer orders appear to execute, but aren't when showing offers are retrieved

Trying to put in offers with createOrder... below is my code for initializing and then creating the order. The order I get back from executeAllActions looks good..? - but then when I fetch offers for the token I just put in an offer on, I never see mine post? Do I need to include the fee in the consideration manually? If so is there documentation on this? Seaport orders should show on on opensea.com once created correct?

Initialization

 this.seaport_v2 = this.getSeaport_v2()

private getSeaport_v2(): Seaport {
    const provider = new JsonRpcProvider(
      `${this.CONFIG.WEB3_PROVIDER_URL}/${this.CONFIG.ALCHEMY_API_KEY}`
    )
    const wallet = Wallet.fromMnemonic(this.CONFIG.WALLET_MNEMONIC)
    const connectedWallet = wallet.connect(provider)
    const seaport_v2Instance = new Seaport(connectedWallet);
    return seaport_v2Instance;
  }

Placing Order

public async makeOffer(
    asset: {
      tokenAddress: string;
      tokenId: string;
      amount: number;
    },
    expireMinutes: number,
  ): Promise<OrderWithCounter | undefined> {
    
  
    const { tokenId, tokenAddress, amount } = asset;
    console.log("about to create buy order")
    console.log("amount: ", amount)
   
    const amountInWei = this.web3Service.convertEthToWei(amount.toString())
    const offerer = this.CONFIG.WALLET_ADDRESS

    const { executeAllActions } = await this.seaport_v2.createOrder(
      {
        offer: [
          {
            amount: amountInWei.toString(),
            token: WrappedEthContract.address,
          },
        ],
        consideration: [
          {
            itemType: ItemType.ERC721,
            token: tokenAddress,
            identifier: tokenId,
            recipient: offerer,
          }
          
        ],
        endTime: Math.round(Date.now() / 1000 + 60 * expireMinutes).toString()
      },
      offerer
    );

    const order = await executeAllActions();
    
    console.dir(order, {depth: null})
    return order;
  }

Return Object

{
  parameters: {
    offerer: '0x02c108Ed5565a310F8c88f25ff78DB9Ec5FbE7DF',
    zone: '0x0000000000000000000000000000000000000000',
    zoneHash: '0x3000000000000000000000000000000000000000000000000000000000000000',
    startTime: '1665430241',
    endTime: '1665430842',
    orderType: 0,
    offer: [
      {
        itemType: 1,
        token: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
        identifierOrCriteria: '0',
        startAmount: '9000000000000000',
        endAmount: '9000000000000000'
      }
    ],
    consideration: [
      {
        itemType: 2,
        token: '0x8d098e7edfdb00d2ec2cdd70b633e2c34d6f945d',
        identifierOrCriteria: '1327',
        startAmount: '1',
        endAmount: '1',
        recipient: '0x02c108Ed5565a310F8c88f25ff78DB9Ec5FbE7DF'
      }
    ],
    totalOriginalConsiderationItems: 1,
    salt: '0x00000000190c8c4a449ddcc4',
    conduitKey: '0x0000000000000000000000000000000000000000000000000000000000000000',
    counter: 0
  },
  signature: '0xc1a8a1ff057f3b851f4e636295c3913f83ddd2c5cabb9689f7b254f9193abf6bd7239e17b5ee3cc205af9b4d77e0d1d8458a0d3e5251df663e72009da55cbb90'
}

I encountered some problems when executing fulfillOrder

I want to use seaport-js to create an order and then use another account to buy nft, here my code

const provider = new ethers.providers.Web3Provider(window.ethereum);
const seaport = new Seaport(provider);

const offerer = 0x......(my account 1)
const fulfiller = 0x......(my account 2)

const {executeAllActions} = await seaport.createOrder(
    {
      conduitKey: "0x0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f0000",
      offer: [
        {
          itemType: ItemType.ERC1155,
          token: "0xf4910C763eD4e47A585E2D34baA9A4b611aE448C",
          identifier: account1 nft token Id,
        },
      ],
      consideration: [
        {
          amount: ethers.utils.parseEther("0.01").toString(),
          recipient: offerer,
        },
      ],
    },
    offerer
);

const order = await executeAllActions();

console.log("order", order)

const {executeAllActions: executeAllFulfillActions} =
    await seaport.fulfillOrder({
      order,
      accountAddress: fulfiller,
    });

const transaction = executeAllFulfillActions();

console.log("transaction", transaction)

Then this error appears in the webpage
image

i m sure that seaport.createOrder is success

How can I solve this problem? Thank you for answering my question!

How to interact with seaport use Java

Is there any official consideration of providing a Java version of the library for us to use? I have searched Google and Github and can't find a Java version of the library.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.