Class OpenSeaSDK

The OpenSea SDK main class.

Constructors

  • Create a new instance of OpenSeaSDK.

    Parameters

    • signerOrProvider: Signer | JsonRpcProvider

      Signer or provider to use for transactions. For example: new ethers.providers.JsonRpcProvider('https://mainnet.infura.io') or new ethers.Wallet(privKey, provider)

    • apiConfig: OpenSeaAPIConfig = {}

      configuration options, including chain

    • Optional logger: ((arg) => void)

      optional function for logging debug strings. defaults to no logging

        • (arg): void
        • Parameters

          • arg: string

          Returns void

    Returns OpenSeaSDK

Properties

api: OpenSeaAPI

API instance

chain: Chain

The configured chain

logger: ((arg) => void)

Logger function to use when debugging

Type declaration

    • (arg): void
    • Parameters

      • arg: string

      Returns void

provider: JsonRpcProvider

Provider to use for transactions.

seaport: Seaport

Seaport client

Methods

  • Add a listener for events emitted by the SDK.

    Parameters

    • event: EventType

      The EventType to listen to.

    • listener: ((data) => void)

      A callback that will accept an object with EventData\

        • (data): void
        • Parameters

          Returns void

    • once: boolean = false

      Whether the listener should only be called once, or continue listening until removed.

    Returns void

  • Instead of signing an off-chain order, this methods allows you to approve an order with an on-chain transaction.

    Parameters

    • order: OrderV2

      Order to approve

    • Optional domain: string

      An optional domain to be hashed and included at the end of fulfillment calldata. This can be used for on-chain order attribution to assist with analytics.

    Returns Promise<string>

    Transaction hash of the approval transaction

    Throws

    Error if the accountAddress is not available through wallet or provider.

    Throws

    Error if the order's protocol address is not supported by OpenSea. See isValidProtocol.

  • Batch approve multiple assets for transfer to the OpenSea conduit. This method checks which assets need approval and batches them efficiently:

    • 0 approvals needed: Returns early
    • 1 approval needed: Sends single transaction
    • 2+ approvals needed: Uses Multicall3 to batch all approvals in one transaction

    Parameters

    • options: {
          assets: {
              amount?: BigNumberish;
              asset: AssetWithTokenStandard;
          }[];
          fromAddress: string;
          overrides?: Overrides;
      }
      • assets: {
            amount?: BigNumberish;
            asset: AssetWithTokenStandard;
        }[]

        Array of assets to approve for transfer

      • fromAddress: string

        The address that owns the assets

      • Optional overrides?: Overrides

        Transaction overrides, ignored if not set.

    Returns Promise<undefined | string>

    Transaction hash of the approval transaction, or undefined if no approvals needed

    Throws

    Error if the fromAddress is not available through wallet or provider.

  • Bulk transfer multiple assets using OpenSea's TransferHelper contract. This method is more gas-efficient than calling transfer() multiple times. Note: All assets must be approved for transfer to the OpenSea conduit before calling this method.

    Parameters

    • options: {
          assets: {
              amount?: BigNumberish;
              asset: AssetWithTokenStandard;
              toAddress: string;
          }[];
          fromAddress: string;
          overrides?: Overrides;
      }
      • assets: {
            amount?: BigNumberish;
            asset: AssetWithTokenStandard;
            toAddress: string;
        }[]

        Array of assets to transfer. Each asset must have tokenStandard set.

      • fromAddress: string

        The address to transfer from

      • Optional overrides?: Overrides

        Transaction overrides, ignored if not set.

    Returns Promise<string>

    Transaction hash of the bulk transfer

    Throws

    Error if any asset is missing required fields (tokenId for NFTs, amount for ERC20/ERC1155).

    Throws

    Error if any asset is not approved for transfer to the OpenSea conduit.

    Throws

    Error if the fromAddress is not available through wallet or provider.

  • Cancel an order onchain, preventing it from ever being fulfilled. This method accepts either a full OrderV2 object or an order hash with protocol address.

    Parameters

    • options: {
          accountAddress: string;
          domain?: string;
          order?: OrderV2;
          orderHash?: string;
          protocolAddress?: string;
      }
      • accountAddress: string

        The account address that will be cancelling the order.

      • Optional domain?: string

        Optional domain for on-chain attribution. Hashed and included in calldata.

      • Optional order?: OrderV2

        The order to cancel (OrderV2 object)

      • Optional orderHash?: string

        Optional order hash to cancel. Must provide protocolAddress if using this.

      • Optional protocolAddress?: string

        Required when using orderHash. The Seaport protocol address for the order.

    Returns Promise<void>

    Throws

    Error if neither order nor orderHash is provided.

    Throws

    Error if the accountAddress is not available through wallet or provider.

    Throws

    Error if the order's protocol address is not supported by OpenSea. See isValidProtocol.

    Example

    // Cancel using OrderV2 object
    await sdk.cancelOrder({
    order: orderV2Object,
    accountAddress: "0x..."
    });

    Example

    // Cancel using order hash
    await sdk.cancelOrder({
    orderHash: "0x123...",
    protocolAddress: "0xabc...",
    accountAddress: "0x..."
    });
  • Cancel multiple orders onchain, preventing them from being fulfilled. This method accepts either full OrderV2 objects, OrderComponents, or order hashes with protocol address.

    Event Behavior: For backwards compatibility with the singular cancelOrder method, this method dispatches a CancelOrder event for the first order only, and only when an OrderV2 object is available (either provided directly or fetched via orderHashes). No event is dispatched when using OrderComponents directly, as they lack the full order data.

    Parameters

    • options: {
          accountAddress: string;
          domain?: string;
          orderHashes?: string[];
          orders?: (OrderV2 | OrderComponents)[];
          overrides?: Overrides;
          protocolAddress?: string;
      }
      • accountAddress: string

        The account address cancelling the orders.

      • Optional domain?: string

        Optional domain for on-chain attribution. Hashed and included in calldata.

      • Optional orderHashes?: string[]

        Optional array of order hashes to cancel. Must provide protocolAddress if using this.

      • Optional orders?: (OrderV2 | OrderComponents)[]

        Array of orders to cancel. Can be OrderV2 objects or OrderComponents.

      • Optional overrides?: Overrides

        Transaction overrides, ignored if not set.

      • Optional protocolAddress?: string

        Required when using orderHashes. The Seaport protocol address for the orders.

    Returns Promise<string>

    Transaction hash of the cancellation.

    Throws

    Error if orderHashes is provided without protocolAddress.

    Throws

    Error if neither orders nor orderHashes is provided.

    Throws

    Error if the accountAddress is not available through wallet or provider.

    Throws

    Error if the order's protocol address is not supported by OpenSea. See isValidProtocol.

  • Create and submit multiple listings using Seaport's bulk order creation. This method uses a single signature for all listings and submits them individually to the OpenSea API with rate limit handling. All listings must be from the same account address.

    Note: If only one listing is provided, this method will use a normal order signature instead of a bulk signature, as bulk signatures are more expensive to decode on-chain due to the merkle proof verification.

    Parameters

    • options: {
          accountAddress: string;
          continueOnError?: boolean;
          listings: {
              amount: BigNumberish;
              asset: AssetWithTokenId;
              buyerAddress?: string;
              domain?: string;
              expirationTime?: number;
              includeOptionalCreatorFees?: boolean;
              listingTime?: number;
              paymentTokenAddress?: string;
              quantity?: BigNumberish;
              salt?: BigNumberish;
              zone?: string;
          }[];
          onProgress?: ((completed, total) => void);
      }
      • accountAddress: string

        Address of the wallet making the listings

      • Optional continueOnError?: boolean

        If true, continue submitting remaining listings even if some fail. Default: false (throw on first error).

      • listings: {
            amount: BigNumberish;
            asset: AssetWithTokenId;
            buyerAddress?: string;
            domain?: string;
            expirationTime?: number;
            includeOptionalCreatorFees?: boolean;
            listingTime?: number;
            paymentTokenAddress?: string;
            quantity?: BigNumberish;
            salt?: BigNumberish;
            zone?: string;
        }[]

        Array of listing parameters. Each listing requires asset, amount, and optionally other listing parameters.

      • Optional onProgress?: ((completed, total) => void)

        Optional callback for progress updates. Called after each listing is submitted (successfully or not).

          • (completed, total): void
          • Parameters

            • completed: number
            • total: number

            Returns void

    Returns Promise<BulkOrderResult>

    BulkOrderResult containing successful orders and any failures.

    Throws

    Error if listings array is empty

    Throws

    Error if the accountAddress is not available through wallet or provider.

    Throws

    Error if any asset does not contain a token id.

    Throws

    Error if continueOnError is false and any submission fails.

  • Create and submit multiple offers using Seaport's bulk order creation. This method uses a single signature for all offers and submits them individually to the OpenSea API with rate limit handling. All offers must be from the same account address.

    Note: If only one offer is provided, this method will use a normal order signature instead of a bulk signature, as bulk signatures are more expensive to decode on-chain due to the merkle proof verification.

    Parameters

    • options: {
          accountAddress: string;
          continueOnError?: boolean;
          offers: {
              amount: BigNumberish;
              asset: AssetWithTokenId;
              domain?: string;
              expirationTime?: BigNumberish;
              paymentTokenAddress?: string;
              quantity?: BigNumberish;
              salt?: BigNumberish;
              zone?: string;
          }[];
          onProgress?: ((completed, total) => void);
      }
      • accountAddress: string

        Address of the wallet making the offers

      • Optional continueOnError?: boolean

        If true, continue submitting remaining offers even if some fail. Default: false (throw on first error).

      • offers: {
            amount: BigNumberish;
            asset: AssetWithTokenId;
            domain?: string;
            expirationTime?: BigNumberish;
            paymentTokenAddress?: string;
            quantity?: BigNumberish;
            salt?: BigNumberish;
            zone?: string;
        }[]

        Array of offer parameters. Each offer requires asset, amount, and optionally other offer parameters.

      • Optional onProgress?: ((completed, total) => void)

        Optional callback for progress updates. Called after each offer is submitted (successfully or not).

          • (completed, total): void
          • Parameters

            • completed: number
            • total: number

            Returns void

    Returns Promise<BulkOrderResult>

    BulkOrderResult containing successful orders and any failures.

    Throws

    Error if offers array is empty

    Throws

    Error if the accountAddress is not available through wallet or provider.

    Throws

    Error if any asset does not contain a token id.

    Throws

    Error if continueOnError is false and any submission fails.

  • Create and submit a collection offer.

    Parameters

    • options: {
          accountAddress: string;
          amount: BigNumberish;
          collectionSlug: string;
          domain?: string;
          expirationTime?: string | number;
          offerProtectionEnabled?: boolean;
          paymentTokenAddress: string;
          quantity: number;
          salt?: BigNumberish;
          traitType?: string;
          traitValue?: string;
          traits?: {
              type: string;
              value: string;
          }[];
      }
      • accountAddress: string

        Address of the wallet making the offer.

      • amount: BigNumberish

        Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units.

      • collectionSlug: string

        Identifier for the collection.

      • Optional domain?: string

        Optional domain for on-chain attribution. Hashed and included in salt.

      • Optional expirationTime?: string | number

        Expiration time (UTC seconds).

      • Optional offerProtectionEnabled?: boolean

        Use signed zone for protection against disabled items. Default: true.

      • paymentTokenAddress: string

        Payment token address. Defaults to WETH.

      • quantity: number

        Number of assets to bid for.

      • Optional salt?: BigNumberish

        Arbitrary salt. Auto-generated if not provided.

      • Optional traitType?: string

        If defined, the trait name to create the collection offer for.

      • Optional traitValue?: string

        If defined, the trait value to create the collection offer for.

      • Optional traits?: {
            type: string;
            value: string;
        }[]

        If defined, an array of traits to create the multi-trait collection offer for.

    Returns Promise<null | CollectionOffer>

    The CollectionOffer that was created.

  • Create and submit a listing for an asset.

    Parameters

    • options: {
          accountAddress: string;
          amount: BigNumberish;
          asset: AssetWithTokenId;
          buyerAddress?: string;
          domain?: string;
          expirationTime?: number;
          includeOptionalCreatorFees?: boolean;
          listingTime?: number;
          paymentTokenAddress?: string;
          quantity?: BigNumberish;
          salt?: BigNumberish;
          zone?: string;
      }
      • accountAddress: string

        Address of the wallet making the listing

      • amount: BigNumberish

        Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units.

      • asset: AssetWithTokenId

        The asset to trade. tokenAddress and tokenId must be defined.

      • Optional buyerAddress?: string

        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.

      • Optional domain?: string

        Optional domain for on-chain attribution. Hashed and included in salt.

      • Optional expirationTime?: number

        Expiration time for the order, in UTC seconds.

      • Optional includeOptionalCreatorFees?: boolean

        If true, optional creator fees will be included in the listing. Default: false.

      • Optional listingTime?: number

        Optional time when the order will become fulfillable, in UTC seconds. Undefined means it will start now.

      • Optional paymentTokenAddress?: string

        ERC20 address for the payment token in the order. If unspecified, defaults to ETH

      • Optional quantity?: BigNumberish

        Number of assets to list. Defaults to 1.

      • Optional salt?: BigNumberish

        Arbitrary salt. Auto-generated if not provided.

      • Optional zone?: string

        Zone for order protection. Defaults to no zone.

    Returns Promise<OrderV2>

    The OrderV2 that was created.

    Throws

    Error if the asset does not contain a token id.

    Throws

    Error if the accountAddress is not available through wallet or provider.

    Throws

    Error if the amount is not greater than 0.

    Throws

    Error if paymentTokenAddress is not WETH on anything other than Ethereum mainnet.

  • Create and validate a listing onchain. Combines order building with onchain validation. Validation costs gas upfront but makes fulfillment cheaper (no signature verification needed).

    Parameters

    • options: {
          accountAddress: string;
          amount: BigNumberish;
          asset: AssetWithTokenId;
          buyerAddress?: string;
          domain?: string;
          expirationTime?: number;
          includeOptionalCreatorFees?: boolean;
          listingTime?: number;
          paymentTokenAddress?: string;
          quantity?: BigNumberish;
          salt?: BigNumberish;
          zone?: string;
      }
      • accountAddress: string

        Address of the wallet making the listing

      • amount: BigNumberish

        Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units.

      • asset: AssetWithTokenId

        The asset to trade. tokenAddress and tokenId must be defined.

      • Optional buyerAddress?: string

        Optional buyer restriction. Only this address can purchase.

      • Optional domain?: string

        Optional domain for on-chain attribution. Hashed and included in salt.

      • Optional expirationTime?: number

        Expiration time (UTC seconds).

      • Optional includeOptionalCreatorFees?: boolean

        Include optional creator fees. Default: false.

      • Optional listingTime?: number

        When order becomes fulfillable (UTC seconds). Defaults to now.

      • Optional paymentTokenAddress?: string

        Payment token address. Defaults to ETH.

      • Optional quantity?: BigNumberish

        Number of assets to list. Defaults to 1.

      • Optional salt?: BigNumberish

        Arbitrary salt. Auto-generated if not provided.

      • Optional zone?: string

        Zone for order protection. Defaults to no zone.

    Returns Promise<string>

    Transaction hash

    Throws

    Error if asset missing token id or accountAddress unavailable.

  • Create and submit an offer on an asset.

    Parameters

    • options: {
          accountAddress: string;
          amount: BigNumberish;
          asset: AssetWithTokenId;
          domain?: string;
          expirationTime?: BigNumberish;
          paymentTokenAddress?: string;
          quantity?: BigNumberish;
          salt?: BigNumberish;
          zone?: string;
      }
      • accountAddress: string

        Address of the wallet making the offer.

      • amount: BigNumberish

        Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units.

      • asset: AssetWithTokenId

        The asset to trade. tokenAddress and tokenId must be defined.

      • Optional domain?: string

        Optional domain for on-chain attribution. Hashed and included in salt.

      • Optional expirationTime?: BigNumberish

        Expiration time for the order, in UTC seconds

      • Optional paymentTokenAddress?: string

        ERC20 address for the payment token in the order. If unspecified, defaults to WETH

      • Optional quantity?: BigNumberish

        Number of assets to bid for. Defaults to 1.

      • Optional salt?: BigNumberish

        Arbitrary salt. Auto-generated if not provided.

      • Optional zone?: string

        Zone for order protection. Defaults to chain's signed zone.

    Returns Promise<OrderV2>

    The OrderV2 that was created.

    Throws

    Error if the asset does not contain a token id.

    Throws

    Error if the accountAddress is not available through wallet or provider.

    Throws

    Error if the amount is not greater than 0.

    Throws

    Error if paymentTokenAddress is not WETH on anything other than Ethereum mainnet.

  • Create and validate an offer onchain. Combines order building with onchain validation. Validation costs gas upfront but makes fulfillment cheaper (no signature verification needed).

    Parameters

    • options: {
          accountAddress: string;
          amount: BigNumberish;
          asset: AssetWithTokenId;
          domain?: string;
          expirationTime?: BigNumberish;
          paymentTokenAddress?: string;
          quantity?: BigNumberish;
          salt?: BigNumberish;
          zone?: string;
      }
      • accountAddress: string

        Address of the wallet making the offer.

      • amount: BigNumberish

        Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units.

      • asset: AssetWithTokenId

        The asset to trade. tokenAddress and tokenId must be defined.

      • Optional domain?: string

        Optional domain for on-chain attribution. Hashed and included in salt.

      • Optional expirationTime?: BigNumberish

        Expiration time (UTC seconds).

      • Optional paymentTokenAddress?: string

        Payment token address. Defaults to WETH.

      • Optional quantity?: BigNumberish

        Number of assets to bid for. Defaults to 1.

      • Optional salt?: BigNumberish

        Arbitrary salt. Auto-generated if not provided.

      • Optional zone?: string

        Zone for order protection. Defaults to chain's signed zone.

    Returns Promise<string>

    Transaction hash

    Throws

    Error if asset missing token id or accountAddress unavailable.

  • Fulfill an order for an asset. The order can be either a listing or an offer. Uses the OpenSea API to generate fulfillment transaction data and executes it directly.

    Parameters

    • options: {
          accountAddress: string;
          assetContractAddress?: string;
          order: OrderV2 | Order | Offer | Listing;
          overrides?: Overrides;
          recipientAddress?: string;
          tokenId?: string;
          unitsToFill?: BigNumberish;
      }
      • accountAddress: string

        Address of the wallet taking the offer.

      • Optional assetContractAddress?: string

        Optional address of the NFT contract for criteria offers (e.g., collection offers). Required when fulfilling collection offers.

      • order: OrderV2 | Order | Offer | Listing

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

      • Optional overrides?: Overrides

        Transaction overrides, ignored if not set.

      • Optional recipientAddress?: string

        Optional recipient address for the NFT when fulfilling a listing. Not applicable for offers.

      • Optional tokenId?: string

        Optional token ID for criteria offers (e.g., collection offers). Required when fulfilling collection offers.

      • Optional unitsToFill?: BigNumberish

        Optional number of units to fill. Defaults to 1 for both listings and offers.

    Returns Promise<string>

    Transaction hash of the order.

    Throws

    Error if the accountAddress is not available through wallet or provider.

    Throws

    Error if the order's protocol address is not supported by OpenSea. See isValidProtocol.

    Throws

    Error if a signer is not provided (read-only providers cannot fulfill orders).

    Throws

    Error if the order hash is not available.

  • Get an account's balance of any Asset. This asset can be an ERC20, ERC1155, or ERC721.

    Parameters

    Returns Promise<bigint>

    The balance of the asset for the account.

    Throws

    Error if the token standard does not support balanceOf.

  • 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

    • options: {
          accountAddress: string;
          order: OrderV2;
      }
      • accountAddress: string

        The account address that will be fulfilling the order

      • order: OrderV2

        Order to check

    Returns Promise<boolean>

    True if the order is fulfillable, else False.

    Throws

    Error if the order's protocol address is not supported by OpenSea. See isValidProtocol.

  • Offchain cancel an order, offer or listing, by its order hash when protected by the SignedZone. Protocol and Chain are required to prevent hash collisions. Please note cancellation is only assured if a fulfillment signature was not vended prior to cancellation.

    Parameters

    • protocolAddress: string

      The Seaport address for the order.

    • orderHash: string

      The order hash, or external identifier, of the order.

    • chain: Chain = ...

      The chain where the order is located.

    • Optional offererSignature: string

      An EIP-712 signature from the offerer of the order. If this is not provided, the API key used to initialize the SDK must belong to the order's offerer. The signature must be a EIP-712 signature consisting of the order's Seaport contract's name, version, address, and chain. The struct to sign is OrderHash containing a single bytes32 field.

    • Optional useSignerToDeriveOffererSignature: boolean

      Derive the offererSignature from the Ethers signer passed into this sdk.

    Returns Promise<CancelOrderResponse>

    The response from the API.

  • Remove all event listeners. This should be called 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

  • Remove an event listener by calling .removeListener() on an event and listener.

    Parameters

    • event: EventType

      The EventType to remove a listener for\

    • listener: ((data) => void)

      The listener to remove

        • (data): void
        • Parameters

          Returns void

    Returns void

  • Transfer an asset. This asset can be an ERC20, ERC1155, or ERC721.

    Parameters

    • options: {
          amount?: BigNumberish;
          asset: AssetWithTokenStandard;
          fromAddress: string;
          overrides?: Overrides;
          toAddress: string;
      }
      • Optional amount?: BigNumberish

        Amount of asset to transfer. Not used for ERC721.

      • asset: AssetWithTokenStandard

        The Asset to transfer. tokenStandard must be set.

      • fromAddress: string

        The address to transfer from

      • Optional overrides?: Overrides

        Transaction overrides, ignored if not set.

      • toAddress: string

        The address to transfer to

    Returns Promise<void>

  • Unwrap wrapped native asset into native asset (e.g. WETH into ETH, WPOL into POL). Emits the UnwrapWeth event when the transaction is prompted.

    Parameters

    • options: {
          accountAddress: string;
          amountInEth: BigNumberish;
      }
      • accountAddress: string

        Address of the user's wallet containing the wrapped native asset

      • amountInEth: BigNumberish

        How much wrapped native asset to unwrap

    Returns Promise<void>

  • Validates an order onchain using Seaport's validate() method. This submits the order onchain and pre-validates the order using Seaport, which makes it cheaper to fulfill since a signature is not needed to be verified during fulfillment for the order, but is not strictly required and the alternative is orders can be submitted to the API for free instead of sent onchain.

    Parameters

    • orderComponents: OrderComponents

      Order components to validate onchain

    • accountAddress: string

      Address of the wallet that will pay the gas to validate the order

    Returns Promise<string>

    Transaction hash of the validation transaction

    Throws

    Error if the accountAddress is not available through wallet or provider.

  • Wrap native asset into wrapped native asset (e.g. ETH into WETH, POL into WPOL). Wrapped native assets are needed for making offers.

    Parameters

    • options: {
          accountAddress: string;
          amountInEth: BigNumberish;
      }
      • accountAddress: string

        Address of the user's wallet containing the native asset

      • amountInEth: BigNumberish

        Amount of native asset to wrap

    Returns Promise<void>