Options
All
  • Public
  • Public/Protected
  • All
Menu

Class OpenSeaPort

Hierarchy

  • OpenSeaPort

Index

Constructors

constructor

  • Your very own seaport. Create a new instance of OpenSeaJS.

    Parameters

    • provider: Provider

      Web3 Provider to use for transactions. For example: const provider = new Web3.providers.HttpProvider('https://mainnet.infura.io')

    • Default value apiConfig: OpenSeaAPIConfig = {}

      configuration options, including networkName

    • Optional logger: undefined | function

      logger, optional, a function that will be called with debugging information

    Returns OpenSeaPort

Properties

api

gasIncreaseFactor

gasIncreaseFactor: number = DEFAULT_GAS_INCREASE_FACTOR

gasPriceAddition

gasPriceAddition: BigNumber = new BigNumber(3)

logger

logger: function

Type declaration

    • (arg: string): void
    • Parameters

      • arg: string

      Returns void

web3

web3: Web3

Methods

_approveAll

  • _approveAll(__namedParameters: object): Promise<(null | string)[]>
  • Parameters

    • __namedParameters: object
      • accountAddress: string
      • proxyAddress: null | string
      • schema: Schema<any>
      • wyAssets: WyvernAsset[]

    Returns Promise<(null | string)[]>

_approveOrder

  • Instead of signing an off-chain order, you can approve an order with on on-chain transaction using this method

    Parameters

    Returns Promise<any>

    Transaction hash of the approval transaction

_computeGasPrice

  • _computeGasPrice(): Promise<BigNumber>
  • Compute the gas price for sending a txn, in wei Will be slightly above the mean to make it faster

    Returns Promise<BigNumber>

_correctGasAmount

  • _correctGasAmount(estimation: number): number
  • Compute the gas amount for sending a txn Will be slightly above the result of estimateGas to make it more reliable

    Parameters

    • estimation: number

      The result of estimateGas for a transaction

    Returns number

_estimateGasForMatch

  • _estimateGasForMatch(__namedParameters: object): Promise<number>
  • Estimate the gas needed to match two orders

    Parameters

    • __namedParameters: object
      • accountAddress: string

        The taker's wallet address

      • buy: Order

        The buy order to match

      • metadata: string

        Metadata bytes32 to send with the match

      • sell: Order

        The sell order to match

    Returns Promise<number>

_estimateGasForTransfer

  • _estimateGasForTransfer(__namedParameters: object): Promise<number>
  • Estimate the gas needed to transfer assets in bulk Used for tests

    Parameters

    • __namedParameters: object
      • assets: Asset[]

        An array of objects with the tokenId and tokenAddress of each of the assets to transfer.

      • fromAddress: string

        The owner's wallet address

      • schemaName: WyvernSchemaName

        The Wyvern schema name corresponding to the asset type

      • toAddress: string

        The recipient's wallet address

    Returns Promise<number>

_getApprovedTokenCount

  • _getApprovedTokenCount(__namedParameters: object): Promise<BigNumber>
  • For a fungible token to use in trades (like W-ETH), get the amount approved for use by the Wyvern transfer proxy. Internal method exposed for dev flexibility.

    Parameters

    • __namedParameters: object
      • accountAddress: string

        Address for the user's wallet

      • tokenAddress: undefined | string

        Address for the token's contract

    Returns Promise<BigNumber>

_getProxy

  • _getProxy(accountAddress: string, retries?: number): Promise<string | null>
  • Get the proxy address for a user's wallet. Internal method exposed for dev flexibility.

    Parameters

    • accountAddress: string

      The user's wallet address

    • Default value retries: number = 0

      Optional number of retries to do

    Returns Promise<string | null>

_initializeProxy

  • _initializeProxy(accountAddress: string): Promise<string>
  • Initialize the proxy for a user's wallet. Proxies are used to make trades on behalf of the order's maker so that trades can happen when the maker isn't online. Internal method exposed for dev flexibility.

    Parameters

    • accountAddress: string

      The user's wallet address

    Returns Promise<string>

