I’m trying to create an NFT listing on the Polygon network using OpenSea’s API v2 but keep getting signature validation errors. My API key works fine for other requests. Here’s what I’m doing:
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(
"wallet_private_key_here",
rpcProvider
);
const seaportInstance = new Seaport(walletSigner);
let counterValue = 0;
let orderSignature = await seaportInstance.signOrder(orderParams, counterValue);
orderParams["counter"] = counterValue;
orderParams.startTime = orderParams.startTime.toString();
orderParams.endTime = orderParams.endTime.toString();
orderParams.totalOriginalConsiderationItems = orderParams.totalOriginalConsiderationItems.toNumber();
const listingData = {
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: listingData,
};
await axios
.request(requestConfig)
.then(function (result) {
console.log("Success:");
console.log(result.data);
})
.catch(function (err) {
console.log("Error occurred:");
console.error(err.response.data);
});
};
const orderParams = {
offerer: "0xB40647092185C2C58F0cBB46d2CbACD8A89cf0599",
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: "0x3064501124F0cBB46d2CbACD8A89cF0599885432",
identifierOrCriteria: "92847665432109876543210987654321098765432109876543210987654321",
startAmount: "1",
endAmount: "1",
},
],
consideration: [
{
itemType: 0,
token: "0x0000000000000000000000000000000000000000",
identifierOrCriteria: "0",
startAmount: "95000000000000000",
endAmount: "95000000000000000",
recipient: "0xB40647092185C2C58F0cBB46d2CbACD8A89cf0599",
},
{
itemType: 0,
token: "0x0000000000000000000000000000000000000000",
identifierOrCriteria: "0",
startAmount: "5000000000000000",
endAmount: "5000000000000000",
recipient: "0x0000a26b00c1F0DF003000390027140000fAa719",
},
],
totalOriginalConsiderationItems: ethers.BigNumber.from("2"),
salt: "987654321012",
conduitKey: "0x0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f0000",
};
createListing(orderParams);
I’ve tried different approaches with web3.js and ethers.js but they all give the same signature error. What am I missing for Polygon network listings?