Skip to content

v6.0.0

Choose a tag to compare

@ryanio ryanio released this 01 Dec 00:25
f9b3660

seaport-js 6.0 runs on viem. ethers, merkletreejs and TypeChain are gone; viem is the only runtime dependency (a peer, ^2.24.0), and the package ships ESM and CommonJS through an exports map at 695 kB unpacked (5.0.0: 1.04 MB). Node 22 or newer.

The library builds, signs and fulfills orders with the same checks as 5.x. New in 6.0: SeaportError codes for the library's own checks, orderToJson/orderFromJson (validated) for orders that travel through APIs, a refusal to send or sign when the wallet and public clients are on different chains, receipt options on executeAllActions, OrderType.CONTRACT, and an EIP-7702 authorizationList override. Built in #1102, #1103, #1104, #1105, #1106 and #1107.

Migrating from 5.x

6.0 runs on viem instead of ethers. The library does the same things and checks the same things; what changes is how you construct it, the types of the values you pass, and what its transaction methods return.

Install

npm install @opensea/seaport-js viem

viem is a peer dependency (^2.24.0). ethers is no longer a dependency, and neither is merkletreejs. The package runs no install script.

The package ships ESM and CommonJS builds with an exports map, built for any runtime (Node, browsers, edge). Node 22 or newer is required: Node 20 reached end of life on 2026-04-30.

Construct

5.x took an ethers provider or signer, plus an overrides object:

const seaport = new Seaport(signer, {
  overrides: { contractAddress, defaultConduitKey },
})

6.0 takes viem clients and flat settings:

import { createPublicClient, createWalletClient, custom, http } from "viem"
import { mainnet } from "viem/chains"
import { Seaport } from "@opensea/seaport-js"

const publicClient = createPublicClient({ chain: mainnet, transport: http() })
const walletClient = createWalletClient({
  chain: mainnet,
  transport: custom(window.ethereum),
  account, // optional: an address or a viem Account
})

const seaport = new Seaport({
  publicClient,
  walletClient,
  seaportAddress, // was overrides.contractAddress
  defaultConduitKey, // was overrides.defaultConduitKey
})
5.x 6.0
first argument (provider or signer) publicClient (required) and walletClient (optional)
overrides.contractAddress seaportAddress
overrides.domainRegistryAddress domainRegistryAddress
overrides.seaportVersion seaportVersion
overrides.defaultConduitKey defaultConduitKey
conduitKeyToConduit, ascendingAmountFulfillmentBuffer, balanceAndApprovalChecksOnOrderCreation unchanged

publicClient does every read. walletClient signs and sends; leave it out for read-only use (building orders, hashing, checking status). The contract and domainRegistry properties are gone; read seaport.seaportAddress and seaport.domainRegistryAddress, and use the ABIs from @opensea/seaport-js/abi with your own clients for raw calls.

Coming from ethers

If the rest of your app uses ethers, you do not need to switch it; wrap what you have for viem. (@opensea/sdk 15 does this for you in its ethers entry.)

A browser wallet: give viem the same EIP-1193 provider you gave ethers.

const [account] = await window.ethereum.request({ method: "eth_requestAccounts" })
const walletClient = createWalletClient({
  chain: mainnet,
  transport: custom(window.ethereum),
  account,
})

An ethers JsonRpcProvider or BrowserProvider can back a viem transport through its send method:

const transport = custom({
  request: ({ method, params }) => ethersProvider.send(method, params ?? []),
})
const publicClient = createPublicClient({ chain: mainnet, transport })

An ethers Wallet holds its key, so use it directly:

import { privateKeyToAccount } from "viem/accounts"

const walletClient = createWalletClient({
  chain: mainnet,
  transport,
  account: privateKeyToAccount(wallet.privateKey as Hex),
})

Any other ethers Signer (a remote or hardware signer): route the wallet's methods to it in a transport, and give the wallet client its address as a JSON-RPC account so viem sends them through that transport.

