// All runtime config comes from env (Coolify sets these). Read once. // ViralAdSource (viraladsource.com rebuild, Marty approved 2026-11-16: "that looks good. Let's go with it."). "Every ad has a source. // Watch yours travel." A network member posts one free text ad; anyone reshares it with their own unique reshare link; every // reshare is a branch of the ad's family tree. Rewards are for verified RESULTS only, never a bare share: // L1 a Boost bought through a branch: the resharer's cut is paid by VASShop in the same transaction (server-signed order). // L2 a verified brand-new network member through a branch: a small POL reward from the contract's reward pot, after real-time // checks (hub-new, confirmed email, not the resharer's device/IP/wallet, no throwaway email, daily cap, fraud score). // PAYOUTS ARE OFF (REWARD_PAYOUTS=1 turns the relay on) until Marty confirms the amounts. // L3 verified views through a branch: ad credits for the resharer, spent on their own ad. Ad credits buy advertising, not income. // Launch numbers APPROVED by Marty 2026-11-17: Boost $5 = a 7-day board spot; resharer 20%, pot 10%, 5 sponsor levels x 10% // (company 20%), split immutable on chain; $0.25 POL new-member reward, 10 a day per person; 10 ad credits per 100 verified views. // Members earn for free: a Boost buys placement only. Level shares and the resharer cut need a network sign-in + a linked wallet. // Still a proposal: the $25/day global pot cap figure and the reward tiers. 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, n)) : d; }; const int = (v, d, min, max) => Math.round(num(v, d, min, max)); const addr = v => /^0x[0-9a-fA-F]{40}$/.test(String(v || '').trim()) ? require('ethers').getAddress(String(v).trim().toLowerCase()) : ''; let tiers = []; try { tiers = JSON.parse(e.REWARD_TIERS || '[]'); } catch (x) { tiers = []; } if (!Array.isArray(tiers) || !tiers.length) tiers = [{ every: 25, cents: 250, lockDays: 14 }]; // PROPOSAL (not yet approved): each 25th verified sign-up from one resharer = a $2.50 bonus, withdrawable after 14 days cfg = { port: Number(e.PORT || 3000), isProd: e.NODE_ENV === 'production', site: e.SITE_HOST || 'viraladsource.com', siteName: 'ViralAdSource', siteId: 'viraladsource', // hub site id, network sign-in audience, netsites id staging: e.STAGING === '1', // staging only: the admin "mark test member" switch, no ad zones 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 ($5, approved). The contract's SKU holds the real price and board days; this is display copy and must match it. // A Boost puts the ad at the top of the reshare board for `days` days per unit. One-time, never a subscription. boost: { sku: int(e.BOOST_SKU, 1, 1, 1000), usd: num(e.BOOST_USD, 5, 0.01, 1000), days: int(e.BOOST_DAYS, 7, 1, 365), maxQty: 10 }, // VASShop split (approved 2026-11-17; IMMUTABLE on the contract, read live from it when the contract is set): basis points split: { resharerBps: int(e.SPLIT_RESHARER_BPS, 2000, 0, 9000), potBps: int(e.SPLIT_POT_BPS, 1000, 0, 9000), levelBps: String(e.SPLIT_LEVEL_BPS || '1000,1000,1000,1000,1000').split(',').map(x => int(x, 0, 0, 9000)).slice(0, 5), maxDepth: 20 }, // ---- L2 new-member rewards ($0.25 in POL, 10 a day per resharer, approved). Payouts OFF unless REWARD_PAYOUTS=1. // potDailyCents = the contract's global pot cap across everyone (display; the contract enforces it). PROPOSAL $25/day. reward: { cents: int(e.REWARD_CENTS, 25, 1, 10000), dailyCap: int(e.REWARD_DAILY_CAP, 10, 0, 1000), tiers, payouts: e.REWARD_PAYOUTS === '1', fraudHold: int(e.FRAUD_HOLD, 50, 1, 100), voucherDays: int(e.REWARD_VOUCHER_DAYS, 30, 1, 365), joinWindowHours: int(e.JOIN_WINDOW_HOURS, 72, 1, 720), potDailyCents: int(e.POT_DAILY_CENTS, 2500, 1, 100000) }, hubJoin: e.HUB_JOIN === '1', // a confirmed sign-up is written to the hub (join-all). OFF on staging: a dry check instead mail: { from: String(e.MAIL_FROM || 'ViralAdSource '), url: String(e.MAIL_URL || '').trim() }, // MAIL_URL unset = no mail sent (staging) // ---- L3 ad credits (approved: 10 credits per 100 verified views through a branch; 1 credit = 1 verified view of your own ad) credits: { per: int(e.CREDITS_PER, 10, 1, 1000), views: int(e.CREDITS_VIEWS, 100, 1, 100000), slots: int(e.CREDIT_SLOTS, 2, 0, 10) }, // verified visitors (the VBB / ViralAdBlitz rules) visitSeconds: int(e.VISIT_SECONDS, 6, 2, 60), visitWindowHours: 24, perIpDay: int(e.VISITS_PER_IP_DAY, 3, 1, 100), boardSize: int(e.BOARD_SIZE, 12, 3, 50), viaDays: int(e.VIA_DAYS, 30, 1, 365), // how long a reshare link's tag stays on a visitor (last touch) maxStep: int(e.MAX_STEP, 50, 2, 500), // the deepest reshare step kept ad: { headline: 60, line: 90 }, linkProbe: e.LINK_PROBE !== '0', explorer: String(e.EXPLORER || (Number(e.CHAIN_ID || 137) === 137 ? 'https://polygonscan.com' : '')).replace(/\/+$/, ''), // VASShop (../contracts). KEEPER_KEY / RELAY_KEY are read by shop.js only, never kept here. contractAddress: addr(e.CONTRACT_ADDRESS), companyWallet: addr(e.COMPANY_WALLET) || '0x7627Fc78876948AC9d95C1C9eB061E7D6d647b70', // Tangem (immutable in VASShop) chainRpc: String(e.CHAIN_RPC || '').trim(), shopStartBlock: int(e.SHOP_START_BLOCK, 0, 0, 1e12), shopConfirmations: int(e.SHOP_CONFIRMATIONS, 10, 0, 1000), shopPollMs: int(e.SHOP_POLL_MS, 30000, 200, 3600000), voucherSeconds: int(e.VOUCHER_SECONDS, 1800, 60, 86400), iapBase: String(e.IAP_URL || 'https://instantadpay.com').replace(/\/+$/, ''), lsBase: String(e.LS_URL || 'https://linkspin.app').replace(/\/+$/, ''), joinUrl: String(e.JOIN_URL || 'https://instantadpay.com/join/{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; } };