OpenSea API v2 returns signature validation error when creating NFT listing on Polygon chain

I’m trying to create an NFT listing on the Polygon network using OpenSea’s v2 API but keep getting signature validation errors. My API key works fine for other endpoints, so that’s not the issue.

const axios = require("axios");
const { Seaport } = require("@opensea/seaport-js");
const ethers = require("ethers");

const createListing = async (orderParams) => {
  const rpcProvider = new ethers.providers.JsonRpcProvider(
    "https://rpc-mumbai.maticvigil.com/"
  );
  const walletSigner = new ethers.Wallet(
    "private_key_here",
    rpcProvider
  );
  const seaportInstance = new Seaport(walletSigner);
  let orderCounter = 0;
  let orderSignature = await seaportInstance.signOrder(orderParams, orderCounter);
  orderParams["counter"] = orderCounter;
  orderParams.startTime = orderParams.startTime.toString();
  orderParams.endTime = orderParams.endTime.toString();
  orderParams.totalOriginalConsiderationItems = orderParams.totalOriginalConsiderationItems.toNumber();
  
  const listingOrder = {
    parameters: orderParams,
    signature: orderSignature,
  };
  
  const requestConfig = {
    method: "POST",
    url: "https://api.opensea.io/v2/orders/matic/seaport/listings",
    headers: {
      accept: "application/json",
      "X-API-KEY": "your_api_key_here",
      "content-type": "application/json",
    },
    data: listingOrder,
  };

  await axios
    .request(requestConfig)
    .then(function (response) {
      console.log("Success response:");
      console.log(response.data);
    })
    .catch(function (error) {
      console.log("Error occurred:");
      console.error(error.response.data);
    });
};

const orderParams = {
  offerer: "0x1234567890123456789012345678901234567890",
  zone: "0x0000000000000000000000000000000000000000",
  zoneHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
  startTime: ethers.BigNumber.from(
    Math.floor(Date.now() / 1000).toString()
  ),
  endTime: ethers.BigNumber.from(
    Math.floor(Date.now() / 1000 + 3600).toString()
  ),
  orderType: 1,
  offer: [
    {
      itemType: 3,
      token: "0xabcdef1234567890abcdef1234567890abcdef12",
      identifierOrCriteria: "12345678901234567890123456789012345678901234567890123456789012345678901234567",
      startAmount: "1",
      endAmount: "1",
    },
  ],
  consideration: [
    {
      itemType: 0,
      token: "0x0000000000000000000000000000000000000000",
      identifierOrCriteria: "0",
      startAmount: "97500000000000000",
      endAmount: "97500000000000000",
      recipient: "0x1234567890123456789012345678901234567890",
    },
    {
      itemType: 0,
      token: "0x0000000000000000000000000000000000000000",
      identifierOrCriteria: "0",
      startAmount: "2500000000000000",
      endAmount: "2500000000000000",
      recipient: "0x9876543210987654321098765432109876543210",
    },
  ],
  totalOriginalConsiderationItems: ethers.BigNumber.from("2"),
  salt: "987654321012",
  conduitKey: "0x0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f0000",
};

createListing(orderParams);

I’ve tried different approaches with web3.js and ethers.js for signature generation, but the same validation error keeps occurring. Has anyone successfully implemented Polygon NFT listings with OpenSea’s v2 API?

This is really interesting! I’ve been fighting similar issues with OpenSea’s v2 API lately - signature validation is such a pain.

Are you sure you’re using the right chain ID when creating your wallet signer? I see you’re using Mumbai testnet RPC, but chain ID mismatches can break signature validation even when everything else looks correct.

Have you logged the actual orderCounter value you’re getting? The counter might not be syncing with what OpenSea expects. Sometimes you need to fetch it directly from the Seaport contract instead of starting at 0.

Are you testing on mainnet Polygon or still on Mumbai? I remember reading that API endpoints and validation behave differently between testnet and mainnet.

What’s the exact error message? Just “signature validation error” or something more specific? That’d help figure out if it’s the signature itself or a parameter formatting issue.

Had this exact problem last month! Your orderCounter’s probably wrong - fetch it from the seaport contract instead of hardcoding 0. Also check if your RPC endpoint actually supports eth_signTypedData_v4. Some Polygon RPCs are flaky with that method.

Looks like a formatting issue with your order parameters before signing. I hit this same problem when BigNumber conversions weren’t timing right. Don’t assume the counter is zero - grab it directly with seaportInstance.getCounter(walletAddress) first. That identifierOrCriteria seems way too long for a token ID. Double-check you’ve got the actual NFT token ID and not something else. OpenSea’s picky about parameter types matching exactly what the contract wants. Also verify your private key matches the offerer address. Yeah, it’s obvious, but I’ve watched people get stuck on this when juggling multiple wallets.