-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.js
55 lines (43 loc) · 1.64 KB
/
utils.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
const origin = "https://deep-index.moralis.io";
const apiKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJub25jZSI6ImIyYzlhZDA2LTFmMmUtNDg0My1hOTFjLWU4MzVlZTQxNzhjZCIsIm9yZ0lkIjoiMzkxMzgxIiwidXNlcklkIjoiNDAyMTU2IiwidHlwZUlkIjoiYjVmMzZjMTMtNjEwNi00ZGM2LTg1NDAtODc2YzkyZDQwODY4IiwidHlwZSI6IlBST0pFQ1QiLCJpYXQiOjE3MTUxMzg2MDEsImV4cCI6NDg3MDg5ODYwMX0.6UWx8L64SGPoOlVEfUeIYcGpYcXysqpX0CeA2icLjo0";
export const getContractNFTs = async (tokenAddress) => {
const url = new URL(`${origin}/api/v2/nft/${tokenAddress}`);
url.searchParams.append("chain", "eth");
url.searchParams.append("format", "decimal");
url.searchParams.append("limit", "20");
const response = await fetch(url, {
headers: {
accept: "application/json",
"X-API-KEY": apiKey,
},
});
return response.json();
};
export const getContractTrades = async (tokenAddress) => {
const url = new URL(`${origin}/api/v2/nft/${tokenAddress}/trades`);
url.searchParams.append("chain", "eth");
url.searchParams.append("marketplace", "opensea");
url.searchParams.append("limit", "20");
const response = await fetch(url, {
headers: {
accept: "application/json",
"X-API-KEY": apiKey,
},
});
return response.json();
};
export const getNFTTransfers = async (tokenAddress, tokenId) => {
const url = new URL(
`${origin}/api/v2/nft/${tokenAddress}/${tokenId}/transfers`
);
url.searchParams.append("chain", "eth");
url.searchParams.append("format", "decimal");
url.searchParams.append("limit", "20");
const response = await fetch(url, {
headers: {
accept: "application/json",
"X-API-KEY": apiKey,
},
});
return response.json();
};