forked from victor-tucci/faucet-testnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfront-end.html
90 lines (76 loc) · 2.28 KB
/
front-end.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
<html>
<head>
<link rel="shortcut icon" href="https://avatars.githubusercontent.com/u/44291167?s=200&v=4" type="image/png">
<title> Beldex Faucet </title>
<style>
hr {
height: 5px;
background-color: #4CAF50;
border: none;
}
</style>
</head>
<body style="background-color:black;text-align: center">
<h1 style="color: #4CAF50"> Beldex TESTNET Faucet</h1><br>
<hr>
<br>
<img id="beldeximage" alt="beldexlogo"
src="https://assets.coingecko.com/coins/images/5111/large/Beldex.png?1559189036" width="150" height="150">
<style>
.button {
background-color: #4CAF50;
/* Green */
border: none;
color: white;
padding: 5px 10px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 14px;
margin: 4px 2px;
border-radius: 5px;
cursor: pointer;
}
</style>
<br><br>
<header style="color: #4CAF50">Enter Your Beldex Testnet Address Below <br>
<hr>
</header><br>
<input id="address" type="text" style="width:790px"><br><br>
<button id="post-btn" class="button">Get Faucet</button>
<br><br>
<hr>
<div style="margin-top:20px">
<span id="hash"></span>
</div>
<script>
const button = document.getElementById('post-btn');
button.addEventListener('click', async _ => {
var user_address = document.getElementById('address').value;
console.log("user_address ", user_address);
const params = {
"address": user_address
}
console.log("params", params);
const response = await fetch('https://faucet.beldex.dev/faucet', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(params)
});
const data = await response.json();
console.log("data", data);
if (data.STATUS == 'FAIL') {
document.getElementById('hash').innerHTML = data.WARNING;
document.getElementById('hash').style.color = 'red';
}
else {
var link = "https://testnet.beldex.dev/tx/" + data.HASH;
document.getElementById('hash').innerHTML = "your transaction id is " + `<a href="${link}">${data.HASH}</a>`;
document.getElementById('hash').style.color = 'green';
}
});
</script>
</body>
</html>