// Contract proof page (trust pack): live facts from /api/contract (read from Polygon, cached 5 minutes on the server).
(async function () {
VAB.renderNav('/contract'); VAB.renderFooter(); VAB.wire('other').catch(() => {});
const el = document.getElementById('facts'); const esc = VAB.esc;
let d; try { d = await VAB.getJSON('/api/contract'); } catch (e) { d = {}; }
const ex = d.explorer || 'https://polygonscan.com';
const addr = (a, note) => a ? '' + esc(a) + '' + (note ? '
' + note + '' : '') : 'not read yet';
if (!d.address) { el.innerHTML = '
| The contract is not live yet. Its address, owner and every Boost will show here, read straight from Polygon. |
'; return; }
const rows = [
['Contract', addr(d.address, 'VABShop on ' + (d.chainId === 137 ? 'Polygon' : 'chain ' + d.chainId))],
['Source code', 'Verified source on Polygonscan and Sourcify: ' + esc(d.verified && d.verified.polygonscan === 'pending' ? 'pending' : 'done')],
['Owner', addr(d.owner, 'A Tangem hardware wallet. It can pause new sales, set the Boost price for future sales and change the keeper. It cannot move anyone\'s money or change the split.')],
['Company', addr(d.company, 'ViralAdBlitz. Fixed in the contract when it was deployed.')],
['Keeper', addr(d.keeper, 'The site\'s signing key. It only signs a buyer\'s sponsor line from the network hub, once, on their first Boost.')],
['Boost', '$' + esc(d.boost && d.boost.usd) + ' for ' + VAB.n(d.boost && d.boost.views) + ' guaranteed views, paid in POL at the live Chainlink price'],
['Sales', d.live ? (d.paused ? 'Paused' : 'Open') + ' ยท ' + VAB.n(d.orderCount) + ' orders so far' : '' + esc(d.error || 'not read yet') + ''],
['Held by the contract', d.live ? VAB.polOf(d.balanceWei) + ' POL' + (BigInt(d.totalOwedWei || 0) > 0n ? ' (all of it owed to wallets whose payment bounced, waiting for them to claim)' : ' (nothing is kept: every Boost is paid out in the same transaction)') : 'not read yet']
];
el.innerHTML = '' + rows.map(r => '| ' + r[0] + ' | ' + r[1] + ' |
').join('') + '';
})();