_makeBundleBuyOrder

  • _makeBundleBuyOrder(__namedParameters: object): Promise<UnhashedOrder>

_makeBundleSellOrder

  • _makeBundleSellOrder(__namedParameters: object): Promise<UnhashedOrder>
  • Parameters

    • __namedParameters: object
      • accountAddress: string
      • assets: Asset[]
      • bundleDescription: undefined | string
      • bundleExternalLink: undefined | string
      • bundleName: string
      • buyerAddress: string
      • endAmount: undefined | number
      • expirationTime: number
      • extraBountyBasisPoints: number
      • paymentTokenAddress: string
      • schemaName: WyvernSchemaName
      • startAmount: number
      • waitForHighestBid: boolean

    Returns Promise<UnhashedOrder>

_makeBuyOrder

  • _makeBuyOrder(__namedParameters: object): Promise<UnhashedOrder>

_makeMatchingOrder

_makeSellOrder

  • _makeSellOrder(__namedParameters: object): Promise<UnhashedOrder>
  • Parameters

    • __namedParameters: object
      • accountAddress: string
      • asset: Asset
      • buyerAddress: string
      • endAmount: undefined | number
      • expirationTime: number
      • extraBountyBasisPoints: number
      • paymentTokenAddress: string
      • schemaName: WyvernSchemaName
      • startAmount: number
      • waitForHighestBid: boolean

    Returns Promise<UnhashedOrder>

_validateBuyOrderParameters

  • _validateBuyOrderParameters(__namedParameters: object): Promise<void>

_validateMatch

  • _validateMatch(__namedParameters: object, retries?: number): Promise<boolean>
  • Validate against Wyvern that a buy and sell order can match

    Parameters

    • __namedParameters: object
      • accountAddress: string

        Address for the user's wallet

      • buy: Order

        The buy order to validate

      • sell: Order

        The sell order to validate

      • shouldValidateBuy: boolean

        Whether to validate the buy order individually.

      • shouldValidateSell: boolean

        Whether to validate the sell order individually.

    • Default value retries: number = 1

      How many times to retry if validation fails

    Returns Promise<boolean>

_validateOrder

  • _validateOrder(order: Order): Promise<boolean>

_validateSellOrderParameters

  • _validateSellOrderParameters(__namedParameters: object): Promise<void>

addListener

  • addListener(event: EventType, listener: function, once?: boolean): EventSubscription
  • Add a listener to a marketplace event

    Parameters

    • event: EventType

      An event to listen for

    • listener: function

      A callback that will accept an object with event data

    • Default value once: boolean = false

      Whether the listener should only be called once

    Returns EventSubscription

approveFungibleToken

  • approveFungibleToken(__namedParameters: object): Promise<string | null>
  • Approve a fungible token (e.g. W-ETH) for use in trades. Called internally, but exposed for dev flexibility. Checks to see if the minimum amount is already approved, first.

    Parameters

    • __namedParameters: object
      • accountAddress: string

        The user's wallet address

      • minimumAmount: any

        The minimum amount needed to skip a transaction. Defaults to the max-integer.

      • tokenAddress: string

        The contract address of the token being approved

    Returns Promise<string | null>

    Transaction hash if a new transaction occurred, otherwise null

approveNonFungibleToken

  • approveNonFungibleToken(__namedParameters: object): Promise<string | null>
  • Approve a non-fungible token for use in trades. Requires an account to be initialized first. Called internally, but exposed for dev flexibility. Checks to see if already approved, first. Then tries different approval methods from best to worst.

    Parameters

    • __namedParameters: object
      • accountAddress: string

        The user's wallet address

      • proxyAddress: null | string

        Address of the user's proxy contract. If not provided, will attempt to fetch it from Wyvern.

      • schemaName: WyvernSchemaName

        The Wyvern schema name corresponding to the asset type

      • skipApproveAllIfTokenAddressIn: string[]

        an optional list of token addresses that, if a token is approve-all type, will skip approval

      • tokenAbi: object[]

        ABI of the token's contract. Defaults to a flexible ERC-721 contract.

      • tokenAddress: string

        The contract address of the token being approved

      • tokenId: string

        Token id to approve, but only used if approve-all isn't supported by the token contract

    Returns Promise<string | null>

    Transaction hash if a new transaction was created, otherwise null

