-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
63 lines (51 loc) · 2.18 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const { Seaport } = require("@opensea/seaport-js");
const { ethers } = require("ethers");
const { data } = require("./details.json");
// Provider must be provided to the signer when supplying a custom signer
const provider = new ethers.providers.JsonRpcProvider(
data.apiKey.goerli.alchemy.url
);
// connecting first add as signer 1 and other as signer 2
const signer1 = new ethers.Wallet(data.accounts.acc1["private-key"], provider);
const signer2 = new ethers.Wallet(data.accounts.acc2["private-key"], provider);
// implemented two seaports obj for different signers
const seaport1 = new Seaport(signer1);
const seaport2 = new Seaport(signer2);
/// offering nad fullfillin it
async function main() {
const offerer = data.accounts.acc1.address; // offerer address which is going to offer
const fulfiller = data.accounts.acc2.address; // fulfiller address which is going to accept or fullfill
console.log("creating order !");
// creating order by signer 1
const { executeAllActions } = await seaport1.createOrder(
{
offer: [
{
itemType: 2,
token: data.contract.goerli.nft,
identifier: "0",
},
],
consideration: [
{
amount: ethers.utils.parseEther("0.1").toString(), // in return we are asking for 0.1 eth
recipient: offerer, // and the recipient must be offerer
},
],
},
offerer
);
console.log("created order success");
const order = await executeAllActions(); // getting the order array to pass in fullfill block
console.log("order : ", order)
// this will be call by signer 1 to fullfill the order
const { executeAllActions: executeAllFulfillActions } =
await seaport2.fulfillOrder({
order, // providing ther order which we are fullfilling
accountAddress: fulfiller, // the address through which we will fulfill
});
const transaction = await executeAllFulfillActions(); // getting the transaction details
console.log("transaction success");
console.log(transaction);
}
main();