Files
linkspin/public/assets/contract.js
T

19 lines
1.1 KiB
JavaScript

// Contract page: live address, chain, explorer + verified-source links, the chain totals. No shared nav (2026-10-07).
(async function () {
const $ = id => document.getElementById(id);
let c = {}; try { c = await (await fetch('/api/config')).json(); } catch (e) {}
const addr = String(c.contract || '');
$('cAddr').textContent = addr || 'not deployed yet';
$('cChain').textContent = c.chainName || '';
const src = 'https://repo.sourcify.dev/contracts/full_match/' + (c.chainId || 137) + '/' + addr + '/';
$('lnkExplorer').href = c.explorer ? c.explorer + '/address/' + addr + '#code' : src;
$('lnkSource').href = src; $('lnkSource2').href = src;
try {
const s = await (await fetch('/api/stats')).json();
$('stMembers').textContent = Number(s.onchainMembers || 0).toLocaleString();
$('stPackages').textContent = Number(s.purchases || 0).toLocaleString();
const pol = Number(BigInt(String(s.payoutWei || s.paidInWei || '0')) / 10000000000000000n) / 100;
$('stPol').textContent = pol.toLocaleString(undefined, { maximumFractionDigits: 2 });
} catch (e) {}
})();