Files
viraladblitz/config.js
T
Marty Bostick 001878bdae ViralAdBlitz v1 (viraladblitz.com rebuild, Marty approved 2026-11-14): the network's text-ad home, local build, not deployed
- Free text ad for network members (InstantAdPay / LinkSpin sign-in or wallet, membership through the hub), one per member
- Member pages viraladblitz.com/<username>: own ad + the first 5 people above in the hub line with a live ad (by place) + 2 Boosted places
- Front page: amber ticker (Boosted starred), Top ads this week by verified clicks, today's numbers, ledger, contract proof
- Verified visitors / views / clicks (ticket + dwell + per-visitor dedupe + per-connection cap + bot filter, owner excluded)
- Boost $5 = 500 guaranteed views through VABShop: keeper-signed EIP-712 line voucher from the hub line, watcher, delivery
  counted per verified view with an audit row each, Network Ad Space text-ad finishing after 30 days (vabnas.js)
- Trust pack: /ledger, /contract, toasts, Telegram card per Boost (once), Terms / Earnings Disclaimer / Privacy (TrustClickz),
  network footer from the hub with tracked links, promo kit (21 creatives) + /promote, LinkSpin zone placeholders, hub report
- Old YFW links via the oldrefs map (admin load route); docstore MySQL documents + row tables
- qa/smoke.mjs 162/162 (stand-in hub, chain, Telegram, NAS; Playwright desktop + phone), qa/chain.mjs 20/20 (real VABShop on anvil)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 13:52:03 -06:00

64 lines
4.6 KiB
JavaScript

// All runtime config comes from env (Coolify sets these). Read once.
// ViralAdBlitz (viraladblitz.com rebuild, Marty approved 2026-11-14): the network's text-ad home. Members post one free text ad;
// each member's page shows their ad plus the ads of the 5 people above them in their network (hub) sponsor line. A Boost ($5,
// one-time, 500 guaranteed network views) is paid in POL through VABShop and split on-chain 10% to each of 5 sponsor levels
// (pass-up to the next person who has boosted) + 50% company. Purchases are inert until CONTRACT_ADDRESS / CHAIN_RPC / KEEPER_KEY are set.
const path = require('path');
let cfg = null;
function get() {
if (cfg) return cfg;
const e = process.env;
const num = (v, d, min, max) => { const n = Number(v); return Number.isFinite(n) && v !== '' && v != null ? Math.min(max, Math.max(min, Math.round(n))) : d; };
const addr = v => /^0x[0-9a-fA-F]{40}$/.test(String(v || '').trim()) ? require('ethers').getAddress(String(v).trim().toLowerCase()) : '';
cfg = {
port: Number(e.PORT || 3000),
isProd: e.NODE_ENV === 'production',
site: e.SITE_HOST || 'viraladblitz.com',
siteName: 'ViralAdBlitz',
siteId: 'viraladblitz', // hub site id, network sign-in audience, netsites id
dataDir: e.DATA_DIR || path.join(__dirname, 'data'),
chainId: Number(e.CHAIN_ID || 137),
chainName: e.CHAIN_NAME || 'Polygon',
publicRpc: e.PUBLIC_RPC || 'https://polygon-bor-rpc.publicnode.com',
walletConnectProjectId: (e.WALLETCONNECT_PROJECT_ID || '').trim(),
// ---- Boost (Marty 2026-11-14: "$5 for 500 guaranteed network views"). The contract's SKU holds the real price; this is the
// display copy and must match it (smoke + chain tests check). One-time, never a subscription.
boost: { sku: num(e.BOOST_SKU, 1, 1, 1000), usd: Number(e.BOOST_USD || 5), views: num(e.BOOST_VIEWS, 500, 1, 1e6), maxQty: 10 },
split: { levels: 5, levelPct: 10, companyPct: 50, maxDepth: 20 }, // VABShop constants (display copy)
deliverDays: num(e.BOOST_DELIVER_DAYS, 30, 1, 365), // on-site delivery window; then Network Ad Space finishes the rest
// the pages
levels: 5, // upline ads on a member's page
lineSearch: num(e.LINE_SEARCH, 20, 5, 50), // hub places walked to find 5 uplines with a live ad
boostSlots: num(e.BOOST_SLOTS, 2, 0, 10), // Boosted places on a member page (the "extra place on the five-level pages")
tickerBoosts: num(e.TICKER_BOOSTS, 12, 0, 50), // starred Boosted ads in the ticker
tickerNewest: num(e.TICKER_NEWEST, 16, 0, 100), // newest ads in the ticker
boardSize: num(e.BOARD_SIZE, 9, 3, 50), // "Top ads this week"
// verified visitors (the VBB rules)
visitSeconds: num(e.VISIT_SECONDS, 6, 2, 60), // page visible this long before views count
visitWindowHours: 24, // one verified view per visitor per ad (and one visit per page) per 24 h
perIpDay: num(e.VISITS_PER_IP_DAY, 3, 1, 100), // distinct browsers counted per connection per 24 h
// text ads
ad: { headline: 60, line: 90 }, // characters
linkProbe: e.LINK_PROBE !== '0', // check the link answers (off in the local smoke test)
explorer: String(e.EXPLORER || (Number(e.CHAIN_ID || 137) === 137 ? 'https://polygonscan.com' : '')).replace(/\/+$/, ''),
// VABShop (../contracts). KEEPER_KEY is read by shop.js only, never kept here.
contractAddress: addr(e.CONTRACT_ADDRESS),
companyWallet: addr(e.COMPANY_WALLET) || '0x7627Fc78876948AC9d95C1C9eB061E7D6d647b70', // Tangem (immutable in VABShop)
chainRpc: String(e.CHAIN_RPC || '').trim(),
shopStartBlock: num(e.SHOP_START_BLOCK, 0, 0, 1e12),
shopConfirmations: num(e.SHOP_CONFIRMATIONS, 10, 0, 1000),
shopPollMs: num(e.SHOP_POLL_MS, 30000, 200, 3600000),
voucherSeconds: num(e.VOUCHER_SECONDS, 1800, 60, 86400),
iapBase: String(e.IAP_URL || 'https://instantadpay.com').replace(/\/+$/, ''),
lsBase: String(e.LS_URL || 'https://linkspin.app').replace(/\/+$/, ''),
// where someone who is not in the network yet joins free under the page owner ({ref} = the owner's network username)
joinUrl: String(e.JOIN_URL || 'https://instantadpay.com/?ref={ref}'),
networkLookupUrl: e.NETWORK_LOOKUP_URL !== undefined ? String(e.NETWORK_LOOKUP_URL).trim()
: String(e.IAP_URL || 'https://instantadpay.com').replace(/\/+$/, '') + '/api/network/member'
};
return cfg;
}
module.exports = { get, reset: () => { cfg = null; } };