const address = (await signer.getAddress()) as Address
const signerTransport = custom({
  async request({ method, params }) {
    switch (method) {
      case "eth_accounts":
      case "eth_requestAccounts":
        return [address]
      case "eth_sendTransaction": {
        const [tx] = params as [
          { to?: string; data?: string; value?: string; gas?: string },
        ]
        const sent = await signer.sendTransaction({
          to: tx.to,
          data: tx.data,
          value: tx.value,
          gasLimit: tx.gas,
        })
        return sent.hash
      }
      case "eth_signTypedData_v4": {
        const [, json] = params as [string, string]
        const { domain, types, message } = JSON.parse(json)
        delete types.EIP712Domain
        return signer.signTypedData(domain, types, message)
      }
      default:
        return ethersProvider.send(method, params ?? [])
    }
  },
})
const walletClient = createWalletClient({
  chain: mainnet,
  transport: signerTransport,
  account: address,
})

Values are bigint, Address and Hex

5.x accepted BigNumberish and numeric strings. 6.0 takes bigint for every amount, identifier, time, salt and counter, viem's Address for addresses, and Hex for byte values. Orders it returns use the same types.

// 5.x
offer: [{ itemType: ItemType.ERC721, token, identifier: "1" }],
consideration: [{ amount: parseEther("1").toString(), recipient }],
endTime: "1767225600",

// 6.0
offer: [{ itemType: ItemType.ERC721, token, identifier: 1n }],
consideration: [{ amount: parseEther("1"), recipient }],
endTime: 1767225600n,
Field 5.x 6.0
amount, endAmount, identifier string bigint
identifiers (criteria) string[] bigint[]
criteria (merkle root) string Hex
startTime, endTime, counter, salt BigNumberish / string bigint
InputCriteria { identifier: string; proof: string[] } { identifier: bigint; proof: Hex[] }
unitsToFill BigNumberish bigint
order parameters numbers strings bigint
orderIndex, itemIndex, index in fulfillments and criteria resolvers number bigint
signature, zoneHash, conduitKey, extraData string Hex

JSON.stringify throws on bigint, and orders travel through APIs, so 6.0 adds two helpers:

import { orderFromJson, orderToJson } from "@opensea/seaport-js"

await fetch(url, { method: "POST", body: JSON.stringify(orderToJson(order)) })

const order = orderFromJson(apiResponse.protocol_data) // decimal or hex strings

Method signatures

Positional optional arguments became option objects, and accountAddress became account, which takes an address or a viem Account. When it is left out, the wallet client's account is used.

5.x 6.0
createOrder(input, accountAddress?, exactApproval?) createOrder(input, { account?, offerer?, exactApproval? })
createBulkOrders(inputs, accountAddress?, exactApproval?) createBulkOrders(inputs, { account?, offerer?, exactApproval? })
fulfillOrder({ ..., accountAddress, recipientAddress }) fulfillOrder({ ..., account, recipient })
fulfillOrders({ ..., accountAddress, recipientAddress }) fulfillOrders({ ..., account, recipient })
matchOrders({ ..., accountAddress }), matchAdvancedOrders(...) account
cancelOrders(orders, accountAddress?, domain?, overrides?) cancelOrders(orders, { account?, domain?, overrides? })
bulkCancelOrders(offerer?, domain?, overrides?) bulkCancelOrders({ account?, domain?, overrides? })
validate(orders, accountAddress?, domain?, overrides?) validate(orders, { account?, domain?, overrides? })
setDomain(domain, accountAddress?, overrides?) setDomain(domain, { account?, overrides? })
signOrder(components, accountAddress?) signOrder(components, { account? })
signBulkOrder(components, accountAddress?) signBulkOrder(components, { account? })

offerer covers the one case where 5.x's accountAddress and the signer differed: a contract wallet (ERC-1271) whose owner signs for it. Pass the owner as account and the wallet as offerer.

Transactions

Every method that sends returns transaction methods, as before. They now return viem values:

5.x 6.0
transact() resolves to an ethers TransactionResponse resolves to the transaction hash; wait with publicClient.waitForTransactionReceipt({ hash })
staticCall() simulate(), decoded with the Seaport ABI
estimateGas() unchanged, bigint
buildTransaction() resolves to an ethers ContractTransaction returns { to, data, value } synchronously
executeAllActions() on a fulfill resolves to a TransactionResponse resolves to the transaction hash
overrides { gasLimit, value, ... } { gas, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, nonce }
// 5.x
const tx = await executeAllActions()
const receipt = await tx.wait()

