OpenSea V2 API: 'Invalid signature' error when attempting to list NFT on Polygon

I’m having trouble with the OpenSea V2 API. I’m trying to list an NFT on the Polygon network, but I keep getting an ‘invalid signature’ error. Here’s what I’ve tried:

  • Used Web3.js and Ethers.js to generate the signature
  • Now using Seaport for signature generation

My code uses Axios to make the API call, and I’m including my API key in the headers. The NFT details are all set up in the customParam object.

I’ve double-checked that my API key works for other OpenSea calls. I’m using the Mumbai testnet as my provider.

Has anyone successfully listed an NFT on Polygon using the OpenSea V2 API? Any tips on what I might be doing wrong with the signature? I’m pretty stumped at this point.

Here’s a simplified version of my code:

const signAndList = async () => {
  const signer = new ethers.Wallet(PRIVATE_KEY, provider);
  const nftMarket = new NFTMarket(signer);
  
  const listingParams = {
    tokenAddress: '0x1234...5678',
    tokenId: '123456',
    price: '0.1',
    expirationTime: Date.now() + 3600000
  };

  const signature = await nftMarket.signListing(listingParams);
  
  const response = await axios.post('https://api.opensea.io/v2/orders/matic/seaport/listings', {
    parameters: listingParams,
    signature: signature
  }, {
    headers: { 'X-API-KEY': API_KEY }
  });

  console.log(response.data);
};

signAndList();

Any help would be much appreciated!

hey there! i’ve been working with the opensea v2 api recently and ran into some similar headaches. have you tried using the seaport.js library directly? it can be a bit easier to work with for signing and creating orders.

also, just a thought - are you sure the nft you’re trying to list is actually on polygon? i made that mistake once and spent hours debugging before realizing my nft was on ethereum mainnet :sweat_smile:

oh, and make sure your wallet has some matic for gas fees. even if you’re using the mumbai testnet, you still need a tiny bit of test matic.

if none of that helps, maybe share a bit more of your code? sometimes it’s the tiniest thing throwing everything off. keep at it, you’ll figure it out!

I’ve encountered similar issues when working with the OpenSea V2 API for Polygon listings. One crucial aspect that might be causing the ‘invalid signature’ error is the chain ID. Make sure you’re using the correct chain ID for Polygon (137) or Mumbai testnet (80001) when generating your signature.

Also, double-check that your listingParams object includes all required fields. OpenSea’s documentation sometimes lags behind their actual requirements. Try adding startAmount, endAmount, and quantity fields to your parameters.

Lastly, ensure your wallet has sufficient MATIC for gas fees. Even on testnet, you need some MATIC in your wallet to sign transactions properly.

If these suggestions don’t resolve the issue, you might want to try using OpenSea’s SDK instead of direct API calls. It can handle some of the intricacies of signature generation more reliably.

hey mate, i had this same problem last week. turns out i was using the wrong network in my provider. make sure ur using the polygon mainnet (chainId 137) instead of mumbai. also, check ur nonce - sometimes it gets messed up and causes weird errors. gl!