5xYourTeam The Draft v1 (phase 1, local only): weekly earned-order draft of holding-tank people, picks as adoptions (stub tank), coaching tools, cards, boards, trust pack

$10 one-time DraftPosition purchases (sponsor 25%, L2-5 5%, 10% Best Coach pot, 45% company) with keeper-signed hub-line
vouchers; pure draft engine with a mocked clock; no contact data anywhere; Telegram to an outbox unless TG_LIVE=1.
Unit 60/60, smoke 156/156 (Playwright 1280/390). Not deployed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-15 06:16:10 -06:00
commit f26ac15712
110 changed files with 6177 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
.git
node_modules
data
qa/out
.env
+36
View File
@@ -0,0 +1,36 @@
# 5xYourTeam (phase 2 values; nothing here is set yet). Never commit real secrets.
PORT=3000
NODE_ENV=production
SITE_HOST=5xyourteam.com
DOCSTORE_URL=mysql://user:pass@host:3306/fivex # REQUIRED in production (never launch on files); set binlog expiry to hours
ADMIN_TOKEN=
SESSION_SECRET=
NETWORK_SSO_SECRET= # same 64-hex value as InstantAdPay / LinkSpin
HUB_ENABLED=1
HUB_URL=https://hub.saasy.top
HUB_SECRET= # hub HUB_SITES entry 'fivex' (not added yet)
HUB_SITE=fivex
NETWORK_SITE_ID=fivex
# DraftPosition (../contracts), after Marty's go
CONTRACT_ADDRESS=
SHOP_START_BLOCK=
PRIZE_WALLET= # the Best Coach pot wallet passed to the constructor
CHAIN_RPC=
KEEPER_KEY= # the voucher key; its address = the contract's keeper
WALLETCONNECT_PROJECT_ID=
# the holding tank: stub (phase 1 fixture) | hub (phase 2, not wired)
TANK_MODE=stub
# the draft (Central time); every value here is an open question for Marty
DRAFT_DOW=1
DRAFT_HOUR_CT=19
DRAFT_ROUNDS=5
DRAFT_PICK_SECONDS=90
PICK_RETURN_DAYS=3
PICK_MAX_OPEN=10
POT_SPLIT=50,30,20
# Telegram: nothing is sent unless TG_LIVE=1 (phase 1 writes tg-outbox.json)
TG_LIVE=
TG_TOKEN=
TG_CHAT=-1001258691510
TG_PAY_TOPIC=632242
OWNER_USERNAME=martbost
+7
View File
@@ -0,0 +1,7 @@
node_modules/
data/
*.log
qa/out/data-*
qa/out/server.log
qa/out/view/
.env
+12
View File
@@ -0,0 +1,12 @@
FROM node:22-alpine
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --omit=dev --no-audit --no-fund
COPY . .
RUN mkdir -p /app/data
ENV NODE_ENV=production
ENV PORT=3000
EXPOSE 3000
# a container that cannot boot is never swapped in (2026-10-08 rule)
HEALTHCHECK --interval=15s --timeout=5s --start-period=20s --retries=4 CMD wget -qO- http://127.0.0.1:3000/health >/dev/null || exit 1
CMD ["node","server.js"]
+70
View File
@@ -0,0 +1,70 @@
# 5xYourTeam app: The Draft (5xyourteam.com rebuild)
Phase 1, LOCAL ONLY (Marty 2026-11-15). Nothing here is deployed; no contract is on chain; the holding tank is a local stub
that adopts nobody and sends no mail; Telegram posts go to an outbox. Plain Node http server, no framework (the ViralAdBlitz /
DownlineHydra pattern). Contract: `../contracts` (DraftPosition).
## What it does
- **A position**: $10 one-time in POL (never a subscription). It gives 5 instant picks from the current pool and a spot in every
weekly draft. Paid through DraftPosition: sponsor 25%, levels 2-5 5% each (pass-up over people with no position, 20 places),
10% to the Best Coach prize pot wallet, 45% company. The server builds the `buy()` call with a keeper-signed EIP-712 line
voucher from the hub line (shop.js, the VABShop pattern); the watcher records each `Purchase` once and adds the instant picks.
- **The draft** (draft.js, pure and unit-tested with a mocked clock; league.js wires it): every Monday 7 PM Central (env), 5 rounds,
straight order. Draft order is EARNED: most of last week's picks started (payouts on or a first purchase), then started ever,
then the earlier position, then a fixed shuffle of (week, coach). A coach in the draft room (the board pinged within 2 minutes)
gets a 90-second clock; an away coach is auto-picked at once from their own queue, else the best available by scouting score.
A coach with 10 open picks is skipped for that slot. A draft missed by more than 6 hours (app down) is skipped, never run late.
- **Picks are adoptions** (tankpool.js): every pick goes through `tank.adopt()` first. The pool never has anyone locked on a
network contract, already sponsored, adopted twice (every pick counts, plus the network's count), spam/throwaway, or inside the
24-hour sign-up grace. An unconverted pick returns to the pool after 3 days, unless that person has now had 2 adoptions (then
they stay with the coach). A started pick stays. A coach cannot release a pick in its first 48 hours.
- **Coaching tools** (`/team`): stat tiles (on my team, started this week, next draft spot, back to pool soon), the focused pick
card (scouting stats, the 5 getting-started steps, one-tap messages, the composer and thread, release), the rest of the team,
who to help first (back to pool soon, one step from payouts, quiet), the draft queue. Someone who is a pick sees their coach,
the steps and the thread, and the coach's builder links. Messages go through the site only. No email, phone or any contact
data is ever shown, stored from sign-in, or exported (smoke-tested).
- **Scouting stats** on draft cards: last seen, the door they came from, wallet linked, game plays and title, POL earned in
games and surfing where the network tracks it ("not tracked yet" otherwise, never invented). Earnings show to coaches only.
- **Cards**: trading cards Rookie (drafted), Starter (wallet), Pro (payouts on), All-Star (first purchase), Hall of Fame (holds a
position of their own). Public cards show milestones, never earnings. Coach page `5xyourteam.com/<username>`.
- **Boards**: Best Coach (picks started inside the Central week; tie = got there first), the week's pot (10% of positions sold
that week, from the Purchase events), Rookie of the Week (the pick that climbed highest that week), last week's top 3.
- **Builder** (`/builder`, wild.js from DownlineHydra, the CryptoTeamBuild builder programs seeded from
`data-seed/programs.seed.json`): coaches save referral IDs; their picks see the coach's link for each program.
- **Trust pack** (proof.js): `/ledger` (every share with its place in the line, passed over, pot, company; Best Coach payouts
with tx), `/contract` (live facts incl. the prize wallet), toasts (positions, picks, level-ups), Telegram sale card (rotated
proof images), Draft Day card (`/draftday/<monday>` 1080x1080, PNG via `tools/art.mjs --draftday`), a line per pot payout;
Terms / Earnings Disclaimer / Privacy naming TrustClickz, 615 Green Valley Drive, Moody, AL 35004; the network footer from the
hub (netsites.js, 5xYourTeam added locally as `fivex`, LinkSpin code `nw5x`).
- **Promo kit** (`/promote`, `/api/promo-kit?u=`): 21 creatives `public/art/kit/fx-{draft,coach,cards}-{shape}.png`, swipe copy.
- **Old links**: `/?<old>`, `/splashpg.php?r=`, `/lcp.php?r=`, `/index.php?r=` 301 to the coach page via the old-ref map
(`POST /api/admin/oldrefs`), `/members/*` to `/team`, any other `*.php` to `/`.
- **Admin** (`/admin`, `ADMIN_TOKEN`): status, run a tick, the week's pot shares, record a pot payout (`POST /api/admin/pot/paid`),
old-link map. Test-only: `POST /api/admin/clock` (needs `ALLOW_TEST_CLOCK=1`, refused in production), `POST /api/admin/stub/status`.
- **Data**: docstore.js (MySQL via `DOCSTORE_URL`, the LinkSpin copy that skips unchanged writes): document `fivex.json` + row
tables `fx_picks`, `fx_msgs`, `fx_refids`; `hubreport.json`, `oldrefs.json`, `tg-outbox.json`, `stub-tank.json` are documents.
## Look
The approved draft-night mockup (2026-11-14): stadium navy #0b1530 / bar #07102a, gold #ffc93c rule and accents, red #ff4d4d
week tag, white scouting cards with navy heads, Oswald + Inter. One stylesheet `public/assets/fx.css`.
Deviation from the mockup on purpose: the mockup's coach card showed an email line; it is gone (no contact data, Marty's rule).
## Run and test
```
npm ci
node server.js # prototype mode (files, stub tank); never launch this way
node qa/unit.test.cjs # 60 checks: tiers, tank rules, earned order, the clocked draft, returns, boards, the split model
# against the fork rehearsal (to the wei), Central weeks, the league end to end
node qa/smoke.mjs # 156 checks against stand-in hub / chain / Telegram (ports 3561-3564) + Playwright 1280/390
UI_FONTS=1 node qa/smoke.mjs # same, Google Fonts allowed so qa/out screenshots show the real type
node tools/pages.mjs # regenerate public/*.html (one source of copy + legal facts)
node tools/art.mjs # icon, OG, proof cards, kit, tier cards; --draftday <base> <monday> for a Draft Day PNG
```
## Phase 2 (needs Marty's go): see the open questions in the build report
Hub `HUB_SITES` entry `fivex` + secret; `tankpool.js` hub mode (pool read, adopt through the tank, status); the network-sites list
and LinkSpin `nw5x`; the contract on chain with the prize wallet; DOCSTORE_URL; old-member reconciliation; PolHunter mission.
+71
View File
@@ -0,0 +1,71 @@
// All runtime config comes from env (Coolify sets these in phase 2). Read once.
// 5xYourTeam "The Draft" (Marty approved 2026-11-14): a $10 one-time position = 5 picks right away + a draft spot every week. Each
// Monday the coaches draft people waiting in the network holding tank, in rounds; draft order is EARNED by how many of last week's
// picks switched on payouts or bought. A pick is an ADOPTION under the tank rules (tankpool.js). Paid in POL through DraftPosition
// (../contracts): sponsor 25%, levels 2-5 5% each (pass-up), 10% weekly Best Coach prize pot, 45% 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 || '5xyourteam.com',
siteName: '5xYourTeam',
siteId: 'fivex', // 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(),
// ---- the position (Marty 2026-11-14: "$10 on 5x your team makes sense"). One-time, never a subscription. The contract's
// priceCents holds the real price; this is display copy and must match it (smoke + chain tests check).
position: { usd: Number(e.POSITION_USD || 10), maxQty: 10, picksOnBuy: num(e.PICKS_ON_BUY, 5, 1, 20) },
// DraftPosition constants (display copy): option C
split: { sponsorPct: 25, levelPct: 5, levels: 5, potPct: 10, companyPct: 45, maxDepth: 20 },
// ---- the weekly draft (US Central). Every number here is an open question for Marty; these are the build's defaults.
draft: {
dow: num(e.DRAFT_DOW, 1, 0, 6), // 1 = Monday
hour: num(e.DRAFT_HOUR_CT, 19, 0, 23), // 7 PM Central
rounds: num(e.DRAFT_ROUNDS, 5, 1, 20), // "draft 5 people from that week's pool"
pickSeconds: num(e.DRAFT_PICK_SECONDS, 90, 5, 3600), // the clock for a coach who is in the draft room
presenceSeconds: num(e.DRAFT_PRESENCE_SECONDS, 120, 10, 3600), // "in the room" = the board page pinged within this long
tickMs: num(e.DRAFT_TICK_MS, 5000, 100, 600000),
lateHours: num(e.DRAFT_LATE_HOURS, 6, 0, 72) // a draft missed by more than this (app down) is skipped
},
picks: {
returnDays: num(e.PICK_RETURN_DAYS, 3, 1, 30), // an unconverted pick goes back to the pool after this
holdHours: num(e.PICK_HOLD_HOURS, 48, 0, 720), // a coach cannot release a pick sooner (the IAP churn rule)
maxOpen: num(e.PICK_MAX_OPEN, 10, 1, 100), // open picks per coach (Marty 11-13: "10 at a time")
maxAdoptions: 2, // per person, lifetime, across the network (tank rule)
graceHours: num(e.PICK_GRACE_HOURS, 24, 0, 168) // a new sign-up is not draftable for this long (IAP GRACE_MS)
},
pot: { split: String(e.POT_SPLIT || '50,30,20').split(',').map(Number).filter(n => n > 0) }, // Best Coach places, % of the week's pot
explorer: String(e.EXPLORER || (Number(e.CHAIN_ID || 137) === 137 ? 'https://polygonscan.com' : '')).replace(/\/+$/, ''),
// DraftPosition (../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 the contract)
prizeWallet: addr(e.PRIZE_WALLET), // the Best Coach pot (immutable in the contract; decided at deploy)
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(/\/+$/, ''),
joinUrl: String(e.JOIN_URL || 'https://instantadpay.com/join/{ref}'),
// the holding tank behind the draft: 'stub' (phase 1, local fixture, adopts nobody for real) | 'hub' (phase 2)
tankMode: /^hub$/i.test(String(e.TANK_MODE || '')) ? 'hub' : 'stub',
stubPool: String(e.STUB_POOL_FILE || '').trim(),
owner: String(e.OWNER_USERNAME || 'martbost'), // builder fallback links (the DownlineHydra rule)
testClock: e.ALLOW_TEST_CLOCK === '1' && e.NODE_ENV !== 'production'
};
return cfg;
}
module.exports = { get, reset: () => { cfg = null; } };
+789
View File
@@ -0,0 +1,789 @@
{
"source": "CryptoTeamBuild downline builder, read-only list (yfw-builder.py list rhi cryptoteambuild cryptoteambuild.com) 2026-11-14 6:45 PM CT",
"rules": "hidden+network = a core or growing head or another network site: never shown as a wild head (admin can change). ctbMemberLinks is the count on cryptoteambuild.com, for reference only; never shown as a DownlineHydra joined count.",
"cats": [
{
"id": "6",
"name": "Ads Earn Network",
"short": "Ads Earn Network"
},
{
"id": "7",
"name": "Infinity Family",
"short": "Infinity Family"
},
{
"id": "8",
"name": "Free Builders",
"short": "Free Builders"
},
{
"id": "9",
"name": "More Ways to Earn",
"short": "More Ways to Earn"
},
{
"id": "10",
"name": "AI and Tools",
"short": "AI and Tools"
},
{
"id": "11",
"name": "Crypto Team Build Network",
"short": "CTB Network"
},
{
"id": "12",
"name": "Crypto Faucets",
"short": "Crypto Faucets"
},
{
"id": "13",
"name": "Safelist Mailers and Traffic Exchanges",
"short": "Mailers and Traffic"
},
{
"id": "0",
"name": "Other programs",
"short": "Other"
}
],
"programs": [
{
"id": "ctb2",
"builderId": 2,
"name": "Ads Earn LTC",
"builderTitle": "Ads Earn LTC",
"url": "https://www.adsearnltc.com/?r={affiliateid}",
"idKind": "path",
"cat": "6",
"order": 1,
"ctbMemberLinks": 119,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb6",
"builderId": 6,
"name": "Elite Downline Club",
"builderTitle": "Elite Downline Club",
"url": "https://www.elitedownlineclub.com/index.php?r={affiliateid}&t=ctb",
"idKind": "path",
"cat": "11",
"order": 2,
"ctbMemberLinks": 179,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb12",
"builderId": 12,
"name": "Infinity Mailer Boost",
"builderTitle": "Infinity Mailer Boost",
"url": "https://infinitymailerboost.com/{affiliateid}",
"idKind": "path",
"cat": "7",
"order": 3,
"ctbMemberLinks": 145,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb13",
"builderId": 13,
"name": "Infinity Traffic Boost",
"builderTitle": "Infinity Traffic Boost",
"url": "https://infinitytrafficboost.com/{affiliateid}",
"idKind": "path",
"cat": "7",
"order": 4,
"ctbMemberLinks": 183,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": true
},
{
"id": "ctb14",
"builderId": 14,
"name": "My Lead Gen Secret",
"builderTitle": "My Lead Gen Secret",
"url": "https://www.myleadgensecret.com/?rid={affiliateid}",
"idKind": "path",
"cat": "9",
"order": 5,
"ctbMemberLinks": 71,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb15",
"builderId": 15,
"name": "Traffic Zipper",
"builderTitle": "Traffic Zipper",
"url": "https://trafficzipper.com/index2.php?af={affiliateid}",
"idKind": "path",
"cat": "13",
"order": 6,
"ctbMemberLinks": 100,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": true
},
{
"id": "ctb16",
"builderId": 16,
"name": "Leased Ad Space",
"builderTitle": "Leased Ad Space",
"url": "https://leasedadspace.com/?aid={affiliateid}",
"idKind": "path",
"cat": "7",
"order": 7,
"ctbMemberLinks": 136,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": true
},
{
"id": "ctb18",
"builderId": 18,
"name": "Unstoppable Domains",
"builderTitle": "Unstoppable Domains",
"url": "https://unstoppabledomains.com/?ref={affiliateid}",
"idKind": "path",
"cat": "9",
"order": 8,
"ctbMemberLinks": 57,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb19",
"builderId": 19,
"name": "Ads Earn Network",
"builderTitle": "Ads Earn Network",
"url": "https://www.adsearnnetwork.com/?{affiliateid}",
"idKind": "path",
"cat": "6",
"order": 9,
"ctbMemberLinks": 147,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": true
},
{
"id": "ctb20",
"builderId": 20,
"name": "Team Builder BTC 2.0",
"builderTitle": "Team Builder BTC 2.0",
"url": "https://www.teambuilderbtc.com/?r={affiliateid}",
"idKind": "path",
"cat": "6",
"order": 10,
"ctbMemberLinks": 95,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb21",
"builderId": 21,
"name": "Early Birds Downline Builder",
"builderTitle": "Early Birds Downline Builder",
"url": "https://www.earlybirdsdownline.com/me/{affiliateid}",
"idKind": "path",
"cat": "6",
"order": 11,
"ctbMemberLinks": 128,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb23",
"builderId": 23,
"name": "Tron Banners",
"builderTitle": "Tron Banners",
"url": "https://tronbanners.io/?{affiliateid}",
"idKind": "path",
"cat": "9",
"order": 12,
"ctbMemberLinks": 116,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb26",
"builderId": 26,
"name": "Ads Earn Tron",
"builderTitle": "Ads Earn Tron",
"url": "https://www.adsearntron.com/?r={affiliateid}",
"idKind": "path",
"cat": "6",
"order": 13,
"ctbMemberLinks": 111,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb27",
"builderId": 27,
"name": "Team Profit Builder",
"builderTitle": "Team Profit Builder",
"url": "https://teamprofitbuilder.com/splashpg.php?pid=2&r={affiliateid}",
"idKind": "path",
"cat": "9",
"order": 14,
"ctbMemberLinks": 107,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb28",
"builderId": 28,
"name": "YourProgramBuilder",
"builderTitle": "Grow Your Downline With Your Program Builder For FREE",
"url": "https://yourprogrambuilder.com/?{affiliateid}",
"idKind": "path",
"cat": "11",
"order": 15,
"ctbMemberLinks": 330,
"hidden": true,
"network": true,
"note": "growing head YourProgramBuilder",
"defaultId": "",
"featured": false
},
{
"id": "ctb29",
"builderId": 29,
"name": "ViralAdBlitz",
"builderTitle": "Join Viral Ad Blitz For FREE",
"url": "https://viraladblitz.com/?{affiliateid}",
"idKind": "path",
"cat": "11",
"order": 16,
"ctbMemberLinks": 304,
"hidden": true,
"network": true,
"note": "core head ViralAdBlitz",
"defaultId": "",
"featured": false
},
{
"id": "ctb30",
"builderId": 30,
"name": "DownlineHydra",
"builderTitle": "Downline Hydra Join It FREE",
"url": "https://downlinehydra.com/?{affiliateid}",
"idKind": "path",
"cat": "11",
"order": 17,
"ctbMemberLinks": 305,
"hidden": true,
"network": true,
"note": "this site (DownlineHydra)",
"defaultId": "",
"featured": false
},
{
"id": "ctb31",
"builderId": 31,
"name": "DownlineScaler",
"builderTitle": "Grow Your Team With Downline Scaler For FREE",
"url": "https://downlinescaler.com/?{affiliateid}",
"idKind": "path",
"cat": "11",
"order": 18,
"ctbMemberLinks": 302,
"hidden": true,
"network": true,
"note": "growing head DownlineScaler",
"defaultId": "",
"featured": false
},
{
"id": "ctb32",
"builderId": 32,
"name": "5xYourTeam",
"builderTitle": "5x Your Team For FREE",
"url": "https://5xyourteam.com/?{affiliateid}",
"idKind": "path",
"cat": "11",
"order": 19,
"ctbMemberLinks": 299,
"hidden": true,
"network": true,
"note": "growing head 5xYourTeam",
"defaultId": "",
"featured": false
},
{
"id": "ctb33",
"builderId": 33,
"name": "Viral Ad Source",
"builderTitle": "Join Our Viral Text Ad Marketing System FREE",
"url": "https://viraladsource.com?{affiliateid}",
"idKind": "path",
"cat": "11",
"order": 20,
"ctbMemberLinks": 170,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb34",
"builderId": 34,
"name": "Downline Banners",
"builderTitle": "Put Your Banners On Autopilot With This Free Platform",
"url": "https://downlinebanners.com?{affiliateid}",
"idKind": "path",
"cat": "11",
"order": 21,
"ctbMemberLinks": 280,
"hidden": true,
"network": true,
"note": "core head Downline Banners",
"defaultId": "",
"featured": false
},
{
"id": "ctb35",
"builderId": 35,
"name": "Network Ad Space",
"builderTitle": "Network Ad Space - Our CTB Ad Marketplace",
"url": "https://networkadspace.com/?id={affiliateid}",
"idKind": "path",
"cat": "11",
"order": 22,
"ctbMemberLinks": 288,
"hidden": true,
"network": true,
"note": "network site Network Ad Space",
"defaultId": "",
"featured": false
},
{
"id": "ctb36",
"builderId": 36,
"name": "Viral Banner Blitz",
"builderTitle": "Grow Your For Free With Viral Banner Blitz",
"url": "https://viralbannerblitz.com?{affiliateid}",
"idKind": "path",
"cat": "11",
"order": 23,
"ctbMemberLinks": 272,
"hidden": true,
"network": true,
"note": "core head Viral Banner Blitz",
"defaultId": "",
"featured": false
},
{
"id": "ctb37",
"builderId": 37,
"name": "Ads Earn ETH",
"builderTitle": "Ads Earn ETH",
"url": "https://adsearneth.com/?id={affiliateid}",
"idKind": "path",
"cat": "6",
"order": 24,
"ctbMemberLinks": 61,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb39",
"builderId": 39,
"name": "PassiveDrip",
"builderTitle": "Join Our Auto Faucet And Earn Every 2 Minutes At PassiveDrip.com",
"url": "https://passivedrip.com/?ref={affiliateid}",
"idKind": "path",
"cat": "11",
"order": 25,
"ctbMemberLinks": 152,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb40",
"builderId": 40,
"name": "CTB VIP",
"builderTitle": "The Crypto Team Build VIP Program",
"url": "https://teambuildvip.com/lcpjoinvip.php?r={affiliateid}",
"idKind": "path",
"cat": "11",
"order": 26,
"ctbMemberLinks": 255,
"hidden": true,
"network": true,
"note": "growing head VIP (The Crypto Team Build VIP Program)",
"defaultId": "",
"featured": false
},
{
"id": "ctb41",
"builderId": 41,
"name": "PaidOfferTasks",
"builderTitle": "PaidOfferTasks.com - Get Paid To Complete Surveys And Tasks",
"url": "https://paidoffertasks.com/?ref={affiliateid}",
"idKind": "path",
"cat": "11",
"order": 27,
"ctbMemberLinks": 89,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb43",
"builderId": 43,
"name": "My Link Shortener",
"builderTitle": "My Link Shortener",
"url": "https://mylnks.xyz/?ref={affiliateid}",
"idKind": "path",
"cat": "11",
"order": 28,
"ctbMemberLinks": 76,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb46",
"builderId": 46,
"name": "CrankOutAI",
"builderTitle": "CrankOutAI.com",
"url": "https://crankoutai.com/?ref={affiliateid}",
"idKind": "path",
"cat": "11",
"order": 29,
"ctbMemberLinks": 81,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb47",
"builderId": 47,
"name": "BTC4Hits",
"builderTitle": "BTC4Hits URL Rotator",
"url": "https://btc4hits.com/?{affiliateid}",
"idKind": "path",
"cat": "11",
"order": 30,
"ctbMemberLinks": 237,
"hidden": true,
"network": true,
"note": "network site BTC4Hits (merging into LinkSpin)",
"defaultId": "",
"featured": false
},
{
"id": "ctb49",
"builderId": 49,
"name": "Mailer.gold",
"builderTitle": "Mailer.gold",
"url": "https://mailer.gold/{affiliateid}",
"idKind": "path",
"cat": "7",
"order": 31,
"ctbMemberLinks": 85,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": true
},
{
"id": "ctb50",
"builderId": 50,
"name": "100 Percent Clicks",
"builderTitle": "100 Percent Clicks Viral Advertising Mailer",
"url": "https://100percentclicks.com/index.php?r={affiliateid}",
"idKind": "path",
"cat": "13",
"order": 32,
"ctbMemberLinks": 93,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb51",
"builderId": 51,
"name": "Traffic Leads 2 Income",
"builderTitle": "Traffic Leads 2 Income - The Income Driven Viral Mailer",
"url": "https://tl2icashmailer.com/?rid={affiliateid}",
"idKind": "path",
"cat": "13",
"order": 33,
"ctbMemberLinks": 83,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb59",
"builderId": 59,
"name": "Xpress Viral Mailer",
"builderTitle": "Xpress Viral Mailer",
"url": "https://xpressviralmailer.com/index.php?referrer={affiliateid}",
"idKind": "path",
"cat": "0",
"order": 34,
"ctbMemberLinks": 52,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb62",
"builderId": 62,
"name": "Tangled Social",
"builderTitle": "Tangled Social (Earn Crypto Just For Using It)",
"url": "https://{affiliateid}.tangled.com",
"idKind": "subdomain",
"cat": "9",
"order": 35,
"ctbMemberLinks": 33,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb63",
"builderId": 63,
"name": "Ads Earn XRP",
"builderTitle": "Ads Earn XRP",
"url": "https://www.adsearnxrp.com/?{affiliateid}",
"idKind": "path",
"cat": "6",
"order": 36,
"ctbMemberLinks": 24,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb66",
"builderId": 66,
"name": "Passive Crypto AI",
"builderTitle": "Passive Crypto AI",
"url": "https://passivecryptoai.com/?r={affiliateid}",
"idKind": "path",
"cat": "11",
"order": 37,
"ctbMemberLinks": 33,
"hidden": true,
"network": true,
"note": "network rebuild Passive Crypto AI (downline-builder site)",
"defaultId": "",
"featured": false
},
{
"id": "ctb67",
"builderId": 67,
"name": "Really Smart Art",
"builderTitle": "Really Smart Art",
"url": "https://www.reallysmart.art/video.aspx?u={affiliateid}",
"idKind": "path",
"cat": "10",
"order": 38,
"ctbMemberLinks": 29,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": true
},
{
"id": "ctb69",
"builderId": 69,
"name": "Sparky AI (PHG Hub)",
"builderTitle": "Automatic Duplication System With Sparky AI",
"url": "https://phghub.ai/{affiliateid}",
"idKind": "path",
"cat": "0",
"order": 39,
"ctbMemberLinks": 16,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb71",
"builderId": 71,
"name": "Amplify AI Workshop",
"builderTitle": "Jour Our Amplify AI Workshop Skool Community",
"url": "https://www.skool.com/amplify-ai/about?ref={affiliateid}",
"idKind": "path",
"cat": "10",
"order": 40,
"ctbMemberLinks": 8,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb72",
"builderId": 72,
"name": "CTB Rewards Telegram App",
"builderTitle": "Earn For Free In Our Native Telegram CTB Rewards App",
"url": "https://ctbrewards.saasy.top/invite/{affiliateid}",
"idKind": "path",
"cat": "11",
"order": 41,
"ctbMemberLinks": 11,
"hidden": false,
"network": false,
"note": "builder URL had a misspelled {affiliateid} placeholder, fixed here",
"defaultId": "",
"featured": false
},
{
"id": "ctb73",
"builderId": 73,
"name": "ClickBaitPays",
"builderTitle": "ClickBaitPays",
"url": "https://cbp-calculator.saasy.top/?ref={affiliateid}",
"idKind": "path",
"cat": "9",
"order": 42,
"ctbMemberLinks": 16,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb74",
"builderId": 74,
"name": "RM Circle",
"builderTitle": "Join Our RM Circle Team Build",
"url": "https://rmcircle.team/my/{affiliateid}",
"idKind": "path",
"cat": "9",
"order": 43,
"ctbMemberLinks": 12,
"hidden": false,
"network": false,
"note": "Marty 2026-11-14: RM Circle is a wild head (never a network core head)",
"defaultId": "",
"featured": true
},
{
"id": "ctb75",
"builderId": 75,
"name": "Ads Earn SOL",
"builderTitle": "Ads Earn SOL",
"url": "https://www.adsearnsol.com/?{affiliateid}",
"idKind": "path",
"cat": "6",
"order": 44,
"ctbMemberLinks": 3,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb76",
"builderId": 76,
"name": "Massifly",
"builderTitle": "Massifly",
"url": "https://massifly.com/?r={affiliateid}",
"idKind": "path",
"cat": "13",
"order": 45,
"ctbMemberLinks": 3,
"hidden": false,
"network": false,
"note": "",
"defaultId": "",
"featured": false
},
{
"id": "ctb77",
"builderId": 77,
"name": "InstantAdPay",
"builderTitle": "InstantAdPay",
"url": "https://instantadpay.com/join/{affiliateid}?promo=CTB&src=cryptoteambuild",
"idKind": "path",
"cat": "11",
"order": 46,
"ctbMemberLinks": 4,
"hidden": true,
"network": true,
"note": "core head InstantAdPay",
"defaultId": "",
"featured": false
}
]
}
+197
View File
@@ -0,0 +1,197 @@
// Database-backed data documents (Marty 2026-11-13, standing rule: "everything database-driven ... files only for early
// prototyping"). Every *.json / *.jsonl data document under DATA_DIR that a module reads or writes with the fs *Sync calls lives
// in MySQL instead of on the volume: table `docs` (name = path relative to DATA_DIR, body LONGTEXT, updated_at). The modules keep
// their code; install() routes their fs calls on those paths to an in-memory copy that init() loads from MySQL at boot, and every
// change is written through to MySQL (coalesced per document, newest body wins, in order, retried until it lands).
//
// One writer at a time: init() claims the `docs_writer` row; an older app copy still running during a deploy finds the row taken
// and stops writing (logged), so it can never put stale data over the new copy's (the 2026-11-13 rotator.json loss).
// First boot: a document missing from MySQL is imported from its file, and the file is renamed <name>.imported-<date> (kept, not
// read again). Files the volume keeps on purpose: KEEP (rebuildable caches, uploads, images, the geo database, queues read by
// listing a folder). The SAME file ships in InstantAdPay and LinkSpin.
'use strict';
const fs = require('fs');
const path = require('path');
const crypto = require('crypto');
const KEEP_FILES = new Set(['chain-index.json']); // a rebuildable cache of the blockchain
const KEEP_DIRS = ['uploads', 'geo', 'refuel-pending', 'backups', 'marks', 'kits', 'kitimg']; // binary files, or folders read by listing
const O = { readFileSync: fs.readFileSync, writeFileSync: fs.writeFileSync, existsSync: fs.existsSync, renameSync: fs.renameSync,
unlinkSync: fs.unlinkSync, statSync: fs.statSync, appendFileSync: fs.appendFileSync };
let ROOT = null, pool = null, ME = crypto.randomBytes(8).toString('hex'), ready = false, writer = true;
const cache = new Map(); // name -> { body: string, at: ms }
const pending = new Map(); // name -> body string | null (delete)
const stored = new Map(); // name -> body as last read from or written to MySQL: an unchanged save is not rewritten (2026-11-15: whole-document rewrites filled core with 115 GB of binlogs)
let flushing = false, timer = null;
const stats = { writes: 0, deletes: 0, refused: 0, errors: 0, imported: 0, lastError: null };
function nameOf(p) {
if (!ROOT || typeof p !== 'string' || !/\.jsonl?$/i.test(p)) return null;
const abs = path.resolve(p); if (!abs.startsWith(ROOT + path.sep)) return null;
const rel = abs.slice(ROOT.length + 1).split(path.sep).join('/');
if (KEEP_FILES.has(rel) || KEEP_DIRS.some(d => rel === d || rel.startsWith(d + '/'))) return null;
return rel;
}
const enoent = p => { const e = new Error("ENOENT: no such file or directory, open '" + p + "'"); e.code = 'ENOENT'; e.errno = -2; e.path = p; return e; };
const enc = o => (typeof o === 'string' ? o : o && o.encoding) || null;
function put(name, body) {
cache.set(name, { body, at: Date.now() });
if (stored.get(name) === body) { pending.delete(name); return; } // same as what MySQL already holds: nothing to write
pending.set(name, body); kick();
}
function drop(name) { cache.delete(name); pending.set(name, null); kick(); }
function kick() { if (!timer) timer = setTimeout(() => { timer = null; flush().catch(() => {}); }, 300); }
async function flush() {
if (!pool || flushing || !pending.size) return;
flushing = true;
try {
for (const [name, body] of [...pending]) {
if (pending.get(name) !== body) continue; // replaced while we were busy: the newer body goes next round
if (!writer) { pending.delete(name); stats.refused++; continue; }
const c = await pool.getConnection();
try {
await c.beginTransaction();
const [[w]] = await c.query('SELECT owner FROM docs_writer WHERE id = 1 FOR UPDATE');
if (!w || w.owner !== ME) { await c.rollback(); writer = false; pending.delete(name); stats.refused++; console.error('docstore: another app copy took over writing; this copy stops writing'); continue; }
if (body === null) { await c.query('DELETE FROM docs WHERE name = ?', [name]); stats.deletes++; }
else { await c.query('INSERT INTO docs (name, body, updated_at) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE body = VALUES(body), updated_at = VALUES(updated_at)', [name, body, Date.now()]); stats.writes++; }
await c.commit();
if (body === null) stored.delete(name); else stored.set(name, body);
if (pending.get(name) === body) pending.delete(name);
} catch (e) { try { await c.rollback(); } catch (x) {} stats.errors++; stats.lastError = String(e.message).slice(0, 200); console.error('docstore write', name, e.message); }
finally { c.release(); }
}
} finally { flushing = false; if (pending.size) setTimeout(() => flush().catch(() => {}), 1000); }
}
// Route the fs *Sync calls on data documents. Installed before any module runs; until init() the documents read from disk.
function install(dataDir) {
if (ROOT) return; ROOT = path.resolve(dataDir);
fs.readFileSync = function (p, o) {
if (!ready && process.env.DOCSTORE_URL && nameOf(p)) console.error('docstore: read before init', p, new Error().stack.split('\n')[2]);
const n = ready ? nameOf(p) : null; if (!n) return O.readFileSync.apply(fs, arguments);
const d = cache.get(n); if (!d) throw enoent(p);
return enc(o) ? d.body : Buffer.from(d.body, 'utf8');
};
fs.existsSync = function (p) { const n = ready ? nameOf(p) : null; return n ? cache.has(n) : O.existsSync.apply(fs, arguments); };
fs.writeFileSync = function (p, data, o) {
const n = ready ? nameOf(p) : null; if (!n) return O.writeFileSync.apply(fs, arguments);
const flag = o && typeof o === 'object' ? o.flag : null;
const s = Buffer.isBuffer(data) ? data.toString('utf8') : String(data);
put(n, flag && flag[0] === 'a' ? ((cache.get(n) || {}).body || '') + s : s);
};
fs.appendFileSync = function (p, data) {
const n = ready ? nameOf(p) : null; if (!n) return O.appendFileSync.apply(fs, arguments);
put(n, ((cache.get(n) || {}).body || '') + (Buffer.isBuffer(data) ? data.toString('utf8') : String(data)));
};
fs.renameSync = function (a, b) {
const nb = ready ? nameOf(b) : null; const na = ready ? nameOf(a) : null;
if (!nb && !na) return O.renameSync.apply(fs, arguments);
let body;
if (na) { const d = cache.get(na); if (!d) throw enoent(a); body = d.body; drop(na); }
else { body = O.readFileSync.call(fs, a, 'utf8'); try { O.unlinkSync.call(fs, a); } catch (e) {} }
if (nb) put(nb, body); else O.writeFileSync.call(fs, b, body);
};
fs.unlinkSync = function (p) { const n = ready ? nameOf(p) : null; if (!n) return O.unlinkSync.apply(fs, arguments); if (!cache.has(n)) throw enoent(p); drop(n); };
fs.statSync = function (p, o) {
const n = ready ? nameOf(p) : null; if (!n) return O.statSync.apply(fs, arguments);
const d = cache.get(n); if (!d) { if (o && o.throwIfNoEntry === false) return undefined; throw enoent(p); }
const size = Buffer.byteLength(d.body, 'utf8'); const t = new Date(d.at);
return { size, mtimeMs: d.at, mtime: t, ctime: t, birthtime: t, isFile: () => true, isDirectory: () => false, isSymbolicLink: () => false };
};
}
// Connect, claim writing, load every document, import files MySQL does not have yet. Throws if MySQL is unreachable: the app
// must not run on an empty copy.
async function init(opts) {
const url = String(process.env.DOCSTORE_URL || '').trim();
if (!url) { console.log('docstore: no DOCSTORE_URL, documents stay files (prototype mode)'); return false; }
const mysql = require('mysql2/promise');
pool = mysql.createPool({ uri: url, connectionLimit: 6, charset: 'utf8mb4' });
await pool.query('CREATE TABLE IF NOT EXISTS docs (name VARCHAR(190) PRIMARY KEY, body LONGTEXT NOT NULL, updated_at BIGINT NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4');
await pool.query('CREATE TABLE IF NOT EXISTS docs_writer (id TINYINT PRIMARY KEY, owner VARCHAR(40) NOT NULL, at BIGINT NOT NULL) ENGINE=InnoDB');
await pool.query('INSERT INTO docs_writer (id, owner, at) VALUES (1, ?, ?) ON DUPLICATE KEY UPDATE owner = VALUES(owner), at = VALUES(at)', [ME, Date.now()]);
const [rows] = await pool.query('SELECT name, body, updated_at FROM docs');
for (const r of rows) { cache.set(r.name, { body: r.body, at: Number(r.updated_at) }); stored.set(r.name, r.body); }
for (const sp of (opts && opts.splits) || []) await openSplit(sp);
// first boot for any document: import its file, then set the file aside
const stamp = new Date().toISOString().slice(0, 10);
const walk = dir => { let out = []; let ents = []; try { ents = fs.readdirSync(dir, { withFileTypes: true }); } catch (e) {} for (const e of ents) { const p = path.join(dir, e.name); if (e.isDirectory()) out = out.concat(walk(p)); else out.push(p); } return out; };
for (const p of walk(ROOT)) {
const n = nameOf(p); if (!n || cache.has(n)) continue;
const body = O.readFileSync.call(fs, p, 'utf8');
if (/\.json$/i.test(n) && body.trim()) { try { JSON.parse(body); } catch (e) { throw new Error('docstore: ' + n + ' is not valid JSON; fix or move it before switching to MySQL'); } }
await pool.query('INSERT INTO docs (name, body, updated_at) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE name = name', [n, body, Date.now()]);
const [[got]] = await pool.query('SELECT body FROM docs WHERE name = ?', [n]);
cache.set(n, { body: got.body, at: Date.now() }); stats.imported++;
O.renameSync.call(fs, p, p + '.imported-' + stamp);
}
for (const sp of (opts && opts.splits) || []) await migrateSplit(sp);
ready = true;
console.log('docstore: MySQL documents ready,', cache.size, 'documents,', stats.imported, 'imported from files this boot');
const shut = () => { flush().catch(() => {}).finally(() => {}); };
process.once('beforeExit', shut);
return true;
}
// ---- row tables: an ever-growing array (spin-link clicks) is one row per item, never a rewrite of the whole document ----
// spec { doc: 'rotator.json', field: 'hits', table: 'rot_hits', key: 'id', ts: 'ts' }. rows(table) gives the loaded items (oldest
// first); the module inserts / deletes rows itself and saves its document WITHOUT the field.
const ROWS = new Map(); const rowQ = []; let rowBusy = false;
async function openSplit(sp) {
await pool.query('CREATE TABLE IF NOT EXISTS `' + sp.table + '` (id VARCHAR(64) PRIMARY KEY, ts BIGINT NOT NULL, body MEDIUMTEXT NOT NULL, KEY ts (ts)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4');
const [r] = await pool.query('SELECT body FROM `' + sp.table + '` ORDER BY ts, id');
ROWS.set(sp.table, r.map(x => JSON.parse(x.body)));
}
async function insertMany(table, items, key, ts) {
for (let i = 0; i < items.length; i += 500) {
const part = items.slice(i, i + 500);
await pool.query('INSERT INTO `' + table + '` (id, ts, body) VALUES ? ON DUPLICATE KEY UPDATE body = VALUES(body), ts = VALUES(ts)', [part.map(x => [String(x[key]), Number(x[ts]) || 0, JSON.stringify(x)])]);
}
}
// first boot: the array still inside the document moves to its table, then the document is saved without it
async function migrateSplit(sp) {
const d = cache.get(sp.doc); if (!d) return;
let obj; try { obj = JSON.parse(d.body); } catch (e) { return; }
const arr = Array.isArray(obj[sp.field]) ? obj[sp.field] : null; if (!arr || !arr.length) return;
await insertMany(sp.table, arr, sp.key, sp.ts);
const [[{ n }]] = await pool.query('SELECT COUNT(*) n FROM `' + sp.table + '`');
if (n < arr.length) throw new Error('docstore: ' + sp.table + ' holds ' + n + ' rows after moving ' + arr.length + '; stopping before the document is changed');
const seen = new Set((ROWS.get(sp.table) || []).map(x => String(x[sp.key]))); const merged = (ROWS.get(sp.table) || []).concat(arr.filter(x => !seen.has(String(x[sp.key]))));
merged.sort((a, b) => (Number(a[sp.ts]) || 0) - (Number(b[sp.ts]) || 0)); ROWS.set(sp.table, merged);
obj[sp.field] = []; const body = JSON.stringify(obj);
await pool.query('UPDATE docs SET body = ?, updated_at = ? WHERE name = ?', [body, Date.now(), sp.doc]); cache.set(sp.doc, { body, at: Date.now() });
console.log('docstore:', arr.length, sp.field, 'moved from', sp.doc, 'to table', sp.table);
}
function rows(table) { return ROWS.get(table) || null; }
function rowOp(op) { if (!pool || !writer) return; rowQ.push(op); if (!rowBusy) runRows(); }
async function runRows() {
rowBusy = true;
try {
while (rowQ.length && writer) {
const op = rowQ[0];
try {
if (op.del) await pool.query('DELETE FROM `' + op.table + '` WHERE id IN (?)', [op.ids]);
else await pool.query('INSERT INTO `' + op.table + '` (id, ts, body) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE body = VALUES(body), ts = VALUES(ts)', [op.id, op.ts, op.body]);
rowQ.shift();
} catch (e) { stats.errors++; stats.lastError = String(e.message).slice(0, 200); await new Promise(r => setTimeout(r, 1000)); }
}
} finally { rowBusy = false; }
}
const rowPut = (table, id, ts, obj) => rowOp({ table, id: String(id), ts: Number(ts) || 0, body: JSON.stringify(obj) });
const rowDel = (table, ids) => { const list = [...ids].map(String); for (let i = 0; i < list.length; i += 1000) rowOp({ table, del: true, ids: list.slice(i, i + 1000) }); };
function isOn() { return ready && !!pool; }
// once across app copies (two run side by side during a deploy): true for the first caller of a key, false after. Without MySQL: true.
async function claim(key) {
if (!pool) return true;
await pool.query('CREATE TABLE IF NOT EXISTS doc_claims (k VARCHAR(190) PRIMARY KEY, at BIGINT NOT NULL) ENGINE=InnoDB');
const [r] = await pool.query('INSERT IGNORE INTO doc_claims (k, at) VALUES (?, ?)', [String(key).slice(0, 190), Date.now()]);
return r.affectedRows === 1;
}
// SIGTERM during a deploy: write what is pending, then exit
async function drain(ms) { const end = Date.now() + (ms || 8000); while ((pending.size || flushing || rowQ.length || rowBusy) && Date.now() < end) { await flush().catch(() => {}); await new Promise(r => setTimeout(r, 100)); } }
function view() { return Object.assign({ ready, writer, documents: cache.size, pending: pending.size, rowQueue: rowQ.length, rowTables: Object.fromEntries([...ROWS].map(([k, v]) => [k, v.length])), bytes: [...cache.values()].reduce((t, d) => t + d.body.length, 0) }, stats); }
module.exports = { install, init, drain, flush, view, nameOf, rows, rowPut, rowDel, isOn, claim };
+205
View File
@@ -0,0 +1,205 @@
// THE DRAFT ENGINE. Pure functions: no I/O, no Date.now(). Every function takes `now` (ms) and the data it needs, so the weekly
// draft is deterministic and unit-tested with a mocked clock (qa/unit.test.cjs). server.js feeds it the store and the tank adapter.
//
// The rules (Marty 2026-11-14, project-5xyourteam-draft):
// - Every coach (holds a position) gets a draft spot every week. Each Monday the coaches draft from that week's pool, in rounds.
// - Draft order is EARNED: most of LAST week's picks "started" (switched on payouts or bought) picks first. Ties: more started
// picks ever, then the earlier first position (seniority), then a fixed shuffle of (week, coach) so nobody is always last.
// - A pick is an ADOPTION under the holding-tank rules: never anyone locked on a network contract or already sponsored, never a
// person adopted twice already (max 2 per person, lifetime, every pick counts), never spam / throwaway, never inside the 24-hour
// sign-up grace, never someone already on a team.
// - A coach in the draft room (the board pinged recently) gets the clock (pickSeconds); a coach who is away is auto-picked at once:
// the first available person on their own queue, else the best available by the scouting score. A coach with a full team
// (maxOpen open picks) is skipped for that slot.
// - An unconverted pick returns to the pool after returnDays. A person whose adoption count has reached the limit stays with the
// coach instead (never back to nobody: the IAP sweep rule). A converted pick (started) stays for good.
'use strict';
const TIERS = ['rookie', 'starter', 'pro', 'allstar', 'hof'];
const TIER_NAME = { rookie: 'Rookie', starter: 'Starter', pro: 'Pro', allstar: 'All-Star', hof: 'Hall of Fame' };
const DAY = 86400000;
// ---- milestones -> card tier. m = { wallet, payouts, purchase, ownTeam } as timestamps (0/absent = not yet) ----
function tierOf(m) {
m = m || {};
if (m.ownTeam) return 'hof'; // holds a 5xYourTeam position of their own: they coach a team now
if (m.purchase) return 'allstar'; // first purchase on the network
if (m.payouts) return 'pro'; // switched on payouts
if (m.wallet) return 'starter'; // linked a wallet
return 'rookie'; // drafted
}
const tierRank = t => TIERS.indexOf(t);
const tierAt = (m, t) => ({ hof: m.ownTeam, allstar: m.purchase, pro: m.payouts, starter: m.wallet }[t] || 0);
// "started" = the conversion the draft order and Best Coach count: payouts switched on or a purchase
const started = m => !!(m && (m.payouts || m.purchase));
const startedAt = m => { if (!m) return 0; const t = [m.payouts, m.purchase].filter(Boolean); return t.length ? Math.min(...t) : 0; };
// ---- scouting score (only real fields; a missing field adds nothing) ----
function score(c, now) {
let s = 0;
if (c.wallet) s += 30;
if (c.games && Number(c.games.plays) > 0) s += Math.min(40, Number(c.games.plays));
const seen = Number(c.lastSeen) || 0;
if (seen) { const age = now - seen; s += age < DAY ? 25 : age < 3 * DAY ? 12 : age < 7 * DAY ? 5 : 0; }
if (c.surfWei && BigInt(c.surfWei) > 0n) s += 10;
if (c.games && c.games.earnedWei && BigInt(c.games.earnedWei) > 0n) s += 10;
return s;
}
// how many adoptions a person has had: every pick here counts, plus the network's count from elsewhere (the tank's own record)
const adoptionCount = (c, picks) => (Number(c.adoptions) || 0) + picks.filter(p => p.person === c.id && p.status !== 'void').length;
const OPEN = ['open'];
// why a tank candidate cannot be drafted right now (null = draftable)
function blocked(c, picks, rules, now) {
if (!c || !c.id) return 'unknown';
if (c.locked) return 'locked'; // locked on a network contract: never offered
if (c.sponsored) return 'sponsored'; // the hub knows a sponsor for them
if (c.spam || c.throwaway) return 'spam'; // spam / throwaway addresses are skipped
if (c.joinedAt && now - c.joinedAt < rules.graceHours * 3600000) return 'grace';
if (picks.some(p => p.person === c.id && OPEN.includes(p.status))) return 'taken';
if (picks.some(p => p.person === c.id && ['done', 'kept'].includes(p.status))) return 'taken';
if (adoptionCount(c, picks) >= rules.maxAdoptions) return 'adopted-twice';
return null;
}
// the draftable pool, best scouting score first (ties: newest sign-in, then id, so the order is fixed)
function pool(cands, picks, rules, now) {
return (cands || []).filter(c => !blocked(c, picks, rules, now))
.map(c => Object.assign({}, c, { score: score(c, now) }))
.sort((a, b) => b.score - a.score || (Number(b.lastSeen) || 0) - (Number(a.lastSeen) || 0) || String(a.id).localeCompare(String(b.id)));
}
// ---- draft order ----
function fnv(s) { let h = 0x811c9dc5; for (const ch of String(s)) { h ^= ch.charCodeAt(0); h = Math.imul(h, 0x01000193) >>> 0; } return h; }
// coaches: [{ address, username, since }]; picks carry week, coach, m (milestones). prevWeek = last week's Monday date.
function standings(coaches, picks, week, prevWeek) {
return coaches.map(c => {
const mine = picks.filter(p => p.coach === c.address);
return { address: c.address, username: c.username || null, since: c.since || 0,
lastWeek: mine.filter(p => p.week === prevWeek && started(p.m)).length,
lifetime: mine.filter(p => started(p.m)).length, tie: fnv(week + '|' + c.address) };
}).sort((a, b) => b.lastWeek - a.lastWeek || b.lifetime - a.lifetime || (a.since || Infinity) - (b.since || Infinity) || a.tie - b.tie);
}
// a new draft: straight rounds (the earned order every round)
function newDraft(o) {
const slots = [];
for (let r = 1; r <= o.rounds; r++) o.order.forEach((coach, i) => slots.push({ round: r, n: i + 1, coach }));
return { week: o.week, at: o.at, rounds: o.rounds, order: o.order.slice(), standings: o.standings || null, slots, made: [], taken: [], unavailable: [],
status: o.order.length ? 'live' : 'done', clockAt: o.at, doneAt: o.order.length ? null : o.at, poolSize: o.poolSize || 0 };
}
const slotLabel = s => s.round + '.' + s.n;
const current = d => (d && d.status === 'live' ? d.slots[d.made.length] || null : null);
// ctx: { pool: [ids, best first], present(addr) -> bool, queue(addr) -> [ids], openCount(addr) -> n, rules: { maxOpen }, pickSeconds }
// -> { type: 'wait', until } | { type: 'auto', slot, coach, person } | { type: 'skip', slot, why } | { type: 'done', why }
function nextAction(d, ctx, now) {
if (!d || d.status !== 'live') return { type: 'done', why: 'not live' };
const i = d.made.length; if (i >= d.slots.length) return { type: 'done', why: 'all rounds made' };
const gone = new Set(d.taken.concat(d.unavailable));
const avail = ctx.pool.filter(id => !gone.has(id));
if (!avail.length) return { type: 'done', why: 'pool empty' };
const slot = d.slots[i];
if (ctx.openCount(slot.coach) >= ctx.rules.maxOpen) return { type: 'skip', slot, why: 'team full' };
const until = d.clockAt + ctx.pickSeconds * 1000;
if (ctx.present(slot.coach) && now < until) return { type: 'wait', until };
const q = (ctx.queue(slot.coach) || []).find(id => avail.includes(id));
return { type: 'auto', slot, coach: slot.coach, person: q || avail[0], fromQueue: !!q };
}
// a coach on the clock picks by hand -> the same action shape, or { error }
function manual(d, coach, person, ctx, now) {
const slot = current(d); if (!slot) return { error: 'The draft is not live.' };
if (slot.coach !== coach) return { error: 'You are not on the clock.' };
const gone = new Set(d.taken.concat(d.unavailable));
if (gone.has(person) || !ctx.pool.includes(person)) return { error: 'That player is no longer available.' };
if (ctx.openCount(coach) >= ctx.rules.maxOpen) return { error: 'Your team is full this week.' };
return { type: 'pick', slot, coach, person, manual: true };
}
// record what happened for the current slot (the adoption already went through, or was refused)
function record(d, act, res, now) {
if (act.type === 'skip') { d.made.push({ slot: slotLabel(act.slot), round: act.slot.round, n: act.slot.n, coach: act.slot.coach, skipped: act.why, at: now }); d.clockAt = now; }
else if (res && res.ok) { d.made.push({ slot: slotLabel(act.slot), round: act.slot.round, n: act.slot.n, coach: act.coach, person: act.person, auto: act.type === 'auto', fromQueue: !!act.fromQueue, pickId: res.pickId || null, at: now }); d.taken.push(act.person); d.clockAt = now; }
else { d.unavailable.push(act.person); } // the tank refused this person (locked a moment ago, adopted elsewhere): the same coach chooses again
return d;
}
function finish(d, why, now) { d.status = 'done'; d.doneAt = now; d.why = why; return d; }
// run every decision due at `now`; adopt(act) -> { ok, pickId } | { error } (may be async). Returns the draft (mutated).
async function run(d, ctx, adopt, now, maxSteps) {
for (let n = 0; n < (maxSteps || 10000); n++) {
const a = nextAction(d, ctx, now);
if (a.type === 'wait') return d;
if (a.type === 'done') { if (d.status === 'live') finish(d, a.why, now); return d; }
if (a.type === 'skip') { record(d, a, null, now); continue; }
const res = await adopt(a);
record(d, a, res, now);
}
return d;
}
// ---- pick returns (the rolling pool) ----
// statusOf(person) -> fresh milestones (or null when the network cannot say: then nothing changes). Returns the changes to apply.
function sweep(picks, statusOf, rules, now) {
const out = [];
for (const p of picks) {
if (p.status !== 'open') continue;
const m = statusOf(p.person); if (!m) continue;
if (started(m)) { out.push({ pick: p, set: { status: 'done', m, tier: tierOf(m), doneAt: now } }); continue; }
if (now < p.expires) { if (JSON.stringify(m) !== JSON.stringify(p.m)) out.push({ pick: p, set: { m, tier: tierOf(m) } }); continue; }
// the window ended unconverted: back to the pool, unless this person has had their adoptions (then they stay with this coach)
const count = (Number(m.adoptions) || 0) + picks.filter(x => x.person === p.person && x.status !== 'void').length;
if (count >= rules.maxAdoptions) out.push({ pick: p, set: { status: 'kept', m, tier: tierOf(m), keptAt: now } });
else out.push({ pick: p, set: { status: 'returned', m, tier: tierOf(m), returnedAt: now }, release: true });
}
return out;
}
// may this coach release a pick now? (the IAP churn rule: not inside the hold)
function canRelease(p, rules, now) { if (p.status !== 'open') return 'That pick is not open.'; if (now - p.at < rules.holdHours * 3600000) return 'You picked them less than ' + rules.holdHours + ' hours ago. Give them a little time first.'; return null; }
// ---- boards ----
// Best Coach: picks that STARTED inside the week [from, to), per coach. Ties: who got there first, then username.
function bestCoach(picks, from, to, nameOf) {
const by = new Map();
for (const p of picks) {
const t = startedAt(p.m); if (!t || t < from || t >= to) continue;
const x = by.get(p.coach) || { coach: p.coach, started: 0, lastAt: 0 }; x.started++; x.lastAt = Math.max(x.lastAt, t); by.set(p.coach, x);
}
return [...by.values()].map(x => Object.assign(x, { username: nameOf ? nameOf(x.coach) : null }))
.sort((a, b) => b.started - a.started || a.lastAt - b.lastAt || String(a.username || a.coach).localeCompare(String(b.username || b.coach)))
.map((x, i) => Object.assign(x, { rank: i + 1 }));
}
// Rookie of the Week: of the picks made that week, the one that climbed highest; ties: reached it first, then the pick id
function rookie(picks, week) {
const l = picks.filter(p => p.week === week && p.status !== 'void').map(p => ({ p, t: tierOf(p.m) })).filter(x => x.t !== 'rookie');
l.sort((a, b) => tierRank(b.t) - tierRank(a.t) || tierAt(a.p.m, a.t) - tierAt(b.p.m, b.t) || a.p.id - b.p.id);
return l.length ? { pick: l[0].p, tier: l[0].t } : null;
}
// the week's pot split into places (percentages of the pot; dust stays in the pot wallet)
function potShares(potWei, split, board) {
const pot = BigInt(potWei || 0);
return split.slice(0, board.length).map((pct, i) => ({ rank: i + 1, coach: board[i].coach, username: board[i].username, pct, wei: (pot * BigInt(Math.round(pct * 100)) / 10000n).toString() }));
}
// ---- coaching: who to help first, and what to say ----
const STEPS = [['signedIn', 'Signed in'], ['username', 'Username'], ['wallet', 'Wallet linked'], ['payouts', 'Payouts on'], ['purchase', 'First purchase']];
function steps(m) { m = m || {}; const done = { signedIn: !!m.lastSeen, username: !!m.username, wallet: !!m.wallet, payouts: !!m.payouts, purchase: !!m.purchase };
const next = STEPS.find(s => !done[s[0]]); return STEPS.map(s => ({ key: s[0], label: s[1], done: done[s[0]], next: !!next && next[0] === s[0] })); }
function helpList(picks, now) {
return picks.filter(p => p.status === 'open').map(p => {
const m = p.m || {}; const left = p.expires - now; const quiet = m.lastSeen ? now - m.lastSeen : Infinity;
let why, say, urgency;
if (left < DAY) { why = 'Back to the pool in ' + (left < 3600000 ? 'under an hour' : Math.ceil(left / 3600000) + ' hours'); urgency = 100; }
else if (m.wallet && !m.payouts) { why = 'Wallet linked: one step from payouts'; urgency = 80; }
else if (quiet > 2 * DAY) { why = m.lastSeen ? 'Quiet ' + Math.floor(quiet / DAY) + ' days: send a nudge' : 'Has not signed in yet'; urgency = 60; }
else if (!m.wallet) { why = 'Active, no wallet yet'; urgency = 40; }
else { why = 'Doing fine'; urgency = 10; }
const nx = steps(m).find(s => s.next);
say = !nx ? 'Great work. Want to build a team of your own next?'
: nx.key === 'wallet' ? 'Want me to walk you through linking a wallet? SafePal or any other crypto wallet works.'
: nx.key === 'payouts' ? 'Ready to switch on payouts? I will walk you through it.'
: nx.key === 'purchase' ? 'You are set up. When you are ready, I can show you the first purchase step.'
: 'Welcome! I am your coach. Reply here any time and I will help you get going.';
return { pickId: p.id, person: p.person, username: p.personName || null, why, say, urgency, daysLeft: Math.max(0, Math.ceil(left / DAY)), next: nx ? nx.label : null };
}).sort((a, b) => b.urgency - a.urgency || a.daysLeft - b.daysLeft || a.pickId - b.pickId);
}
module.exports = { TIERS, TIER_NAME, tierOf, tierRank, started, startedAt, score, blocked, pool, adoptionCount, standings, newDraft, nextAction, manual, record, finish, run,
current, slotLabel, sweep, canRelease, bestCoach, rookie, potShares, steps, helpList, fnv };
+40
View File
@@ -0,0 +1,40 @@
// A member's sponsor line from the network hub (the one source of truth, Marty 2026-11-13/14). Walks hubpeople.sponsorOf()
// up to `max` places, nearest first: [{ depth, id, username, wallet }]. Used two ways:
// - position vouchers: the wallets of the line, bound on chain on the buyer's first position (DraftPosition binds link by link)
// - the coach card: who sponsors this coach on the network
// Answers are cached 5 minutes per start person. {ok: false} = the hub did not answer all the way (the line is partial); the
// caller decides (pages fall back to the last good line; vouchers are not signed on a partial line).
'use strict';
const hubpeople = require('./hubpeople');
const TTL = () => Number(process.env.HUB_CACHE_MS || 5 * 60000);
const cache = new Map(); const lastGood = new Map();
async function walk(person, max) {
const line = []; const seen = new Set([person.id]); let p = person;
for (let depth = 1; depth <= max; depth++) {
if (!p.sponsor || !p.sponsor.id) return { ok: true, line };
if (seen.has(p.sponsor.id)) return { ok: true, line, loop: true }; // a loop in the hub data: stop
const r = await hubpeople.sponsorOf(p); if (!r.ok) return { ok: false, line };
if (!r.person) return { ok: true, line };
seen.add(r.person.id);
line.push({ depth, id: r.person.id, username: r.person.username ? String(r.person.username) : null, wallet: hubpeople.wallet(r.person) });
p = r.person;
}
return { ok: true, line };
}
// start = { ref: username } | { wallet }. -> { ok, person, line, stale? }
async function lineOf(start, max) {
const k = JSON.stringify(start) + '|' + max; const hit = cache.get(k);
if (hit && Date.now() - hit.at < TTL()) return hit.v;
const me = start.wallet ? await hubpeople.byWallet(start.wallet) : await hubpeople.byRef(start.ref);
let v;
if (!me.ok) v = { ok: false, person: null, line: [] };
else if (!me.person) v = { ok: true, person: null, line: [] };
else { const w = await walk(me.person, max); v = { ok: w.ok, person: me.person, line: w.line }; }
if (v.ok) { cache.set(k, { at: Date.now(), v }); lastGood.set(k, v); if (cache.size > 20000) cache.clear(); if (lastGood.size > 20000) lastGood.clear(); return v; }
const lg = lastGood.get(k); return lg ? Object.assign({}, lg, { ok: false, stale: true }) : v;
}
module.exports = { lineOf, walk, _reset: () => { cache.clear(); lastGood.clear(); } };
+62
View File
@@ -0,0 +1,62 @@
// Network hub lookups (Marty 2026-11-14: "want everything looped through the hub to verify membership"). The hub is the one
// record per person across the network; this asks it who a username, wallet or hub id is:
// POST /v1/resolve {ref: <username or wallet>} | {wallet} | {id: 'h_...'} -> {person: view or null}
// signed as HUB_SITE with HUB_SECRET (X-Hub-Site, X-Hub-Ts, X-Hub-Sig = hex HMAC-SHA256(ts + newline + raw body)), the same
// scheme as hubreport.js. This site cannot see emails (seeEmails false): a person is {id, username, wallet, sponsor: {id, username}, blocked, ...}.
// Answers (people and misses) are cached HUB_CACHE_MS (5 minutes). A failed call (timeout, refused, any non-200) is never
// cached: it returns {ok: false} so the caller can fall back, and the hub is skipped for 30 seconds so pages never wait on it.
// On unless HUB_LOOKUP=0; needs HUB_URL and a 32+ character HUB_SECRET (HUB_ENABLED only switches the shadow report).
'use strict';
const crypto = require('crypto');
const DEFAULT_SITE = 'fivex';
const ADDR_RE = /^0x[0-9a-f]{40}$/;
const TTL = () => Number(process.env.HUB_CACHE_MS || 5 * 60000);
const TIMEOUT = () => Number(process.env.HUB_LOOKUP_TIMEOUT_MS || 2500);
const on = () => !/^(0|false|no|off)$/i.test(String(process.env.HUB_LOOKUP || '').trim())
&& !!String(process.env.HUB_URL || '').trim() && String(process.env.HUB_SECRET || '').trim().length >= 32;
const cache = new Map(); let downUntil = 0; let lastError = null; const stats = { asked: 0, cached: 0, failed: 0 };
async function call(body) {
const raw = JSON.stringify(body); const ts = String(Date.now());
const sig = crypto.createHmac('sha256', String(process.env.HUB_SECRET).trim()).update(ts + '\n' + raw).digest('hex');
const ac = new AbortController(); const t = setTimeout(() => ac.abort(), TIMEOUT());
try {
const r = await fetch(String(process.env.HUB_URL).trim().replace(/\/+$/, '') + '/v1/resolve', { method: 'POST', body: raw, signal: ac.signal,
headers: { 'Content-Type': 'application/json', 'X-Hub-Site': String(process.env.HUB_SITE || DEFAULT_SITE).trim(), 'X-Hub-Ts': ts, 'X-Hub-Sig': sig } });
if (r.status !== 200) throw new Error('hub answered ' + r.status);
const j = await r.json();
if (!j || typeof j !== 'object' || !('person' in j)) throw new Error('hub answer has no person field');
return j.person && typeof j.person === 'object' ? j.person : null;
} finally { clearTimeout(t); }
}
// {ok: true, person: view | null} when the hub answered; {ok: false} when it is off or unreachable (the caller falls back)
async function resolve(body) {
if (!on() || Date.now() < downUntil) return { ok: false };
const k = JSON.stringify(body); const hit = cache.get(k);
if (hit && Date.now() - hit.at < TTL()) { stats.cached++; return { ok: true, person: hit.person }; }
stats.asked++;
let person;
try { person = await call(body); } catch (e) {
stats.failed++; downUntil = Date.now() + Number(process.env.HUB_DOWN_MS || 30000);
if (!lastError || Date.now() - lastError.at > 600000) console.error('hub lookup failed, falling back:', e.name === 'AbortError' ? 'timeout' : e.message);
lastError = { at: Date.now(), error: e.name === 'AbortError' ? 'timeout' : String(e.message).slice(0, 120) };
return { ok: false };
}
if (cache.size > 20000) cache.clear();
cache.set(k, { at: Date.now(), person });
if (person && person.id) cache.set(JSON.stringify({ id: person.id }), { at: Date.now(), person });
return { ok: true, person };
}
const wallet = p => (p && ADDR_RE.test(String(p.wallet || '').toLowerCase()) ? String(p.wallet).toLowerCase() : null);
// a username or wallet -> person (a blocked person counts as unknown)
async function byRef(ref) { const r = await resolve({ ref: String(ref || '').trim().toLowerCase() }); return r.ok ? { ok: true, person: r.person && !r.person.blocked ? r.person : null } : r; }
async function byWallet(w) { const r = await resolve({ wallet: String(w || '').trim().toLowerCase() }); return r.ok ? { ok: true, person: r.person && !r.person.blocked ? r.person : null } : r; }
async function byId(id) { if (!/^h_[0-9a-f]{16}$/.test(String(id || ''))) return { ok: true, person: null }; const r = await resolve({ id: String(id) }); return r.ok ? { ok: true, person: r.person && !r.person.blocked ? r.person : null } : r; }
// the person's network sponsor as a full person (with wallet), resolved through the hub by hub id. {ok, person: sponsor or null}
async function sponsorOf(p) { if (!p || !p.sponsor || !p.sponsor.id) return { ok: true, person: null }; return byId(p.sponsor.id); }
function view() { return { on: on(), down: Date.now() < downUntil, cached: cache.size, stats, lastError }; }
module.exports = { resolve, byRef, byWallet, byId, sponsorOf, wallet, view, on, _reset: () => { cache.clear(); downUntil = 0; } };
+75
View File
@@ -0,0 +1,75 @@
// Network hub report (the Downline Banners / VBB hubreport.js pattern, 2026-11-14). 5xYourTeam coaches are wallets, so every DraftPosition purchase
// goes to the hub by wallet:
// the buyer's first purchase: POST /v1/contract-bind { contract: 'fivex', wallet, sponsorRef: <sponsor wallet>, spentCents, tx, at }
// every later purchase: POST /v1/contract-spend { contract: 'fivex', wallet, cents, tx, at }
// signed as HUB_SITE (default fivex) with HUB_SECRET (X-Hub-Site, X-Hub-Ts, X-Hub-Sig = hex HMAC-SHA256(ts + newline + raw body)).
// One way only: nothing the hub answers changes anything here. A wallet the hub does not know (404) is kept in `unknown` and asked
// again every 6 hours (the member may link it on InstantAdPay later). Off unless HUB_ENABLED=1 with HUB_URL and a 32+ char HUB_SECRET.
// State lives in hubreport.json (a MySQL document through docstore when DOCSTORE_URL is set).
'use strict';
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const CONTRACT = 'fivex';
const ZERO = '0x0000000000000000000000000000000000000000';
const enabled = () => /^(1|true|yes|on)$/i.test(String(process.env.HUB_ENABLED || '').trim())
&& !!String(process.env.HUB_URL || '').trim() && String(process.env.HUB_SECRET || '').trim().length >= 32;
const RECHECK = 6 * 3600000;
let R = null, st = null, busy = false;
const FILE = () => path.join(R.dataDir, 'hubreport.json');
function load() {
if (st) return st;
try { st = JSON.parse(fs.readFileSync(FILE(), 'utf8')); } catch (e) { st = {}; }
st.sent = st.sent || {}; st.bound = st.bound || {}; st.unknown = st.unknown || {}; st.errors = st.errors || {}; st.log = st.log || [];
return st;
}
function save() { try { fs.writeFileSync(FILE() + '.tmp', JSON.stringify(load())); fs.renameSync(FILE() + '.tmp', FILE()); } catch (e) { console.error('hubreport save', e.message); } }
function note(x) { const s = load(); s.log.push(Object.assign({ ts: Date.now() }, x)); if (s.log.length > 200) s.log = s.log.slice(-200); }
async function post(route, body) {
const raw = JSON.stringify(body); const ts = String(Date.now());
const sig = crypto.createHmac('sha256', String(process.env.HUB_SECRET).trim()).update(ts + '\n' + raw).digest('hex');
const ac = new AbortController(); const t = setTimeout(() => ac.abort(), 15000);
try {
const r = await fetch(String(process.env.HUB_URL).trim().replace(/\/+$/, '') + route, { method: 'POST', body: raw, signal: ac.signal,
headers: { 'Content-Type': 'application/json', 'X-Hub-Site': String(process.env.HUB_SITE || 'fivex').trim(), 'X-Hub-Ts': ts, 'X-Hub-Sig': sig } });
let j = null; try { j = await r.json(); } catch (e) {}
return { status: r.status, body: j };
} finally { clearTimeout(t); }
}
async function tick() {
if (!enabled() || busy) return; busy = true;
try {
const s = load(); const now = Date.now();
const list = R.purchases().slice().sort((a, b) => (a.block || 0) - (b.block || 0) || (a.at || 0) - (b.at || 0));
for (const p of list) {
if (s.sent[p.key]) continue;
const a = p.buyer;
if (s.unknown[a] && now - s.unknown[a].at < RECHECK) continue;
const tx = String(p.key).split(':')[0];
const bind = !s.bound[a];
const body = bind
? { contract: CONTRACT, wallet: a, sponsorRef: p.sponsor && p.sponsor !== ZERO ? p.sponsor : '', spentCents: p.usdCents || 0, tx, at: p.at || now }
: { contract: CONTRACT, wallet: a, cents: p.usdCents || 0, tx, at: p.at || now };
let r; try { r = await post(bind ? '/v1/contract-bind' : '/v1/contract-spend', body); }
catch (e) { s.errors[p.key] = { at: now, error: e.message }; break; } // hub unreachable: try again next tick
if (r.status === 200) { s.sent[p.key] = { at: now, route: bind ? 'bind' : 'spend' }; if (bind) s.bound[a] = now; delete s.unknown[a]; delete s.errors[p.key]; note({ sent: p.key, bind }); }
else if (r.status === 404) { s.unknown[a] = { at: now, sponsor: p.sponsor || null }; note({ unknown: a }); }
else { s.errors[p.key] = { at: now, status: r.status, error: r.body && (r.body.error || r.body.message) }; note({ error: p.key, status: r.status }); if (r.status >= 500) break; }
}
save();
} finally { busy = false; }
}
// deps: { dataDir, purchases: () => [{ key, buyer, sponsor, usdCents, block, at }] }
function init(deps) {
R = deps; if (!enabled()) return; load(); save();
const every = Math.max(200, Number(process.env.HUB_TICK_MS) || 60000);
setTimeout(() => tick().catch(e => console.error('hubreport', e.message)), Math.min(20000, every)).unref();
setInterval(() => tick().catch(e => console.error('hubreport', e.message)), every).unref();
}
function view() { if (!R) return { enabled: false }; const s = load(); return { enabled: enabled(), site: String(process.env.HUB_SITE || 'fivex').trim(), sent: Object.keys(s.sent).length, bound: Object.keys(s.bound).length, unknown: s.unknown, errors: s.errors, log: s.log.slice(-30) }; }
module.exports = { init, tick, view, enabled, CONTRACT };
+150
View File
@@ -0,0 +1,150 @@
// The league: the draft engine (draft.js, pure) wired to the store and the holding tank (tankpool.js). One tick at a time:
// 1. sweep the open picks: fresh milestones from the tank; started picks stay (done), unconverted ones past the return window go
// back to the pool (or stay with the coach once the person has had their 2 adoptions)
// 2. on draft day at the draft hour (Central): create the week's draft from the earned order and the pool snapshot
// 3. while the draft is live: run every decision that is due (a coach in the room gets the clock, an absent coach is auto-picked)
// 4. when it finishes: the Draft Day card (proof.js, the outbox in phase 1)
// Every pick goes through tank.adopt() first; a pick is recorded only when the adoption went through.
// The clock is injectable (clock.now()): tests move it with POST /api/admin/clock when ALLOW_TEST_CLOCK=1 (never in production).
'use strict';
const store = require('./store');
const draft = require('./draft');
const tank = require('./tankpool');
const D = 86400000;
let C = null, proof = null, offset = 0, busy = Promise.resolve(), cands = [], candsAt = 0;
const clock = { now: () => Date.now() + offset, set: t => { offset = t - Date.now(); }, offset: () => offset };
const rules = () => ({ maxOpen: C.picks.maxOpen, maxAdoptions: C.picks.maxAdoptions, graceHours: C.picks.graceHours, holdHours: C.picks.holdHours, returnDays: C.picks.returnDays });
const lock = fn => { const r = busy.then(fn, fn); busy = r.catch(() => {}); return r; };
function init(cfg, deps) { C = cfg; proof = deps.proof; }
// ---- weeks (Central) ----
function weekInfo(now) {
const week = store.ctWeek(now);
const at = w => store.ctToMs(store.addDays(w, (C.draft.dow + 6) % 7), C.draft.hour); // dow 1 = Monday = the week's first day
const draftAt = at(week); const next = at(store.addDays(week, 7));
return { week, prevWeek: store.addDays(week, -7), nextWeek: store.addDays(week, 7), draftAt, nextDraftAt: now < draftAt ? draftAt : next,
from: store.ctToMs(week, 0), to: store.ctToMs(store.addDays(week, 7), 0) };
}
const nameOf = a => { const m = store.member(a); return m && m.username ? m.username : null; };
const openCount = a => store.picksOf(a).filter(p => p.status === 'open').length;
// ---- the pool ----
async function candidates(now, fresh) {
if (fresh || now - candsAt > 15000 || !cands.length) { try { cands = await tank.candidates(now); candsAt = now; } catch (e) { console.error('tank candidates', e.message); } }
return cands;
}
async function pool(now) { return draft.pool(await candidates(now), store.picks(), rules(), now); }
const ownTeam = id => { const m = store.memberByHub(id); return m && store.positionsOf(m.address) > 0 ? (store.firstPositionAt(m.address) || 1) : 0; };
// ---- a pick = an adoption ----
async function makePick(coach, person, kind, extra, now) {
const c = cands.find(x => x.id === person) || { id: person };
const r = await tank.adopt({ coach: { address: coach, username: nameOf(coach), hubId: (store.member(coach) || {}).hubId || null }, person, kind });
if (!r || !r.ok) return { error: (r && r.error) || 'The holding tank did not answer.' };
const s = (await tank.status([person], now))[person] || {};
const m = Object.assign({ lastSeen: s.lastSeen || 0, username: s.username || c.username || null, wallet: s.wallet || 0, payouts: s.payouts || 0, purchase: s.purchase || 0, ownTeam: ownTeam(person) }, { door: s.door || c.door || null, games: s.games || c.games || null, surfWei: s.surfWei || c.surfWei || null });
const p = store.addPick(Object.assign({ week: weekInfo(now).week, kind, coach, coachName: nameOf(coach), person, personName: c.username || s.username || null, door: c.door || null,
status: 'open', at: now, expires: now + C.picks.returnDays * D, m, tier: draft.tierOf(m), ref: r.ref || null }, extra || {}));
candsAt = 0; // the pool changed
store.bump('picks');
return { ok: true, pickId: p.id, pick: p };
}
// ---- 1. sweep ----
async function sweep(now) {
const open = store.picks().filter(p => p.status === 'open' || p.status === 'done' || p.status === 'kept');
if (!open.length) return { changed: 0 };
const ids = [...new Set(open.map(p => p.person))];
const sts = await tank.status(ids, now);
const statusOf = id => { const s = sts[id]; if (!s) return null; return Object.assign({}, s, { ownTeam: ownTeam(id) }); };
// done / kept picks only refresh their milestones (cards keep levelling up)
for (const p of open.filter(x => x.status !== 'open')) { const m = statusOf(p.person); if (m) { const t = draft.tierOf(m); if (t !== p.tier || JSON.stringify(m) !== JSON.stringify(p.m)) { if (t !== p.tier) p.levelAt = now; p.m = m; p.tier = t; store.savePick(p); } } }
const ch = draft.sweep(store.picks(), statusOf, rules(), now);
for (const c of ch) {
if (c.release) { const r = await tank.release({ coach: c.pick.coach, person: c.pick.person, why: 'return window ended' }); if (!r || !r.ok) continue; }
if (c.set.tier && c.set.tier !== c.pick.tier) c.pick.levelAt = now; // the toast time, on the league clock
Object.assign(c.pick, c.set); store.savePick(c.pick);
}
if (ch.length) candsAt = 0;
return { changed: ch.length };
}
// ---- 2 + 3. the draft ----
function ctx(d, now) {
return { pool: d.poolIds || [], present: a => { const m = store.member(a); return !!(m && m.presenceAt && now - m.presenceAt < C.draft.presenceSeconds * 1000); },
queue: a => (store.member(a) || {}).queue || [], openCount, rules: rules(), pickSeconds: C.draft.pickSeconds };
}
async function ensureDraft(now) {
const w = weekInfo(now);
if (now < w.draftAt || store.draft(w.week)) return store.draft(w.week);
if (now > w.draftAt + C.draft.lateHours * 3600000) return null; // the app was down through draft time: that week is skipped, never run late
const coaches = store.coaches().map(m => ({ address: m.address, username: m.username, since: store.firstPositionAt(m.address) }));
const stand = draft.standings(coaches, store.picks(), w.week, w.prevWeek);
const pl = await pool(now);
const d = draft.newDraft({ week: w.week, at: now, rounds: C.draft.rounds, order: stand.map(s => s.address), standings: stand.map(s => ({ address: s.address, username: s.username, lastWeek: s.lastWeek, lifetime: s.lifetime })), poolSize: pl.length });
d.poolIds = pl.map(c => c.id);
store.putDraft(d);
console.log('draft: week', w.week, 'started with', stand.length, 'coaches,', pl.length, 'in the pool');
return d;
}
async function advance(d, now) {
if (!d || d.status !== 'live') return d;
await candidates(now);
const was = d.status;
await draft.run(d, ctx(d, now), act => makePick(act.coach, act.person, 'draft', { slot: draft.slotLabel(act.slot), round: act.slot.round, auto: act.type === 'auto' }, now), now);
store.putDraft(d);
if (was === 'live' && d.status === 'done') {
const rows = d.made.filter(x => x.person).map(x => ({ slot: x.slot, coach: nameOf(x.coach), person: (store.pick(x.pickId) || {}).personName || null }));
const w = weekInfo(now);
proof && proof.draftDay(d, rows, { players: rows.length, coaches: d.order.length, potWei: proof.potOf(w.from, w.to) }).catch(() => {});
}
return d;
}
async function tick() {
return lock(async () => {
const now = clock.now();
const s = await sweep(now).catch(e => { console.error('sweep', e.message); return { changed: 0 }; });
let d = await ensureDraft(now).catch(e => { console.error('draft create', e.message); return null; });
d = await advance(d, now).catch(e => { console.error('draft run', e.message); return d; });
return { swept: s.changed, draft: d ? { week: d.week, status: d.status, made: d.made.length } : null };
});
}
// a coach on the clock picks by hand
async function manualPick(coach, person) {
return lock(async () => {
const now = clock.now(); const d = store.draft(weekInfo(now).week);
if (!d || d.status !== 'live') return { error: 'The draft is not live right now.' };
await candidates(now);
const act = draft.manual(d, coach, person, ctx(d, now), now); if (act.error) return act;
const res = await makePick(coach, person, 'draft', { slot: draft.slotLabel(act.slot), round: act.slot.round, auto: false }, now);
draft.record(d, act, res, now); store.putDraft(d);
if (res.error) return res;
await advance(d, now);
return { ok: true, pickId: res.pickId };
});
}
// instant picks: 5 per position, from the current pool, any time outside a live draft
async function instantPick(coach, person) {
return lock(async () => {
const now = clock.now(); const d = store.draft(weekInfo(now).week);
if (d && d.status === 'live') return { error: 'The draft is live. Instant picks open again when it ends.' };
if (store.credits(coach) < 1) return { error: 'You have no instant picks left. Your next picks come in the Monday draft.' };
if (openCount(coach) >= C.picks.maxOpen) return { error: 'Your team is full (' + C.picks.maxOpen + ' open picks). Help one get started first.' };
const pl = await pool(now); if (!pl.some(c => c.id === person)) return { error: 'That player is no longer available.' };
const res = await makePick(coach, person, 'instant', {}, now); if (res.error) return res;
store.addCredits(coach, -1);
return { ok: true, pickId: res.pickId, credits: store.credits(coach) };
});
}
async function release(coach, pickId) {
return lock(async () => {
const now = clock.now(); const p = store.pick(pickId);
if (!p || p.coach !== coach) return { error: 'Not your pick.' };
const why = draft.canRelease(p, rules(), now); if (why) return { error: why };
const r = await tank.release({ coach, person: p.person, why: 'released by the coach' }); if (!r || !r.ok) return { error: (r && r.error) || 'The holding tank did not answer.' };
p.status = 'returned'; p.releasedAt = now; p.released = true; store.savePick(p); candsAt = 0;
return { ok: true };
});
}
module.exports = { init, clock, tick, sweep, ensureDraft, advance, manualPick, instantPick, release, pool, candidates, weekInfo, rules, openCount, nameOf };
+63
View File
@@ -0,0 +1,63 @@
// The network sites list for the footer's "Part of the network" line (Marty 2026-11-14 trust pack).
// One source: the hub's public GET /v1/network-sites (HUB_URL). Cached 10 minutes, refreshed in the background, never waits on a
// slow hub (2.5 s timeout), and falls back to the same built-in list. Never RM Circle, never the games.
// The same file lives in every network site (InstantAdPay, LinkSpin, Downline Banners, VBB, ViralAdBlitz, 5xYourTeam, Stack POL).
// 5xYourTeam: its 'fivex' entry and the LinkSpin code nw5x are local until the hub list and LinkSpin netlinks.js add them (phase 2).
const FALLBACK = [
{ id: 'iap', name: 'InstantAdPay', url: 'https://instantadpay.com' },
{ id: 'linkspin', name: 'LinkSpin', url: 'https://linkspin.app' },
{ id: 'dlb', name: 'Downline Banners', url: 'https://downlinebanners.com' },
{ id: 'vbb', name: 'Viral Banner Blitz', url: 'https://viralbannerblitz.com' },
{ id: 'viraladblitz', name: 'ViralAdBlitz', url: 'https://viraladblitz.com' },
{ id: 'fivex', name: '5xYourTeam', url: 'https://5xyourteam.com' },
{ id: 'stackpol', name: 'Stack POL', url: 'https://stackpol.com' },
{ id: 'earnerscorner', name: 'Earners Corner', url: 'https://earnerscorner.com' }
];
const TTL = 10 * 60 * 1000;
let cache = { at: 0, list: FALLBACK, from: 'fallback' };
let inflight = null;
const hubUrl = () => String(process.env.HUB_URL || 'https://hub.saasy.top').trim().replace(/\/+$/, '');
function clean(list) {
if (!Array.isArray(list)) return null;
const ok = list.filter(s => s && typeof s.name === 'string' && /^https:\/\/[a-z0-9.-]+(\/[^\s"'<>]*)?$/i.test(String(s.url || '')))
.slice(0, 30).map(s => ({ id: String(s.id || s.name).toLowerCase().replace(/[^a-z0-9]+/g, '').slice(0, 30), name: String(s.name).slice(0, 60), url: String(s.url).replace(/\/+$/, '') }));
return ok.length ? ok : null;
}
function refresh() {
if (inflight || process.env.NETWORK_SITES_HUB === '0') return inflight;
const ac = new AbortController(); const t = setTimeout(() => ac.abort(), 2500);
inflight = fetch(hubUrl() + '/v1/network-sites', { signal: ac.signal })
.then(r => (r.ok ? r.json() : null))
.then(j => { const l = clean(j); if (l) cache = { at: Date.now(), list: l, from: 'hub' }; else cache.at = Date.now(); })
.catch(() => { cache.at = Date.now() - TTL + 60 * 1000; }) // hub down: try again in a minute, keep the last good list
.finally(() => { clearTimeout(t); inflight = null; });
return inflight;
}
function list() { if (Date.now() - cache.at > TTL) refresh(); return cache.list; }
// Tracked links (Marty 2026-11-14: "make sure each of these sites is its own traffic source and link spun so we can track it"): each
// entry also gets go = the LinkSpin network link for that site with ?src=<this site>, so a click shows in LinkSpin Reports under the
// site that sent it (LinkSpin netlinks.js: fixed codes on the admin account). This site = NETWORK_SITE_ID, else the request host.
// No go for this site itself, or when this site cannot be told (a test host): the page then uses the plain url.
const CODES = { iap: 'nwiap', linkspin: 'nwls', dlb: 'nwdlb', vbb: 'nwvbb', viraladblitz: 'nwvab', fivex: 'nw5x', stackpol: 'nwsp', earnerscorner: 'nwec' };
const linksBase = () => String(process.env.NETWORK_LINKS_BASE || 'https://linkspin.app').trim().replace(/\/+$/, '');
const hostOf = u => { try { return new URL(u).hostname.toLowerCase().replace(/^www\./, ''); } catch (e) { return ''; } };
function selfId(req, l) {
const env = String(process.env.NETWORK_SITE_ID || '').trim().toLowerCase(); if (env) return env;
const h = String((req && req.headers && (req.headers['x-forwarded-host'] || req.headers.host)) || '').split(',')[0].trim().toLowerCase().replace(/:\d+$/, '').replace(/^www\./, '');
const m = h && (l || list()).find(s => hostOf(s.url) === h); return m ? m.id : '';
}
// the LinkSpin-tracked link to site `id` sent from site `from` (from = id: the site's own promo kit); extra = { s1: member username, s2: one path segment }
function tracked(id, from, extra) {
const code = CODES[id]; if (!code || !from) return '';
const q = new URLSearchParams({ src: from }); for (const [k, v] of Object.entries(extra || {})) if (v) q.set(k, String(v));
return linksBase() + '/r/' + code + '?' + q.toString();
}
function withGo(l, me) { return l.map(s => { const go = me && s.id !== me ? tracked(s.id, me) : ''; return go ? Object.assign({}, s, { go }) : s; }); }
// GET /api/network-sites: public, cacheable, the same answer on every page
function handle(req, res) {
const l = list();
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'public, max-age=300', 'X-Content-Type-Options': 'nosniff' });
res.end(JSON.stringify(withGo(l, selfId(req, l))));
}
module.exports = { list, handle, refresh, tracked, selfId, withGo, CODES, FALLBACK, _state: () => cache };
+230
View File
@@ -0,0 +1,230 @@
// Network sign-in between InstantAdPay and LinkSpin (Marty approved 2026-11-12). The SAME file ships in both repos; each
// server calls init({ self, peer, peerBase, ... hooks }) and hands every request to handle() before its own routes.
//
// One flow, used two ways. R = the site the member is going TO (receiver), P = the site they are signed in on (provider).
// 1. R GET /sso/start?mode=go|check&to=/path R makes a random state, keeps it in a 5-minute HttpOnly cookie (nsso.st),
// sets the loop guard (nsso.tried, 30 minutes) and sends the browser to P.
// 2. P GET /sso/check?st=<state>&to=/path P looks at its OWN member session (never the admin portal). Signed in:
// P mints a token bound to R, the state and the email, and sends the browser
// to R /sso/in?t=<token>. Not signed in: R /sso/in?none=1&to=/path.
// 3. R GET /sso/in?t=<token> R checks signature, audience, expiry (60 s), the state against its cookie
// (so nobody can push their own token into someone else's browser), and spends
// the nonce (a second use is refused). The email must already be a member
// here; then R makes an ordinary session and redirects to the relative path.
// Outbound links: P GET /go/<peer>?to=/path is the hop a signed-in member's cross-site link points at. Signed out (or the
// secret not set), it is a plain redirect to the other site, so it is always safe to link through.
// Silent check: R's sign-in page calls GET /api/sso/status; { check: true } means "bounce once through P". The guard cookie
// stops a second bounce for 30 minutes, signing out sets nsso.off (12 hours, cleared by the next deliberate cross-site link),
// bots and non-page fetches never bounce.
// Token: "v1.<base64url JSON>.<base64url HMAC-SHA256(NETWORK_SSO_SECRET, 'nsso.v1.' + JSON part)>", JSON = { iss, aud, email,
// st, to, iat, exp, n[, wallet, name] }. The token grants a plain member session and nothing else: no wallet action, payout or purchase rides on it.
//
// Wallet sites (Downline Banners, 2026-11-13, Marty: "sign in once and be logged into all these sites"). Downline Banners has no email
// accounts; its members are wallets. IAP and LinkSpin list it under `wallets: { bannerline: base }` and vouch one way: /go/bannerline
// and /sso/check?r=bannerline mint a token that also carries the member's wallet (the one they signed in with, else the main wallet
// their account linked by signature) and username. Downline Banners runs this file with `from: { iap, linkspin }`, accepts a token from
// either, and makes a session for that wallet. /sso/start?via=<site> picks which site to ask; old copies ignore the new parameters.
'use strict';
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const SECRET = () => String(process.env.NETWORK_SSO_SECRET || '').trim();
const enabled = () => SECRET().length >= 32;
const TTL = 60 * 1000; // token life
const SKEW = 30 * 1000; // clock skew allowed between the two servers
const STATE_AGE = 300; // seconds: the state cookie
const GO_STATE_AGE = 1200; // seconds: the state cookie on a deliberate tap (time to sign in on the provider first, 2026-11-14)
const BACK_AGE = 1200; // seconds: the provider remembers an unfinished deliberate check while the member signs in
const TRIED_AGE = 1800; // seconds: one silent check per browser per 30 minutes
const OFF_AGE = 12 * 3600; // seconds: no silent check after a sign-out on this site
const HINT_AGE = 300; // seconds: the email prefill when the member is not here yet
const NAMES = { iap: 'InstantAdPay', linkspin: 'LinkSpin', bannerline: 'Downline Banners', vbb: 'Viral Banner Blitz', viraladblitz: 'ViralAdBlitz', fivex: '5xYourTeam' }; // vbb = Viral Banner Blitz, a wallet site like Downline Banners (2026-11-14); viraladblitz = ViralAdBlitz, a wallet site like VBB (2026-11-15)
const WALLET_RE = /^0x[0-9a-f]{40}$/;
let C = null; // { self, peer, peerBase(), isProd, dataDir, db, member(req), accept(email, req, v), signIn(email, req, v), landing(to), signinPath(to), defaultPath,
// wallets?: { site: base() } + wallet(session) -> { address, name }, from?: { site: base() } }
const b64u = buf => Buffer.from(buf).toString('base64').replace(/=+$/, '').replace(/\+/g, '-').replace(/\//g, '_');
const unb64u = s => Buffer.from(String(s).replace(/-/g, '+').replace(/_/g, '/'), 'base64');
const mac = s => crypto.createHmac('sha256', SECRET()).update('nsso.v1.' + s).digest();
const mask = e => String(e || '').replace(/^(.).*(@.*)$/, '$1***$2');
const log = (what, email, extra) => console.log('network-sso', what, email ? mask(email) : '-', extra || '');
// a same-site relative path, or the default. No scheme, no host, no protocol-relative //x, no backslashes, no control characters.
function safePath(to, dflt) {
const d = dflt == null ? '/' : dflt;
const s = String(to == null ? '' : to);
if (!s || s.length > 600 || s[0] !== '/' || s[1] === '/' || s[1] === '\\' || /[\\\u0000-\u001f\u007f\s]/.test(s)) return d;
try { const x = new URL(s, 'http://x.invalid'); if (x.host !== 'x.invalid' || x.protocol !== 'http:') return d; return x.pathname + x.search + x.hash; } catch (e) { return d; }
}
function mint(o) {
const now = o.now || Date.now();
const t = { iss: o.iss, aud: o.aud, email: String(o.email || '').trim().toLowerCase(), st: o.st, to: safePath(o.to), iat: now, exp: now + TTL, n: crypto.randomBytes(16).toString('hex') };
if (o.wallet) t.wallet = String(o.wallet).toLowerCase();
if (o.name) t.name = String(o.name).slice(0, 40);
const body = b64u(JSON.stringify(t));
return 'v1.' + body + '.' + b64u(mac(body));
}
// -> { ok, email, to, n, exp } or { error: reason }
function verify(tok, o) {
if (!enabled()) return { error: 'off' };
const m = /^v1\.([A-Za-z0-9_-]{20,2000})\.([A-Za-z0-9_-]{43})$/.exec(String(tok || ''));
if (!m) return { error: 'malformed' };
const want = mac(m[1]), got = unb64u(m[2]);
if (want.length !== got.length || !crypto.timingSafeEqual(want, got)) return { error: 'signature' };
let p; try { p = JSON.parse(unb64u(m[1]).toString('utf8')); } catch (e) { return { error: 'malformed' }; }
const now = (o && o.now) || Date.now();
if (!p || p.aud !== o.aud || ![].concat(o.iss).includes(p.iss)) return { error: 'audience' };
if (!(Number(p.exp) > now) || Number(p.iat) > now + SKEW || Number(p.exp) - Number(p.iat) > TTL) return { error: 'expired' };
if (!/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(String(p.email || ''))) return { error: 'email' };
if (!/^[a-f0-9]{32}$/.test(String(p.n || ''))) return { error: 'malformed' };
const st = String((o && o.st) || '');
if (!/^[a-f0-9]{32}$/.test(st) || !/^[a-f0-9]{32}$/.test(String(p.st || '')) || !crypto.timingSafeEqual(Buffer.from(st), Buffer.from(p.st))) return { error: 'state' };
if (p.wallet != null && !WALLET_RE.test(String(p.wallet))) return { error: 'wallet' };
const name = p.name != null && /^[A-Za-z0-9_.-]{1,40}$/.test(String(p.name)) ? String(p.name) : null;
return { ok: true, iss: p.iss, email: String(p.email).toLowerCase(), wallet: p.wallet || null, name, to: safePath(p.to), n: p.n, exp: Number(p.exp) };
}
// single use: true the first time a nonce is spent. MySQL when the site runs on it (two app copies during a deploy share it),
// else memory + a small file in DATA_DIR (survives a restart inside the 60-second window).
const used = new Map(); let fileLoaded = false, tableReady = null;
const FILE = () => C && C.dataDir ? path.join(C.dataDir, 'network-sso-nonces.json') : null;
function prune(now) { for (const [k, exp] of used) if (exp < now) used.delete(k); }
function loadFile() {
if (fileLoaded) return; fileLoaded = true;
try { const o = JSON.parse(fs.readFileSync(FILE(), 'utf8')); for (const k of Object.keys(o)) used.set(k, Number(o[k])); } catch (e) {}
}
function saveFile() { const f = FILE(); if (!f) return; try { fs.writeFileSync(f + '.tmp', JSON.stringify(Object.fromEntries(used))); fs.renameSync(f + '.tmp', f); } catch (e) { console.error('network-sso nonce save', e.message); } }
async function spend(n, exp) {
const now = Date.now(); loadFile(); prune(now);
if (used.has(n)) return false;
used.set(n, Number(exp) + SKEW); saveFile();
const db = C && C.db;
if (db && db.enabled && db.enabled()) {
try {
if (!tableReady) tableReady = db.q('CREATE TABLE IF NOT EXISTS network_sso_nonces (n VARCHAR(40) PRIMARY KEY, exp BIGINT NOT NULL) ENGINE=InnoDB').catch(e => { tableReady = null; throw e; });
await tableReady;
await db.q('INSERT INTO network_sso_nonces (n, exp) VALUES (?, ?)', [n, Number(exp) + SKEW]);
if (Math.random() < 0.05) db.q('DELETE FROM network_sso_nonces WHERE exp < ?', [now]).catch(() => {});
} catch (e) { if (/duplicate/i.test(e.message || '') || e.code === 'ER_DUP_ENTRY') return false; console.error('network-sso nonce db', e.message); return false; } // fail closed
}
return true;
}
// crawlers, link previews and headless browsers never bounce
const BOT_RE = /bot|crawl|spider|slurp|preview|facebookexternalhit|embedly|quora link|whatsapp|telegram|discord|skype|curl|wget|python|httpclient|headless|lighthouse|pingdom|monitor|go-http|java\/|okhttp|axios|node-fetch|undici/i;
const isBot = req => { const ua = String(req.headers['user-agent'] || ''); return !ua || BOT_RE.test(ua); };
// only a real top-level page load may start a bounce (sec-fetch-dest is sent by every current browser)
const notPage = req => { const d = req.headers['sec-fetch-dest']; return !!d && d !== 'document'; };
function cookies(req) {
const out = {};
for (const p of String(req.headers.cookie || '').split(';')) { const i = p.indexOf('='); if (i > 0) { try { out[p.slice(0, i).trim()] = decodeURIComponent(p.slice(i + 1).trim()); } catch (e) {} } }
return out;
}
const ck = (k, v, age, httpOnly) => k + '=' + encodeURIComponent(v) + '; Path=/; SameSite=Lax; Max-Age=' + age + (httpOnly ? '; HttpOnly' : '') + (C && C.isProd ? '; Secure' : '');
const go = (res, loc, set) => { const h = { Location: loc, 'Cache-Control': 'no-store', 'Referrer-Policy': 'no-referrer', 'X-Robots-Tag': 'noindex' }; if (set && set.length) h['Set-Cookie'] = set; res.writeHead(302, h); res.end(); return true; };
const sendJson = (res, obj, set) => { const h = { 'Content-Type': 'application/json', 'Cache-Control': 'no-store' }; if (set && set.length) h['Set-Cookie'] = set; res.writeHead(200, h); res.end(JSON.stringify(obj)); return true; };
function init(opts) { C = Object.assign({ defaultPath: '/' }, opts); fileLoaded = false; used.clear(); }
// the cookie a sign-out adds: no silent check on this site for 12 hours (a deliberate cross-site link still signs in)
const offCookie = () => ck('nsso.off', '1', OFF_AGE, true);
// -> true when the request was one of ours and has been answered
async function handle(req, res, u) {
if (!C || req.method !== 'GET') return false;
const p = u.pathname;
const peerName = NAMES[C.peer] || C.peer;
const goTo = p.startsWith('/go/') ? p.slice(4) : '';
const walletBase = x => (C.wallets && Object.prototype.hasOwnProperty.call(C.wallets, x) ? C.wallets[x] : null);
if (goTo && (goTo === C.peer || walletBase(goTo))) {
const base = goTo === C.peer ? C.peerBase() : walletBase(goTo)();
const to = safePath(u.searchParams.get('to'), '/');
const plain = base + to;
if (!enabled() || isBot(req)) return go(res, plain);
let s = null; try { s = await C.member(req); } catch (e) {}
if (!s || !s.email) return go(res, plain);
if (goTo !== C.peer) { let w = null; try { w = await C.wallet(s); } catch (e) {} if (!w || !w.address) return go(res, plain); } // no wallet to vouch for: a plain link
return go(res, base + '/sso/start?mode=go' + (goTo === C.peer ? '' : '&via=' + C.self) + '&to=' + encodeURIComponent(to));
}
if (p === '/sso/start') {
const to = safePath(u.searchParams.get('to'), C.defaultPath);
const mode = u.searchParams.get('mode') === 'go' ? 'go' : 'check';
const via = String(u.searchParams.get('via') || '');
const from = C.from && Object.prototype.hasOwnProperty.call(C.from, via) ? C.from[via] : null; // a wallet site may ask either provider
if (!enabled() || isBot(req) || notPage(req)) return go(res, to);
let s = null; try { s = await C.member(req); } catch (e) {}
if (s && (s.email || s.address)) return go(res, to); // already signed in here
const c = cookies(req);
if (mode === 'check' && (c['nsso.tried'] || c['nsso.off'])) return go(res, to);
const st = crypto.randomBytes(16).toString('hex');
const set = [ck('nsso.st', st, mode === 'go' ? GO_STATE_AGE : STATE_AGE, true), ck('nsso.tried', '1', TRIED_AGE, true)];
if (mode === 'go' && c['nsso.off']) set.push(ck('nsso.off', '', 0, true));
return go(res, (from ? from() : C.peerBase()) + '/sso/check?st=' + st + (C.from ? '&r=' + C.self : '') + '&to=' + encodeURIComponent(to) + (mode === 'go' ? '&m=go' : ''), set);
}
if (p === '/sso/resume') { // signed in on the provider after a deliberate tap: finish the check it was asked for (2026-11-14)
const q = new URLSearchParams(cookies(req)['nsso.back'] || '');
const clear = [ck('nsso.back', '', 0, true)];
if (!/^[a-f0-9]{32}$/.test(q.get('st') || '')) return go(res, C.defaultPath, clear);
return go(res, '/sso/check?st=' + q.get('st') + (q.get('r') ? '&r=' + encodeURIComponent(q.get('r')) : '') + '&to=' + encodeURIComponent(safePath(q.get('to'), '/')), clear);
}
if (p === '/sso/check') {
const st = String(u.searchParams.get('st') || '');
const to = safePath(u.searchParams.get('to'), '/');
const r = String(u.searchParams.get('r') || '');
const wb = r && r !== C.peer ? walletBase(r) : null; // a wallet site asking: the token carries the wallet
const base = wb ? wb() : C.peerBase(), aud = wb ? r : C.peer, forName = NAMES[aud] || aud;
const none = base + '/sso/in?none=1&to=' + encodeURIComponent(to);
if (!enabled() || !/^[a-f0-9]{32}$/.test(st)) return go(res, none);
let s = null; try { s = await C.member(req); } catch (e) {}
if (!s || !s.email) {
if (u.searchParams.get('m') === 'go' && !isBot(req)) { // a deliberate tap: sign in here first, then /sso/resume finishes the trip
log('check: not signed in here, asking to sign in', null, 'for ' + forName);
const back = new URLSearchParams({ st, to }); if (r) back.set('r', r);
return go(res, C.signinPath(C.defaultPath), [ck('nsso.back', back.toString(), BACK_AGE, true)]);
}
log('check: not signed in here', null, 'for ' + forName); return go(res, none);
}
let w = null;
if (wb) { try { w = await C.wallet(s); } catch (e) {} if (!w || !WALLET_RE.test(String(w.address || '').toLowerCase())) { log('check: no wallet on the account', s.email, 'for ' + forName); return go(res, none); } }
log('token issued', s.email, 'for ' + forName);
return go(res, base + '/sso/in?t=' + mint({ iss: C.self, aud, email: s.email, wallet: w && w.address, name: w && w.name, st, to }));
}
if (p === '/sso/in') {
const c = cookies(req);
const set = [ck('nsso.st', '', 0, true)];
if (u.searchParams.get('none')) { log('none: not signed in on ' + peerName); return go(res, C.signinPath(safePath(u.searchParams.get('to'), C.defaultPath)), set); }
const v = verify(u.searchParams.get('t'), { iss: [C.peer].concat(Object.keys(C.from || {})), aud: C.self, st: c['nsso.st'] });
if (v.error) { log('refused: ' + v.error); return go(res, C.signinPath(C.defaultPath), set); }
if (!(await spend(v.n, v.exp))) { log('refused: token already used', v.email); return go(res, C.signinPath(v.to), set); }
let a = null; try { a = await C.accept(v.email, req, v); } catch (e) { a = { fallback: 'error ' + e.message }; }
if (!a || !a.ok) { // not a member here yet (or not allowed to sign in): the normal email-code sign-in, email filled in
log('fallback to email code: ' + ((a && a.fallback) || 'not accepted'), v.email);
set.push(ck('nsso.hint', v.email, HINT_AGE, true));
return go(res, C.signinPath(v.to), set);
}
let cookie = null; try { cookie = await C.signIn(v.email, req, v); } catch (e) { console.error('network-sso sign-in', e.message); }
if (!cookie) { log('fallback to email code: session not made', v.email); return go(res, C.signinPath(v.to), set); }
set.push(cookie); if (c['nsso.off']) set.push(ck('nsso.off', '', 0, true));
log('signed in from ' + (NAMES[v.iss] || peerName), v.email);
return go(res, C.landing(v.to === '/' ? C.defaultPath : v.to), set); // no page named: the dashboard, not the public home page (2026-11-13)
}
if (p === '/api/sso/status') {
const c = cookies(req); const set = [];
let s = null; try { s = await C.member(req); } catch (e) {}
const signedIn = !!(s && (s.email || s.address));
const out = { peer: peerName, check: enabled() && !signedIn && !isBot(req) && !c['nsso.tried'] && !c['nsso.off'] };
if (c['nsso.hint']) { if (!signedIn) out.hint = c['nsso.hint']; set.push(ck('nsso.hint', '', 0, true)); }
return sendJson(res, out, set);
}
return false;
}
// true when this browser came here from a deliberate network tap and still has to finish it after signing in
const pendingBack = req => !!cookies(req)['nsso.back'];
module.exports = { init, handle, enabled, pendingBack, mint, verify, spend, safePath, isBot, offCookie, mask, TTL, NAMES };
+240
View File
@@ -0,0 +1,240 @@
{
"name": "5xyourteam",
"version": "0.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "5xyourteam",
"version": "0.1.0",
"dependencies": {
"ethers": "^6.13.0",
"mysql2": "^3.11.0"
},
"engines": {
"node": ">=20"
}
},
"node_modules/@adraffy/ens-normalize": {
"version": "1.11.1",
"resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.11.1.tgz",
"integrity": "sha512-nhCBV3quEgesuf7c7KYfperqSS14T8bYuvJ8PcLJp6znkZpFc0AuW4qBtr8eKVyPPe/8RSr7sglCWPU5eaxwKQ==",
"license": "MIT"
},
"node_modules/@noble/curves": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz",
"integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==",
"license": "MIT",
"dependencies": {
"@noble/hashes": "1.3.2"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@noble/hashes": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz",
"integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==",
"license": "MIT",
"engines": {
"node": ">= 16"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@types/node": {
"version": "22.7.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.5.tgz",
"integrity": "sha512-jML7s2NAzMWc//QSJ1a3prpk78cOPchGvXJsC3C6R6PSMoooztvRVQEz89gmBTBY1SPMaqo5teB4uNHPdetShQ==",
"license": "MIT",
"dependencies": {
"undici-types": "~6.19.2"
}
},
"node_modules/aes-js": {
"version": "4.0.0-beta.5",
"resolved": "https://registry.npmjs.org/aes-js/-/aes-js-4.0.0-beta.5.tgz",
"integrity": "sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q==",
"license": "MIT"
},
"node_modules/aws-ssl-profiles": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/aws-ssl-profiles/-/aws-ssl-profiles-1.1.2.tgz",
"integrity": "sha512-NZKeq9AfyQvEeNlN0zSYAaWrmBffJh3IELMZfRpJVWgrpEbtEpnjvzqBPf+mxoI287JohRDoa+/nsfqqiZmF6g==",
"license": "MIT",
"engines": {
"node": ">= 6.0.0"
}
},
"node_modules/ethers": {
"version": "6.17.0",
"resolved": "https://registry.npmjs.org/ethers/-/ethers-6.17.0.tgz",
"integrity": "sha512-BpyrpIPJ3ydEVow8zGaz1DuPS7YU8DcWxuBnY9a0UA/lvAPwrMr+EPXsfrul628SRaekPNeIM4UFh/91GWZang==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/ethers-io/"
},
{
"type": "individual",
"url": "https://www.buymeacoffee.com/ricmoo"
}
],
"license": "MIT",
"dependencies": {
"@adraffy/ens-normalize": "1.11.1",
"@noble/curves": "1.2.0",
"@noble/hashes": "1.3.2",
"@types/node": "22.7.5",
"aes-js": "4.0.0-beta.5",
"tslib": "2.7.0",
"ws": "8.21.0"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/generate-function": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.3.1.tgz",
"integrity": "sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ==",
"license": "MIT",
"dependencies": {
"is-property": "^1.0.2"
}
},
"node_modules/iconv-lite": {
"version": "0.7.3",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz",
"integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==",
"license": "MIT",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3.0.0"
},
"engines": {
"node": ">=0.10.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/is-property": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz",
"integrity": "sha512-Ks/IoX00TtClbGQr4TWXemAnktAQvYB7HzcCxDGqEZU6oCmb2INHuOoKxbtR+HFkmYWBKv/dOZtGRiAjDhj92g==",
"license": "MIT"
},
"node_modules/long": {
"version": "5.3.2",
"resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz",
"integrity": "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==",
"license": "Apache-2.0"
},
"node_modules/lru.min": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/lru.min/-/lru.min-1.1.5.tgz",
"integrity": "sha512-5J9ysMYUpYIg9RF2vJpy9SinEmSviFSe0GyPpCQ4L5QSkLAgeLXlTAOu2ZwWUU5m+0SBl6gUU1R1ZQB3aKypfA==",
"license": "MIT",
"engines": {
"bun": ">=1.0.0",
"deno": ">=1.30.0",
"node": ">=8.0.0"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wellwelwel"
}
},
"node_modules/mysql2": {
"version": "3.24.6",
"resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.24.6.tgz",
"integrity": "sha512-enu73KhbAua2L3dIxjc6qg6ZJ7H3pt1BImZASWNWY5xSsmJ1ZuUPULTDGXgmJbI61vb+nJAG19IZclIq19UidQ==",
"license": "MIT",
"dependencies": {
"aws-ssl-profiles": "^1.1.2",
"generate-function": "^2.3.1",
"iconv-lite": "^0.7.3",
"long": "^5.3.2",
"lru.min": "^1.1.4",
"named-placeholders": "^1.1.6",
"sql-escaper": "^1.5.1"
},
"engines": {
"node": ">= 8.0"
},
"peerDependencies": {
"@types/node": ">= 8"
}
},
"node_modules/named-placeholders": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/named-placeholders/-/named-placeholders-1.1.6.tgz",
"integrity": "sha512-Tz09sEL2EEuv5fFowm419c1+a/jSMiBjI9gHxVLrVdbUkkNUUfjsVYs9pVZu5oCon/kmRh9TfLEObFtkVxmY0w==",
"license": "MIT",
"dependencies": {
"lru.min": "^1.1.0"
},
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"license": "MIT"
},
"node_modules/sql-escaper": {
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/sql-escaper/-/sql-escaper-1.5.2.tgz",
"integrity": "sha512-6CKD38c31SENivxOADeMNLdukOnUxUcflKtzVWzace7Riv1v7cAEym5Cx9Q7gYZ3ezIJI7ZpqecQq8cqNeSSFg==",
"license": "MIT",
"engines": {
"bun": ">=1.0.0",
"deno": ">=2.0.0",
"node": ">=12.0.0"
},
"funding": {
"type": "github",
"url": "https://github.com/mysqljs/sql-escaper?sponsor=1"
}
},
"node_modules/tslib": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz",
"integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==",
"license": "0BSD"
},
"node_modules/undici-types": {
"version": "6.19.8",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz",
"integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==",
"license": "MIT"
},
"node_modules/ws": {
"version": "8.21.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.21.0.tgz",
"integrity": "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==",
"license": "MIT",
"engines": {
"node": ">=10.0.0"
},
"peerDependencies": {
"bufferutil": "^4.0.1",
"utf-8-validate": ">=5.0.2"
},
"peerDependenciesMeta": {
"bufferutil": {
"optional": true
},
"utf-8-validate": {
"optional": true
}
}
}
}
}
+17
View File
@@ -0,0 +1,17 @@
{
"name": "5xyourteam",
"version": "0.1.0",
"private": true,
"description": "5xYourTeam (5xyourteam.com rebuild): The Draft. A $10 one-time position = 5 picks right away + a draft spot every week; coaches draft people waiting in the network holding tank every Monday, draft order earned by last week's started picks. DraftPosition split on-chain: sponsor 25%, levels 2-5 5% each, 10% Best Coach pot, 45% company.",
"main": "server.js",
"scripts": {
"start": "node server.js",
"test": "node qa/unit.test.cjs",
"qa": "node qa/smoke.mjs"
},
"engines": { "node": ">=20" },
"dependencies": {
"ethers": "^6.13.0",
"mysql2": "^3.11.0"
}
}
+99
View File
@@ -0,0 +1,99 @@
// Promo kit (the VBB / ViralAdBlitz pattern): the ONE place the 5xYourTeam creatives and swipe copy live. Published as a public JSON
// feed, GET /api/promo-kit?u=<network username or wallet>, read by /promote and by InstantAdPay's promo center ("Network sites").
// Facts come from config.js (position price, picks on buy, split). Copy rules: a position buys a seat in the draft, not income;
// nothing is promised; no em dashes; no earnings caps; wallets = "SafePal or any other crypto wallet"; never a subscription.
// Creatives: public/art/kit/fx-<angle>-<shape>.png, rendered by tools/art.mjs (neutral names: no size tokens, no ad words).
'use strict';
const fs = require('fs');
const path = require('path');
const C = require('./config').get();
const netsites = require('./netsites');
const KIT_DIR = path.join(__dirname, 'public', 'art', 'kit');
const SHAPES = { tile: [125, 125, 'Square button'], strip: [468, 60, 'Strip'], leader: [728, 90, 'Leaderboard'], box: [300, 250, 'Box'],
tower: [160, 600, 'Skyscraper'], social: [1200, 630, 'Social share'], square: [1080, 1080, 'Square post'] };
const ANGLES = { draft: 'The weekly draft', coach: 'Coach your picks', cards: 'Trading cards that level up' };
function copy() {
const p = C.position;
const seat = '$' + p.usd + ' one-time position gives you ' + p.picksOnBuy + ' picks right away and a draft spot every week';
return {
lines: [
'Every Monday the coaches on 5xYourTeam draft people who joined the network without a sponsor. A ' + seat + '. {{LINK}}',
'Draft order is earned: help last week\'s picks get started and you pick first next Monday. {{LINK}}',
'Your picks show up as trading cards that level up as they do: Rookie, Starter, Pro, All-Star, Hall of Fame. {{LINK}}',
'You get the right to sponsor and help, never anyone\'s contact details. Coaching happens in site messages. {{LINK}}',
'One payment in POL with SafePal or any other crypto wallet, never a subscription, split on-chain in the same transaction. {{LINK}}'
],
headlines: ['Draft Your Team Every Monday', 'Coach Them Up, Pick First', 'Five Picks Today, More Every Week'],
email: {
subject: 'A weekly draft for people who need a sponsor',
body: [
'Hi,',
'',
'People join our network every day without a sponsor. On 5xYourTeam the coaches draft them, every Monday, in rounds.',
'',
'A ' + seat + '. The draft order is earned: the coaches who helped the most of last week\'s picks get started pick first.',
'',
'Each pick shows a scouting card (last seen, the door they came in through, wallet linked, games played where that is tracked) and you coach them through site messages. Nobody\'s email is ever shown or sold.',
'',
'It is paid once in POL with SafePal or any other crypto wallet, never a subscription, and split on-chain in the same transaction.',
'',
'A position buys a seat in the draft and coaching tools, not income. Nothing is promised.',
'',
'Here is my page:',
'{{LINK}}'
].join('\n')
},
posts: [
'I coach a team on 5xYourTeam. Every Monday we draft people who joined the network without a sponsor, and draft order is earned by helping your picks get started.\n\n{{LINK}}',
'My picks are trading cards that level up as they get going. Rookie today, Pro when payouts go on. A ' + seat + '.\n\n{{LINK}}'
]
};
}
const NOTE = 'A position buys a seat in the draft and coaching tools, not income. Nothing is promised.';
const REF_RE = /^(?:[A-Za-z0-9_.-]{2,40}|0x[0-9a-fA-F]{40})$/;
const base = () => 'https://' + C.site;
let files = null;
function creatives() {
if (files) return files;
let names = []; try { names = fs.readdirSync(KIT_DIR).filter(f => /^fx-[a-z]+-[a-z]+\.png$/.test(f)); } catch (e) {}
const out = [];
for (const angle of Object.keys(ANGLES)) for (const shape of Object.keys(SHAPES)) {
const f = 'fx-' + angle + '-' + shape + '.png'; if (!names.includes(f)) continue;
const [w, h, label] = SHAPES[shape];
out.push({ key: angle + '-' + shape, angle, angleLabel: ANGLES[angle], shape, label, w, h, url: base() + '/art/kit/' + f });
}
return (files = out);
}
function kit(u) {
const ref = REF_RE.test(String(u || '')) ? String(u) : '';
const link = ref && !/^0x/i.test(ref) ? base() + '/' + encodeURIComponent(ref) : base() + '/' + (ref ? '?ref=' + encodeURIComponent(ref) : '');
const q = ref ? '?ref=' + encodeURIComponent(ref) : '';
const fill = s => s.split('{{LINK}}').join(link);
const track = seg => netsites.tracked(C.siteId, C.siteId, { s1: ref, s2: seg });
const t = copy();
return {
v: 1, site: C.site, name: C.siteName, updated: '2026-11-15', username: ref || null,
tagline: 'The weekly draft for people who need a sponsor.',
links: [
{ key: 'page', label: 'Your coach page', url: link, tracked: track('') },
{ key: 'join', label: 'Get a position', url: base() + '/join' + q, tracked: track('join') },
{ key: 'ledger', label: 'Live ledger', url: base() + '/ledger' + q, tracked: track('ledger') }
],
linkTemplate: base() + '/{username}', trackedTemplate: netsites.tracked(C.siteId, C.siteId) + '&s1={username}',
creatives: creatives().map(c => Object.assign({}, c, { html: '<a href="' + link + '" target="_blank" rel="noopener"><img src="' + c.url + '" width="' + c.w + '" height="' + c.h + '" alt="5xYourTeam"></a>' })),
lines: t.lines.map(fill), headlines: t.headlines, email: { subject: t.email.subject, body: fill(t.email.body) }, posts: t.posts.map(fill),
note: NOTE, promotePage: base() + '/promote'
};
}
function handle(req, res, u, sendFile) {
if (u.pathname === '/promote' && (req.method === 'GET' || req.method === 'HEAD') && sendFile) { sendFile(res, path.join(__dirname, 'public', 'promote.html')); return true; }
if (u.pathname !== '/api/promo-kit') return false;
const cors = { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET', 'Access-Control-Allow-Headers': 'Content-Type' };
if (req.method === 'OPTIONS') { res.writeHead(204, cors); res.end(); return true; }
if (req.method !== 'GET' && req.method !== 'HEAD') return false;
res.writeHead(200, Object.assign({ 'Content-Type': 'application/json', 'Cache-Control': 'public, max-age=300', 'X-Content-Type-Options': 'nosniff' }, cors));
res.end(JSON.stringify(kit(u.searchParams.get('u')))); return true;
}
module.exports = { kit, handle, creatives, SHAPES, ANGLES, copy, NOTE };
+181
View File
@@ -0,0 +1,181 @@
// Trust pack (Marty 2026-11-14: live ledger, contract proof, toasts, a Telegram post per sale with an image + stats, payment
// notifications). The ViralAdBlitz / Downline Banners pattern, with the 5xYourTeam split:
// - ledger(): every position purchase (the Purchase events shop.js recorded) with its split read from the receipt: the sponsor
// share (level 1, 25%), levels 2-5 (5% each) with each person's place in the buyer's line, who was passed over, the Best Coach
// prize pot (10%), the company. Plus the Best Coach pot payouts recorded by the admin (tx hashes).
// - contract(): live facts for /contract (owner, company, prize wallet, keeper, paused, orders, what it holds), cached 5 minutes.
// - Telegram: (1) a sale card per purchase (a prebuilt 5xYourTeam proof image, rotated; the coach, every share paid in the same
// transaction with its POL, this week's numbers, the verify link); (2) the Draft Day card after each draft (results image +
// picks); (3) one line per Best Coach payout. PHASE 1: nothing is sent unless TG_LIVE=1 with TG_TOKEN + TG_CHAT; otherwise every
// post goes to the document tg-outbox.json (shown on /admin) so the wording can be checked. Once per key across app copies
// (in-process guard + docstore.claim), never a sale older than 2 hours. TG_API (tests) = a stand-in.
'use strict';
const fs = require('fs');
const path = require('path');
const store = require('./store');
const docstore = require('./docstore');
const SPLIT = { sponsorBps: 2500, levelBps: 500, potBps: 1000, denom: 10000, potLevel: 6 }; // DraftPosition constants
const CARDS = ['/art/proof/fx-proof-navy.png', '/art/proof/fx-proof-gold.png', '/art/proof/fx-proof-field.png']; // rotated per post
const st = { posted: 0, queued: 0, skipped: 0, failed: 0, lastError: null };
let C = null, shop = null, names = null, weekStats = () => ({});
const sent = new Set();
const once = k => { if (sent.has(k)) return false; sent.add(k); if (sent.size > 5000) sent.clear(); return true; };
function init(cfg, deps) { C = cfg; shop = deps.shop; names = deps.nameOf || null; if (deps.weekStats) weekStats = deps.weekStats; }
const live = () => process.env.TG_LIVE === '1' && !!(process.env.TG_TOKEN && process.env.TG_CHAT);
const lc = a => String(a || '').toLowerCase();
const short = a => a ? a.slice(0, 6) + '...' + a.slice(-4) : '';
function nameLocal(addr) { const m = store.member(lc(addr)); return m && m.username ? m.username : null; }
async function nameOf(addr) { const local = nameLocal(addr); if (local) return local; if (names) { try { const n = await names(lc(addr)); if (n) return n; } catch (e) {} } return null; }
const who = (addr, name) => name ? '@' + name : short(lc(addr));
const pol = wei => { const v = Number(BigInt(wei || 0) / 10n ** 12n) / 1e6; return v >= 100 ? v.toFixed(2) : v.toFixed(4); };
const usd = cents => '$' + (Number(cents || 0) / 100).toFixed(2);
const esc = s => String(s == null ? '' : s).replace(/[&<>]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;' }[c]));
const what = x => (Number(x.qty) > 1 ? x.qty + ' positions' : 'a position');
// the split of one order: from the receipt when read, else from the Purchase event (who got each level is then unknown)
function split(x) {
if (Array.isArray(x.pays) && x.pays.length) return x.pays;
let paid = 0n; try { paid = BigInt(x.weiPaid || 0); } catch (e) {}
const out = [];
for (let i = 1; i <= Number(x.levelsPaid || 0); i++) out.push({ level: i, depth: null, to: null, wei: (paid * BigInt(i === 1 ? SPLIT.sponsorBps : SPLIT.levelBps) / BigInt(SPLIT.denom)).toString() });
out.push({ level: SPLIT.potLevel, depth: 0, to: lc(C.prizeWallet), wei: String(x.prizePaid != null ? x.prizePaid : paid * BigInt(SPLIT.potBps) / BigInt(SPLIT.denom)) });
out.push({ level: 0, depth: 0, to: lc(C.companyWallet), wei: String(x.companyPaid || 0) });
return out;
}
// the contract's pass-up split as a pure model (preview + tests): line = [{ who, qualified }] nearest first, wei = POL kept.
// Mirrors DraftPosition._split exactly: first qualified 25%, next four 5%, within 20 places; pot 10%; company the remainder.
function model(line, wei) {
const W = BigInt(wei); const sp = W * BigInt(SPLIT.sponsorBps) / BigInt(SPLIT.denom), lv = W * BigInt(SPLIT.levelBps) / BigInt(SPLIT.denom), pot = W * BigInt(SPLIT.potBps) / BigInt(SPLIT.denom);
const pays = [], over = [], seen = new Set(); let total = 0n;
for (let i = 0; i < Math.min(line.length, 20) && pays.length < 5; i++) {
const x = line[i]; if (!x.qualified) { over.push({ who: x.who, depth: i + 1 }); continue; }
if (seen.has(x.who)) continue; seen.add(x.who);
const amt = pays.length === 0 ? sp : lv; pays.push({ level: pays.length + 1, depth: i + 1, to: x.who, wei: amt.toString() }); total += amt;
}
return { pays, over, pot: pot.toString(), company: (W - total - pot).toString() };
}
const label = p => p.level === 0 ? 'company' : p.level === SPLIT.potLevel ? 'pot' : p.level === 1 ? 'sponsor' : 'level ' + p.level;
// ---- public ledger ----
function rows() { return store.purchases().map(x => Object.assign({ tx: x.key.split(':')[0] }, x)); }
function ledger(n) {
const lim = Math.min(200, Math.max(1, Number(n) || 50));
const list = rows().map(x => ({ kind: 'position', tx: x.tx, at: (x.blockAt ? x.blockAt * 1000 : x.at) || null, orderId: x.orderId, buyer: x.buyer, buyerName: nameLocal(x.buyer), what: what(x), qty: x.qty,
usdCents: x.usdCents, weiPaid: x.weiPaid,
pays: split(x).map(p => ({ level: p.level, label: label(p), depth: p.depth, to: p.to, name: p.to ? nameLocal(p.to) : null, wei: p.wei, failed: p.failed || undefined })),
passedOver: (x.over || []).map(o => ({ depth: o.depth, name: nameLocal(o.who) || null, who: o.who })) })).sort((a, b) => (b.at || 0) - (a.at || 0));
let wei = 0n, pot = 0n, cents = 0, positions = 0;
for (const x of rows()) { positions += Number(x.qty) || 1; cents += Number(x.usdCents) || 0; try { wei += BigInt(x.weiPaid || 0); pot += BigInt(x.prizePaid || 0); } catch (e) {} }
const payouts = Object.entries(store.state().payouts || {}).flatMap(([week, l]) => l.map(p => Object.assign({ week }, p))).sort((a, b) => (b.at || 0) - (a.at || 0));
return { contract: C.contractAddress || null, explorer: C.explorer, prizeWallet: C.prizeWallet || null, items: list.slice(0, lim), payouts: payouts.slice(0, 50),
totals: { positions, orders: list.length, usdCents: cents, weiPaid: wei.toString(), potWei: pot.toString() } };
}
// the week's pot: 10% of every position sold that Central week (from the Purchase events)
function potOf(from, to) {
let w = 0n; for (const x of rows()) { const t = (x.blockAt ? x.blockAt * 1000 : x.at) || 0; if (t >= from && t < to) { try { w += BigInt(x.prizePaid || 0); } catch (e) {} } }
return w.toString();
}
// ---- contract facts (cached 5 minutes) ----
let cCache = null;
async function contract() {
if (cCache && Date.now() - cCache.at < 300000) return cCache.v;
const v = { address: C.contractAddress || null, chainId: C.chainId, explorer: C.explorer, split: C.split, position: { usd: C.position.usd },
verified: { sourcify: false, polygonscan: 'pending', sourcifyUrl: C.contractAddress ? 'https://repo.sourcify.dev/' + C.chainId + '/' + C.contractAddress : null },
ownerNote: "Marty's Tangem hardware wallet", prizeWallet: C.prizeWallet || null, live: false };
if (shop && shop.watching()) {
const { Interface } = require('ethers');
const I = new Interface(['function owner() view returns (address)', 'function company() view returns (address)', 'function prizeWallet() view returns (address)', 'function keeper() view returns (address)',
'function paused() view returns (bool)', 'function totalOwed() view returns (uint256)', 'function orderCount() view returns (uint256)', 'function priceCents() view returns (uint256)']);
const read = async fn => I.decodeFunctionResult(fn, await shop.rpc('eth_call', [{ to: C.contractAddress, data: I.encodeFunctionData(fn, []) }, 'latest']))[0];
try {
const [owner, company, prize, keeper, paused, totalOwed, orderCount, cents, bal] = await Promise.all(['owner', 'company', 'prizeWallet', 'keeper', 'paused', 'totalOwed', 'orderCount', 'priceCents'].map(read)
.concat([shop.rpc('eth_getBalance', [C.contractAddress, 'latest'])]));
Object.assign(v, { owner: lc(owner), company: lc(company), prizeWallet: lc(prize), keeper: lc(keeper), paused: !!paused, totalOwedWei: totalOwed.toString(), orderCount: Number(orderCount),
priceCents: Number(cents), balanceWei: BigInt(bal).toString(), live: true, readAt: Date.now() });
} catch (e) { v.error = 'The chain did not answer just now. Try again in a minute.'; }
}
cCache = { at: Date.now(), v };
if (v.error) cCache.at = Date.now() - 240000;
return v;
}
// ---- Telegram (phase 1: the outbox) ----
const OUTBOX = () => path.join(C.dataDir, 'tg-outbox.json');
function outbox() { try { return JSON.parse(fs.readFileSync(OUTBOX(), 'utf8')); } catch (e) { return []; } }
async function tg(method, body, key) {
if (!live()) {
const l = outbox(); l.push({ at: Date.now(), key, method, body }); fs.writeFileSync(OUTBOX(), JSON.stringify(l.slice(-100))); st.queued++; return true;
}
const base = String(process.env.TG_API || 'https://api.telegram.org').replace(/\/+$/, '');
const b = Object.assign({ chat_id: process.env.TG_CHAT, parse_mode: 'HTML' }, body);
if (process.env.TG_PAY_TOPIC) b.message_thread_id = Number(process.env.TG_PAY_TOPIC);
const r = await fetch(base + '/bot' + process.env.TG_TOKEN + '/' + method, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(b), signal: AbortSignal.timeout(15000) });
const j = await r.json().catch(() => ({}));
if (!j.ok) { st.failed++; st.lastError = String(j.description || r.status).slice(0, 160); console.error('proof: telegram', method, 'failed', r.status, st.lastError); return false; }
st.posted++; return true;
}
const photoUrl = p => (process.env.TG_PHOTO_BASE ? String(process.env.TG_PHOTO_BASE).replace(/\/+$/, '') : 'https://' + C.site) + p;
function weekLine() {
const w = weekStats();
return '\u{1F4CA} This week: ' + (w.positions || 0) + ' position' + (w.positions === 1 ? '' : 's') + ' · ' + (w.coaches || 0) + ' coaches · ' + (w.started || 0) + ' picks started · pot ' + pol(w.potWei || 0) + ' POL';
}
async function caption(x) {
const lines = ['\u{1F3C8} <b>5xYourTeam</b>', '\u{1F4DD} ' + esc(who(x.buyer, await nameOf(x.buyer))) + ' joined The Draft: ' + esc(what(x)) + ' · ' + usd(x.usdCents) + ' (' + pol(x.weiPaid) + ' POL)'];
const s = split(x); let levels = 0;
for (const p of s) {
if (p.level === 0) { lines.push('\u{1F3E6} 5xYourTeam: ' + pol(p.wei) + ' POL'); continue; }
if (p.level === SPLIT.potLevel) { lines.push('\u{1F3C6} Best Coach pot 10%: ' + pol(p.wei) + ' POL'); continue; }
levels++;
const where = p.depth && p.depth !== p.level ? ' (place ' + p.depth + ' in the line)' : '';
const pct = p.level === 1 ? 'Sponsor 25%' : 'Level ' + p.level + ' 5%';
if (p.failed) lines.push('⚠️ ' + pct + ' payment to ' + esc(who(p.to, await nameOf(p.to))) + ' bounced; it waits in the contract for them to claim');
else lines.push('\u{1F4B8} ' + pct + ': ' + pol(p.wei) + ' POL → ' + (p.to ? esc(who(p.to, await nameOf(p.to))) : 'sponsor') + where);
}
if (levels === 0) lines.push('Nobody in this line holds a position yet, so the level shares went to 5xYourTeam.');
if ((x.over || []).length) lines.push(x.over.length === 1 ? '1 person in the line holds no position yet and was passed over; their share went up the line.' : x.over.length + ' people in the line hold no position yet and were passed over; their shares went up the line.');
lines.push('Paid by the contract in this same transaction. It keeps nothing and there is nothing to withdraw.');
lines.push(weekLine());
lines.push('· <a href="' + esc(C.explorer) + '/tx/' + esc(x.tx) + '">Verify on Polygonscan</a> · <a href="https://' + esc(C.site) + '/ledger">Live ledger</a>');
return lines.join('\n');
}
let card = 0;
// shop.js calls this once per newly recorded purchase (rec = the stored purchase, tx = its transaction)
function onPurchase(rec, tx) {
const x = Object.assign({ tx }, rec);
(async () => {
try {
const sp = await shop.readSplit(tx, rec.orderId);
if (sp) { const S = store.state(); const k = Object.keys(S.purchases || {}).find(k2 => k2.startsWith(lc(tx) + ':') && S.purchases[k2].orderId === rec.orderId);
if (k) { Object.assign(S.purchases[k], { pays: sp.pays, over: sp.over, bound: sp.bound }); store.save(); } Object.assign(x, { pays: sp.pays, over: sp.over }); }
} catch (e) {}
const at = (rec.blockAt ? rec.blockAt * 1000 : rec.at) || Date.now();
if (Date.now() - at > 2 * 3600000) { st.skipped++; return; }
const text = await caption(x);
const key = 'fxtg:' + lc(tx) + ':' + rec.orderId;
if (!once(key) || !(await docstore.claim(key))) return; // never the same sale twice
const photo = photoUrl(CARDS[card++ % CARDS.length]);
let ok = await tg('sendPhoto', { photo, caption: text }, key);
if (!ok) ok = await tg('sendMessage', { text, disable_web_page_preview: true }, key);
})().catch(e => { st.failed++; st.lastError = String(e.message).slice(0, 160); });
}
// the Draft Day card: d = the finished draft, rows = [{ slot, coach, person }], stats = { players, coaches, potWei }
async function draftDay(d, rows, stats) {
const key = 'fxdraft:' + d.week;
if (!once(key) || !(await docstore.claim(key))) return false;
const top = rows.slice(0, 12).map(r => '<b>' + esc(r.slot) + '</b> ' + esc('@' + (r.coach || '?')) + ' takes ' + esc('@' + (r.person || '?'))).join('\n');
const text = ['\u{1F3C8} <b>5xYourTeam · Draft Day results, week of ' + esc(d.week) + '</b>', top, (rows.length > 12 ? '...and ' + (rows.length - 12) + ' more picks' : ''),
'\u{1F465} ' + stats.players + ' players drafted · ' + stats.coaches + ' coaches', '\u{1F3C6} Best Coach pot this week: ' + pol(stats.potWei) + ' POL',
'Draft order next Monday is earned: get your picks started. · <a href="https://' + esc(C.site) + '/">The draft board</a>'].filter(Boolean).join('\n');
return tg('sendPhoto', { photo: photoUrl('/art/draftday/week-' + d.week + '.png'), caption: text }, key);
}
// one line per Best Coach payout (recorded by the admin with its tx hash)
async function payoutLine(week, p) {
const key = 'fxpot:' + week + ':' + p.rank;
if (!once(key) || !(await docstore.claim(key))) return false;
return tg('sendMessage', { text: '\u{1F3C6} <b>5xYourTeam</b> Best Coach, week of ' + esc(week) + ': #' + p.rank + ' ' + esc('@' + (p.username || short(p.coach))) + ' got ' + pol(p.wei) + ' POL from the pot · <a href="' + esc(C.explorer) + '/tx/' + esc(p.tx) + '">Verify</a>', disable_web_page_preview: true }, key);
}
function view() { return Object.assign({ telegram: live() ? 'live' : 'outbox (phase 1: nothing is sent)', topic: process.env.TG_PAY_TOPIC || null, outbox: outbox().slice(-10) }, st); }
module.exports = { model, init, ledger, potOf, contract, onPurchase, draftDay, payoutLine, caption, split, view, live, outbox, CARDS, SPLIT };
+34
View File
@@ -0,0 +1,34 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
<title>Admin | 5xYourTeam</title>
<meta name="description" content="Admin.">
<meta name="robots" content="noindex">
<meta property="og:type" content="website">
<meta property="og:site_name" content="5xYourTeam">
<meta property="og:title" content="Admin | 5xYourTeam">
<meta property="og:description" content="Admin.">
<meta property="og:url" content="https://5xyourteam.com/admin">
<meta property="og:image" content="https://5xyourteam.com/art/og-share.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://5xyourteam.com/art/og-share.png">
<meta name="theme-color" content="#07102a">
<link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Oswald:wght@500;700&family=Inter:wght@400;600;700&display=swap">
<link rel="stylesheet" href="/assets/fx.css?v=1">
</head>
<body data-page="admin">
<main class="wrap">
<form id="tokForm" class="row dark"><input id="tok" type="password" placeholder="admin token" aria-label="Admin token" style="max-width:320px"><button class="btn-gold" type="submit">Open</button><button class="btn-ghost" type="button" id="tickBtn">Run a tick now</button></form>
<section class="panel"><h3>Status</h3><pre id="statusOut" class="kit-pre"></pre></section>
<section class="panel"><h3>Best Coach pot (last week)</h3><pre id="potOut" class="kit-pre"></pre></section>
<section class="panel"><h3>Old-link map (JSON {"oldrefs": {"old": "network username"}})</h3><input type="file" id="oldFile" accept="application/json"><pre id="oldOut" class="kit-pre"></pre></section>
</main>
<script src="/assets/common.js?v=1"></script>
<script src="/assets/misc.js?v=1"></script>
</body>
</html>
Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

+90
View File
@@ -0,0 +1,90 @@
// The Draft Board (front page): who is on the clock, this week's pool as scouting cards, the draft tracker, Best Coach standings,
// Rookie of the Week and the Best Coach pot. Every figure comes from /api/board; a missing stat says "not tracked yet".
(async function () {
FX.renderNav('/'); FX.renderFooter();
const $ = FX.$, esc = FX.esc;
const c = await FX.getConfig().catch(() => ({}));
const me = await FX.getJSON('/api/me').catch(() => ({}));
let B = null, busy = false, showAll = false;
const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
const hourLabel = h => (h % 12 || 12) + ' ' + (h < 12 ? 'AM' : 'PM');
const pol = w => w == null ? 'not tracked yet' : FX.polOf(w) + ' POL';
function hero(b) {
const d = b.draft; const cur = d && d.onClock;
const when = days[(c.draft || {}).dow == null ? 1 : c.draft.dow] + ' ' + hourLabel(b.draftHour) + ' Central';
if (d && d.status === 'live' && cur) {
$('heroKick').textContent = cur.me ? 'YOU\'RE ON THE CLOCK' : 'THE DRAFT IS LIVE';
$('heroTitle').textContent = cur.me ? 'Pick ' + cur.n + ' of Round ' + cur.round + '. Make it count.' : 'Pick ' + cur.n + ' of Round ' + cur.round + ': @' + cur.coach + ' is on the clock.';
$('heroClock').hidden = false; $('heroClock').dataset.until = cur.until;
} else if (d && d.status === 'done' && b.now < b.nextDraftAt) {
$('heroKick').textContent = 'NEXT DRAFT: ' + when.toUpperCase();
$('heroTitle').textContent = d.made ? d.made + ' players drafted this week. Get your picks started.' : 'Next draft ' + FX.when(b.nextDraftAt) + '.';
$('heroClock').hidden = false; $('heroClock').dataset.until = b.nextDraftAt;
} else {
$('heroKick').textContent = 'DRAFT DAY: ' + when.toUpperCase();
$('heroTitle').textContent = b.rounds + ' rounds. Draft order is earned.';
$('heroClock').hidden = false; $('heroClock').dataset.until = b.now < b.draftAt ? b.draftAt : b.nextDraftAt;
}
}
function clock() { const el = $('heroClock'); if (!el || el.hidden) return; const u = Number(el.dataset.until || 0); const live = B && B.draft && B.draft.status === 'live';
el.textContent = live ? 'Clock: ' + FX.left(u - Date.now() - (B.now - B.fetched)) : 'Starts in ' + FX.left(u - Date.now() - (B.now - B.fetched)); }
function scout(p, b) {
const coach = b.me && b.me.coach; const live = b.draft && b.draft.status === 'live'; const onClock = live && b.draft.onClock && b.draft.onClock.me;
const queued = b.me && (b.me.queue || []).includes(p.id);
let act = '';
if (onClock) act = '<button type="button" class="btn" data-draft="' + esc(p.id) + '">DRAFT</button>';
else if (coach && !live && b.me.credits > 0) act = '<button type="button" class="btn" data-instant="' + esc(p.id) + '">DRAFT NOW</button>';
else if (coach) act = '<button type="button" class="btn" data-queue="' + esc(p.id) + '">' + (queued ? 'ON MY QUEUE' : 'ADD TO QUEUE') + '</button>';
else act = '<a class="btn" href="/join">GET A POSITION</a>';
const rows = [['Game plays', p.plays == null ? 'not tracked yet' : FX.n(p.plays)], ['Plays', p.game || (p.plays === 0 ? 'none yet' : p.plays == null ? 'not tracked yet' : 'none yet')]];
if (coach) rows.push(['Earned in games', pol(p.gameWei)], ['Earned surfing', pol(p.surfWei)]);
rows.push(['Last seen', FX.ago(p.lastSeen, b.now)], ['Came from', p.door || 'not tracked yet'], ['Wallet', p.wallet ? 'linked' : 'not yet']);
return '<article class="scout"><div class="hd"><b>@' + esc(p.username || 'player') + '</b>' + (p.hot ? '<span class="tag">HOT</span>' : '') + '</div><div class="bd">'
+ rows.map(r => '<div class="kvr"><span>' + r[0] + '</span><b>' + esc(r[1]) + '</b></div>').join('') + '</div><div class="ft">' + act + '</div></article>';
}
function paint(b) {
B = b; B.fetched = Date.now(); FX.setWeek(b.week); hero(b);
$('potWei').textContent = FX.polOf(b.pot.wei) + ' POL';
$('potRank').innerHTML = b.me && b.me.coach ? '<span>Your draft spot next Monday</span><b>#' + esc(b.me.nextSpot || '?') + '</b>' : '<span>Coaches this week</span><b>' + FX.n(b.coaches) + '</b>';
const coach = b.me && b.me.coach;
$('poolNote').textContent = (b.poolSize ? FX.n(b.poolSize) + ' people waiting for a sponsor. ' : '') + (coach ? (b.me.credits > 0 && !(b.draft && b.draft.status === 'live') ? 'You have ' + b.me.credits + ' instant pick' + (b.me.credits === 1 ? '' : 's') + ': draft now, or queue players for Monday.' : 'Queue the players you want; an away coach is auto-picked from their queue.') : 'Usernames only, never contact details. Coaches see earnings where they are tracked.');
const shown = showAll ? b.pool : b.pool.slice(0, 8);
$('poolMore').hidden = showAll || b.pool.length <= 8; $('poolMore').textContent = 'Show all ' + b.pool.length + ' players';
$('pool').innerHTML = b.pool.length ? shown.map(p => scout(p, b)).join('') : '<p class="muted">The pool is empty right now. People who join the network without a sponsor show up here after their first 24 hours.</p>';
// tracker
const d = b.draft;
if (d && d.status === 'live') {
$('trackTitle').textContent = 'DRAFT TRACKER: ROUND ' + (d.onClock ? d.onClock.round : '');
const rows = d.rows.slice(0, 6).reverse().map(x => '<tr' + (x.me ? ' class="me"' : '') + '><td>' + esc(x.slot) + '</td><td>@' + esc(x.coach) + '</td><td>' + (x.person ? '@' + esc(x.person) : '<span class="muted">' + esc(x.skipped === 'team full' ? 'skipped: team full' : 'skipped') + '</span>') + '</td><td>' + esc(x.tierName || '') + '</td></tr>')
.concat(d.room.map((r, i) => '<tr' + (r.me ? ' class="me"' : '') + '><td>' + esc(r.slot) + '</td><td class="c">' + (i === 0 ? (r.me ? 'You are on the clock' : '@' + esc(r.coach) + ' is on the clock') : '@' + esc(r.coach)) + '</td><td>' + (i === 0 ? '...' : '') + '</td><td></td></tr>'));
$('track').innerHTML = rows.join('');
} else if (d && d.rows.length) {
$('trackTitle').textContent = 'DRAFT RESULTS: WEEK OF ' + b.week;
$('track').innerHTML = d.rows.filter(x => x.person).slice(0, 15).map(x => '<tr' + (x.me ? ' class="me"' : '') + '><td>' + esc(x.slot) + '</td><td>@' + esc(x.coach) + '</td><td>@' + esc(x.person) + '</td><td>' + esc(x.tierName || '') + '</td></tr>').join('');
} else { $('trackTitle').textContent = 'DRAFT TRACKER'; $('track').innerHTML = '<tr><td colspan="4" class="muted">The draft starts ' + esc(FX.when(b.now < b.draftAt ? b.draftAt : b.nextDraftAt)) + '. Every coach gets a spot every week.</td></tr>'; }
$('best').innerHTML = b.best.length ? b.best.map(x => '<div class="r' + (x.me ? ' me' : '') + '"><span>' + x.rank + '. @' + esc(x.coach) + '</span><b>' + x.started + ' started</b></div>').join('')
: '<p class="muted small">No picks started yet this week. The first coach to get one going leads the board.</p>';
$('potRule').textContent = '"Started" = a pick switched on payouts or made a first purchase. The pot is 10% of every position sold this week' + (b.pot.split && b.pot.split.length ? ', shared ' + b.pot.split.join('/') + ' by the top ' + b.pot.split.length + ' coaches after the week.' : '.');
$('rookie').innerHTML = b.rookie ? FX.card(b.rookie) : '<p class="muted small">The first pick this week to link a wallet takes it.</p>';
$('lastBest').innerHTML = b.lastWeekBest.length ? b.lastWeekBest.map(x => '<div class="r"><span>' + x.rank + '. @' + esc(x.coach) + '</span><b>' + x.started + ' started</b></div>').join('') : '<p class="muted small">No results from last week yet.</p>';
wire();
}
function wire() {
document.querySelectorAll('[data-draft]').forEach(el => el.onclick = () => act('/api/draft/pick', { person: el.dataset.draft }, 'Drafted. They show on My Team now.'));
document.querySelectorAll('[data-instant]').forEach(el => el.onclick = () => act('/api/my/instant', { person: el.dataset.instant }, 'Drafted. They show on My Team now.'));
document.querySelectorAll('[data-queue]').forEach(el => el.onclick = async () => {
const q = (B.me.queue || []).slice(); const id = el.dataset.queue; const i = q.indexOf(id); if (i >= 0) q.splice(i, 1); else q.push(id);
const r = await FX.post('/api/my/queue', { ids: q }); if (r.error) return FX.status(r.error, 'err'); B.me.queue = r.queue; paint(B);
});
}
async function act(url, body, okMsg) {
if (busy) return; busy = true;
try { const r = await FX.post(url, body); if (r.error) FX.status(r.error, 'err'); else FX.status(okMsg, 'ok'); await load(); } finally { busy = false; }
}
async function load() { const b = await FX.getJSON('/api/board'); if (!b.error) paint(b); return b; }
$('poolMore').onclick = () => { showAll = true; paint(B); };
await load();
setInterval(clock, 1000); clock();
setInterval(() => { load().catch(() => {}); }, 6000);
if (me.signedIn) { const ping = () => FX.post('/api/presence', {}).catch(() => {}); ping(); setInterval(ping, 30000); }
})();
+18
View File
@@ -0,0 +1,18 @@
// Card Collection: trading cards that level up as the picks do (Rookie, Starter, Pro, All-Star, Hall of Fame). Public cards show
// milestones, never earnings. ?u=<coach> shows that coach's team; signed in, your own team; otherwise the five tiers explained.
(async function () {
FX.renderNav('/cards'); FX.renderFooter();
const $ = FX.$, esc = FX.esc;
const TIERS = [['rookie', 'Rookie', 'Drafted'], ['starter', 'Starter', 'Wallet linked'], ['pro', 'Pro', 'Payouts switched on'], ['allstar', 'All-Star', 'First purchase'], ['hof', 'Hall of Fame', 'Built a team of their own']];
$('tiers').innerHTML = TIERS.map(t => FX.card({ tier: t[0], tierName: t[1], username: t[1].toLowerCase().replace(/[^a-z]/g, ''), coach: 'your team', milestone: t[2], plays: null, kind: 'draft', round: null })).join('');
let u = new URLSearchParams(location.search).get('u') || '';
let title = '', list = [];
if (!/^[A-Za-z0-9_.-]{2,40}$/.test(u)) {
const me = await FX.getJSON('/api/me').catch(() => ({}));
if (me.signedIn) { const d = await FX.getJSON('/api/my'); if (!d.error) { list = (d.picks || []).filter(p => p.status !== 'returned').map(p => ({ tier: p.tier, tierName: p.tierName, username: p.username, coach: d.username || 'me', round: p.round, kind: p.kind, milestone: TIERS.find(t => t[0] === p.tier)[2], plays: p.plays, status: p.status })); title = 'My team'; } }
} else {
const d = await FX.getJSON('/api/coach?u=' + encodeURIComponent(u));
if (!d.error) { list = d.team; title = '@' + d.username + '\'s team'; }
}
if (title) { $('mine').hidden = false; $('mineTitle').textContent = title; $('mineCards').innerHTML = list.length ? list.map(x => FX.card(x)).join('') : '<p class="muted">No cards yet: they appear with the first pick.</p>'; }
})();
+14
View File
@@ -0,0 +1,14 @@
// A coach page, 5xyourteam.com/<username>: the coach card (since, positions, picks started) and the team as trading cards. Public:
// milestones only, never earnings or contact details.
(async function () {
FX.renderNav(''); FX.renderFooter();
const $ = FX.$, esc = FX.esc;
const u = decodeURIComponent(location.pathname.replace(/^\/|\/$/g, ''));
const d = await FX.getJSON('/api/coach?u=' + encodeURIComponent(u));
if (d.error) { $('cName').textContent = 'No coach by that name yet'; return; }
$('cName').textContent = '@' + d.username;
$('cSince').textContent = 'Coach since ' + FX.when(d.since);
$('cStats').innerHTML = '<div class="kvr"><span>Positions</span><b>' + FX.n(d.positions) + '</b></div><div class="kvr"><span>On the team</span><b>' + FX.n(d.team.length) + '</b></div><div class="kvr"><span>Picks started</span><b>' + FX.n(d.started) + '</b></div>';
$('cTeam').innerHTML = d.team.length ? d.team.map(x => FX.card(x)).join('') : '<p class="muted">Their first picks show here.</p>';
$('cJoin').href = d.joinUrl; $('cJoin').textContent = 'Join the network free under @' + d.username;
})();
+97
View File
@@ -0,0 +1,97 @@
// Shared page helpers (FX namespace, modelled on the ViralAdBlitz / VBB common.js): nav, footer (legal links, the company line, the
// network line from the hub), toasts of real events, and small formatters. Every number on a page comes from the API.
window.FX = (function () {
let cfgP = null;
const $ = id => document.getElementById(id);
const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
const getConfig = () => cfgP || (cfgP = fetch('/api/config').then(r => r.json()));
const short = a => a ? a.slice(0, 6) + '...' + a.slice(-4) : '';
const n = x => Number(x || 0).toLocaleString('en-US');
function status(msg, cls, id) { const el = $(id || 'status'); if (!el) return; el.hidden = !msg; el.className = 'note ' + (cls || ''); el.textContent = msg || ''; }
async function getJSON(url, opts) { const r = await fetch(url, opts); let j = {}; try { j = await r.json(); } catch (e) {} if (!r.ok && !j.error) j.error = 'Request failed (' + r.status + ')'; j._status = r.status; return j; }
const post = (url, body) => getJSON(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body || {}) });
const polOf = (w, d) => { try { const k = BigInt(w || 0); if (k === 0n) return '0'; const v = Number(k / 10n ** 12n) / 1e6; return v.toFixed(d != null ? d : (v >= 100 ? 2 : v >= 1 ? 2 : 4)); } catch (e) { return '0'; } };
const when = t => t ? new Date(t).toLocaleString('en-US', { timeZone: 'America/Chicago', weekday: 'short', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) + ' CT' : '';
// "today", "yesterday", "3 days ago" (Central days) or "not seen yet"
function ago(t, nowMs) {
if (!t) return 'not seen yet';
const day = x => new Date(x).toLocaleDateString('en-CA', { timeZone: 'America/Chicago' });
const now = nowMs || Date.now(); const dd = Math.round((Date.parse(day(now)) - Date.parse(day(t))) / 86400000);
return dd <= 0 ? 'today' : dd === 1 ? 'yesterday' : dd + ' days ago';
}
function left(ms) { if (ms <= 0) return 'now'; const m = Math.ceil(ms / 60000); if (m < 60) return m + ' min'; const h = Math.floor(m / 60); if (h < 48) return h + ' h ' + (m % 60) + ' min'; return Math.round(h / 24) + ' days'; }
const initials = s => String(s || '?').replace(/[^A-Za-z0-9]/g, '').slice(0, 2).toUpperCase() || '?';
let weekLabel = '';
function renderNav(active, week) {
const nav = document.createElement('nav'); nav.className = 'top';
const links = [['/', 'Draft Board'], ['/team', 'My Team'], ['/cards', 'Card Collection'], ['/join', 'Get a Position'], ['/ledger', 'Ledger'], ['/contract', 'Contract']];
nav.innerHTML = '<div class="wrap"><a class="brand" href="/" aria-label="5xYourTeam, the draft board"><span class="wm">5X<b>YOUR</b>TEAM</span><span class="wk" id="navWeek" hidden></span></a><div class="links">'
+ links.map(l => '<a href="' + l[0] + '"' + (l[0] === active ? ' class="on" aria-current="page"' : '') + '>' + l[1] + '</a>').join('') + '</div></div>';
document.body.prepend(nav);
if (week) setWeek(week);
}
// ISO-ish week number of a Monday date (the mockup's "DRAFT WEEK 46")
function weekNo(monday) { const d = new Date(monday + 'T12:00:00Z'); const t = new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate() + 3)); const y = new Date(Date.UTC(t.getUTCFullYear(), 0, 4)); return 1 + Math.round(((t - y) / 86400000 - 3 + ((y.getUTCDay() + 6) % 7)) / 7); }
function setWeek(monday) { const el = $('navWeek'); if (!el || !monday) return; weekLabel = 'DRAFT WEEK ' + weekNo(monday); el.textContent = weekLabel; el.hidden = false; }
const NET = [['iap', 'InstantAdPay', 'https://instantadpay.com'], ['linkspin', 'LinkSpin', 'https://linkspin.app'], ['dlb', 'Downline Banners', 'https://downlinebanners.com'],
['vbb', 'Viral Banner Blitz', 'https://viralbannerblitz.com'], ['viraladblitz', 'ViralAdBlitz', 'https://viraladblitz.com'], ['fivex', '5xYourTeam', 'https://5xyourteam.com'], ['stackpol', 'Stack POL', 'https://stackpol.com'], ['earnerscorner', 'Earners Corner', 'https://earnerscorner.com']].map(a => ({ id: a[0], name: a[1], url: a[2] }));
function netLine(el) {
if (!el) return;
const paint = list => { el.innerHTML = '<b>Part of the network</b> &middot; One account across the network: ' + list.map(s => (s.id === 'fivex' || /5xyourteam\.com/.test(s.url))
? '<span class="here" aria-current="page">' + esc(s.name) + '</span>' : '<a href="' + esc(s.go || s.url) + '" target="_blank" rel="noopener nofollow">' + esc(s.name) + '</a>').join(' &middot; '); };
paint(NET);
fetch('/api/network-sites').then(r => r.json()).then(l => { if (Array.isArray(l) && l.length) paint(l.some(s => s.id === 'fivex') ? l : l.concat([NET[5]])); }).catch(() => {});
}
function renderFooter() {
const f = document.createElement('footer'); f.className = 'foot';
f.innerHTML = '<div class="wrap"><p><b>5xYourTeam</b>, the weekly draft for people who need a sponsor</p>'
+ '<p>A position buys a draft spot and coaching tools, not income. Nothing is promised.</p>'
+ '<p><a href="/">Draft Board</a> &middot; <a href="/team">My Team</a> &middot; <a href="/cards">Cards</a> &middot; <a href="/join">Get a Position</a> &middot; <a href="/promote">Promote</a></p>'
+ '<p class="legal-links"><a href="/terms">Terms</a> &middot; <a href="/disclaimer">Earnings Disclaimer</a> &middot; <a href="/privacy">Privacy</a> &middot; <a href="/contract">Contract</a> &middot; <a href="/ledger">Ledger</a> &middot; <a href="https://instantadpay.com/support" target="_blank" rel="noopener">Support</a></p>'
+ '<p class="co">TrustClickz &middot; 615 Green Valley Drive, Moody, AL 35004</p><p class="netline"></p></div>';
document.body.appendChild(f);
netLine(f.querySelector('.netline'));
toasts();
}
// live toasts: real new positions, picks and level-ups only, bottom-right, never older than 30 minutes
let toastsOn = false;
function toasts() {
if (toastsOn) return; toastsOn = true;
const seen = new Set(); let first = true;
const box = document.createElement('div'); box.className = 'toasts'; box.setAttribute('aria-live', 'polite'); document.body.appendChild(box);
const show = c => {
const el = document.createElement('a'); el.className = 'toast' + (c.kind === 'position' ? ' red' : '');
if (c.kind === 'position') { el.href = '/ledger'; el.innerHTML = '<b>' + (c.name ? '@' + esc(c.name) : 'A new coach') + ' joined The Draft</b><br><span>Paid on-chain, split by the contract in the same transaction</span>'; }
else if (c.kind === 'level') { el.href = '/cards'; el.innerHTML = '<b>@' + esc(c.person || 'a pick') + ' just made ' + esc(c.tierName) + (c.name ? ' on @' + esc(c.name) + '\'s team' : '') + '</b><br><span>' + (c.tierName === 'Starter' ? 'Wallet linked. One step from Pro.' : c.tierName === 'Pro' ? 'Payouts switched on.' : 'Leveling up.') + '</span>'; }
else { el.href = '/'; el.innerHTML = '<b>' + (c.name ? '@' + esc(c.name) : 'A coach') + ' drafted @' + esc(c.person || 'a player') + '</b><br><span>' + (c.slot ? 'Pick ' + esc(c.slot) : 'An instant pick') + '</span>'; }
box.appendChild(el); requestAnimationFrame(() => el.classList.add('in'));
setTimeout(() => { el.classList.remove('in'); setTimeout(() => el.remove(), 400); }, 7000);
};
const tick = async () => {
const d = await getJSON('/api/recent').catch(() => null); const all = (d && d.items) || [];
const fresh = all.filter(c => !seen.has(c.key)); all.forEach(c => seen.add(c.key));
const list = first ? fresh.slice(0, 1) : fresh.reverse(); first = false;
list.slice(0, 3).forEach((c, i) => setTimeout(() => show(c), 1500 + i * 8000));
};
tick(); setInterval(tick, 25000);
}
// a trading card (milestones only, never earnings)
function card(c, opts) {
const o = opts || {};
return '<article class="tc ' + esc(c.tier) + (c.status === 'returned' ? ' faded' : '') + '"><div class="tier">' + esc(c.tierName) + '</div><div class="face">' + esc(initials(c.username)) + '</div>'
+ '<div class="info"><b>@' + esc(c.username || 'player') + '</b><span>Team @' + esc(c.coach) + (c.round ? ' · Round ' + esc(c.round) : c.kind === 'instant' ? ' · Instant pick' : '') + '</span><span>' + esc(c.milestone) + '</span>'
+ '<span>Games played: ' + (c.plays == null ? 'not tracked yet' : n(c.plays)) + '</span>' + (c.status === 'returned' ? '<span class="dim">Back in the pool</span>' : '') + (o.extra || '') + '</div></article>';
}
// signed in on InstantAdPay already? one quick hop there and back signs you in here too
async function silentSso(to) { try { const ss = await getJSON('/api/sso/status'); if (ss && ss.check) { location.replace('/sso/start?mode=check&via=iap&to=' + encodeURIComponent(to)); return true; } } catch (e) {} return false; }
function signInBlock(to) {
const t = encodeURIComponent(to);
return '<div class="signin"><a class="btn-gold" href="/sso/start?mode=go&amp;via=iap&amp;to=' + t + '">Sign in with InstantAdPay</a><a class="btn-gold" href="/sso/start?mode=go&amp;via=linkspin&amp;to=' + t + '">Sign in with LinkSpin</a><button class="btn-line" type="button" data-wallet-signin>Sign in with your wallet</button></div>'
+ '<p class="small">Your wallet: SafePal or any other crypto wallet. Signing in is free and cannot move funds.</p>';
}
function wireSignIn(root) {
(root || document).querySelectorAll('[data-wallet-signin]').forEach(b => { b.onclick = async () => {
try { status('Check your wallet for the sign-in message.'); await FXWallet.signIn(); location.reload(); } catch (e) { status(String(e && e.message || e).slice(0, 300), 'err'); } }; });
}
return { $, esc, getConfig, short, status, getJSON, post, n, polOf, when, ago, left, initials, renderNav, renderFooter, setWeek, weekNo, card, silentSso, signInBlock, wireSignIn };
})();
+24
View File
@@ -0,0 +1,24 @@
// Contract proof page (trust pack): live facts from /api/contract (read from Polygon, cached 5 minutes on the server).
(async function () {
FX.renderNav('/contract'); FX.renderFooter();
const el = document.getElementById('facts'); const esc = FX.esc;
let d; try { d = await FX.getJSON('/api/contract'); } catch (e) { d = {}; }
const ex = d.explorer || 'https://polygonscan.com';
const addr = (a, note) => a ? '<a href="' + esc(ex) + '/address/' + esc(a) + '" target="_blank" rel="noopener">' + esc(a) + '</a>' + (note ? '<br><span class="small">' + note + '</span>' : '') : '<span class="muted">not read yet</span>';
const sp = d.split || { sponsorPct: 25, levelPct: 5, potPct: 10, companyPct: 45, maxDepth: 20 };
const splitRow = ['The split', 'Sponsor ' + sp.sponsorPct + '%, levels 2 to 5 ' + sp.levelPct + '% each, Best Coach pot ' + sp.potPct + '%, 5xYourTeam ' + sp.companyPct + '%. Someone in the line with no position is passed over and the share goes up to the next person who holds one, up to ' + sp.maxDepth + ' places. Fixed in the code: no setter can change it.'];
if (!d.address) { el.innerHTML = '<tbody><tr><th>Status</th><td class="muted">The contract is not live yet. Its address, owner, prize pot wallet and every position will show here, read straight from Polygon.</td></tr><tr><th>' + splitRow[0] + '</th><td>' + splitRow[1] + '</td></tr></tbody>'; return; }
const rows = [
['Contract', addr(d.address, 'DraftPosition 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 price of future positions and change the keeper. It cannot move anyone\'s money or change the split.')],
['Company', addr(d.company, '5xYourTeam. Fixed in the contract when it was deployed.')],
['Best Coach pot', addr(d.prizeWallet, 'Receives 10% of every position in the same transaction. Fixed in the contract when it was deployed. Each payout from it is listed on the ledger.')],
['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 position.')],
splitRow,
['Position', '$' + esc(d.position && d.position.usd) + ' one-time, paid in POL at the live Chainlink price' + (d.priceCents ? ' (contract price: $' + (d.priceCents / 100).toFixed(2) + ')' : '')],
['Sales', d.live ? (d.paused ? '<b>Paused</b>' : 'Open') + ' · ' + FX.n(d.orderCount) + ' orders so far' : '<span class="muted">' + esc(d.error || 'not read yet') + '</span>'],
['Held by the contract', d.live ? FX.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 position is paid out in the same transaction)') : '<span class="muted">not read yet</span>']
];
el.innerHTML = '<tbody>' + rows.map(r => '<tr><th>' + r[0] + '</th><td>' + r[1] + '</td></tr>').join('') + '</tbody>';
})();
+175
View File
@@ -0,0 +1,175 @@
/* 5xYourTeam: the approved "draft night" look (mockup 2026-11-14): stadium navy, gold, a red tag; white trading cards with a navy
header; Oswald headlines + Inter text. Distinct from the other network sites (IAP mint, DLB ultraviolet, VBB pop-art,
ViralAdBlitz daylight royal, DownlineHydra parchment). One stylesheet, variables up top. */
:root{
--bg:#0b1530;--bar:#07102a;--panel:#13214a;--panel2:#1b2c5e;--line:#2a3a6e;--ink:#eef2fb;--muted:#b8c4e0;--dim:#8f9cc0;
--gold:#ffc93c;--gold2:#ffe08a;--red:#ff4d4d;--paper:#fff;--paperInk:#0b1530;--paperMuted:#4a587e;
--rookie:#9aa6c4;--starter:#1f8a5b;--pro:#2f5be0;--allstar:#ffc93c;--hof:#ff4d4d;
--disp:Oswald,Impact,'Arial Narrow',sans-serif;--text:Inter,system-ui,-apple-system,'Segoe UI',sans-serif;
}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--text);font-size:16px;line-height:1.5;overflow-x:hidden}
a{color:var(--gold)}a:hover{color:var(--gold2)}
img{max-width:100%}
h1,h2,h3{font-family:var(--disp);font-weight:700;letter-spacing:.5px;line-height:1.05;margin:0}
h2{font-size:30px;text-transform:uppercase}
h3{font-size:20px;text-transform:uppercase}
.wrap{max-width:1200px;margin:0 auto;padding:0 24px}
main.wrap{padding-top:32px;padding-bottom:40px;display:flex;flex-direction:column;gap:32px}
.kicker{margin:0;font-family:var(--disp);font-size:14px;letter-spacing:3px;color:var(--gold);text-transform:uppercase}
.muted{color:var(--muted)}.dim{color:var(--dim)}
.note{margin:0;padding:10px 14px;background:var(--panel2);border-left:4px solid var(--gold);font-size:14px}
.note.err{border-color:var(--red)}.note.ok{border-color:var(--starter)}
.hidden,[hidden]{display:none!important}
/* header */
nav.top{background:var(--bar);border-bottom:4px solid var(--gold);position:relative;z-index:5}
nav.top .wrap{display:flex;align-items:center;gap:20px;flex-wrap:wrap;padding-top:14px;padding-bottom:14px}
.brand{display:flex;align-items:center;gap:10px;margin-right:auto;text-decoration:none}
.wm{font-family:var(--disp);font-weight:700;font-size:30px;letter-spacing:1px;color:#fff;white-space:nowrap}.wm b{color:var(--gold);font-weight:700}
.wk{font-family:var(--disp);font-size:12px;background:var(--red);color:#fff;padding:3px 8px;letter-spacing:2px;white-space:nowrap}
nav.top .links{display:flex;gap:18px;flex-wrap:wrap;font-size:14px;font-weight:600}
nav.top .links a{color:var(--muted);text-decoration:none;padding-bottom:2px;border-bottom:2px solid transparent}
nav.top .links a.on,nav.top .links a:hover{color:#fff;border-bottom-color:var(--gold)}
/* buttons */
.btn,.btn-gold,.btn-line,.btn-ghost{display:inline-flex;align-items:center;justify-content:center;gap:8px;border:0;cursor:pointer;text-decoration:none;font-family:var(--disp);letter-spacing:1px;text-transform:uppercase;font-size:16px;padding:12px 18px;line-height:1.1}
.btn{background:var(--paperInk);color:var(--gold)}.btn:hover{background:#13214a;color:var(--gold2)}
.btn-gold{background:var(--gold);color:var(--paperInk)}.btn-gold:hover{background:var(--gold2);color:var(--paperInk)}
.btn-line{background:transparent;color:#fff;border:2px solid var(--gold);padding:10px 16px}.btn-line:hover{background:var(--panel2);color:#fff}
.btn-ghost{background:transparent;color:var(--muted);border:2px solid var(--line);padding:10px 16px;font-family:var(--text);text-transform:none;letter-spacing:0;font-weight:600;font-size:14px}
button:disabled{opacity:.5;cursor:not-allowed}
.row{display:flex;flex-wrap:wrap;gap:10px;align-items:center}
/* hero */
.hero{display:flex;flex-wrap:wrap;gap:16px;align-items:stretch}
.hero .copy{flex:999 1 520px;min-width:0;display:flex;flex-direction:column;gap:10px}
.hero h1{font-size:58px;color:#fff}
.hero .lead{margin:0;font-size:17px;color:var(--muted);max-width:640px}
.potbox{flex:1 1 280px;background:var(--panel);border:2px solid var(--gold);padding:18px;display:flex;flex-direction:column;gap:10px}
.potbox .lab{font-family:var(--disp);letter-spacing:2px;color:var(--gold);font-size:13px;text-transform:uppercase}
.potbox b.big{font-family:var(--disp);font-size:44px;color:#fff;line-height:1}
.potbox .kv{display:flex;justify-content:space-between;border-top:1px solid var(--line);padding-top:10px;font-size:14px}.potbox .kv b{color:var(--gold)}
.clock{font-family:var(--disp);font-size:22px;color:var(--gold);letter-spacing:1px}
/* section heads */
.sh{display:flex;align-items:baseline;justify-content:space-between;flex-wrap:wrap;gap:8px}
.sh p{margin:0;color:var(--muted);font-size:14px}
/* scouting cards (the pool) */
.pool{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px}
.scout{background:var(--paper);color:var(--paperInk);display:flex;flex-direction:column}
.scout .hd{background:var(--panel);color:#fff;padding:12px 14px;display:flex;justify-content:space-between;align-items:center;gap:8px}
.scout .hd b{font-family:var(--disp);font-size:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
.tag{font-family:var(--disp);font-size:12px;background:var(--gold);color:var(--paperInk);padding:2px 6px;letter-spacing:1px;white-space:nowrap}
.tag.red{background:var(--red);color:#fff}
.scout .bd{padding:14px;display:flex;flex-direction:column;gap:6px;font-size:14px;flex:1}
.kvr{display:flex;justify-content:space-between;gap:10px}.kvr span{color:var(--paperMuted)}.kvr b{text-align:right}
.scout .ft{margin:0 14px 14px;display:flex;gap:6px}
.scout .ft .btn{flex:1;font-size:15px;padding:11px 8px}
.scout .ft .q{flex:0 0 auto;background:#e5e9f4;color:var(--paperInk);border:0;font-family:var(--disp);padding:0 12px;cursor:pointer;letter-spacing:1px}
.scout .ft .q.on{background:var(--gold)}
.scout.mine .hd{background:var(--starter)}
/* panels, tables */
.panel{background:var(--panel);padding:20px;display:flex;flex-direction:column;gap:10px;min-width:0}
.split{display:flex;flex-wrap:wrap;gap:20px}
.split>.wide{flex:999 1 560px}.split>.side{flex:1 1 300px}
.tbl{overflow-x:auto}
table{width:100%;border-collapse:collapse;font-size:14px}
th{color:var(--gold);text-align:left;font-family:var(--disp);letter-spacing:1px;font-weight:500;padding:8px;border-bottom:1px solid var(--line);white-space:nowrap}
td{padding:8px;border-bottom:1px solid var(--line);vertical-align:top}
tr.me td{background:var(--panel2)}tr.me td.c{color:var(--gold);font-weight:700}
.board{display:flex;flex-direction:column;gap:6px}
.board .r{display:flex;justify-content:space-between;font-size:15px;border-bottom:1px solid var(--line);padding-bottom:6px;gap:10px}
.board .r b{color:var(--gold);white-space:nowrap}.board .r.me span{color:var(--gold);font-weight:700}
.small{font-size:13px;color:var(--muted)}
/* stat tiles */
.stats{display:flex;flex-wrap:wrap;gap:14px}
.stat{flex:1 1 200px;background:var(--panel);padding:16px;display:flex;flex-direction:column;gap:4px}
.stat span{font-family:var(--disp);letter-spacing:2px;font-size:12px;color:var(--gold);text-transform:uppercase}
.stat b{font-family:var(--disp);font-size:36px;line-height:1}
.stat em{font-style:normal;font-size:13px;color:var(--muted)}
/* the focused pick */
.focus{background:var(--paper);color:var(--paperInk);display:flex;flex-wrap:wrap}
.focus .who{flex:1 1 280px;background:var(--panel);color:#fff;padding:22px;display:flex;flex-direction:column;gap:8px}
.focus .who .k{font-family:var(--disp);letter-spacing:2px;color:var(--gold);font-size:13px;text-transform:uppercase}
.focus .who b.n{font-family:var(--disp);font-size:30px;word-break:break-all}
.focus .who .kvr span{color:var(--muted)}
.focus .act{flex:999 1 520px;min-width:0;padding:22px;display:flex;flex-direction:column;gap:14px}
.focus h3{font-size:22px}
.steps{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:8px;font-size:13px;text-align:center}
.steps div{background:#e5e9f4;color:var(--paperMuted);padding:10px 6px}
.steps .done{background:var(--starter);color:#fff}.steps .next{background:var(--gold);color:var(--paperInk);font-weight:700}
.taps{display:flex;flex-wrap:wrap;gap:8px}
.taps button{background:var(--paperInk);color:#fff;border:0;padding:12px 14px;font-size:14px;cursor:pointer;text-align:left;font-family:var(--text)}
.taps button:hover{background:var(--panel2)}
textarea,input,select{font:inherit;font-size:15px;padding:10px 12px;border:2px solid #c6cde0;background:#fff;color:var(--paperInk);width:100%;border-radius:0}
.dark textarea,.dark input,.dark select{background:var(--bar);color:var(--ink);border-color:var(--line)}
textarea{min-height:84px;resize:vertical}
.thread{display:flex;flex-direction:column;gap:8px;max-height:260px;overflow:auto;padding:4px 0}
.msg{padding:10px 12px;background:#eef1f8;font-size:14px;max-width:85%;white-space:pre-wrap;word-break:break-word}
.msg.mine{background:var(--paperInk);color:#fff;align-self:flex-end}
.msg em{display:block;font-style:normal;font-size:11px;opacity:.7;margin-top:4px}
/* team grid */
.team{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}
.mini{background:var(--panel);padding:14px;display:flex;flex-direction:column;gap:6px;cursor:pointer;border:2px solid transparent;text-align:left;color:var(--ink);font:inherit}
.mini:hover,.mini.on{border-color:var(--gold)}
.mini b{font-family:var(--disp);font-size:18px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.mini .t{color:var(--gold);font-size:13px;text-transform:uppercase;letter-spacing:1px}
.mini .s{color:var(--muted);font-size:13px}
.help{display:flex;flex-direction:column;gap:8px}
.help .h{display:flex;gap:12px;align-items:center;justify-content:space-between;background:var(--panel2);padding:10px 12px;flex-wrap:wrap}
.help .h b{font-family:var(--disp);font-size:17px}
/* trading cards */
.cards{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:20px}
.tc{border:6px solid var(--rookie);background:#e5e9f4;color:var(--paperInk);min-height:380px;display:flex;flex-direction:column}
.tc .tier{font-family:var(--disp);letter-spacing:3px;text-align:center;padding:6px;background:var(--rookie);color:var(--paperInk);text-transform:uppercase}
.tc .face{height:150px;display:flex;align-items:center;justify-content:center;font-family:var(--disp);font-size:48px;background:#c6cde0;color:var(--paperMuted)}
.tc .info{padding:12px;display:flex;flex-direction:column;gap:4px;font-size:13px}
.tc .info b{font-family:var(--disp);font-size:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.tc.starter{border-color:var(--starter);background:#eaf6ef}.tc.starter .tier{background:var(--starter);color:#fff}.tc.starter .face{background:#bfe3cf;color:#1f5c40}
.tc.pro{border-color:var(--pro);background:#e8eefc}.tc.pro .tier{background:var(--pro);color:#fff}.tc.pro .face{background:#c3d2fa;color:#1d3a96}
.tc.allstar{border-color:var(--allstar);background:#fff7df;box-shadow:0 0 0 3px var(--paperInk),0 0 24px rgba(255,201,60,.6)}.tc.allstar .tier{background:var(--allstar)}.tc.allstar .face{background:#ffe8a3;color:#7a5a00}
.tc.hof{border-color:var(--gold);background:#1a1030;color:#fff;box-shadow:0 0 0 3px var(--red)}.tc.hof .tier{background:linear-gradient(90deg,var(--gold),var(--red))}.tc.hof .face{background:#2a1a4a;color:var(--gold)}
.tc.faded{opacity:.55}
/* coach card */
.ccard{display:flex;flex-wrap:wrap;gap:0;background:var(--paper);color:var(--paperInk)}
.ccard .l{flex:1 1 260px;background:var(--panel);color:#fff;padding:22px;display:flex;flex-direction:column;gap:8px;border-left:8px solid var(--gold)}
.ccard .l b{font-family:var(--disp);font-size:36px;word-break:break-all}
.ccard .r{flex:999 1 400px;padding:22px;display:flex;flex-direction:column;gap:12px}
/* steps strip on the front page */
.how{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}
.how .s{background:var(--panel);padding:18px;display:flex;flex-direction:column;gap:6px;border-top:4px solid var(--gold)}
.how .s b{font-family:var(--disp);font-size:40px;color:var(--gold);line-height:1}
.splitbar{display:flex;height:34px;font-size:12px;font-weight:700}
.splitbar div{display:flex;align-items:center;justify-content:center;color:var(--paperInk);overflow:hidden;white-space:nowrap}
.legal .card{background:var(--panel);padding:20px}.legal .card h2{font-size:22px;margin-bottom:8px}.legal .card p,.legal .card li{color:var(--muted)}
.signin{display:flex;flex-wrap:wrap;gap:10px}
/* footer */
footer.foot{border-top:1px solid var(--line);padding:24px 0;text-align:center;color:var(--dim);font-size:13px}
footer.foot p{margin:4px 0}footer.foot a{color:var(--gold)}footer.foot .here{color:#fff;font-weight:700}
/* toasts */
.toasts{position:fixed;right:24px;bottom:24px;z-index:50;display:flex;flex-direction:column;gap:8px;max-width:320px;pointer-events:none}
.toast{background:#fff;color:var(--paperInk);border-left:6px solid var(--gold);padding:12px 16px;font-size:14px;box-shadow:0 8px 24px rgba(0,0,0,.45);text-decoration:none;opacity:0;transform:translateY(10px);transition:all .35s;pointer-events:auto}
.toast.in{opacity:1;transform:none}.toast span{color:var(--paperMuted)}.toast.red{border-color:var(--red)}
.net-zone{text-align:center;margin:12px auto}.net-zone-label{font-size:11px;color:var(--dim)}
/* phones */
@media (max-width:1000px){.pool,.team{grid-template-columns:repeat(2,minmax(0,1fr))}.cards{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media (max-width:640px){
.wrap{padding:0 16px}main.wrap{padding-top:20px;gap:24px}
.wm{font-size:24px}nav.top .links{gap:12px;font-size:13px}
.hero h1{font-size:38px}h2{font-size:24px}
.pool{grid-template-columns:minmax(0,1fr)}.team{grid-template-columns:repeat(2,minmax(0,1fr))}.cards{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.tc{min-height:300px}.tc .face{height:100px;font-size:36px}
.steps{grid-template-columns:repeat(2,minmax(0,1fr))}.how{grid-template-columns:minmax(0,1fr)}
.toasts{left:16px;right:16px;bottom:16px;max-width:none}
}
/* promo kit (kitpage.js) */
.card{background:var(--panel);padding:20px;display:flex;flex-direction:column;gap:10px}
.btn.small{font-size:13px;padding:8px 12px}.btn.sec{background:var(--panel2);color:#fff}
.kit-row{display:flex;gap:10px;align-items:center;justify-content:space-between;border-bottom:1px solid var(--line);padding:8px 0;flex-wrap:wrap}
.kit-l{display:flex;flex-direction:column;gap:2px;min-width:0;flex:1}.kit-lab{font-size:12px;color:var(--gold);font-family:var(--disp);letter-spacing:1px;text-transform:uppercase;display:block}
.kit-url{font-size:13px;color:var(--muted);word-break:break-all}.kit-txt{margin:0;flex:1;min-width:0;color:var(--ink)}
.kit-tabs{display:flex;flex-wrap:wrap;gap:6px}.kit-tab{background:var(--panel2);color:var(--muted);border:0;padding:8px 12px;cursor:pointer;font:inherit;font-size:14px}.kit-tab.on{background:var(--gold);color:var(--paperInk)}
.kit-set{display:flex;flex-wrap:wrap;gap:16px;align-items:flex-start}.kit-fig{margin:0;display:flex;flex-direction:column;gap:6px;max-width:100%}
.kit-fig img{height:auto;max-width:100%;display:block}.kit-social img,.kit-square img{width:360px}
.kit-fig figcaption{font-size:13px;display:flex;flex-wrap:wrap;gap:6px;align-items:center}.kit-acts{display:flex;gap:6px;flex-wrap:wrap}
.kit-pre{white-space:pre-wrap;font:inherit;font-size:14px;color:var(--muted);margin:0;background:var(--bar);padding:12px}
.ccard .l .kvr{color:var(--muted)}.ccard .l .kvr span{color:var(--muted)}.ccard .l .kvr b{font-family:var(--text);font-size:15px;color:#fff;word-break:normal}
.splitbar div{font-size:11px;padding:0 4px}
+44
View File
@@ -0,0 +1,44 @@
// Get a Position: $10 one-time through DraftPosition. The server builds the buy() call for the signed-in member (POST /api/my/order,
// with a fresh line voucher when the member's sponsor line is not on the contract yet); the member's own wallet sends it. After the
// transaction confirms, the page waits for the watcher to record it (then the 5 instant picks show on My Team).
(async function () {
FX.renderNav('/join'); FX.renderFooter();
const $ = FX.$, esc = FX.esc;
const c = await FX.getConfig().catch(() => ({}));
const P = c.position || { usd: 10, picksOnBuy: 5, maxQty: 10 }, S = c.split || {};
$('jPrice').textContent = '$' + P.usd; $('jPicks').textContent = P.picksOnBuy;
$('splitbar').innerHTML = [['Sponsor ' + S.sponsorPct + '%', S.sponsorPct, '#ffc93c'], ['L2-5 ' + S.levelPct + '% each', S.levelPct * 4, '#ffe08a'], ['Pot ' + S.potPct + '%', S.potPct, '#1f8a5b'], ['5xYourTeam ' + S.companyPct + '%', S.companyPct, '#c6cde0']]
.map(x => '<div style="flex:' + x[1] + ';background:' + x[2] + '" title="' + esc(x[0]) + '">' + esc(x[0]) + '</div>').join('');
$('jQty').innerHTML = Array.from({ length: P.maxQty }, (_, i) => '<option value="' + (i + 1) + '">' + (i + 1) + ' position' + (i ? 's' : '') + ' ($' + P.usd * (i + 1) + ', ' + P.picksOnBuy * (i + 1) + ' instant picks)</option>').join('');
const fmtPol = (wei, d) => { const k = d || 4; const s = (BigInt(wei) * 10n ** BigInt(k) / 10n ** 18n).toString().padStart(k + 1, '0'); return s.slice(0, -k) + '.' + s.slice(-k); };
const me = await FX.getJSON('/api/me').catch(() => ({}));
if (!me.signedIn) { $('jSign').hidden = false; $('jSignBox').innerHTML = FX.signInBlock('/join'); FX.wireSignIn($('jSignBox')); }
async function quote() {
if (!c.shop || !c.shop.live) { $('jPol').textContent = 'Positions open when the contract goes live.'; $('jBuy').disabled = true; return; }
const q = await FX.getJSON('/api/quote?qty=' + $('jQty').value);
$('jPol').textContent = q.error ? q.error : 'about ' + fmtPol(q.wei, 2) + ' POL at today\'s Chainlink price';
$('jBuy').disabled = !!q.error || !me.signedIn;
}
$('jQty').onchange = quote; quote();
$('jBuy').onclick = async () => {
const say = (m, cls) => FX.status(m, cls);
try {
$('jBuy').disabled = true;
say('Connecting your wallet...');
const addr = String(await FXWallet.activeAddress(await FXWallet.connect()) || '').toLowerCase();
if (!addr) throw new Error('No wallet connected. Tap the button again and pick SafePal or any other crypto wallet.');
if (addr !== me.address) throw new Error('Your wallet is connected as ' + FX.short(addr) + ', but you are signed in here as ' + FX.short(me.address) + '. A position goes to the wallet that pays, so switch your wallet app to ' + FX.short(me.address) + ', or sign out and sign in with ' + FX.short(addr) + '.');
const od = await FX.post('/api/my/order', { qty: Number($('jQty').value) }); if (od.error) throw new Error(od.error);
const value = BigInt(od.value);
try { const bal = await FXWallet.balance(addr); if (bal < value) throw new Error('This wallet holds ' + fmtPol(bal) + ' POL. The position needs about ' + fmtPol(value) + ' POL plus a little gas. Add POL on Polygon and try again.'); } catch (e) { if (/holds/.test(e.message)) throw e; }
say('Confirm the payment in your wallet: about ' + fmtPol(value) + ' POL ($' + od.usd + '). Anything above the exact price comes straight back in the same transaction.');
const hash = await FXWallet.sendTx(od.to, od.data, od.value);
say('Payment sent. Waiting for Polygon to confirm it...');
const r = await FXWallet.waitTx(hash);
if (r.status !== '0x1') throw new Error('The transaction did not go through, so nothing was charged except gas.');
FX.post('/api/my/paid', {}).catch(() => {});
say('Confirmed on Polygon. Your instant picks show on My Team within about a minute.', 'ok');
for (let i = 0; i < 72; i++) { await new Promise(res => setTimeout(res, 5000)); if (i % 4 === 3) FX.post('/api/my/paid', {}).catch(() => {}); const d = await FX.getJSON('/api/my'); if (d.coach) { location.href = '/team'; return; } }
} catch (e) { say(String(e && e.message || e).slice(0, 400), 'err'); $('jBuy').disabled = false; }
};
})();
+51
View File
@@ -0,0 +1,51 @@
// Promote page renderer (2026-11-14). Draws a promo kit (GET /api/promo-kit) into a container: links, creatives grouped by angle,
// swipe lines, headlines, an email and social posts, each with a copy button. Same file on Downline Banners, Viral Banner Blitz, ViralAdBlitz and 5xYourTeam;
// the page script decides the username and the look comes from the site's own CSS (.card, .btn, .kit-*).
window.KitPage = (function () {
const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
async function copy(text, btn) {
try { await navigator.clipboard.writeText(text); } catch (e) {
const t = document.createElement('textarea'); t.value = text; document.body.appendChild(t); t.select(); try { document.execCommand('copy'); } catch (e2) {} t.remove();
}
if (btn) { const o = btn.textContent; btn.textContent = 'Copied'; setTimeout(() => { btn.textContent = o; }, 1400); }
}
const TXT = [];
const cb = (text, label, cls) => { TXT.push(text); return '<button type="button" class="btn small ' + (cls || 'sec') + '" data-kc="' + (TXT.length - 1) + '">' + esc(label || 'Copy') + '</button>'; };
// on the kit's own site, show creatives from this origin (same files; the copied URL stays absolute)
function local(url, k) { try { const u = new URL(url); return u.hostname === k.site && location.hostname !== k.site ? u.pathname : url; } catch (e) { return url; } }
const row = (label, url, cls) => '<div class="kit-row"><div class="kit-l"><span class="kit-lab">' + esc(label) + '</span><code class="kit-url">' + esc(url) + '</code></div>' + cb(url, 'Copy link', cls) + '</div>';
function render(root, k) {
TXT.length = 0;
const angles = []; const by = {};
(k.creatives || []).forEach(c => { if (!by[c.angle]) { by[c.angle] = []; angles.push(c); } by[c.angle].push(c); });
let h = '';
h += '<div class="card"><h3>Your links</h3>' + (k.username ? '<p class="muted small">Every link, creative and line below carries <b>' + esc(k.username) + '</b>.</p>' : '<p class="muted small">Add your network username above so these links carry it.</p>')
+ k.links.map(l => row(l.label, l.url, '') + (l.tracked ? row(l.label + ', tracked', l.tracked, 'sec') : '')).join('')
+ (k.links.some(l => l.tracked) ? '<p class="muted small">A tracked link goes through LinkSpin first, so the network can see which site sent the visit, then opens the same page with your username. Use either one.</p>' : '') + '</div>';
h += '<div class="card"><h3>Creatives</h3><p class="muted small">Download them, or copy the HTML: it already links to you.</p><div class="kit-tabs" role="tablist">'
+ angles.map((c, i) => '<button type="button" class="kit-tab' + (i ? '' : ' on') + '" data-ka="' + esc(c.angle) + '">' + esc(c.angleLabel) + '</button>').join('') + '</div>';
angles.forEach((a, i) => {
h += '<div class="kit-set" data-ks="' + esc(a.angle) + '"' + (i ? ' hidden' : '') + '>' + by[a.angle].map(c =>
'<figure class="kit-fig kit-' + esc(c.shape) + '"><a href="' + esc(c.url) + '" target="_blank" rel="noopener"><img src="' + esc(local(c.url, k)) + '" alt="' + esc(k.name + ', ' + c.label) + '" width="' + c.w + '" height="' + c.h + '" loading="lazy"></a>'
+ '<figcaption><b>' + esc(c.label) + '</b> <span class="muted">' + c.w + 'x' + c.h + '</span><span class="kit-acts"><a class="btn small sec" href="' + esc(c.url) + '" download>Download</a>' + cb(c.url, 'Copy URL') + cb(c.html, 'Copy HTML') + '</span></figcaption></figure>').join('') + '</div>';
});
h += '</div>';
h += '<div class="card"><h3>Short lines</h3><p class="muted small">For chats, comments, text ads and signatures.</p>' + k.lines.map(t => '<div class="kit-row"><p class="kit-txt">' + esc(t) + '</p>' + cb(t) + '</div>').join('') + '</div>';
h += '<div class="card"><h3>Headlines</h3>' + k.headlines.map(t => '<div class="kit-row"><p class="kit-txt"><b>' + esc(t) + '</b></p>' + cb(t) + '</div>').join('') + '</div>';
h += '<div class="card"><h3>Email</h3><div class="kit-row"><p class="kit-txt"><span class="kit-lab">Subject</span>' + esc(k.email.subject) + '</p>' + cb(k.email.subject, 'Copy subject') + '</div>'
+ '<pre class="kit-pre">' + esc(k.email.body) + '</pre><div class="kit-row" style="justify-content:flex-end">' + cb(k.email.body, 'Copy email') + '</div></div>';
h += '<div class="card"><h3>Social posts</h3>' + k.posts.map(t => '<div class="kit-post"><pre class="kit-pre">' + esc(t) + '</pre><div class="kit-row" style="justify-content:flex-end">' + cb(t, 'Copy post') + '</div></div>').join('') + '</div>';
if (k.note) h += '<p class="muted small kit-note">' + esc(k.note) + '</p>';
root.innerHTML = h;
root.querySelectorAll('[data-kc]').forEach(b => b.addEventListener('click', () => copy(TXT[Number(b.dataset.kc)], b)));
root.querySelectorAll('[data-ka]').forEach(b => b.addEventListener('click', () => {
root.querySelectorAll('[data-ka]').forEach(x => x.classList.toggle('on', x === b));
root.querySelectorAll('[data-ks]').forEach(s => { s.hidden = s.dataset.ks !== b.dataset.ka; });
}));
}
async function load(root, u) {
const r = await fetch('/api/promo-kit' + (u ? '?u=' + encodeURIComponent(u) : ''), { cache: 'no-store' });
const k = await r.json(); render(root, k); return k;
}
return { render, load, copy };
})();
+31
View File
@@ -0,0 +1,31 @@
// Live ledger (trust pack): every position with every share paid in the same transaction (sponsor 25%, levels 2-5 5%, with each
// person's place in the buyer's line), who was passed over, the Best Coach pot and the company, plus every Best Coach payout, from
// /api/ledger, refreshed every 30 seconds.
(function () {
FX.renderNav('/ledger'); FX.renderFooter();
const esc = FX.esc;
const pol = w => FX.polOf(w) + ' POL';
const usd = c => '$' + (Number(c || 0) / 100).toFixed(2);
const who = (a, nm) => nm ? '@' + esc(nm) : '<span class="small">' + esc(FX.short(a || '')) + '</span>';
async function load() {
let d; try { d = await FX.getJSON('/api/ledger?n=100'); } catch (e) { return; } if (!d || !d.items) return;
const ex = d.explorer || 'https://polygonscan.com'; const t = d.totals || {};
document.getElementById('totals').innerHTML = '<div class="stat"><span>Positions on-chain</span><b>' + FX.n(t.positions) + '</b></div>'
+ '<div class="stat"><span>To the Best Coach pot</span><b>' + pol(t.potWei) + '</b><em>10% of every position</em></div>'
+ '<div class="stat"><span>In positions</span><b>' + usd(t.usdCents) + '</b><em>at the price when bought</em></div>'
+ '<div class="stat"><span>Withdrawals needed</span><b>0</b><em>every share is paid in the same transaction</em></div>';
const body = document.querySelector('#rows tbody');
if (!d.items.length) body.innerHTML = '<tr><td colspan="4" class="muted">No positions yet. The first one shows here within a minute of its transaction.</td></tr>';
else body.innerHTML = d.items.map(r => {
const link = '<a href="' + esc(ex) + '/tx/' + esc(r.tx) + '" target="_blank" rel="noopener">verify</a>';
const pays = (r.pays || []).map(p => p.level === 0 ? '5xYourTeam: ' + pol(p.wei) : p.level === 6 ? 'Best Coach pot: ' + pol(p.wei)
: (p.level === 1 ? 'Sponsor 25%' : 'Level ' + p.level + ' 5%') + ': ' + pol(p.wei) + ' to ' + (p.to ? who(p.to, p.name) : 'sponsor') + (p.depth && p.depth !== p.level ? ' <span class="small">(place ' + p.depth + ')</span>' : '') + (p.failed ? ' <span class="small">(bounced, waiting in the contract for them to claim)</span>' : '')).join('<br>');
const over = (r.passedOver || []).length ? '<br><span class="small">Passed over (no position yet): ' + r.passedOver.map(o => (o.name ? '@' + esc(o.name) : esc(FX.short(o.who))) + ' at place ' + o.depth).join(', ') + '</span>' : '';
return '<tr><td class="small">' + FX.when(r.at) + '</td><td>' + who(r.buyer, r.buyerName) + ' bought ' + esc(r.what) + ' for ' + usd(r.usdCents) + '</td><td class="small">' + pays + over + '</td><td>' + link + '</td></tr>';
}).join('');
const pb = document.querySelector('#payouts tbody');
pb.innerHTML = (d.payouts || []).length ? d.payouts.map(p => '<tr><td>' + esc(p.week) + '</td><td>#' + esc(p.rank) + ' ' + who(p.coach, p.username) + '</td><td>' + pol(p.wei) + '</td><td><a href="' + esc(ex) + '/tx/' + esc(p.tx) + '" target="_blank" rel="noopener">verify</a></td></tr>').join('')
: '<tr><td colspan="4" class="muted">No Best Coach payouts yet. Each one is listed here with its transaction.</td></tr>';
}
load(); setInterval(load, 30000);
})();
+46
View File
@@ -0,0 +1,46 @@
// Small pages: promote (the kit), builder (my CryptoTeamBuild builder IDs), admin, legal. One file, chosen by data-page on <body>.
(async function () {
const page = document.body.dataset.page; const $ = FX.$, esc = FX.esc;
if (page === 'legal') { FX.renderNav(''); FX.renderFooter(); return; }
if (page === 'promote') {
FX.renderNav(''); FX.renderFooter();
const RE = /^(?:[A-Za-z0-9_.-]{2,40}|0x[0-9a-fA-F]{40})$/;
let u = new URLSearchParams(location.search).get('u') || '';
if (!RE.test(u)) { u = ''; try { const me = await FX.getJSON('/api/me'); if (me.signedIn) u = me.username || me.address || ''; } catch (e) {} }
if (!u) { try { u = localStorage.getItem('kit.u') || ''; } catch (e) {} if (!RE.test(u)) u = ''; }
$('whoIn').value = u;
const show = async name => { try { await KitPage.load($('kit'), name); FX.status(''); } catch (e) { FX.status('Could not load the kit. Try again in a moment.', 'err'); } };
$('whoForm').addEventListener('submit', e => { e.preventDefault(); const v = $('whoIn').value.trim().replace(/^@/, ''); if (v && !RE.test(v)) return FX.status('That does not look like a username.', 'err'); try { localStorage.setItem('kit.u', v); } catch (e2) {} show(v); });
return show(u);
}
if (page === 'builder') {
FX.renderNav(''); FX.renderFooter();
const me = await FX.getJSON('/api/me');
if (!me.signedIn) { $('bSign').hidden = false; $('bSignBox').innerHTML = FX.signInBlock('/builder'); FX.wireSignIn($('bSignBox')); return; }
const d = await FX.getJSON('/api/my/builder'); if (d.error) return FX.status(d.error, 'err');
$('bList').innerHTML = d.programs.map(p => '<div class="kit-row"><div class="kit-l"><span class="kit-lab">' + esc(p.name) + '</span><code class="kit-url">' + esc(p.example) + '</code></div><div class="row dark" style="flex:0 1 320px"><input data-p="' + esc(p.id) + '" value="' + esc(p.myId) + '" placeholder="your referral ID" aria-label="Your referral ID for ' + esc(p.name) + '"><button type="button" class="btn small" data-s="' + esc(p.id) + '">Save</button></div></div>').join('');
document.querySelectorAll('[data-s]').forEach(b => b.onclick = async () => { const inp = document.querySelector('[data-p="' + b.dataset.s + '"]'); const r = await FX.post('/api/my/builder', { program: b.dataset.s, refId: inp.value }); FX.status(r.error || 'Saved. Your picks see this link when they open your builder links.', r.error ? 'err' : 'ok'); if (!r.error) inp.value = r.refId; });
return;
}
if (page === 'admin') {
FX.renderNav(''); FX.renderFooter();
let tok = ''; try { tok = sessionStorage.getItem('fx.admin') || ''; } catch (e) {}
const H = () => ({ 'x-admin-token': tok, 'Content-Type': 'application/json' });
const show = (el, o) => { el.textContent = JSON.stringify(o, null, 2); };
const load = async () => { if (!tok) return; show($('statusOut'), await FX.getJSON('/api/admin/status', { headers: H() })); show($('potOut'), await FX.getJSON('/api/admin/pot', { headers: H() })); };
$('tokForm').addEventListener('submit', e => { e.preventDefault(); tok = $('tok').value.trim(); try { sessionStorage.setItem('fx.admin', tok); } catch (x) {} load(); });
$('tickBtn').onclick = async () => { show($('statusOut'), await FX.getJSON('/api/admin/tick', { method: 'POST', headers: H(), body: '{}' })); };
$('oldFile').addEventListener('change', async e => { const f = e.target.files[0]; if (!f) return; const r = await fetch('/api/admin/oldrefs', { method: 'POST', headers: H(), body: await f.text() }); show($('oldOut'), await r.json()); });
return load();
}
if (page === 'draftday') {
// the 1080 x 1080 Draft Day results card (tools/art.mjs renders it to PNG for Telegram); no nav, no footer
const wk = location.pathname.split('/').pop();
const d = await FX.getJSON('/api/draftday?week=' + encodeURIComponent(wk));
$('ddWeek').textContent = 'WEEK ' + FX.weekNo(wk);
$('ddRows').innerHTML = (d.rows || []).slice(0, 6).map(r => '<div class="dd-r"><span class="s">' + esc(r.slot) + '</span><span>@' + esc(r.coach) + ' takes @' + esc(r.person) + '</span></div>').join('') || '<div class="dd-r"><span>No picks yet</span></div>';
$('ddStats').textContent = FX.n(d.players || 0) + ' players drafted · ' + FX.n(d.coaches || 0) + ' coaches';
$('ddPot').textContent = 'Best Coach pot: ' + FX.polOf(d.potWei || 0) + ' POL';
document.body.dataset.ready = '1';
}
})();
+81
View File
@@ -0,0 +1,81 @@
// My Team (the coach's dashboard): stat tiles, instant picks left, the focused pick card (scouting stats, the getting-started
// steps, one-tap messages, the message composer and thread, release), the rest of the team, who to help first, the draft queue.
// Someone who is a pick sees their coach here instead (steps, the thread, the coach's builder links). Messages go through the
// site only; no contact details are ever shown. Every figure comes from /api/my.
(async function () {
FX.renderNav('/team'); FX.renderFooter();
const $ = FX.$, esc = FX.esc;
const c = await FX.getConfig().catch(() => ({}));
const me = await FX.getJSON('/api/me');
if (!me.signedIn) {
if (await FX.silentSso('/team')) return;
$('signin').hidden = false; $('signinBox').innerHTML = FX.signInBlock('/team'); FX.wireSignIn($('signinBox')); return;
}
$('signout').hidden = false; $('signout').onclick = async () => { await FX.post('/api/auth/logout'); location.reload(); };
const pol = w => w == null ? 'not tracked yet' : FX.polOf(w) + ' POL';
let D = null, focus = null;
const stat = (k, v, note) => '<div class="stat"><span>' + k + '</span><b>' + v + '</b>' + (note ? '<em>' + note + '</em>' : '') + '</div>';
const stepsHtml = steps => '<div class="steps">' + steps.map(s => '<div class="' + (s.done ? 'done' : s.next ? 'next' : '') + '">' + esc(s.label) + (s.next ? ' (next)' : '') + '</div>').join('') + '</div>';
const thread = items => items.length ? items.map(x => '<div class="msg' + (x.mine ? ' mine' : '') + '">' + esc(x.text) + '<em>' + esc(FX.when(x.at)) + '</em></div>').join('') : '<p class="small" style="color:#4a587e">No messages yet. Say hello: they see it in their member area.</p>';
async function load() {
const d = await FX.getJSON('/api/my'); if (d.error) { FX.status(d.error, 'err'); return; }
D = d; $('dash').hidden = false;
$('hello').textContent = d.username ? '@' + d.username : FX.short(d.address);
// a pick: their coach
if (d.myCoach) {
const mc = d.myCoach; $('myCoach').hidden = false;
$('mcName').textContent = '@' + mc.coach; $('mcTier').textContent = mc.tierName + ' · on the team since ' + FX.when(mc.since);
$('mcSteps').innerHTML = stepsHtml(mc.steps);
$('mcThread').innerHTML = thread(mc.messages.map(x => ({ mine: x.dir === 'out', text: x.text, at: x.at })));
$('mcSend').onclick = async () => { const t = $('mcText').value.trim(); if (!t) return; const r = await FX.post('/api/my/message', { pick: mc.pickId, text: t }); if (r.error) return FX.status(r.error, 'err'); $('mcText').value = ''; load(); };
$('mcBuilder').innerHTML = mc.builder.slice(0, 8).map(p => '<a class="btn small" href="' + esc(p.url) + '" target="_blank" rel="noopener nofollow">' + esc(p.name) + '</a>').join(' ') || '<span class="small">No builder links yet.</span>';
}
if (!d.coach && !d.picks.length) { $('noCoach').hidden = false; if (!d.myCoach) $('coachTools').hidden = true; return; }
$('coachTools').hidden = false;
const s = d.stats;
$('stats').innerHTML = stat('On my team', s.onTeam, s.open + ' open of ' + s.maxOpen) + stat('Started this week', s.startedThisWeek, 'payouts on or a first purchase')
+ stat('Next draft spot', s.nextSpot ? '#' + s.nextSpot : '-', 'earned by this week\'s starts') + stat('Back to pool soon', s.backSoon, 'within 24 hours');
$('credits').hidden = !(d.credits > 0);
$('creditsN').textContent = d.credits + ' instant pick' + (d.credits === 1 ? '' : 's');
if (d.page) { $('myPage').hidden = false; $('myPageLink').href = d.page; $('myPageLink').textContent = d.page.replace(/^https:\/\//, ''); }
const team = d.picks.filter(p => ['open', 'done', 'kept'].includes(p.status));
if (!focus || !team.some(p => p.id === focus)) focus = (d.help[0] && d.help[0].pickId) || (team[0] && team[0].id) || null;
paintFocus(team.find(p => p.id === focus));
const rest = team.filter(p => p.id !== focus);
$('team').innerHTML = rest.length ? rest.map(p => '<button type="button" class="mini' + (p.id === focus ? ' on' : '') + '" data-f="' + p.id + '"><b>@' + esc(p.username || 'player') + '</b><span class="t">' + esc(p.tierName) + (p.status === 'open' ? '' : ' · on the team') + '</span><span class="s">'
+ esc(p.status === 'open' ? (p.daysLeft <= 1 ? 'Back to the pool in ' + (p.daysLeft ? '1 day' : 'under a day') : (d.help.find(h => h.pickId === p.id) || {}).why || '') : 'Started: stays on your team') + (p.unread ? ' · ' + p.unread + ' new' : '') + '</span></button>').join('')
: '<p class="muted">' + (team.length ? 'Nobody else on the team yet. ' : 'No picks yet. ') + (d.credits ? 'Use your instant picks on the Draft Board.' : 'Your next picks come in the Monday draft.') + '</p>';
document.querySelectorAll('[data-f]').forEach(b => b.onclick = () => { focus = Number(b.dataset.f); load(); });
$('help').innerHTML = d.help.length ? d.help.slice(0, 8).map(h => '<div class="h"><div><b>@' + esc(h.username || 'player') + '</b><div class="small">' + esc(h.why) + '</div></div><button type="button" class="btn small" data-f2="' + h.pickId + '">Coach them</button></div>').join('')
: '<p class="muted small">Nobody needs a nudge right now.</p>';
document.querySelectorAll('[data-f2]').forEach(b => b.onclick = () => { focus = Number(b.dataset.f2); load().then(() => $('focus').scrollIntoView({ behavior: 'smooth' })); });
const past = d.picks.filter(p => p.status === 'returned');
$('pastWrap').hidden = !past.length;
$('past').innerHTML = past.slice(0, 12).map(p => '<span class="btn-ghost">@' + esc(p.username || 'player') + '</span>').join(' ');
$('queue').innerHTML = d.queue.length ? '<p class="small">' + d.queue.length + ' player' + (d.queue.length === 1 ? '' : 's') + ' on your queue. If you are away when your pick comes up, the first one still available is drafted for you. Edit it on the <a href="/">Draft Board</a>.</p>' : '<p class="small">Your queue is empty: if you are away when your pick comes up, the best available player by scouting score is drafted for you. Add players from the <a href="/">Draft Board</a>.</p>';
}
async function paintFocus(p) {
const el = $('focus'); if (!p) { el.hidden = true; return; } el.hidden = false;
const label = p.kind === 'instant' ? 'INSTANT PICK' : 'ROUND ' + (p.round || '?') + ' PICK';
$('fKick').textContent = label + ' · ' + p.tierName.toUpperCase();
$('fName').textContent = '@' + (p.username || 'player');
$('fWhen').textContent = 'Picked ' + FX.when(p.at) + (p.status === 'open' ? ' · ' + (p.daysLeft ? p.daysLeft + ' day' + (p.daysLeft === 1 ? '' : 's') + ' left to start' : 'goes back to the pool today') : ' · started, stays on your team');
$('fStats').innerHTML = [['Game plays', p.plays == null ? 'not tracked yet' : FX.n(p.plays) + (p.game ? ' (' + p.game + ')' : '')], ['Earned in games', pol(p.gameWei)], ['Earned surfing', pol(p.surfWei)], ['Came from', p.door || 'not tracked yet'], ['Last seen', FX.ago(p.lastSeen)]]
.map(r => '<div class="kvr"><span>' + r[0] + '</span><b>' + esc(r[1]) + '</b></div>').join('');
$('fSteps').innerHTML = stepsHtml(p.steps);
const h = D.help.find(x => x.pickId === p.id);
const taps = [h ? h.say : 'Great work so far. Anything I can help with?', 'Any questions so far? Reply here and I will walk you through it.', p.game ? 'Nice run in ' + p.game + '!' : 'Welcome to the team! I am here to help.'];
$('fTaps').innerHTML = taps.map((t, i) => '<button type="button" data-tap="' + i + '">"' + esc(t) + '"</button>').join('');
document.querySelectorAll('[data-tap]').forEach(b => b.onclick = () => { $('fText').value = taps[Number(b.dataset.tap)]; $('fText').focus(); });
$('fSend').onclick = async () => { const t = $('fText').value.trim(); if (!t) return; const r = await FX.post('/api/my/message', { pick: p.id, text: t }); if (r.error) return FX.status(r.error, 'err'); $('fText').value = ''; FX.status('Sent. They see it in their member area.', 'ok'); thr(); };
$('fRelease').hidden = p.status !== 'open';
$('fRelease').onclick = async () => { if (!confirmBox()) return; const r = await FX.post('/api/my/release', { pick: p.id }); FX.status(r.error || 'Released back to the pool.', r.error ? 'err' : 'ok'); load(); };
async function thr() { const t = await FX.getJSON('/api/my/messages?pick=' + p.id); $('fThread').innerHTML = thread(t.items || []); }
thr();
}
// releasing is a commitment decision: ask in the page (no browser dialogs)
let armed = 0; function confirmBox() { if (Date.now() - armed < 6000) { armed = 0; return true; } armed = Date.now(); FX.status('Tap "Release to the pool" again within 6 seconds to confirm. They go back to the pool for another coach, and it still counts as one of their two adoptions.', ''); return false; }
await load();
setInterval(() => { load().catch(() => {}); }, 30000);
})();
+233
View File
@@ -0,0 +1,233 @@
// 5xYourTeam wallet sign-in: the VBB / Downline Banners wallet.js (same AppKit build, chain guard, dead-session recovery)
// with its buy flow (2026-11-14): sendTx() hard-guards the chain, sets Polygon's fee floor from /api/gas and recovers a dead
// WalletConnect session once; waitTx() polls /api/tx; balance() is the pre-flight check. The page builds the call on the server.
window.FXWallet = (function () {
const pad = v => BigInt(v).toString(16).padStart(64, '0');
const padAddr = a => { if (!a) return pad(0); if (!/^0x[0-9a-fA-F]{40}$/.test(a)) throw new Error('Bad address: ' + a); return a.slice(2).toLowerCase().padStart(64, '0'); };
// Normalize a chainId to a decimal number. eth_chainId is meant to return a
// hex string, but some wallets return a number or a decimal string — compare
// numerically so a wallet's shape never crashes the flow.
const chainNum = v => {
if (v == null) return NaN;
if (typeof v === 'number') return v;
const s = String(v).trim();
return /^0x/i.test(s) ? parseInt(s, 16) : parseInt(s, 10);
};
const APPKIT_URL = 'https://cdn.jsdelivr.net/npm/@reown/appkit-cdn@1.8.23/dist/appkit.js';
let modal = null, akPromise = null, provider = null;
async function initAppKit(c) {
if (modal) return modal;
if (akPromise) return akPromise;
akPromise = (async () => {
const mod = await import(APPKIT_URL);
const { createAppKit, WagmiAdapter, networks } = mod;
const netMap = { 80002: networks.polygonAmoy, 137: networks.polygon, 31337: networks.hardhat || networks.localhost };
const base = netMap[Number(c.chainId)] || networks.polygonAmoy;
// Override the chain's RPC with our clean public endpoint. AppKit's built-in
// networks advertise the WalletConnect RPC proxy
// (rpc.walletconnect.org/v1/?chainId=…&projectId=…) as the chain RPC, and
// wallets reject that query-string URL as "Invalid URL" when adding/switching
// the network — the cause of Trust's "Invalid URL", MetaMask's switch loop,
// and the failed mobile buy (the chain switch never completed).
const rpc = String(c.rpc || '').trim();
const net = rpc ? Object.assign({}, base, { rpcUrls: { default: { http: [rpc] }, public: { http: [rpc] } } }) : base;
// Accept the wallet's usual networks too, so AppKit doesn't trap the user in
// its own "Switch Network" modal — that modal loops on a testnet the wallet
// can't auto-add. We switch to `net` ourselves (wallet_addEthereumChain adds
// + switches in one step) and sendTx hard-guards the chain before signing.
const allNets = [net];
for (const k of ['polygon', 'mainnet']) {
try { const n = networks[k]; if (n && n.id !== net.id) allNets.push(n); } catch (e) {}
}
const projectId = String(c.walletConnectProjectId || '').trim();
const wagmiAdapter = new WagmiAdapter({ networks: allNets, projectId });
modal = createAppKit({
adapters: [wagmiAdapter], networks: allNets, projectId, defaultNetwork: net,
metadata: { name: '5xYourTeam', description: 'The weekly draft for people who need a sponsor.',
url: location.origin, icons: [location.origin + '/art/icon-192.png'] },
features: { analytics: false, email: false, socials: [] },
// Picker order: wallets without Trust's balance-proportion block go first.
// Trust Wallet is NOT excluded; it just drops out of the featured row into
// "All wallets" (Marty, 2026-09-09: move Trust to the bottom, not off).
featuredWalletIds: [
'0b415a746fb9ee99cce155c2ceca0c6f6061b1dbca2d722b3ba16381d0562150', // SafePal (recommended, listed first)
'c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96', // MetaMask
'a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393', // Phantom
'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa' // Coinbase Wallet
]
});
return modal;
})();
return akPromise;
}
function currentAddress() { try { return (modal && modal.getAddress && modal.getAddress()) || null; } catch (e) { return null; } }
function waitForConnection(timeoutMs) {
if (currentAddress()) return Promise.resolve(currentAddress());
return new Promise((resolve, reject) => {
let done = false, unsub = null;
const finish = (addr, err) => { if (done) return; done = true; try { unsub && unsub(); } catch (e) {} err ? reject(err) : resolve(addr); };
try { unsub = modal.subscribeAccount(acc => { if (acc && acc.isConnected && acc.address) finish(acc.address); }); } catch (e) {}
const t0 = Date.now();
(function poll() {
if (done) return;
const a = currentAddress();
if (a) return finish(a);
if (Date.now() - t0 > (timeoutMs || 180000)) return finish(null, new Error('Wallet connection timed out. Tap Connect and try again.'));
setTimeout(poll, 400);
})();
});
}
async function resolveProvider() {
for (let i = 0; i < 20; i++) {
try { const p = modal.getWalletProvider ? await Promise.resolve(modal.getWalletProvider()) : null; if (p && p.request) return p; } catch (e) {}
await new Promise(r => setTimeout(r, 300));
}
throw new Error('Could not reach your wallet. Try connecting again.');
}
function eth() { if (!provider) throw new Error('Connect your wallet first.'); return provider; }
const isInjected = () => !!(provider && window.ethereum && (provider === window.ethereum || provider.isMetaMask));
// the account the wallet will actually sign with: for an injected wallet (MetaMask
// extension) that is its active account, which can differ from AppKit's cached one
async function activeAddress(fallback) {
if (isInjected()) { try { const a = await provider.request({ method: 'eth_accounts' }); if (a && a[0]) return a[0]; } catch (e) {} }
return fallback || currentAddress();
}
// Force the wallet's own account picker. Injected wallets stay connected to the
// site, so a plain disconnect/reconnect never shows one: asking for permissions
// again makes MetaMask open its account-selection prompt, and whatever the user
// ticks becomes the active account. WalletConnect wallets fall back to a fresh
// session (the picker + the wallet app's own account choice).
async function pickAccount() {
const c = await FX.getConfig();
await initAppKit(c);
const inj = window.ethereum;
if (inj && inj.request) {
try {
await inj.request({ method: 'wallet_requestPermissions', params: [{ eth_accounts: {} }] });
const accs = await inj.request({ method: 'eth_accounts' });
if (accs && accs[0]) { provider = inj; await ensureChain(c).catch(() => {}); return accs[0]; }
} catch (e) {
if (e && (e.code === 4001 || /reject|denied/i.test(String(e.message || '')))) throw new Error('You closed the account picker. Pick the account you want and try again.');
}
}
return freshConnect(c);
}
// A WalletConnect session can die underneath AppKit's cached "connected"
// state: the wallet app rejects or kills it (Trust does this after its own
// security stop), the phone sleeps, the relay drops. AppKit still reports an
// address, so the next request fails with a "disconnected" style error.
// Detect that, wipe the stale session, and re-open the picker for a fresh one.
const DEAD_RE = /disconnect|not connected|no matching key|session (topic|expired|deleted|not found)|call connect|please call connect|missing or invalid|relay/i;
const isDead = e => DEAD_RE.test(String((e && e.message) || e || ''));
async function freshConnect(c) {
try { FX.status('Your wallet session dropped. Reconnect in the picker…'); } catch (e) {}
await disconnect();
try { await modal.open(); } catch (e) {}
const addr = await waitForConnection(180000);
try { if (modal && modal.close) await modal.close(); } catch (e) {}
provider = await resolveProvider();
await ensureChain(c).catch(() => {});
return addr;
}
async function connect() {
const c = await FX.getConfig();
await initAppKit(c);
let addr = currentAddress();
if (!addr) {
// give AppKit a moment to rehydrate an existing session before popping the
// picker — otherwise an already-connected wallet still gets the modal
for (let i = 0; i < 8 && !addr; i++) { await new Promise(r => setTimeout(r, 150)); addr = currentAddress(); }
}
if (!addr) { try { await modal.open(); } catch (e) {} addr = await waitForConnection(180000); }
try { if (modal && modal.close) await modal.close(); } catch (e) {} // dismiss the picker once we're connected
provider = await resolveProvider();
// probe the session: a dead WalletConnect session answers with a disconnect error
try { await provider.request({ method: 'eth_chainId' }); }
catch (e) { if (isDead(e)) return freshConnect(c); }
await ensureChain(c).catch(() => {}); // AppKit already connects on the right network; switch is best-effort
return addr;
}
async function ensureChain(c) {
const want = '0x' + Number(c.chainId).toString(16);
let cur; try { cur = await eth().request({ method: 'eth_chainId' }); } catch (e) { return; }
if (chainNum(cur) === Number(c.chainId)) return;
try {
await eth().request({ method: 'wallet_switchEthereumChain', params: [{ chainId: want }] });
} catch (e) {
// any failure (not just 4902): try to add the chain — wallet_addEthereumChain
// adds AND switches in one step, which is what unblocks wallets that can't
// otherwise reach a chain they don't already have (e.g. a testnet).
const addParams = { chainId: want, chainName: c.chainName, nativeCurrency: { name: 'POL', symbol: 'POL', decimals: 18 }, rpcUrls: [c.rpc] };
if (c.explorer && /^https?:\/\//i.test(c.explorer)) addParams.blockExplorerUrls = [c.explorer];
try { await eth().request({ method: 'wallet_addEthereumChain', params: [addParams] }); } catch (e2) {}
}
}
// SIWE: challenge -> personal_sign -> verify (server sets the session cookie)
async function signIn(opts) {
const addr = (opts && opts.pick) ? await pickAccount() : await activeAddress(await connect());
const ch = await (await fetch('/api/auth/challenge', { method: 'POST',
headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ address: addr }) })).json();
if (ch.error) throw new Error(ch.error);
// hex-encode the message (Trust and others require hex for personal_sign)
const hexMsg = '0x' + Array.from(new TextEncoder().encode(ch.message)).map(b => b.toString(16).padStart(2, '0')).join('');
const sig = await eth().request({ method: 'personal_sign', params: [hexMsg, addr] });
const r = await (await fetch('/api/auth/verify', { method: 'POST',
headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ address: addr, signature: sig, asPosition: !!(opts && opts.asPosition) }) })).json();
if (r.error) throw new Error(r.error);
return r;
}
async function sendTx(to, data, valueHex) {
const c = await FX.getConfig();
const addr = await connect();
const wantNum = Number(c.chainId);
let cur; try { cur = await eth().request({ method: 'eth_chainId' }); } catch (e) {}
if (!isNaN(chainNum(cur)) && chainNum(cur) !== wantNum) {
await ensureChain(c);
try { cur = await eth().request({ method: 'eth_chainId' }); } catch (e) {}
if (!isNaN(chainNum(cur)) && chainNum(cur) !== wantNum)
throw new Error('Your wallet is on the wrong network. Switch it to ' + (c.chainName || 'Polygon') + ', then try again.');
}
const tx = { from: await activeAddress(addr), to, data };
if (valueHex) tx.value = valueHex;
try { const g = await (await fetch('/api/gas')).json(); if (g && g.maxPriorityFeePerGas && g.maxFeePerGas) { tx.maxPriorityFeePerGas = g.maxPriorityFeePerGas; tx.maxFeePerGas = g.maxFeePerGas; } } catch (e) {}
try { return await eth().request({ method: 'eth_sendTransaction', params: [tx] }); }
catch (e) {
if (!isDead(e)) throw e;
tx.from = await freshConnect(c);
return eth().request({ method: 'eth_sendTransaction', params: [tx] });
}
}
async function waitTx(hash) {
for (let i = 0; i < 120; i++) {
try { const r = await (await fetch('/api/tx/' + hash)).json(); if (r.found) return r; } catch (e) { /* app switch on a phone: keep polling */ }
await new Promise(res => setTimeout(res, 2500));
}
throw new Error('Still waiting for the transaction. Check it on the explorer; your position shows once it confirms.');
}
async function balance(addr) {
await connect();
return BigInt(await eth().request({ method: 'eth_getBalance', params: [addr || currentAddress(), 'latest'] }));
}
async function disconnect() {
// AppKit's disconnect can hang on the WalletConnect relay (esp. mobile) —
// never block on it, so the UI can't get stuck "disconnecting".
try { if (modal && modal.disconnect) await Promise.race([modal.disconnect(), new Promise(r => setTimeout(r, 1200))]); } catch (e) {}
provider = null;
try { Object.keys(localStorage).forEach(k => { if (/wc@2|walletconnect|w3m|wcm|reown|wagmi|appkit/i.test(k)) localStorage.removeItem(k); }); } catch (e) {}
}
function walletName() { try { const w = modal && modal.getWalletInfo && modal.getWalletInfo(); return (w && w.name) || ''; } catch (e) { return ''; } }
return { connect, signIn, sendTx, waitTx, balance, disconnect, address: currentAddress, activeAddress, pickAccount, walletName };
})();
+35
View File
@@ -0,0 +1,35 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
<title>My Builder Links | 5xYourTeam</title>
<meta name="description" content="Your referral IDs in the CryptoTeamBuild downline builder: your picks see your links.">
<meta name="robots" content="noindex">
<meta property="og:type" content="website">
<meta property="og:site_name" content="5xYourTeam">
<meta property="og:title" content="My Builder Links | 5xYourTeam">
<meta property="og:description" content="Your referral IDs in the CryptoTeamBuild downline builder: your picks see your links.">
<meta property="og:url" content="https://5xyourteam.com/builder">
<meta property="og:image" content="https://5xyourteam.com/art/og-share.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://5xyourteam.com/art/og-share.png">
<meta name="theme-color" content="#07102a">
<link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Oswald:wght@500;700&family=Inter:wght@400;600;700&display=swap">
<link rel="stylesheet" href="/assets/fx.css?v=1">
</head>
<body data-page="builder">
<main class="wrap">
<section><p class="kicker">MY BUILDER LINKS</p><h1 style="font-size:44px">The CryptoTeamBuild downline builder</h1><p class="muted">Save your referral ID for the programs you are in. Your picks see your link for each one on their My Team page.</p></section>
<section id="bSign" class="panel" hidden><div id="bSignBox"></div></section>
<p id="status" class="note" hidden></p>
<section class="panel" id="bList"></section>
</main>
<script src="/assets/common.js?v=1"></script>
<script src="/assets/wallet.js?v=1"></script>
<script src="/assets/misc.js?v=1"></script>
</body>
</html>
+34
View File
@@ -0,0 +1,34 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
<title>Card Collection | 5xYourTeam</title>
<meta name="description" content="Trading cards that level up as your picks do: Rookie, Starter, Pro, All-Star, Hall of Fame.">
<link rel="canonical" href="https://5xyourteam.com/cards">
<meta property="og:type" content="website">
<meta property="og:site_name" content="5xYourTeam">
<meta property="og:title" content="Card Collection | 5xYourTeam">
<meta property="og:description" content="Trading cards that level up as your picks do: Rookie, Starter, Pro, All-Star, Hall of Fame.">
<meta property="og:url" content="https://5xyourteam.com/cards">
<meta property="og:image" content="https://5xyourteam.com/art/og-share.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://5xyourteam.com/art/og-share.png">
<meta name="theme-color" content="#07102a">
<link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Oswald:wght@500;700&family=Inter:wght@400;600;700&display=swap">
<link rel="stylesheet" href="/assets/fx.css?v=1">
</head>
<body>
<main class="wrap">
<section class="sh"><div><p class="kicker">CARD COLLECTION</p><h1 style="font-size:44px">Trading cards: they level up as your picks do</h1></div><p>Public cards show milestones, never earnings.</p></section>
<section id="mine" hidden style="display:flex;flex-direction:column;gap:12px"><h2 id="mineTitle"></h2><div class="cards" id="mineCards"></div></section>
<section style="display:flex;flex-direction:column;gap:12px"><h2>The five tiers</h2><div class="cards" id="tiers"></div>
<p class="small">Rookie when drafted, Starter when they link a wallet, Pro when they switch on payouts, All-Star at their first purchase, Hall of Fame when they hold a position of their own and coach a team.</p></section>
</main>
<script src="/assets/common.js?v=1"></script>
<script src="/assets/cards.js?v=1"></script>
</body>
</html>
+33
View File
@@ -0,0 +1,33 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
<title>Coach | 5xYourTeam</title>
<meta name="description" content="A 5xYourTeam coach and their team, as trading cards.">
<link rel="canonical" href="https://5xyourteam.com/">
<meta property="og:type" content="website">
<meta property="og:site_name" content="5xYourTeam">
<meta property="og:title" content="Coach | 5xYourTeam">
<meta property="og:description" content="A 5xYourTeam coach and their team, as trading cards.">
<meta property="og:url" content="https://5xyourteam.com/">
<meta property="og:image" content="https://5xyourteam.com/art/og-share.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://5xyourteam.com/art/og-share.png">
<meta name="theme-color" content="#07102a">
<link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Oswald:wght@500;700&family=Inter:wght@400;600;700&display=swap">
<link rel="stylesheet" href="/assets/fx.css?v=1">
</head>
<body>
<main class="wrap">
<section class="ccard"><div class="l"><span class="kicker">COACH</span><b id="cName"></b><span class="muted small" id="cSince"></span><div id="cStats" style="display:flex;flex-direction:column;gap:4px;font-size:14px"></div></div>
<div class="r"><h3>The team</h3><p class="small" style="color:#4a587e">Milestones only. Every Monday this coach drafts people who joined the network without a sponsor and helps them get started.</p><div class="row"><a class="btn-gold" id="cJoin" href="https://instantadpay.com/">Join the network free</a><a class="btn" href="/join">Coach a team of your own</a></div></div></section>
<section class="cards" id="cTeam"></section>
</main>
<script src="/assets/common.js?v=1"></script>
<script src="/assets/coach.js?v=1"></script>
</body>
</html>
+32
View File
@@ -0,0 +1,32 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
<title>The Contract | 5xYourTeam</title>
<meta name="description" content="DraftPosition on Polygon: who owns it, the fixed split, the Best Coach pot wallet, what it holds.">
<link rel="canonical" href="https://5xyourteam.com/contract">
<meta property="og:type" content="website">
<meta property="og:site_name" content="5xYourTeam">
<meta property="og:title" content="The Contract | 5xYourTeam">
<meta property="og:description" content="DraftPosition on Polygon: who owns it, the fixed split, the Best Coach pot wallet, what it holds.">
<meta property="og:url" content="https://5xyourteam.com/contract">
<meta property="og:image" content="https://5xyourteam.com/art/og-share.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://5xyourteam.com/art/og-share.png">
<meta name="theme-color" content="#07102a">
<link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Oswald:wght@500;700&family=Inter:wght@400;600;700&display=swap">
<link rel="stylesheet" href="/assets/fx.css?v=1">
</head>
<body>
<main class="wrap">
<section><p class="kicker">CONTRACT</p><h1 style="font-size:44px">Check the contract yourself</h1><p class="muted">Read live from Polygon. No owner withdraw, no proxy, the split fixed in the code.</p></section>
<section class="panel"><div class="tbl"><table id="facts"></table></div></section>
</main>
<script src="/assets/common.js?v=1"></script>
<script src="/assets/contract.js?v=1"></script>
</body>
</html>
+36
View File
@@ -0,0 +1,36 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
<title>Earnings Disclaimer | 5xYourTeam</title>
<meta name="description" content="A position buys a draft spot and coaching tools, not income. Nothing is promised.">
<link rel="canonical" href="https://5xyourteam.com/disclaimer">
<meta property="og:type" content="website">
<meta property="og:site_name" content="5xYourTeam">
<meta property="og:title" content="Earnings Disclaimer | 5xYourTeam">
<meta property="og:description" content="A position buys a draft spot and coaching tools, not income. Nothing is promised.">
<meta property="og:url" content="https://5xyourteam.com/disclaimer">
<meta property="og:image" content="https://5xyourteam.com/art/og-share.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://5xyourteam.com/art/og-share.png">
<meta name="theme-color" content="#07102a">
<link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Oswald:wght@500;700&family=Inter:wght@400;600;700&display=swap">
<link rel="stylesheet" href="/assets/fx.css?v=1">
</head>
<body data-page="legal">
<main class="wrap legal">
<section><p class="kicker">5XYOURTEAM</p><h1 style="font-size:44px">Earnings Disclaimer</h1><p class="muted">A position buys a draft spot and coaching tools, not income. Nothing is promised.</p></section>
<section class="card"><h2>What you are buying</h2><p>A 5xYourTeam position is a seat in the weekly draft and the tools to coach the people you draft. It is not an investment, a business opportunity, a share of profits or a promise of any payment.</p></section>
<section class="card"><h2>Level shares and prizes are not promised</h2><p>The contract pays a level share only when someone in your line chooses to buy a position. Nobody is required to buy one, and we do not know or promise whether anyone ever will. Many coaches receive nothing, and many receive less than they spend. The Best Coach pot depends on what is sold that week. Your results depend on other people's free choices.</p></section>
<section class="card"><h2>No examples are promises</h2><p>Any number on this site, in the ledger or in a Telegram post shows what really happened in one transaction. It is not a typical result and not a forecast.</p></section>
<section class="card"><h2>Prices and taxes</h2><p>Positions are priced in US dollars and paid in POL, whose price moves. You are responsible for any taxes on what you receive where you live.</p></section>
<section class="card"><h2>Who to ask</h2><p>TrustClickz, 615 Green Valley Drive, Moody, AL 35004. <a href="https://instantadpay.com/support" target="_blank" rel="noopener">Network support</a>.</p></section>
</main>
<script src="/assets/common.js?v=1"></script>
<script src="/assets/misc.js?v=1"></script>
</body>
</html>
+13
View File
@@ -0,0 +1,13 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="robots" content="noindex"><title>Draft Day | 5xYourTeam</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Oswald:wght@500;700&family=Inter:wght@400;600;700&display=swap"><style>
*{box-sizing:border-box}body{margin:0;width:1080px;height:1080px;overflow:hidden;background:#0b1530}
.dd{width:1080px;height:1080px;background:#0b1530;color:#fff;font-family:Inter,system-ui,sans-serif;padding:64px;display:flex;flex-direction:column;gap:32px;border:14px solid #ffc93c}
.top{display:flex;justify-content:space-between;align-items:center}.wm{font-family:Oswald,Impact,sans-serif;font-weight:700;font-size:44px;letter-spacing:1px}.wm b{color:#ffc93c}
.wk{font-family:Oswald,sans-serif;font-size:22px;background:#ff4d4d;padding:6px 14px;letter-spacing:3px}
h1{margin:0;font-family:Oswald,Impact,sans-serif;font-weight:700;font-size:120px;line-height:.95}h1 span{color:#ffc93c}
.rows{display:flex;flex-direction:column;gap:14px;font-size:30px}.dd-r{display:flex;justify-content:space-between;border-bottom:2px solid #2a3a6e;padding-bottom:10px}.dd-r .s{font-family:Oswald,sans-serif;color:#ffc93c}
.ft{margin-top:auto;display:flex;justify-content:space-between;align-items:flex-end}.ft div{display:flex;flex-direction:column;gap:6px;font-size:26px}.ft .p{color:#ffc93c}.url{font-family:Oswald,sans-serif;font-size:26px;color:#b8c4e0}
</style></head><body data-page="draftday"><div class="dd"><div class="top"><span class="wm">5X<b>YOUR</b>TEAM</span><span class="wk" id="ddWeek"></span></div>
<h1>DRAFT DAY<br><span>RESULTS</span></h1><div class="rows" id="ddRows"></div>
<div class="ft"><div><span id="ddStats"></span><span class="p" id="ddPot"></span></div><span class="url">5xyourteam.com</span></div></div>
<script src="/assets/common.js?v=1"></script><script src="/assets/misc.js?v=1"></script></body></html>
+59
View File
@@ -0,0 +1,59 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
<title>5xYourTeam | The weekly draft for people who need a sponsor</title>
<meta name="description" content="Every Monday the coaches draft people who joined the network without a sponsor. A $10 one-time position: 5 picks right away and a draft spot every week. Draft order is earned.">
<link rel="canonical" href="https://5xyourteam.com/">
<meta property="og:type" content="website">
<meta property="og:site_name" content="5xYourTeam">
<meta property="og:title" content="5xYourTeam | The weekly draft for people who need a sponsor">
<meta property="og:description" content="Every Monday the coaches draft people who joined the network without a sponsor. A $10 one-time position: 5 picks right away and a draft spot every week. Draft order is earned.">
<meta property="og:url" content="https://5xyourteam.com/">
<meta property="og:image" content="https://5xyourteam.com/art/og-share.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://5xyourteam.com/art/og-share.png">
<meta name="theme-color" content="#07102a">
<link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Oswald:wght@500;700&family=Inter:wght@400;600;700&display=swap">
<link rel="stylesheet" href="/assets/fx.css?v=1">
</head>
<body>
<main class="wrap">
<section class="hero">
<div class="copy"><p class="kicker" id="heroKick">THE DRAFT</p><h1 id="heroTitle">Draft your team every Monday.</h1>
<p class="lead">Draft order is earned: the coaches who got the most of last week's picks started pick first. Help your picks get going and you move up next Monday.</p>
<p class="clock" id="heroClock" hidden></p></div>
<div class="potbox"><span class="lab">Best Coach pot this week</span><b class="big" id="potWei">0 POL</b><span class="muted small">10% of every position sold this week</span><div class="kv" id="potRank"></div></div>
</section>
<p id="status" class="note" hidden></p>
<section style="display:flex;flex-direction:column;gap:12px">
<div class="sh"><h2>This week's pool</h2><p id="poolNote">People waiting for a sponsor. Usernames only, never contact details.</p></div>
<div class="pool" id="pool"></div>
<div class="row"><button type="button" class="btn-line" id="poolMore" hidden>Show all players</button></div>
</section>
<section class="split">
<div class="panel wide"><h3 id="trackTitle" style="font-size:24px">DRAFT TRACKER</h3><div class="tbl"><table><thead><tr><th>PICK</th><th>COACH</th><th>DRAFTED</th><th>CARD</th></tr></thead><tbody id="track"></tbody></table></div></div>
<div class="panel side"><h3 style="font-size:24px">Best Coach standings</h3><div class="board" id="best"></div><span class="small" id="potRule"></span>
<h3 style="margin-top:10px">Last week</h3><div class="board" id="lastBest"></div></div>
</section>
<section class="split">
<div class="panel side"><h3 style="font-size:24px">Rookie of the Week</h3><div id="rookie" style="max-width:240px"></div></div>
<div class="panel wide"><h3 style="font-size:24px">How The Draft works</h3>
<div class="how">
<div class="s"><b>1</b><h3>Get a position</h3><p class="muted small">$10 one-time in POL with SafePal or any other crypto wallet, never a subscription. It comes with 5 picks right away.</p></div>
<div class="s"><b>2</b><h3>Draft every Monday</h3><p class="muted small">5 rounds from that week's pool. Away? You are auto-picked from your queue, or the best available player.</p></div>
<div class="s"><b>3</b><h3>Coach them up</h3><p class="muted small">Help them link a wallet and switch on payouts, through site messages. Picks that do not start go back to the pool after 3 days.</p></div>
</div>
<p class="small">You get the right to sponsor and help your picks, never their email or any contact details: you coach through site messages, and they get the network's normal "you have a new sponsor" email. Nobody locked on a network contract is ever in the pool, and nobody is adopted more than twice.</p>
<div class="row"><a class="btn-gold" href="/join">Get a position</a><a class="btn-line" href="/cards">See the trading cards</a><a class="btn-ghost" href="/ledger">Live ledger</a></div>
<p class="small">A position buys a draft spot and coaching tools, not income. Nothing is promised.</p></div>
</section>
</main>
<script src="/assets/common.js?v=1"></script>
<script src="/assets/board.js?v=1"></script>
</body>
</html>
+41
View File
@@ -0,0 +1,41 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
<title>Get a Position | 5xYourTeam</title>
<meta name="description" content="A $10 one-time position: 5 picks right away and a draft spot every Monday. Paid in POL, split on-chain in the same transaction.">
<link rel="canonical" href="https://5xyourteam.com/join">
<meta property="og:type" content="website">
<meta property="og:site_name" content="5xYourTeam">
<meta property="og:title" content="Get a Position | 5xYourTeam">
<meta property="og:description" content="A $10 one-time position: 5 picks right away and a draft spot every Monday. Paid in POL, split on-chain in the same transaction.">
<meta property="og:url" content="https://5xyourteam.com/join">
<meta property="og:image" content="https://5xyourteam.com/art/og-share.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://5xyourteam.com/art/og-share.png">
<meta name="theme-color" content="#07102a">
<link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Oswald:wght@500;700&family=Inter:wght@400;600;700&display=swap">
<link rel="stylesheet" href="/assets/fx.css?v=1">
</head>
<body>
<main class="wrap">
<section class="hero"><div class="copy"><p class="kicker">GET A POSITION</p><h1><span id="jPrice">$10</span> once. <span id="jPicks">5</span> picks today. A draft spot every Monday.</h1>
<p class="lead">One payment in POL with SafePal or any other crypto wallet. It never renews and is never a subscription.</p></div>
<div class="potbox"><span class="lab">What you get</span><ul class="muted small" style="margin:0;padding-left:18px"><li>5 instant picks from this week's pool</li><li>A spot in every Monday draft, 5 rounds</li><li>Coaching tools: scouting stats, the steps, site messages, who to help first</li><li>A coach page and trading cards for your team</li><li>Up to 10 open picks at a time</li></ul></div></section>
<section id="jSign" class="panel" hidden><h3>Sign in first</h3><p class="muted small">The position goes to the wallet you are signed in with.</p><div id="jSignBox"></div></section>
<section class="panel dark"><h3 style="font-size:24px">Buy</h3><label class="small" for="jQty">How many positions</label><select id="jQty"></select><p class="muted" id="jPol"></p>
<div class="row"><button type="button" class="btn-gold" id="jBuy" disabled>Pay with my wallet</button></div><p id="status" class="note" hidden></p>
<p class="small">Anything you send above the exact price comes back to you in the same transaction. Payments are final once confirmed.</p></section>
<section class="panel"><h3 style="font-size:24px">Where your $10 goes, in the same transaction</h3><div class="splitbar" id="splitbar"></div>
<p class="small">Your sponsor gets 25% and levels 2 to 5 of your network sponsor line get 5% each. Only people who hold a position can receive a share: anyone in your line who does not is passed over and the share goes up to the next person who does. 10% goes to the weekly Best Coach pot and 45% to 5xYourTeam. The contract keeps nothing. Check it on the <a href="/contract">contract page</a> and every payment on the <a href="/ledger">ledger</a>.</p>
<p class="small">A position buys a draft spot and coaching tools, not income. Nothing is promised.</p></section>
</main>
<script src="/assets/common.js?v=1"></script>
<script src="/assets/wallet.js?v=1"></script>
<script src="/assets/join.js?v=1"></script>
</body>
</html>
+34
View File
@@ -0,0 +1,34 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
<title>Live Ledger | 5xYourTeam</title>
<meta name="description" content="Every 5xYourTeam position and every share it paid, in the same transaction, with links to verify on Polygonscan.">
<link rel="canonical" href="https://5xyourteam.com/ledger">
<meta property="og:type" content="website">
<meta property="og:site_name" content="5xYourTeam">
<meta property="og:title" content="Live Ledger | 5xYourTeam">
<meta property="og:description" content="Every 5xYourTeam position and every share it paid, in the same transaction, with links to verify on Polygonscan.">
<meta property="og:url" content="https://5xyourteam.com/ledger">
<meta property="og:image" content="https://5xyourteam.com/art/og-share.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://5xyourteam.com/art/og-share.png">
<meta name="theme-color" content="#07102a">
<link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Oswald:wght@500;700&family=Inter:wght@400;600;700&display=swap">
<link rel="stylesheet" href="/assets/fx.css?v=1">
</head>
<body>
<main class="wrap">
<section><p class="kicker">LIVE LEDGER</p><h1 style="font-size:44px">Every position, every share, on-chain</h1></section>
<section class="stats" id="totals"></section>
<section class="panel"><div class="tbl"><table id="rows"><thead><tr><th>WHEN</th><th>POSITION</th><th>PAID IN THE SAME TRANSACTION</th><th></th></tr></thead><tbody></tbody></table></div></section>
<section class="panel"><h3 style="font-size:24px">Best Coach payouts</h3><div class="tbl"><table id="payouts"><thead><tr><th>WEEK</th><th>COACH</th><th>POL</th><th></th></tr></thead><tbody></tbody></table></div></section>
</main>
<script src="/assets/common.js?v=1"></script>
<script src="/assets/ledger.js?v=1"></script>
</body>
</html>
+38
View File
@@ -0,0 +1,38 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
<title>Privacy Policy | 5xYourTeam</title>
<meta name="description" content="What 5xYourTeam keeps about you, why, and for how long.">
<link rel="canonical" href="https://5xyourteam.com/privacy">
<meta property="og:type" content="website">
<meta property="og:site_name" content="5xYourTeam">
<meta property="og:title" content="Privacy Policy | 5xYourTeam">
<meta property="og:description" content="What 5xYourTeam keeps about you, why, and for how long.">
<meta property="og:url" content="https://5xyourteam.com/privacy">
<meta property="og:image" content="https://5xyourteam.com/art/og-share.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://5xyourteam.com/art/og-share.png">
<meta name="theme-color" content="#07102a">
<link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Oswald:wght@500;700&family=Inter:wght@400;600;700&display=swap">
<link rel="stylesheet" href="/assets/fx.css?v=1">
</head>
<body data-page="legal">
<main class="wrap legal">
<section><p class="kicker">5XYOURTEAM</p><h1 style="font-size:44px">Privacy Policy</h1><p class="muted">What 5xYourTeam keeps about you, why, and for how long.</p></section>
<section class="card"><h2>Who we are</h2><p>5xYourTeam is run by TrustClickz, 615 Green Valley Drive, Moody, AL 35004.</p></section>
<section class="card"><h2>What we keep</h2><ul><li>Your wallet address and network username.</li><li>Your network record from the network hub: your hub id and your sponsor line. 5xYourTeam does not store your email. When you sign in through InstantAdPay or LinkSpin, your email is used once to find your network record and is not kept.</li><li>Your positions, which are public on the Polygon blockchain.</li><li>The draft: who drafted whom and when, each pick's milestones (wallet linked, payouts on, first purchase), and the scouting facts shown on draft cards where the network tracks them (last seen, the site you joined through, game plays and earnings).</li><li>Site messages between a coach and their pick.</li><li>Your saved builder referral IDs.</li></ul></section>
<section class="card"><h2>What coaches see about a pick</h2><p>A username, the scouting facts above and their milestones. Never an email, phone number or any other contact details, and no list is ever exported or sold. Anyone can see trading cards, which show milestones only, never earnings.</p></section>
<section class="card"><h2>Cookies</h2><p>A sign-in cookie (7 days), a cookie that remembers whose page you came from (30 days), and short-lived cookies for signing in through the network. No advertising or tracking cookies of our own.</p></section>
<section class="card"><h2>Who else sees data</h2><ul><li>The Polygon blockchain: every position and payment is public there.</li><li>The network hub, which keeps one record per person across the network sites.</li><li>The network holding tank (InstantAdPay and LinkSpin), which records each adoption and sends the normal new-sponsor email.</li><li>Our Telegram payments topic: each position is posted with the buyer's username (or a shortened wallet) and the amounts paid, and the Draft Day results with usernames.</li><li>Services the pages load: Google Fonts and WalletConnect (Reown) when you connect a wallet.</li></ul><p>We do not sell personal data.</p></section>
<section class="card"><h2>Your choices</h2><p>You can ask us to remove your account and messages here. Records on the blockchain cannot be removed by anyone.</p></section>
<section class="card"><h2>Contact</h2><p>TrustClickz, 615 Green Valley Drive, Moody, AL 35004. <a href="https://instantadpay.com/support" target="_blank" rel="noopener">Network support</a>. Last updated November 15, 2026.</p></section>
</main>
<script src="/assets/common.js?v=1"></script>
<script src="/assets/misc.js?v=1"></script>
</body>
</html>
+35
View File
@@ -0,0 +1,35 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
<title>Promo Kit | 5xYourTeam</title>
<meta name="description" content="Links, creatives and copy for 5xYourTeam, with your username in every link.">
<link rel="canonical" href="https://5xyourteam.com/promote">
<meta property="og:type" content="website">
<meta property="og:site_name" content="5xYourTeam">
<meta property="og:title" content="Promo Kit | 5xYourTeam">
<meta property="og:description" content="Links, creatives and copy for 5xYourTeam, with your username in every link.">
<meta property="og:url" content="https://5xyourteam.com/promote">
<meta property="og:image" content="https://5xyourteam.com/art/og-share.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://5xyourteam.com/art/og-share.png">
<meta name="theme-color" content="#07102a">
<link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Oswald:wght@500;700&family=Inter:wght@400;600;700&display=swap">
<link rel="stylesheet" href="/assets/fx.css?v=1">
</head>
<body data-page="promote">
<main class="wrap">
<section><p class="kicker">PROMO KIT</p><h1 style="font-size:44px">Share The Draft</h1></section>
<form id="whoForm" class="row dark"><input id="whoIn" placeholder="your network username" aria-label="Your network username" style="max-width:320px"><button class="btn-gold" type="submit">Use my username</button></form>
<p id="status" class="note" hidden></p>
<div id="kit" style="display:flex;flex-direction:column;gap:16px"></div>
</main>
<script src="/assets/common.js?v=1"></script>
<script src="/assets/kitpage.js?v=1"></script>
<script src="/assets/misc.js?v=1"></script>
</body>
</html>
+59
View File
@@ -0,0 +1,59 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
<title>My Team | 5xYourTeam</title>
<meta name="description" content="Coach your picks: scouting stats, the getting-started steps, one-tap messages and who to help first.">
<meta name="robots" content="noindex">
<meta property="og:type" content="website">
<meta property="og:site_name" content="5xYourTeam">
<meta property="og:title" content="My Team | 5xYourTeam">
<meta property="og:description" content="Coach your picks: scouting stats, the getting-started steps, one-tap messages and who to help first.">
<meta property="og:url" content="https://5xyourteam.com/team">
<meta property="og:image" content="https://5xyourteam.com/art/og-share.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://5xyourteam.com/art/og-share.png">
<meta name="theme-color" content="#07102a">
<link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Oswald:wght@500;700&family=Inter:wght@400;600;700&display=swap">
<link rel="stylesheet" href="/assets/fx.css?v=1">
</head>
<body>
<main class="wrap">
<section id="signin" class="panel" hidden><p class="kicker">MY TEAM</p><h1 style="font-size:44px">Sign in to coach your team</h1><p class="muted">Sign in with your network account, or with your wallet. Your picks, cards and messages are here.</p><div id="signinBox"></div></section>
<p id="status" class="note" hidden></p>
<div id="dash" hidden style="display:flex;flex-direction:column;gap:28px">
<div class="sh"><div><p class="kicker">MY TEAM</p><h1 style="font-size:44px" id="hello"></h1></div><div class="row"><span id="myPage" hidden class="small">My coach page: <a id="myPageLink" href="#"></a></span><a class="btn-ghost" href="/promote">Promo kit</a><a class="btn-ghost" href="/builder">My builder links</a><button type="button" class="btn-ghost" id="signout" hidden>Sign out</button></div></div>
<section id="myCoach" class="ccard" hidden>
<div class="l"><span class="kicker">YOUR COACH</span><b id="mcName"></b><span class="muted small" id="mcTier"></span></div>
<div class="r"><h3>Getting started</h3><div id="mcSteps"></div><h3>Messages</h3><div class="thread" id="mcThread"></div>
<textarea id="mcText" maxlength="600" placeholder="Write to your coach" aria-label="Message to your coach"></textarea><div class="row"><button type="button" class="btn" id="mcSend">Send</button></div>
<h3>Your coach's builder links</h3><div class="row" id="mcBuilder"></div></div>
</section>
<section id="noCoach" class="panel" hidden><h3>You do not coach a team yet</h3><p class="muted">A $10 one-time position gives you 5 picks right away and a draft spot every Monday.</p><div class="row"><a class="btn-gold" href="/join">Get a position</a></div></section>
<div id="coachTools" hidden style="display:flex;flex-direction:column;gap:28px">
<section class="stats" id="stats"></section>
<p class="note" id="credits" hidden>You have <b id="creditsN"></b> to use now. Pick them from the pool on the <a href="/">Draft Board</a>.</p>
<section class="focus" id="focus" hidden>
<div class="who"><span class="k" id="fKick"></span><b class="n" id="fName"></b><span class="muted small" id="fWhen"></span><div id="fStats" style="display:flex;flex-direction:column;gap:4px;font-size:14px;margin-top:6px"></div>
<span class="small" style="margin-top:auto">No contact details here, by design: you coach through site messages.</span></div>
<div class="act"><h3>Getting started</h3><div id="fSteps"></div>
<h3 style="font-size:18px">One-tap messages</h3><div class="taps" id="fTaps"></div>
<textarea id="fText" maxlength="600" placeholder="Write a message. It goes to their member area." aria-label="Message to your pick"></textarea>
<div class="row"><button type="button" class="btn-gold" id="fSend">Send message</button><button type="button" class="btn-ghost" id="fRelease">Release to the pool</button></div>
<div class="thread" id="fThread"></div></div>
</section>
<section style="display:flex;flex-direction:column;gap:12px"><h2>The rest of my team</h2><div class="team" id="team"></div></section>
<section class="split"><div class="panel wide"><h3 style="font-size:24px">Who to help first</h3><div class="help" id="help"></div></div>
<div class="panel side"><h3 style="font-size:24px">My draft queue</h3><div id="queue"></div><div id="pastWrap" hidden><h3>Back in the pool</h3><div class="row" id="past"></div></div></div></section>
</div>
</div>
</main>
<script src="/assets/common.js?v=1"></script>
<script src="/assets/wallet.js?v=1"></script>
<script src="/assets/team.js?v=1"></script>
</body>
</html>
+43
View File
@@ -0,0 +1,43 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
<title>Terms and Conditions | 5xYourTeam</title>
<meta name="description" content="The rules for using 5xYourTeam, in plain English.">
<link rel="canonical" href="https://5xyourteam.com/terms">
<meta property="og:type" content="website">
<meta property="og:site_name" content="5xYourTeam">
<meta property="og:title" content="Terms and Conditions | 5xYourTeam">
<meta property="og:description" content="The rules for using 5xYourTeam, in plain English.">
<meta property="og:url" content="https://5xyourteam.com/terms">
<meta property="og:image" content="https://5xyourteam.com/art/og-share.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://5xyourteam.com/art/og-share.png">
<meta name="theme-color" content="#07102a">
<link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Oswald:wght@500;700&family=Inter:wght@400;600;700&display=swap">
<link rel="stylesheet" href="/assets/fx.css?v=1">
</head>
<body data-page="legal">
<main class="wrap legal">
<section><p class="kicker">5XYOURTEAM</p><h1 style="font-size:44px">Terms and Conditions</h1><p class="muted">The rules for using 5xYourTeam, in plain English.</p></section>
<section class="card"><h2>Who we are</h2><p>5xYourTeam (5xyourteam.com) is run by TrustClickz, 615 Green Valley Drive, Moody, AL 35004. It is part of the network: one network account works across InstantAdPay, LinkSpin, Downline Banners, Viral Banner Blitz, ViralAdBlitz, 5xYourTeam, Stack POL and Earners Corner. By using 5xYourTeam you agree to these terms.</p></section>
<section class="card"><h2>What 5xYourTeam is</h2><p>5xYourTeam runs The Draft. People who join the network without a sponsor wait in the network holding tank. Every Monday the coaches on 5xYourTeam draft them, in rounds. A drafted person (a pick) is adopted by their coach under the holding-tank rules, and their coach becomes their network sponsor while the pick is open.</p></section>
<section class="card"><h2>What a position is</h2><p>A position is a single, one-time purchase of $10. It gives you 5 instant picks from the current pool, a spot in every weekly draft, the coaching tools, a coach page and trading cards. You can buy more than one; each adds 5 instant picks. Nothing renews and nothing is ever billed again. There are no subscriptions.</p><p>Positions are paid in POL on Polygon at the live Chainlink POL/USD price the contract reads when you buy. Anything you send above the price comes back to you in the same transaction.</p><p>What you buy is a seat in the draft and the tools to coach. It is not income, an investment or a share of anything.</p></section>
<section class="card"><h2>The draft</h2><p>The draft order is earned: coaches with more of last week's picks started (payouts switched on, or a first purchase) pick first; ties go to more picks started overall, then the earlier position. A coach in the draft room has a clock for each pick; a coach who is away is picked for automatically, from their own queue or the best available player. A coach may hold up to 10 open picks.</p><p>A pick that has not started within 3 days goes back to the pool, unless that person has now been adopted twice, in which case they stay with their coach. A started pick stays on the team. A coach cannot release a pick in its first 48 hours. The pool never includes anyone locked to a sponsor on a network contract, anyone the network already knows a sponsor for, anyone adopted twice, spam or throwaway sign-ups, or anyone in their first 24 hours.</p></section>
<section class="card"><h2>Coaching rules</h2><p>Coaches get the right to sponsor and help their picks. They never get a pick's email, phone number or any other contact details, and no list of picks is ever sold or exported. Coaching happens through 5xYourTeam site messages; the pick also receives the network's normal email telling them who their new sponsor is. Be helpful and honest: no spam, no pressure, no income claims, nothing illegal. We may remove a coach who breaks these rules.</p></section>
<section class="card"><h2>How a payment is split</h2><p>The DraftPosition contract splits each position in the same transaction it is paid: 25% to your sponsor, 5% to each of levels 2 to 5 of your network sponsor line, 10% to the weekly Best Coach prize pot wallet, and 45% to 5xYourTeam.</p><p>Only someone who holds a position can receive a level share. Someone in the line who does not is passed over, and the share goes up to the next person who does: the first such person gets the 25% share, the next four get 5% each, looking up to 20 places up the line. A share nobody qualifies for goes to 5xYourTeam.</p><p>Your sponsor line comes from the network hub. On your first position the site signs it and the contract records it link by link. A link already recorded is never changed. The split is fixed in the contract code and there is no owner withdraw.</p></section>
<section class="card"><h2>The Best Coach pot</h2><p>10% of every position goes to a separate prize wallet fixed in the contract. Each week the pot is shared among the coaches whose picks started the most that week, as announced on the draft board. Every payout from the pot is listed on the <a href="/ledger">ledger</a> with its transaction. Prizes depend on the pot that week and are not promised.</p></section>
<section class="card"><h2>Nothing is promised</h2><p>We do not promise or guarantee any income, payout, prize or result. A level share is paid only when someone in your line chooses to buy a position. Read the <a href="/disclaimer">Earnings Disclaimer</a>.</p></section>
<section class="card"><h2>No refunds</h2><p>Payments are made on the blockchain and are final once confirmed. We cannot reverse, cancel or refund them. Check the amount before you confirm in your wallet.</p></section>
<section class="card"><h2>Crypto risk</h2><ul><li>The price of POL moves. The dollar value of a payment can be higher or lower later than when it was paid.</li><li>You are responsible for your wallet and its recovery phrase. Nobody, including us, can recover a lost wallet or reverse a payment sent from it.</li><li>Each transaction costs a small network fee (gas) in POL, paid to the network, not to us.</li><li>Use SafePal or any other crypto wallet you trust, and never share your recovery phrase with anyone. We will never ask for it.</li></ul></section>
<section class="card"><h2>The service</h2><p>The site is provided as it is. We work to keep it running but cannot promise it will always be available or free of errors. The smart contract runs on Polygon on its own; its rules are public on the <a href="/contract">contract page</a>. We may change features, draft settings, the price of future positions or these terms; changes apply from the date they are posted here. As far as the law allows, our total responsibility to you is limited to what you paid for the purchase in question. These terms are governed by the laws of the State of Alabama, USA.</p></section>
<section class="card"><h2>Contact</h2><p>TrustClickz, 615 Green Valley Drive, Moody, AL 35004. <a href="https://instantadpay.com/support" target="_blank" rel="noopener">Network support</a>. Last updated November 15, 2026.</p></section>
</main>
<script src="/assets/common.js?v=1"></script>
<script src="/assets/misc.js?v=1"></script>
</body>
</html>
+344
View File
@@ -0,0 +1,344 @@
{
"note": "LOCAL TEST FIXTURE for the phase 1 stub tank. Not real people. Times are hours before the app booted.",
"people": [
{
"id": "h_3affc1ada35faebb",
"username": "rookie_one",
"door": "InstantAdPay",
"joinedHoursAgo": 939,
"seenHoursAgo": 3,
"walletHoursAgo": 104,
"games": {
"plays": 3,
"title": "Road Agent",
"earnedWei": "380000000000000000"
}
},
{
"id": "h_eb022863fe3bc491",
"username": "surfqueen",
"door": "LinkSpin",
"joinedHoursAgo": 910,
"seenHoursAgo": 20,
"surfWei": "269000000000000000"
},
{
"id": "h_6238d6f010f3f9c5",
"username": "newbie77",
"door": "BTC4Hits",
"joinedHoursAgo": 185,
"seenHoursAgo": null,
"games": {
"plays": 0,
"title": null,
"earnedWei": null
}
},
{
"id": "h_887d6e1bb8235fe8",
"username": "cryptomike",
"door": "Downline Banners",
"joinedHoursAgo": 100,
"seenHoursAgo": 50,
"walletHoursAgo": 163
},
{
"id": "h_a1436ef135f3db34",
"username": "gamerdad",
"door": "Viral Banner Blitz",
"joinedHoursAgo": 874,
"seenHoursAgo": 1,
"games": {
"plays": 54,
"title": "Shards of Valor",
"earnedWei": "90000000000000000"
}
},
{
"id": "h_fa121ef0eac78fde",
"username": "lunaclicks",
"door": "CryptoTeamBuild",
"joinedHoursAgo": 591,
"seenHoursAgo": 30,
"surfWei": "275000000000000000"
},
{
"id": "h_0aeabeb6af047906",
"username": "tradewinds",
"door": "LinkSpin",
"joinedHoursAgo": 367,
"seenHoursAgo": 3,
"walletHoursAgo": 103,
"games": {
"plays": 46,
"title": "ClutterHunt",
"earnedWei": "240000000000000000"
}
},
{
"id": "h_9f18ef0a0d91dc4d",
"username": "polypat",
"door": "InstantAdPay",
"joinedHoursAgo": 189,
"seenHoursAgo": 120
},
{
"id": "h_172d8f222f9eb21b",
"username": "clickfox",
"door": "InstantAdPay",
"joinedHoursAgo": 506,
"seenHoursAgo": 3,
"games": {
"plays": 30,
"title": "Circuit Brawl",
"earnedWei": "350000000000000000"
}
},
{
"id": "h_da20f879170c19a4",
"username": "maria_g",
"door": "LinkSpin",
"joinedHoursAgo": 664,
"seenHoursAgo": 3,
"walletHoursAgo": 112,
"surfWei": "120000000000000000"
},
{
"id": "h_3f3409eb1420f7eb",
"username": "bitbuilder",
"door": "BTC4Hits",
"joinedHoursAgo": 374,
"seenHoursAgo": 200,
"games": {
"plays": 29,
"title": "Circuit Brawl",
"earnedWei": "180000000000000000"
}
},
{
"id": "h_1b1edcfd7d4b6fe4",
"username": "sunnyside",
"door": "Downline Banners",
"joinedHoursAgo": 186,
"seenHoursAgo": 3
},
{
"id": "h_99673703afc3a234",
"username": "jetsetjoe",
"door": "Viral Banner Blitz",
"joinedHoursAgo": 639,
"seenHoursAgo": 50,
"walletHoursAgo": 19,
"games": {
"plays": 39,
"title": "PolyBreak",
"earnedWei": "300000000000000000"
}
},
{
"id": "h_47213d4ea578f9d1",
"username": "adsurfer",
"door": "CryptoTeamBuild",
"joinedHoursAgo": 922,
"seenHoursAgo": 70,
"surfWei": "99000000000000000"
},
{
"id": "h_9848af6d869e9db9",
"username": "kimchi_k",
"door": "LinkSpin",
"joinedHoursAgo": 423,
"seenHoursAgo": 30,
"games": {
"plays": 23,
"title": "Gem Kingdom",
"earnedWei": "80000000000000000"
}
},
{
"id": "h_3fe73adad20e7c82",
"username": "dealhunter",
"door": "InstantAdPay",
"joinedHoursAgo": 627,
"seenHoursAgo": 20,
"walletHoursAgo": 158
},
{
"id": "h_f06b5bded0aae139",
"username": "quietquill",
"door": "InstantAdPay",
"joinedHoursAgo": 763,
"seenHoursAgo": 50,
"games": {
"plays": 5,
"title": "PolyBreak",
"earnedWei": "80000000000000000"
}
},
{
"id": "h_f0fe77765837b89e",
"username": "lotusleaf",
"door": "LinkSpin",
"joinedHoursAgo": 407,
"seenHoursAgo": 200,
"surfWei": "98000000000000000"
},
{
"id": "h_39fea889d5a1d527",
"username": "hopscotch",
"door": "BTC4Hits",
"joinedHoursAgo": 404,
"seenHoursAgo": 200,
"walletHoursAgo": 194,
"games": {
"plays": 43,
"title": "Road Agent",
"earnedWei": "380000000000000000"
}
},
{
"id": "h_e25cdaa177422bbb",
"username": "pixelpaul",
"door": "Downline Banners",
"joinedHoursAgo": 882,
"seenHoursAgo": 8
},
{
"id": "h_0c4f10d69e5305f4",
"username": "nightowl22",
"door": "Viral Banner Blitz",
"joinedHoursAgo": 767,
"seenHoursAgo": 200,
"games": {
"plays": 13,
"title": "Shards of Valor",
"earnedWei": "260000000000000000"
}
},
{
"id": "h_86e910ef9cb5ff2f",
"username": "garden_gina",
"door": "CryptoTeamBuild",
"joinedHoursAgo": 133,
"seenHoursAgo": 50,
"walletHoursAgo": 46,
"surfWei": "297000000000000000"
},
{
"id": "h_e7b0293c9b3d76d1",
"username": "ridgeback",
"door": "LinkSpin",
"joinedHoursAgo": 31,
"seenHoursAgo": 8,
"games": {
"plays": 56,
"title": "PolyBreak",
"earnedWei": "260000000000000000"
}
},
{
"id": "h_bb41753eafce6811",
"username": "tinytrader",
"door": "InstantAdPay",
"joinedHoursAgo": 618,
"seenHoursAgo": 1
},
{
"id": "h_489c134cec719d65",
"username": "mapleleaf",
"door": "InstantAdPay",
"joinedHoursAgo": 559,
"seenHoursAgo": 1,
"walletHoursAgo": 52,
"games": {
"plays": 50,
"title": "Gem Kingdom",
"earnedWei": "240000000000000000"
}
},
{
"id": "h_e1abfd1b267ee264",
"username": "oceanview",
"door": "LinkSpin",
"joinedHoursAgo": 117,
"seenHoursAgo": 3,
"surfWei": "205000000000000000"
},
{
"id": "h_91c2569472b58816",
"username": "redrover",
"door": "BTC4Hits",
"joinedHoursAgo": 481,
"seenHoursAgo": 8,
"games": {
"plays": 9,
"title": "ClutterHunt",
"earnedWei": "350000000000000000"
}
},
{
"id": "h_a6b75313af665383",
"username": "buzzybee",
"door": "Downline Banners",
"joinedHoursAgo": 829,
"seenHoursAgo": 30,
"walletHoursAgo": 188
},
{
"id": "h_locked0000000001",
"username": "lockedlarry",
"door": "InstantAdPay",
"joinedHoursAgo": 300,
"seenHoursAgo": 2,
"locked": true
},
{
"id": "h_sponsored0000001",
"username": "hasasponsor",
"door": "LinkSpin",
"joinedHoursAgo": 300,
"seenHoursAgo": 2,
"sponsored": true
},
{
"id": "h_spam000000000001",
"username": "xx_spam_xx",
"door": "LinkSpin",
"joinedHoursAgo": 300,
"seenHoursAgo": 2,
"spam": true
},
{
"id": "h_throwaway000001",
"username": "temp_mail_9",
"door": "InstantAdPay",
"joinedHoursAgo": 300,
"seenHoursAgo": 2,
"throwaway": true
},
{
"id": "h_grace00000000001",
"username": "brandnew",
"door": "InstantAdPay",
"joinedHoursAgo": 5,
"seenHoursAgo": 1
},
{
"id": "h_twice00000000001",
"username": "twiceadopted",
"door": "InstantAdPay",
"joinedHoursAgo": 900,
"seenHoursAgo": 4,
"adoptionsElsewhere": 2
},
{
"id": "h_once000000000001",
"username": "onceadopted",
"door": "LinkSpin",
"joinedHoursAgo": 900,
"seenHoursAgo": 4,
"adoptionsElsewhere": 1,
"walletHoursAgo": 40
}
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 329 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 KiB

Some files were not shown because too many files have changed in this diff Show More