cancelOrder

  • cancelOrder(__namedParameters: object): Promise<void>
  • Cancel an order on-chain, preventing it from ever being fulfilled.

    Parameters

    • __namedParameters: object
      • accountAddress: string

        The order maker's wallet address

      • order: Order

        The order to cancel

    Returns Promise<void>

computeFees

  • computeFees(__namedParameters: object): Promise<OpenSeaFees>
  • Compute the fees for an order

    Parameters

    • __namedParameters: object
      • assetContract: undefined | OpenSeaAssetContract

        Optional prefetched asset contract (including fees) to use instead of assets

      • assets: undefined | Asset[]

        Array of addresses and ids that will be in the order

      • extraBountyBasisPoints: number

        The basis points to add for the bounty. Will throw if it exceeds the assets' contract's OpenSea fee.

      • isPrivate: boolean

        Whether the order is private or not (known taker)

      • side: OrderSide

        The side of the order (buy or sell)

    Returns Promise<OpenSeaFees>

createBundleBuyOrder

  • createBundleBuyOrder(__namedParameters: object): Promise<Order>
  • Create a buy order to make an offer on a bundle or group of assets. Will throw an 'Insufficient balance' error if the maker doesn't have enough W-ETH to make the offer. If the user hasn't approved W-ETH access yet, this will emit ApproveCurrency before asking for approval.

    Parameters

    • __namedParameters: object
      • accountAddress: string

        Address of the maker's wallet

      • expirationTime: number

        Expiration time for the order, in seconds. An expiration time of 0 means "never expire"

      • paymentTokenAddress: undefined | string

        Optional address for using an ERC-20 token in the order. If unspecified, defaults to W-ETH

      • schemaName: WyvernSchemaName

        The Wyvern schema name corresponding to the asset type

      • sellOrder: undefined | Order

        Optional sell order (like an English auction) to ensure fee compatibility

      • startAmount: number

        Value of the offer, in units of the payment token (or wrapped ETH if no payment token address specified)

      • tokenAddresses: string[]

        Addresses of the tokens' contracts. Must be the same length as tokenIds. Each address corresponds with its respective token ID in the tokenIds array.

      • tokenIds: string[]

        Token IDs of the assets.

    Returns Promise<Order>

