-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
I created a route which aims to list NFTs using OpenSea: `router.post('/sell', async (req, res) => {
const { tokenId, price } = req.body;
if (!tokenId || !price || !privateKey || !account) {
return res.status(400).json({ error: 'Token ID, price, private key, and account address are required.' });
}
try {
const priceInWei = web3.utils.toWei(price.toString(), 'ether');
const currentTime = Math.floor(Date.now() / 1000);
const endTime = currentTime + (60 * 60 * 24);
const listingParameters = {
offerer: account,
offer: [{
itemType: 2,
token: contractAddress,
identifierOrCriteria: tokenId,
startAmount: "1",
endAmount: "1"
}],
consideration: [{
itemType: 0,
token: "0x0000000000000000000000000000000000000000",
identifierOrCriteria: "0",
startAmount: priceInWei,
endAmount: priceInWei,
recipient: account
}],
startTime: currentTime,
endTime: endTime,
orderType: 0,
zone: "0x00000000000000adc04c56bf30ac9d3c0aaf14dc",
zoneHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
salt: web3.utils.randomHex(32),
conduitKey: "0x0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f0000",
totalOriginalConsiderationItems: 1,
counter: 0
};
const orderHash = web3.utils.sha3(JSON.stringify(listingParameters));
const signature = web3.eth.accounts.sign(orderHash, privateKey);
const listing = {
parameters: listingParameters,
signature: signature.signature,
protocol_address: '0x00000000000000adc04c56bf30ac9d3c0aaf14dc',
};
const apiUrl = `https://api.opensea.io/v2/orders/sepolia/seaport/listings`;
const options = {
method: 'POST',
url: apiUrl,
headers: {
'accept': 'application/json',
'content-type': 'application/json',
'X-API-KEY': process.env.OPENSEA_API_KEY,
},
data: listing
};
const response = await axios.request(options);
console.log('Listing response:', response.data);
res.status(200).json({ message: 'NFT listed successfully', data: response.data });
} catch (error) {
console.error('Error listing NFT:', error.message);
if (error.response) {
console.error('Full error details:', error.response.data);
}
res.status(500).json({ error: 'Failed to list NFT.', details: error.message });
}
});
but it is throwing me an error:
Error listing NFT: Request failed with status code 500
Full error details: {
errors: [
'We encountered an exception while processing your request. Please try again later.'
]
}`
Metadata
Metadata
Assignees
Labels
No labels