-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
173 lines (158 loc) · 7.01 KB
/
index.html
File metadata and controls
173 lines (158 loc) · 7.01 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Tatum Hackathon Demo: Simple On-Chain Wallet Tracker</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
body {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
font-family: 'Inter', sans-serif;
min-height: 100vh;
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 2rem;
background: rgba(255, 255, 255, 0.95);
border-radius: 12px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}
.hero-image img {
width: 100%;
height: auto;
border-radius: 8px;
margin-bottom: 1rem;
}
.btn {
background: linear-gradient(45deg, #ff6b35, #f7931e);
color: white;
padding: 0.75rem 1.5rem;
border-radius: 8px;
font-weight: 600;
transition: transform 0.3s;
}
.btn:hover {
transform: scale(1.05);
}
.balance-card {
background: #f8f9fa;
padding: 1.5rem;
border-radius: 8px;
margin-top: 1rem;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.error-msg {
color: #dc3545;
font-size: 0.9rem;
}
@media (max-width: 768px) {
.container {
padding: 1rem;
}
.hero-image img {
height: 200px;
object-fit: cover;
}
}
</style>
</head>
<body>
<div class="container">
<header class="text-center mb-8">
<div class="hero-image mb-6">
<img src="https://storage.googleapis.com/workspace-0f70711f-8b4e-4d94-86f1-2a93ccde5887/image/cd5212ff-166d-4457-a8e2-b5f204d73724.png" alt="Blockchain dashboard" />
</div>
<h1 class="text-4xl font-bold text-gray-800 mb-2">Tatum Hackathon Demo</h1>
<p class="text-xl text-gray-600">Simple On-Chain Wallet Tracker using Tatum APIs</p>
<p class="text-sm text-gray-500 mt-2">This app checks wallet balances on supported chains (e.g., Bitcoin, Ethereum). Built with HTML, CSS, JS, and Tatum API integration for the hackathon.</p>
</header>
<section id="wallet-form" class="mb-8">
<h2 class="text-2xl font-semibold mb-4">Enter Wallet Details</h2>
<div class="flex flex-col md:flex-row gap-4">
<select id="chain-select" class="p-3 border rounded-lg flex-1">
<option value="bitcoin-mainnet">Bitcoin (Mainnet)</option>
<option value="ethereum-mainnet">Ethereum (Mainnet)</option>
<option value="polygon-mainnet">Polygon (Mainnet)</option>
</select>
<input type="text" id="wallet-address" placeholder="Enter wallet address" class="p-3 border rounded-lg flex-1" required />
<button id="check-balance" class="btn flex-shrink-0">Check Balance</button>
</div>
<p class="text-xs text-gray-400 mt-2">Note: This app now uses your mainnet API key for live functionality.</p>
</section>
<section id="balance-result" class="balance-card hidden">
<h3 class="text-xl font-semibold mb-4">Wallet Balance</h3>
<div id="balance-info">
<p><strong>Address:</strong> <span id="address-display"></span></p>
<p><strong>Chain:</strong> <span id="chain-display"></span></p>
<p><strong>Balance:</strong> <span id="balance-amount">Loading...</span></p>
</div>
<div id="error-message" class="error-msg mt-4 hidden"></div>
</section>
<footer class="mt-8 text-center text-gray-600">
<p>Get your free Tatum API key from <a href="https://dashboard.tatum.io" class="text-blue-500 underline" target="_blank">dashboard.tatum.io</a></p>
<p>Join the <a href="https://discord.gg/tatum" class="text-purple-500 underline" target="_blank">Discord</a> for support.</p>
</footer>
</div>
<script>
const apiKey = 't-68bbc8b2df17eb0844ef69a8-7421ff274a3a4a3884990a06'; // <-- Your Tatum mainnet API key
const checkBalanceBtn = document.getElementById('check-balance');
const balanceResult = document.getElementById('balance-result');
const errorMsg = document.getElementById('error-message');
const addressDisplay = document.getElementById('address-display');
const chainDisplay = document.getElementById('chain-display');
const balanceAmount = document.getElementById('balance-amount');
const walletAddress = document.getElementById('wallet-address');
const chainSelect = document.getElementById('chain-select');
checkBalanceBtn.addEventListener('click', async () => {
const address = walletAddress.value.trim();
const chain = chainSelect.value;
if (!address) {
showError('Please enter a valid wallet address.');
return;
}
balanceResult.classList.add('hidden');
errorMsg.classList.add('hidden');
try {
balanceAmount.textContent = 'Loading...';
let balanceUrl = '';
if (chain === 'bitcoin-mainnet') {
balanceUrl = `https://api.tatum.io/v3/bitcoin/address/balance/${address}`;
} else if (chain === 'ethereum-mainnet') {
balanceUrl = `https://api.tatum.io/v3/ethereum/address/balance/${address}`;
} else if (chain === 'polygon-mainnet') {
balanceUrl = `https://api.tatum.io/v3/polygon/address/balance/${address}`;
} else {
showError('Unsupported chain selected.');
return;
}
const response = await fetch(balanceUrl, {
method: 'GET',
headers: {
'x-api-key': apiKey
}
});
if (!response.ok) {
throw new Error('Failed to fetch balance. Check address and try again.');
}
const data = await response.json();
const balance = data.balance ? `${data.balance} Wei/Satoshis` : '0';
addressDisplay.textContent = address;
chainDisplay.textContent = chain;
balanceAmount.textContent = balance;
balanceResult.classList.remove('hidden');
} catch (error) {
showError(error.message);
}
});
function showError(message) {
errorMsg.textContent = message;
errorMsg.classList.remove('hidden');
balanceResult.classList.add('hidden');
}
</script>
</body>
</html>
</content>
</create_file>