// 6.0
const hash = await executeAllActions()
const receipt = await publicClient.waitForTransactionReceipt({ hash })

executeAllActions() and executeApprovals() still send each approval first. They now wait for each approval's receipt and throw if one reverted, since the next transaction depends on it. Both take optional { confirmations, timeout } for those waits.

transact() estimates gas before sending unless you pass gas, so a call that would revert throws with the decoded error instead of being mined. A value you pass in overrides now wins over the native amount seaport-js computes. Sending and signing throw SeaportError("CHAIN_MISMATCH") when the wallet client and public client are on different chains.

A domain tag is still appended to the calldata, and buildTransaction, estimateGas and transact all include it.

Errors

A Seaport revert is reported the way viem's writeContract reports one: a ContractFunctionExecutionError whose cause is a ContractFunctionRevertedError with the error decoded by name.

import { BaseError, ContractFunctionRevertedError } from "viem"

try {
  await actions.at(-1)!.transactionMethods.transact()
} catch (error) {
  const revert =
    error instanceof BaseError &&
    error.walk(e => e instanceof ContractFunctionRevertedError)
  if (revert instanceof ContractFunctionRevertedError) {
    console.log(revert.data?.errorName) // e.g. "InvalidSignature"
  }
}

The library's own checks (an unknown conduit, a missing balance, an order already filled, malformed order JSON) throw a SeaportError with a code such as "UNKNOWN_CONDUIT" or "FULFILLER_INSUFFICIENT_BALANCE"; branch on the code rather than the message. The messages are unchanged from 5.x.

Imports

5.x published its compiled files under lib/, and some consumers imported from there. 6.0 has two entry points, and nothing under lib/ can be imported directly.

5.x 6.0
@opensea/seaport-js @opensea/seaport-js
@opensea/seaport-js/lib/types @opensea/seaport-js
@opensea/seaport-js/lib/constants @opensea/seaport-js
@opensea/seaport-js/lib/utils/item (isCurrencyItem, getMaximumSizeForOrder, ...) @opensea/seaport-js
@opensea/seaport-js/lib/utils/order (generateRandomSalt, mapInputItemToOfferItem) @opensea/seaport-js
@opensea/seaport-js/lib/utils/merkletree (MerkleTree) @opensea/seaport-js
@opensea/seaport-js/lib/abi/Seaport (SeaportABI) @opensea/seaport-js/abi (seaportAbi)
@opensea/seaport-js/lib/typechain-types removed; use the ABIs with viem

The abi entry point has seaportAbi, conduitControllerAbi, conduitAbi, domainRegistryAbi, erc20Abi, erc721Abi and erc1155Abi, all as const so viem types every call.

Other changes

  • generateRandomSalt() returns a bigint. The layout is unchanged: an optional four byte domain tag, 20 zero bytes, then 8 random bytes.
  • getTagFromDomain(domain) returns 0x plus the four tag bytes (5.x returned the eight hex characters without 0x).
  • MerkleTree takes bigint[] identifiers. An empty tree's root is the zero hash (5.x returned "0"). Roots and proofs are otherwise byte-identical to 5.x.
  • getMessageToSign() returns viem's serializeTypedData output. It is the same EIP-712 payload; numbers are written as decimal strings and EIP712Domain is included in types.
  • getOrderHash(components) is also exported as a standalone function.
  • orderFromJson validates what it reads (addresses, hex lengths, integer ranges, enum values) and throws SeaportError("INVALID_ORDER_JSON") rather than coercing a malformed value. It still does not judge an order's terms: show or check an API order before executeAllActions().
  • New: OrderType.CONTRACT, SEAPORT_CONTRACT_VERSION_V1_5, orderComponentsToJson/orderComponentsFromJson, and an EIP-7702 authorizationList transaction override.
  • getDomain(tag, index) takes a number or bigint. getDomains falls back to reading one index at a time only when the failure is not a network error.
  • The seaport.OPENSEA_CONDUIT_KEY instance property is gone; import OPENSEA_CONDUIT_KEY instead.
  • seaport.contract (an ethers Contract) and seaport.domainRegistry are gone.