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?