Replies: 3 comments 10 replies
-
you should just use opensea-js |
Beta Was this translation helpful? Give feedback.
-
@ryanio can you please point me to the doc or give me code example how to do it? i have been trying to find the solution for last few days but didnt find any solution so posted it here. |
Beta Was this translation helpful? Give feedback.
-
@ryanio i tried but still signOrder is taking more than 1 sec to return signature, here is my updated code: const seaport = new Seaport(signer, { const seaportName = "Seaport"; const orderType = { const offerer = walletAddress; let orderComponents = { }, (async () => { const order = await seaport.api.postOrder(ord, { })();`` |
Beta Was this translation helpful? Give feedback.
-
I am trying to submit a offer using api and but getting "Invalid order signature error".
I will really apprecaite any help , here is my code
`const { ethers, utils, BigNumber, Wallet } = require("ethers"); // module used for intracting with Ethereum Network and signing transactions
const { OpenSeaPort, Chain, OpenSeaSDK, OpenSeaAPI } = require("opensea-js"); // opensea api module
const { Seaport } = require("@opensea/seaport-js");
const { generateRandomSalt } = require("@opensea/seaport-js/lib/utils/order");
const providerUrl = process.env.PROVIDER; // Endpoint to interact with the Ethereum blockchain
const walletAddress = process.env.WALLET_ADDRESS; //wallet address
const walletPrivateKey = process.env.WALLET_PRIVATE_KEY; //wallet private key
const network = process.env.NETWORK || "mainnet"; //
const openSeaApiKey = process.env.OPENSEA_API_KEY; // Opensea API key
const provider = new ethers.providers.JsonRpcProvider(providerUrl);
const signer = new ethers.Wallet(walletPrivateKey, provider);
const seaport = new OpenSeaPort(signer, {
chain: network == "mainnet" ? Chain.Mainnet : Chain.Sepolia,
apiKey: openSeaApiKey,
});
const orderType = {
OrderComponents: [
{ name: "offerer", type: "address" },
{ name: "zone", type: "address" },
{ name: "offer", type: "OfferItem[]" },
{ name: "consideration", type: "ConsiderationItem[]" },
{ name: "orderType", type: "uint8" },
{ name: "startTime", type: "uint256" },
{ name: "endTime", type: "uint256" },
{ name: "zoneHash", type: "bytes32" },
{ name: "salt", type: "uint256" },
{ name: "conduitKey", type: "bytes32" },
{ name: "counter", type: "uint256" },
{ name: "totalOriginalConsiderationItems", type: "uint256" },
],
OfferItem: [
{ name: "itemType", type: "uint8" },
{ name: "token", type: "address" },
{ name: "identifierOrCriteria", type: "uint256" },
{ name: "startAmount", type: "uint256" },
{ name: "endAmount", type: "uint256" },
],
ConsiderationItem: [
{ name: "itemType", type: "uint8" },
{ name: "token", type: "address" },
{ name: "identifierOrCriteria", type: "uint256" },
{ name: "startAmount", type: "uint256" },
{ name: "endAmount", type: "uint256" },
{ name: "recipient", type: "address" },
],
};
const seaportName = "Seaport";
const seaportVersion = "1.5";
const chainId = "1";
const seaportContractAddress = "0x00000000000000ADc04C56Bf30aC9d3c0aAF14dC";
const domainData = {
name: seaportName,
version: seaportVersion,
chainId: chainId,
verifyingContract: seaportContractAddress,
};
const orderType = {
OrderComponents: [
{ name: "offerer", type: "address" },
{ name: "zone", type: "address" },
{ name: "offer", type: "OfferItem[]" },
{ name: "consideration", type: "ConsiderationItem[]" },
{ name: "orderType", type: "uint8" },
{ name: "startTime", type: "uint256" },
{ name: "endTime", type: "uint256" },
{ name: "zoneHash", type: "bytes32" },
{ name: "salt", type: "uint256" },
{ name: "conduitKey", type: "bytes32" },
{ name: "counter", type: "uint256" },
{ name: "totalOriginalConsiderationItems", type: "uint256" },
],
OfferItem: [
{ name: "itemType", type: "uint8" },
{ name: "token", type: "address" },
{ name: "identifierOrCriteria", type: "uint256" },
{ name: "startAmount", type: "uint256" },
{ name: "endAmount", type: "uint256" },
],
ConsiderationItem: [
{ name: "itemType", type: "uint8" },
{ name: "token", type: "address" },
{ name: "identifierOrCriteria", type: "uint256" },
{ name: "startAmount", type: "uint256" },
{ name: "endAmount", type: "uint256" },
{ name: "recipient", type: "address" },
],
};
const offerer = walletAddress;
const amount = "0.005";
let orderComponents = {
offerer: offerer,
zone: "0x0000000000000000000000000000000000000000",
offer: [
{
itemType: 1,
token: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
identifierOrCriteria: 0,
startAmount: ethers.utils.parseEther(amount).toString(),
endAmount: ethers.utils.parseEther(amount).toString(),
},
],
consideration: [
{
itemType: ItemType.ERC1155,
token: "0xc36cf0cfcb5d905b8b513860db0cfe63f6cf9f5c",
identifierOrCriteria: "221864103232451878178120244045512873869312",
startAmount: 1,
endAmount: 1,
recipient: offerer,
},
{
itemType: 1,
token: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
identifierOrCriteria: 0,
startAmount: (ethers.utils.parseEther(amount) * 0.025).toString(),
endAmount: (ethers.utils.parseEther(amount) * 0.025).toString(),
recipient: "0x0000a26b00c1F0DF003000390027140000fAa719",
},
{
itemType: 1,
token: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
identifierOrCriteria: 0,
startAmount: (ethers.utils.parseEther(amount) * 0.1).toString(),
endAmount: (ethers.utils.parseEther(amount) * 0.1).toString(),
recipient: "0x0e4708e33A335A62D51075941285a952D6b8F395",
],
orderType: 0,
startTime: Math.round(Date.now() / 1000).toString(),
endTime: Math.round(Date.now() / 1000 + 15 * 60).toString(),
zoneHash:
"0x0000000000000000000000000000000000000000000000000000000000000000",
salt: generateRandomSalt(),
conduitKey:
"0x0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f0000",
counter: 0,
totalOriginalConsiderationItems: 3,
};
(async () => {
let signature = await signer._signTypedData(
domainData,
orderType,
orderComponents
);
log(signature);
if (signature.length === 132) {
signature = ethers.utils.splitSignature(signature).compact;
}
log(signature);
const ord = {
parameters: orderComponents,
signature: signature,
};
const order = await seaport.api.postOrder(ord, {
protocol: "seaport",
version: "1.5",
protocolAddress: seaportContractAddress,
side: "bid",
});
})();`
Beta Was this translation helpful? Give feedback.
All reactions