createBundleSellOrder

  • createBundleSellOrder(__namedParameters: object): Promise<Order>
  • Create a sell order to auction a bundle of assets. Will throw a 'You do not own this asset' error if the maker doesn't have one of the assets. If the user hasn't approved access to any of the assets yet, this will emit ApproveAllAssets (or ApproveAsset if the contract doesn't support approve-all) before asking for approval for each asset.

    Parameters

    • __namedParameters: object
      • accountAddress: string

        The address of the maker of the bundle and the owner of all the assets.

      • assets: Asset[]

        An array of objects with the tokenId and tokenAddress of each of the assets to bundle together.

      • bundleDescription: undefined | string

        Optional description of the bundle. Markdown is allowed.

      • bundleExternalLink: undefined | string

        Optional link to a page that adds context to the bundle.

      • bundleName: string

        Name of the bundle

      • buyerAddress: any

        Optional address that's allowed to purchase this bundle. If specified, no other address will be able to take the order, unless it's the null address.

      • endAmount: undefined | number

        Optional price of the asset at the end of its expiration time. If not specified, will be set to startAmount.

      • expirationTime: number

        Expiration time for the order, in seconds. An expiration time of 0 means "never expire."

      • extraBountyBasisPoints: number

        Optional basis points (1/100th of a percent) to reward someone for referring the fulfillment of this order

      • paymentTokenAddress: any

        Address of the ERC-20 token to accept in return. If undefined or null, uses Ether.

      • schemaName: WyvernSchemaName

        The Wyvern schema name corresponding to the asset type

      • startAmount: number

        Price of the asset at the start of the auction, or minimum acceptable bid if it's an English auction.

      • waitForHighestBid: boolean

        If set to true, this becomes an English auction that increases in price for every bid. The highest bid wins when the auction expires, as long as it's at least startAmount. expirationTime must be > 0.

    Returns Promise<Order>

createBuyOrder

  • createBuyOrder(__namedParameters: object): Promise<Order>
  • Create a buy order to make an offer on an asset. Will throw an 'Insufficient balance' error if the maker doesn't have enough W-ETH to make the offer. If the user hasn't approved W-ETH access yet, this will emit ApproveCurrency before asking for approval.

    Parameters

    • __namedParameters: object
      • accountAddress: string

        Address of the maker's wallet

      • expirationTime: number

        Expiration time for the order, in seconds. An expiration time of 0 means "never expire"

      • paymentTokenAddress: undefined | string

        Optional address for using an ERC-20 token in the order. If unspecified, defaults to W-ETH

      • schemaName: WyvernSchemaName

        The Wyvern schema name corresponding to the asset type

      • sellOrder: undefined | Order

        Optional sell order (like an English auction) to ensure fee compatibility

      • startAmount: number

        Value of the offer, in units of the payment token (or wrapped ETH if no payment token address specified)

      • tokenAddress: string

        Address of the token's contract

      • tokenId: string

        Token ID

    Returns Promise<Order>

createFactorySellOrders

  • createFactorySellOrders(__namedParameters: object): Promise<Order[]>
  • Create multiple sell orders in bulk to auction assets out of an asset factory. Will throw a 'You do not own this asset' error if the maker doesn't own the factory. Items will mint to users' wallets only when they buy them. See https://docs.opensea.io/docs/opensea-initial-item-sale-tutorial for more info. If the user hasn't approved access to the token yet, this will emit ApproveAllAssets (or ApproveAsset if the contract doesn't support approve-all) before asking for approval.

    Parameters

    • __namedParameters: object
      • accountAddress: string

        Address of the factory owner's wallet

      • assetId: undefined | string

        Identifier for the asset, if you just want to post orders for one asset.

      • assetIds: undefined | string[]

        Identifiers for the assets, if you want to post orders for many assets at once.

      • buyerAddress: any

        Optional address that's allowed to purchase each item. If specified, no other address will be able to take each order.

      • endAmount: undefined | number

        Optional price of the asset at the end of its expiration time. If not specified, will be set to startAmount. Units are in the amount of a token above the token's decimal places (integer part). For example, for ether, expected units are in ETH, not wei.

      • expirationTime: number

        Expiration time for the order, in seconds. An expiration time of 0 means "never expire."

      • extraBountyBasisPoints: number

        Optional basis points (1/100th of a percent) to reward someone for referring the fulfillment of each order

      • factoryAddress: string

        Address of the factory contract

      • numberOfOrders: number

        Number of times to repeat creating the same order for each asset. If greater than 5, creates them in batches of 5. Requires an apiKey to be set during seaport initialization in order to not be throttled by the API.

      • paymentTokenAddress: any

        Address of the ERC-20 token to accept in return. If undefined or null, uses Ether.

      • schemaName: WyvernSchemaName
      • startAmount: number

        Price of the asset at the start of the auction, or minimum acceptable bid if it's an English auction. Units are in the amount of a token above the token's decimal places (integer part). For example, for ether, expected units are in ETH, not wei.

      • waitForHighestBid: boolean

        If set to true, this becomes an English auction that increases in price for every bid. The highest bid wins when the auction expires, as long as it's at least startAmount. expirationTime must be > 0.

    Returns Promise<Order[]>

createSellOrder

  • createSellOrder(__namedParameters: object): Promise<Order>
  • Create a sell order to auction an asset. Will throw a 'You do not own this asset' error if the maker doesn't have the asset. If the user hasn't approved access to the token yet, this will emit ApproveAllAssets (or ApproveAsset if the contract doesn't support approve-all) before asking for approval.

    Parameters

    • __namedParameters: object
      • accountAddress: string

        Address of the maker's wallet

      • buyerAddress: any

        Optional address that's allowed to purchase this item. If specified, no other address will be able to take the order, unless its value is the null address.

      • endAmount: undefined | number

        Optional price of the asset at the end of its expiration time. Units are in the amount of a token above the token's decimal places (integer part). For example, for ether, expected units are in ETH, not wei.

      • expirationTime: number

        Expiration time for the order, in seconds. An expiration time of 0 means "never expire."

      • extraBountyBasisPoints: number

        Optional basis points (1/100th of a percent) to reward someone for referring the fulfillment of this order

      • paymentTokenAddress: any

        Address of the ERC-20 token to accept in return. If undefined or null, uses Ether.

      • schemaName: WyvernSchemaName

        The Wyvern schema name corresponding to the asset type

      • startAmount: number

        Price of the asset at the start of the auction. Units are in the amount of a token above the token's decimal places (integer part). For example, for ether, expected units are in ETH, not wei.

      • tokenAddress: string

        Address of the token's contract

      • tokenId: string

        Token ID

      • waitForHighestBid: boolean

        If set to true, this becomes an English auction that increases in price for every bid. The highest bid wins when the auction expires, as long as it's at least startAmount. expirationTime must be > 0.

    Returns Promise<Order>

fulfillOrder

  • fulfillOrder(__namedParameters: object): Promise<void>
  • Fullfill or "take" an order for an asset, either a buy or sell order

    Parameters

    • __namedParameters: object
      • accountAddress: string

        The taker's wallet address

      • order: Order

        The order to fulfill, a.k.a. "take"

      • referrerAddress: undefined | string

        The optional address that referred the order

    Returns Promise<void>

getCurrentPrice

  • getCurrentPrice(order: Order): Promise<any>
  • Gets the price for the order using the contract

    Parameters

    • order: Order

      The order to calculate the price for

    Returns Promise<any>

getFungibleTokens

  • getFungibleTokens(__namedParameters?: object): Promise<FungibleToken[]>
  • Get known fungible tokens (ERC-20) that match your filters.

    Parameters

    • Default value __namedParameters: object = {}
      • address: undefined | string

        Filter by the ERC-20 contract address for the token, e.g. "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359" for Dai

      • name: undefined | string

        Filter by the name of the ERC-20 contract. Not guaranteed to exist or be unique for each token type. e.g. '' for Dai and 'Decentraland' for MANA FUTURE: officiallySupported: Filter for tokens that are officially supported and shown on opensea.io

      • symbol: undefined | string

        Filter by the ERC-20 symbol for the token, e.g. "DAI" for Dai stablecoin

    Returns Promise<FungibleToken[]>

getTokenBalance

  • getTokenBalance(__namedParameters: object): Promise<BigNumber>
  • Get the balance of a fungible token.

    Parameters

    • __namedParameters: object
      • accountAddress: string

        User's account address

      • tokenAbi: object[]

        ABI for the token's contract. Defaults to ERC20

      • tokenAddress: undefined | string

        Optional address of the token's contract. Defaults to W-ETH

    Returns Promise<BigNumber>

isAssetTransferrable

  • isAssetTransferrable(__namedParameters: object, retries?: number): Promise<boolean>
  • Returns whether an asset is transferrable. An asset may not be transferrable if its transfer function is locked for some reason, e.g. an item is being rented within a game or trading has been locked for an item type.

    Parameters

    • __namedParameters: object
      • didOwnerApprove: boolean

        If the owner and fromAddress has already approved the asset for sale. Required if checking an ERC-721 v1 asset (like CryptoKitties) that doesn't check if the transferFrom caller is the owner of the asset (only allowing it if it's an approved address).

      • fromAddress: string

        The account address that currently owns the asset

      • schemaName: WyvernSchemaName

        The Wyvern schema name corresponding to the asset type

      • toAddress: string

        The account address that will be acquiring the asset

      • tokenAddress: string

        Address of the token's contract

      • tokenId: string

        ID of the token to check

    • Default value retries: number = 1

      How many times to retry if false

    Returns Promise<boolean>

isOrderFulfillable

  • isOrderFulfillable(__namedParameters: object, retries?: number): Promise<boolean>
  • Returns whether an order is fulfillable. An order may not be fulfillable if a target item's transfer function is locked for some reason, e.g. an item is being rented within a game or trading has been locked for an item type.

    Parameters

    • __namedParameters: object
      • accountAddress: string

        The account address that will be fulfilling the order

      • order: Order

        Order to check

      • referrerAddress: undefined | string

        The optional address that referred the order

    • Default value retries: number = 1

      How many times to retry if false

    Returns Promise<boolean>

removeAllListeners

  • removeAllListeners(event?: EventType): void
  • Remove all event listeners. Good idea to call this when you're unmounting a component that listens to events to make UI updates

    Parameters

    • Optional event: EventType

      Optional EventType to remove listeners for

    Returns void

removeListener

  • removeListener(subscription: EventSubscription): void
  • Remove an event listener, included here for completeness. Simply calls .remove() on a subscription

    Parameters

    • subscription: EventSubscription

      The event subscription returned from addListener

    Returns void

transfer

  • transfer(__namedParameters: object): Promise<string>
  • Transfer a fungible or non-fungible asset to another address

    Parameters

    • __namedParameters: object
      • asset: FungibleToken | Asset

        The fungible or non-fungible asset to transfer

      • fromAddress: string

        The owner's wallet address

      • quantity: number

        The amount of the asset to transfer, if it's fungible (optional)

      • schemaName: WyvernSchemaName

        The Wyvern schema name corresponding to the asset type. Defaults to "ERC721" (non-fungible) assets, but can be ERC1155, ERC20, and others.

      • toAddress: string

        The recipient's wallet address

    Returns Promise<string>

    Transaction hash

transferAll

  • transferAll(__namedParameters: object): Promise<string>
  • Transfer one or more assets to another address. ERC-721 and ERC-1155 assets are supported

    Parameters

    • __namedParameters: object
      • assets: Asset[]

        An array of objects with the tokenId and tokenAddress of each of the assets to transfer.

      • fromAddress: string

        The owner's wallet address

      • schemaName: WyvernSchemaName

        The Wyvern schema name corresponding to the asset type

      • toAddress: string

        The recipient's wallet address

    Returns Promise<string>

    Transaction hash

transferOne

  • transferOne(__namedParameters: object): Promise<string>
  • DEPRECATED: use transfer instead Transfer an NFT asset to another address

    Parameters

    • __namedParameters: object
      • asset: WyvernAsset | Asset

        The asset to transfer

      • fromAddress: string

        The owner's wallet address

      • isWyvernAsset: boolean

        Whether the passed asset is a generic WyvernAsset, for backwards compatibility

      • schemaName: WyvernSchemaName

        The Wyvern schema name corresponding to the asset type

      • toAddress: string

        The recipient's wallet address

    Returns Promise<string>

    Transaction hash

unwrapWeth

  • unwrapWeth(__namedParameters: object): Promise<void>
  • Unwrap W-ETH into ETH. Emits the UnwrapWeth event when the transaction is prompted.

    Parameters

    • __namedParameters: object
      • accountAddress: string

        Address of the user's wallet containing the W-ETH

      • amountInEth: number

        How much W-ETH to unwrap

    Returns Promise<void>

validateAndPostOrder

  • validateAndPostOrder(order: Order): Promise<Order>

wrapEth

  • wrapEth(__namedParameters: object): Promise<void>
  • Wrap ETH into W-ETH. W-ETH is needed for placing buy orders (making offers). Emits the WrapEth event when the transaction is prompted.

    Parameters

    • __namedParameters: object
      • accountAddress: string

        Address of the user's wallet containing the ether

      • amountInEth: number

        How much ether to wrap

    Returns Promise<void>

Generated using TypeDoc