-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
55 lines (50 loc) · 2.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PEERCOIN</title>
<!-- Link to Bootstrap CSS (you can download it or use a CDN) -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.min.css">
</head>
<body>
<div class="container mt-5">
<h1>PEERCOIN</h1>
<form id="transactionForm">
<div class="form-group">
<label for="accountToAddress">Recipient's Ethereum Address:</label>
<input type="text" class="form-control" id="accountToAddress" required>
</div>
<div class="form-group">
<label for="amountTo">Amount to Send (Ether):</label>
<input type="number" step="0.01" class="form-control" id="amountTo" required>
</div>
<button type="submit" class="btn btn-primary">Send Transaction</button>
</form>
<div id="transactionResult" class="mt-3"></div>
</div>
<!-- Link to Bootstrap JS and jQuery (required for Bootstrap) -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap/dist/js/bootstrap.min.js"></script>
<script>
document.getElementById('transactionForm').addEventListener('submit', async function (e) {
e.preventDefault();
const accountToAddress = document.getElementById('accountToAddress').value;
const amountTo = document.getElementById('amountTo').value;
const response = await fetch('/send-transaction', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ accountToAddress, amountTo }),
});
if (response.ok) {
const result = await response.json();
document.getElementById('transactionResult').innerHTML = `Transaction sent: ${result.transactionHash}`;
} else {
document.getElementById('transactionResult').innerHTML = 'Transaction failed';
}
});
</script>
</body>
</html>