document.addEventListener('DOMContentLoaded', function () {
async function fetchStats() {
try {
const response = await fetch("https://lillycoin.net/api/stats");
const data = await response.json();
if (data) {
const statsContainer = document.getElementById("stats-container");
const logContainer = document.getElementById("transaction-log");
// Update stats
statsContainer.innerHTML = `
Total Sold: ${data.total_sold} LYL
Total Remaining: ${data.total_remaining} LYL
Total Transactions: ${data.total_transactions}
Transactions in Last 24 Hours: ${data.transactions_today}
`;
// Build transaction log
if (data.transactions && data.transactions.length > 0) {
logContainer.innerHTML = "Recent Transactions:
";
data.transactions.forEach(tx => {
const txAmount = parseFloat(tx.amount).toFixed(2);
const txHash = tx.tx_hash || "";
const wallet = tx.wallet_address;
// Optional: Add hyperlink to view on XRP Ledger explorer
const explorerLink = txHash
? `View`
: "";
logContainer.innerHTML += `
- ${txAmount} XRP → ${txAmount / 0.05} LYL | Wallet: ${wallet} ${explorerLink}
`;
});
} else {
logContainer.innerHTML = "No recent transactions.";
}
}
} catch (error) {
console.error("Error fetching stats:", error);
}
}
fetchStats();
setInterval(fetchStats, 30000);
});