import type { Seaport } from "@opensea/seaport-js"; import type { OrderComponents } from "@opensea/seaport-js/lib/types"; import { OpenSeaAPI } from "../api/api"; import type { CollectionOffer, Listing, Offer, Order, RequestInstantApiKeyResponse } from "../api/types"; import type { OrderV2 } from "../orders/types"; import type { ContractCaller, OpenSeaWallet } from "../provider/types"; import type { Amount, AssetWithTokenId, AssetWithTokenStandard, Chain, EventData } from "../types"; import { EventType } from "../types"; import { type BulkOrderResult } from "./orders"; /** * Configuration passed to the base SDK by entry-point constructors. */ export interface BaseSDKConfig { wallet: OpenSeaWallet; contractCaller: ContractCaller; seaport: Seaport; api: OpenSeaAPI; chain: Chain; logger: (arg: string) => void; /** Get available account addresses for requireAccountIsAvailable checks */ getAvailableAccounts: () => Promise; cachedPaymentTokenDecimals: { [address: string]: number; }; } /** * Base OpenSea SDK class containing all shared business logic. * Entry-point classes (ethers, viem) extend this and only differ in constructor. * @category Main Classes */ export declare class BaseOpenSeaSDK { /** Seaport client @see {@link https://github.com/ProjectOpenSea/seaport-js} */ seaport: Seaport; /** Logger function to use when debugging */ logger: (arg: string) => void; /** API instance */ readonly api: OpenSeaAPI; /** The configured chain */ readonly chain: Chain; protected _wallet: OpenSeaWallet; protected _contractCaller: ContractCaller; private _emitter; private _cachedPaymentTokenDecimals; private _getAvailableAccounts; private _tokensManager; private _assetsManager; private _cancellationManager; private _ordersManager; private _fulfillmentManager; protected constructor(config: BaseSDKConfig); /** * Request a free-tier OpenSea API key without authentication. The returned * key can be passed as `apiKey` into the SDK constructor to bootstrap usage. * Keys expire after 7 days. * * @example * ```ts * const { apiKey } = await OpenSeaSDK.requestInstantApiKey() * const sdk = new OpenSeaSDK(provider, { apiKey }) * ``` * * @param apiBaseUrl Optional base URL override (defaults to mainnet). */ static requestInstantApiKey(apiBaseUrl?: string): Promise; /** * Add a listener for events emitted by the SDK. * @param event The {@link EventType} to listen to. * @param listener A callback that will accept an object with {@link EventData} * @param once Whether the listener should only be called once. */ addListener(event: EventType, listener: (data: EventData) => void, once?: boolean): void; /** * Remove an event listener. * @param event The {@link EventType} to remove a listener for * @param listener The listener to remove */ removeListener(event: EventType, listener: (data: EventData) => void): void; /** * Remove all event listeners. Call when unmounting a component that listens to events. * @param event Optional EventType to remove listeners for */ removeAllListeners(event?: EventType): void; /** * Wrap native asset into wrapped native asset (e.g. ETH into WETH, POL into WPOL). * Wrapped native assets are needed for making offers. * @param options * @param options.amountInEth Amount of native asset to wrap * @param options.accountAddress Address of the user's wallet containing the native asset */ wrapEth(options: { amountInEth: Amount; accountAddress: string; }): Promise; /** * Unwrap wrapped native asset into native asset (e.g. WETH into ETH, WPOL into POL). * Emits the `UnwrapWeth` event when the transaction is prompted. * @param options * @param options.amountInEth How much wrapped native asset to unwrap * @param options.accountAddress Address of the user's wallet containing the wrapped native asset */ unwrapWeth(options: { amountInEth: Amount; accountAddress: string; }): Promise; /** * Create and submit an offer on an asset. * @param options * @param options.asset The asset to trade. tokenAddress and tokenId must be defined. * @param options.accountAddress Address of the wallet making the offer. * @param options.amount Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units. * @param options.quantity Number of assets to bid for. Defaults to 1. * @param options.domain Optional domain for onchain attribution. * @param options.salt Arbitrary salt. Auto-generated if not provided. * @param options.expirationTime Expiration time for the order, in UTC seconds * @param options.zone Zone for order protection. Defaults to chain's signed zone. * @returns The {@link Offer} that was created. */ createOffer(options: { asset: AssetWithTokenId; accountAddress: string; amount: Amount; quantity?: Amount; domain?: string; salt?: Amount; expirationTime?: Amount; zone?: string; }): Promise; /** * Create and submit a listing for an asset. * @param options * @param options.asset The asset to trade. tokenAddress and tokenId must be defined. * @param options.accountAddress Address of the wallet making the listing * @param options.amount Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units. * @param options.quantity Number of assets to list. Defaults to 1. * @param options.domain Optional domain for onchain attribution. * @param options.salt Arbitrary salt. Auto-generated if not provided. * @param options.listingTime Optional time when the order will become fulfillable, in UTC seconds. * @param options.expirationTime Expiration time for the order, in UTC seconds. * @param options.buyerAddress Optional address that's allowed to purchase this item. * @param options.includeOptionalCreatorFees If true, optional creator fees will be included. Default: false. * @param options.zone Zone for order protection. Defaults to no zone. * @returns The {@link Listing} that was created. */ createListing(options: { asset: AssetWithTokenId; accountAddress: string; amount: Amount; quantity?: Amount; domain?: string; salt?: Amount; listingTime?: number; expirationTime?: number; buyerAddress?: string; includeOptionalCreatorFees?: boolean; zone?: string; }): Promise; /** Create and submit multiple listings using Seaport's bulk order creation. */ createBulkListings(options: { listings: Array<{ asset: AssetWithTokenId; amount: Amount; quantity?: Amount; domain?: string; salt?: Amount; listingTime?: number; expirationTime?: number; buyerAddress?: string; includeOptionalCreatorFees?: boolean; zone?: string; }>; accountAddress: string; continueOnError?: boolean; onProgress?: (completed: number, total: number) => void; }): Promise>; /** Create and submit multiple offers using Seaport's bulk order creation. */ createBulkOffers(options: { offers: Array<{ asset: AssetWithTokenId; amount: Amount; quantity?: Amount; domain?: string; salt?: Amount; expirationTime?: Amount; zone?: string; }>; accountAddress: string; continueOnError?: boolean; onProgress?: (completed: number, total: number) => void; }): Promise>; /** Create and submit a collection offer. */ createCollectionOffer(options: { collectionSlug: string; accountAddress: string; amount: Amount; quantity: number; domain?: string; salt?: Amount; expirationTime?: number | string; offerProtectionEnabled?: boolean; traitType?: string; traitValue?: string; traits?: Array<{ type: string; value: string; }>; numericTraits?: Array<{ type: string; min?: number; max?: number; }>; }): Promise; /** * 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. * @param options * @param options.order The order to fulfill, a.k.a. "take" * @param options.accountAddress Address of the wallet taking the offer. * @param options.assetContractAddress Optional address of the NFT contract for criteria offers. * @param options.tokenId Optional token ID for criteria offers. * @param options.unitsToFill Optional number of units to fill. Defaults to 1. * @param options.recipientAddress Optional recipient address for the NFT when fulfilling a listing. * @param options.includeOptionalCreatorFees Whether to include optional creator fees. Defaults to false. * @param options.overrides Transaction overrides (gasLimit, maxFeePerGas, etc.). * @returns Transaction hash of the order. */ fulfillOrder(options: { order: OrderV2 | Order | Listing | Offer; accountAddress: string; assetContractAddress?: string; tokenId?: string; unitsToFill?: Amount; recipientAddress?: string; includeOptionalCreatorFees?: boolean; overrides?: Record; }): Promise; /** * Fulfill a private listing directly using Seaport's matchOrders. * The order must have a taker address set (i.e., it is a private listing). * @param options * @param options.order The private listing order to fulfill. Must have a taker address. * @param options.accountAddress Address of the wallet fulfilling the order. * @param options.domain Optional domain for onchain attribution. * @param options.overrides Transaction overrides (gasLimit, maxFeePerGas, etc.). * @returns Transaction hash of the fulfillment. */ fulfillPrivateOrder(options: { order: OrderV2; accountAddress: string; domain?: string; overrides?: Record; }): Promise; /** * Get cross-chain fulfillment data for one or more listings. * Supports same-chain, cross-token, and cross-chain purchases (up to 50 listings). * All listings must be EVM (Seaport orders). Payment can be from any chain (EVM or SVM). * Returns an ordered list of transactions to sign and submit. * @param options * @param options.listings Array of listings to fulfill (order hash, chain, protocol address) * @param options.fulfillerAddress The buyer's wallet address * @param options.paymentChain Chain slug of the payment token (EVM or SVM) * @param options.paymentTokenAddress Payment token contract address (0x0...0 for native) * @param options.recipientAddress Optional different recipient for the NFTs */ getCrossChainFulfillmentData(options: { listings: Array<{ hash: string; chain: string; protocolAddress: string; }>; fulfillerAddress: string; paymentChain: string; paymentTokenAddress: string; recipientAddress?: string; }): Promise<{ transactions: { chain: string; to?: string | undefined; data: string; value?: string | undefined; valueHex?: string | undefined; svm?: { from: string; instructions: { programId: string; accounts: { pubkey: string; signer: boolean; writable: boolean; }[]; data?: string | undefined; }[]; addressLookupTables: string[]; } | undefined; }[]; }>; /** Returns whether an order is fulfillable. */ isOrderFulfillable(options: { order: OrderV2; accountAddress: string; }): Promise; /** Approve an order with an onchain transaction. */ approveOrder(order: OrderV2, domain?: string): Promise; /** * Validates an order onchain using Seaport's validate() method, approving it * without an offchain signature. Does not post the order to OpenSea. */ validateOrderOnchain(orderComponents: OrderComponents, accountAddress: string, protocolAddress?: string): Promise; /** * Create a listing and validate it onchain instead of signing it offchain. * Does not post the listing to OpenSea. Returns a transaction hash. */ createListingAndValidateOnchain(options: { asset: AssetWithTokenId; accountAddress: string; amount: Amount; quantity?: Amount; domain?: string; salt?: Amount; listingTime?: number; expirationTime?: number; buyerAddress?: string; includeOptionalCreatorFees?: boolean; zone?: string; }): Promise; /** * Create an offer and validate it onchain instead of signing it offchain. * Does not post the offer to OpenSea. Returns a transaction hash. */ createOfferAndValidateOnchain(options: { asset: AssetWithTokenId; accountAddress: string; amount: Amount; quantity?: Amount; domain?: string; salt?: Amount; expirationTime?: Amount; zone?: string; }): Promise; /** * Cancel multiple orders onchain, preventing them from being fulfilled. * @param options * @param options.orders Array of orders to cancel. Can be OrderV2 objects or OrderComponents. * @param options.orderHashes Optional array of order hashes to cancel. * @param options.accountAddress The account address cancelling the orders. * @param options.protocolAddress The Seaport protocol address for the orders. * @param options.domain Optional domain for onchain attribution. * @param options.overrides Transaction overrides (gasLimit, maxFeePerGas, etc.). * @returns Transaction hash of the cancellation. */ cancelOrders(options: { orders?: Array; orderHashes?: string[]; accountAddress: string; protocolAddress?: string; domain?: string; overrides?: Record; }): Promise; /** * Cancel an order onchain, preventing it from ever being fulfilled. * @returns Transaction hash of the cancellation. */ cancelOrder(options: { order?: OrderV2; orderHash?: string; accountAddress: string; protocolAddress?: string; domain?: string; }): Promise; /** Offchain cancel an order by its order hash when protected by the SignedZone. */ offchainCancelOrder(protocolAddress: string, orderHash: string, chain?: Chain, offererSignature?: string, useSignerToDeriveOffererSignature?: boolean): Promise<{ lastSignatureIssuedValidUntil: string; }>; /** * Get an account's balance of any Asset. */ getBalance(options: { accountAddress: string; asset: AssetWithTokenStandard; }): Promise; /** * Transfer an asset. This asset can be an ERC20, ERC1155, or ERC721. * @param options * @param options.asset The Asset to transfer. tokenStandard must be set. * @param options.amount Amount of asset to transfer. Not used for ERC721. * @param options.fromAddress The address to transfer from * @param options.toAddress The address to transfer to * @param options.overrides Transaction overrides (gasLimit, maxFeePerGas, etc.). */ transfer(options: { asset: AssetWithTokenStandard; amount?: Amount; fromAddress: string; toAddress: string; overrides?: Record; }): Promise; /** Bulk transfer multiple assets using OpenSea's TransferHelper contract. */ bulkTransfer(options: { assets: Array<{ asset: AssetWithTokenStandard; toAddress: string; amount?: Amount; }>; fromAddress: string; overrides?: Record; }): Promise; /** Batch approve multiple assets for transfer to the OpenSea conduit. */ batchApproveAssets(options: { assets: Array<{ asset: AssetWithTokenStandard; amount?: Amount; }>; fromAddress: string; overrides?: Record; }): Promise; /** * Compute the `basePrice` parameter to be used to price an order. */ private _getPriceParameters; private _dispatch; private _requireAccountIsAvailable; private _confirmTransaction; }