-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
85 lines (85 loc) · 2.77 KB
/
index.html
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE html>
<html>
<head>
<script src="https://aloycwl.github.io/js/cdn/jquery.min.js"></script>
<script src="https://aloycwl.github.io/js/cdn/web3.min.js"></script>
<script src="https://aloycwl.github.io/js/cdn/web3ac.js"></script>
<title>Agora Marketplace - World's First NFT DEX</title>
</head>
<body>
<b>Your NFTS</b> |
<a href="fetch_using_etherscan_api.html">Etherscan API Example</a> |
<a href="buy.html">Buy Example</a><br />
<a href="?id=1">Mainnet</a> | <a href="?id=5">Goerli</a><br />
<a id="body"></a>
</body>
<script>
u = new URLSearchParams(window.location.search).get('id');
offset = 0;
CA1 = '0x07b2de1b0d412d567ca4028ab229fd8a671f2491';
CS = 'https://aloycwl.github.io/agora_frontend/css/agora.css';
CHAIN = u > 0 ? u : 1;
async function display(o) {
options =
CHAIN == 1 ? { 'X-API-KEY': 'ff2304b6277a4e299bcfd285fce397d8' } : {};
await fetch(
`https://${
CHAIN == 1 ? '' : 'testnets-'
}api.opensea.io/api/v1/assets?owner=${acct}&order_direction=desc&offset=${o}&limit=50`,
{
method: 'GET',
headers: options,
}
)
.then((response) => response.json())
.then((response) => (a = response.assets));
for (i = 0; i < a.length; i++)
$('#body').append(
`<div class="nfts"><b>${a[i].asset_contract.name}</b> - ${
a[i].name
}<br><i>${a[i].description}</i> ${
a[i].animation_url == null
? `<img src='${a[i].image_url}'>`
: `<video autoplay muted loop><source src='${a[i].animation_url}'></video>`
}<p id=p${a[i].id}><input id=t${
a[i].id
} placeholder='Price'><button onclick='sell("${
a[i].asset_contract.address
}",${a[i].token_id},${a[i].id})'>Sell</button><p></div></div>`
);
}
async function sell(addr, tokenid, id) {
t = $('#t' + id).val();
waitTxt(1, 'p' + id);
CA2 = addr;
load2();
await contract2.methods.approve(CA1, tokenid).send(FA);
await contract.methods.Sell(CA2, tokenid, t).send(FA);
waitTxt(0, 'p' + id);
}
(async () => {
await load(
[
{
inputs: [u3, u1, u1],
name: 'Sell',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
],
CA1
);
display(offset);
})();
$(window).scroll(function () {
if (
Math.ceil($(window).scrollTop()) ==
Math.ceil($(document).height() - $(window).height())
) {
offset += 50;
display(offset);
}
});
</script>
</html>