Catalog npm
Back to packageRELEASE DETAILS

1.1.2

npm

31port-js

[Seaport](https://github.com/ProjectOpenSea/seaport) is a new marketplace protocol for safely and efficiently buying and selling NFTs. This is a JavaScript library intended to make interfacing with the contract reasonable and easy.

Published2 Nov 2023
Direct dependencies44
Transitive dependenciesNot calculated

README

Current package documentation

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 JavaScript library intended to make interfacing with the contract reasonable and easy.

Synopsis

This is a JavaScript 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.providers.Web3Provider(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.providers.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.providers.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.utils.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.address,
  });

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.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 44

Native requirements
44 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
@0xsequence/multicall
Environment
{
  "local_name": "@0xsequence/multicall",
  "alias": false,
  "peer_metadata": null
}
^0.39.0runtime
ethers
Environment
{
  "local_name": "ethers",
  "alias": false,
  "peer_metadata": null
}
^5.6.7runtime
merkletreejs
Environment
{
  "local_name": "merkletreejs",
  "alias": false,
  "peer_metadata": null
}
^0.3.9runtime
@nomiclabs/hardhat-ethers
Environment
{
  "local_name": "@nomiclabs/hardhat-ethers",
  "alias": false,
  "peer_metadata": null
}
^2.0.5development
@nomiclabs/hardhat-waffle
Environment
{
  "local_name": "@nomiclabs/hardhat-waffle",
  "alias": false,
  "peer_metadata": null
}
^2.0.3development
@rari-capital/solmate
Environment
{
  "local_name": "@rari-capital/solmate",
  "alias": false,
  "peer_metadata": null
}
^6.2.0development
@typechain/ethers-v5
Environment
{
  "local_name": "@typechain/ethers-v5",
  "alias": false,
  "peer_metadata": null
}
^9.0.0development
@typechain/hardhat
Environment
{
  "local_name": "@typechain/hardhat",
  "alias": false,
  "peer_metadata": null
}
^5.0.0development
@types/chai
Environment
{
  "local_name": "@types/chai",
  "alias": false,
  "peer_metadata": null
}
^4.3.0development
@types/chai-as-promised
Environment
{
  "local_name": "@types/chai-as-promised",
  "alias": false,
  "peer_metadata": null
}
^7.1.5development
@types/mocha
Environment
{
  "local_name": "@types/mocha",
  "alias": false,
  "peer_metadata": null
}
^9.1.1development
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
^12.20.47development
@typescript-eslint/eslint-plugin
Environment
{
  "local_name": "@typescript-eslint/eslint-plugin",
  "alias": false,
  "peer_metadata": null
}
^5.27.1development
@typescript-eslint/parser
Environment
{
  "local_name": "@typescript-eslint/parser",
  "alias": false,
  "peer_metadata": null
}
^5.27.1development
c8
Environment
{
  "local_name": "c8",
  "alias": false,
  "peer_metadata": null
}
^7.11.3development
chai
Environment
{
  "local_name": "chai",
  "alias": false,
  "peer_metadata": null
}
^4.3.6development
chai-as-promised
Environment
{
  "local_name": "chai-as-promised",
  "alias": false,
  "peer_metadata": null
}
^7.1.1development
concurrently
Environment
{
  "local_name": "concurrently",
  "alias": false,
  "peer_metadata": null
}
^7.1.0development
domain-registry
Environment
{
  "local_name": "domain-registry",
  "alias": false,
  "peer_metadata": null
}
github:ProjectOpenSea/domain-registry#70a5cb3dc919a13660dd83518fb2ab070009cce6development
dotenv
Environment
{
  "local_name": "dotenv",
  "alias": false,
  "peer_metadata": null
}
^10.0.0development
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
^8.17.0development
eslint-config-prettier
Environment
{
  "local_name": "eslint-config-prettier",
  "alias": false,
  "peer_metadata": null
}
^8.5.0development
eslint-config-standard
Environment
{
  "local_name": "eslint-config-standard",
  "alias": false,
  "peer_metadata": null
}
^17.0.0development
eslint-plugin-import
Environment
{
  "local_name": "eslint-plugin-import",
  "alias": false,
  "peer_metadata": null
}
^2.25.4development
eslint-plugin-n
Environment
{
  "local_name": "eslint-plugin-n",
  "alias": false,
  "peer_metadata": null
}
^15.2.0development
eslint-plugin-prettier
Environment
{
  "local_name": "eslint-plugin-prettier",
  "alias": false,
  "peer_metadata": null
}
^3.4.1development
eslint-plugin-promise
Environment
{
  "local_name": "eslint-plugin-promise",
  "alias": false,
  "peer_metadata": null
}
^6.0.0development
ethereum-waffle
Environment
{
  "local_name": "ethereum-waffle",
  "alias": false,
  "peer_metadata": null
}
^3.4.4development
hardhat
Environment
{
  "local_name": "hardhat",
  "alias": false,
  "peer_metadata": null
}
^2.9.1development
hardhat-gas-reporter
Environment
{
  "local_name": "hardhat-gas-reporter",
  "alias": false,
  "peer_metadata": null
}
^1.0.8development
husky
Environment
{
  "local_name": "husky",
  "alias": false,
  "peer_metadata": null
}
>=6development
lint-staged
Environment
{
  "local_name": "lint-staged",
  "alias": false,
  "peer_metadata": null
}
>=10development
prettier
Environment
{
  "local_name": "prettier",
  "alias": false,
  "peer_metadata": null
}
^2.5.1development
prettier-package-json
Environment
{
  "local_name": "prettier-package-json",
  "alias": false,
  "peer_metadata": null
}
^2.6.3development
prettier-plugin-solidity
Environment
{
  "local_name": "prettier-plugin-solidity",
  "alias": false,
  "peer_metadata": null
}
^1.0.0-beta.13development
seaport
Environment
{
  "local_name": "seaport",
  "alias": false,
  "peer_metadata": null
}
github:ProjectOpenSea/seaport#76e508657888e3ec84039e1da269c822826991efdevelopment
seaport_v1_4
Environment
{
  "local_name": "seaport_v1_4",
  "alias": false,
  "peer_metadata": null
}
github:ProjectOpenSea/seaport#1.4development
sinon
Environment
{
  "local_name": "sinon",
  "alias": false,
  "peer_metadata": null
}
^13.0.1development
sinon-chai
Environment
{
  "local_name": "sinon-chai",
  "alias": false,
  "peer_metadata": null
}
^3.7.0development
solhint
Environment
{
  "local_name": "solhint",
  "alias": false,
  "peer_metadata": null
}
^3.3.7development
solidity-coverage
Environment
{
  "local_name": "solidity-coverage",
  "alias": false,
  "peer_metadata": null
}
^0.7.20development
ts-node
Environment
{
  "local_name": "ts-node",
  "alias": false,
  "peer_metadata": null
}
^10.7.0development
typechain
Environment
{
  "local_name": "typechain",
  "alias": false,
  "peer_metadata": null
}
^7.0.1development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^4.6.2development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-5NC2BWcEi0gEzdrP7WnrUTdFjfZjGFfCcYv5ce6XgyVqZ0o57ydM9X//+xOYdNy2yOdCJvQT6pw17ai4qTsEhQ==",
  "shasum": "dd3a61104ad61f3178d6a96ec5ff115586d7e9c6",
  "tarball": "https://registry.npmjs.org/31port-js/-/31port-js-1.1.2.tgz",
  "fileCount": 96,
  "unpackedSize": 738973,
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEYCIQDUqpxPbKbypOQhWSrIN7WlAFczySpE4bbWDB1xXh9v8wIhAMvIYdwGXH0PhVTmf14XkRMxhSPsqTmIzn7BuZIxePOT"
    }
  ]
}

Repository

PENDING
projectopensea/seaport-js

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 19:24 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:71d6a2fc7c9377d794d97f21afe0a2624157f159bfbb32800f8a1a44dcf9bf83

Other collected versions

1.1.815 Nov1.1.713 Nov1.1.66 Nov1.1.52 Nov1.1.32 Nov1.1.116 MayView all collected versions →