-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoken-details.js
26 lines (21 loc) · 1023 Bytes
/
token-details.js
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
async function fetchTokenDetails() {
try {
let response = await fetch('https://tn10api.kasplex.org/v1/krc20/tokenlist');
let data = await response.json();
// Log the full response to see its structure
console.log(data);
let token = data.result.find(t => t.tick.toLowerCase() === 'kasx');
console.log(token); // Log the token details
if (token) {
const minted = parseInt(token.minted, 10);
const supply = parseInt(token.supply, 10);
const percentageMinted = ((minted / supply) * 100).toFixed(2);
document.getElementById('token-percentage-minted').textContent = `Minted: ${percentageMinted}%`;
} else {
document.getElementById('token-percentage-minted').textContent = 'Token Not Found';
}
} catch (error) {
console.error('Error fetching token details:', error);
document.getElementById('token-percentage-minted').textContent = 'Error loading percentage.';
}
}