-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
134 lines (111 loc) · 3.27 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<html>
<style>
.page {
background-color: white;
}
.header {
text-align: center;
margin-top: 80px;
font-weight: 300;
font-style: normal;
color: #F15541;
font-family: 'Circular Std Book';
line-height: 1;
font-size: 50px;
}
.button-container {
position: relative;
top: 20%;
display: flex;
justify-content: center;
}
.button {
height: 75px;
width: 200px;
font-weight: 400;
font-style: normal;
border: none;
border-radius: 2rem;
background-color: #00BAC6;
color: #fff;
font-size: 20px;
font-family: 'Circular Std Book';
}
.footer {
position: fixed;
left: 30;
top: 30;
width: 100%;
background-color: white;
text-align: left;
}
.img-container {
position: relative;
top: 5%;
display: flex;
justify-content: center;
}
.img-footer {
max-width: 12.5%;
border-width: .5em;
}
.img-nft {
width: 25%;
border-width: 1em;
border-style: solid;
border-color: #FEC241;
}
.success-msg {
font-size: 20px;
font-weight: bold;
font-family: 'Circular Std Book';
color: #5BCA81;
display: none;
text-align: center;
}
</style>
<head>
<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
<script src="https://unpkg.com/moralis/dist/moralis.js"></script>
<link href="//db.onlinewebfonts.com/c/860c3ec7bbc5da3e97233ccecafe512e?family=Circular+Std+Book" rel="stylesheet" type="text/css"/>
</head>
<body class="page">
<h1 class="header">Redeem your NFT</h1>
<div class="img-container">
<img class="img-nft" src="guy-fieiri-flame_1.avif" alt="nft image" ></img>
</div>
<div class="button-container">
<button class="button" id="btn-transfer">Transfer NFT</button>
<p id="success-msg" class="success-msg">You have successfully transferred your NFT to your wallet!</p>
</div>
<div class='footer'>
<img class="img-footer" src="lightsoy-white-bg.png" alt="bentobox logo"></img>
</div>
<script>
const serverUrl = "https://0ntys4th7t1x.usemoralis.com:2053/server";
const appId = "0HT1FBQOYn6p1X9OQYUgMZOMcr3i5b28Z3oarTa8";
Moralis.start({ serverUrl, appId });
async function transfer() {
user = await Moralis.authenticate();
console.log(user);
const userWalletAddress = user.attributes.accounts[0]
console.log('wallet address', userWalletAddress);
// sending a token with token id = 0
const options = {
type: "erc721",
receiver: userWalletAddress,
contractAddress: "0x445C1327Bc03A1c1e140164eA3f69FeFB1Fda23c",
tokenId: "0",
};
let transaction = await Moralis.transfer(options);
const result = await transaction.wait();
console.log(result, "HIT <<<<")
if (result) {
document.getElementById('btn-transfer').style = 'display: none;'
document.getElementById('success-msg').style = 'display: block;'
}
}
document.getElementById('btn-transfer').onclick = transfer;
</script>
</body>
</html>