diff --git a/carry.js b/carry.js
index 6fcb7b2..7fafb7a 100644
--- a/carry.js
+++ b/carry.js
@@ -15,7 +15,7 @@ let ethers = null; try { ethers = require('ethers'); } catch (e) {}
const fs = require('fs');
const path = require('path');
-let X = {}; // { dataDir, accounts, registry, chain, mailer, messages, siteConfig, adminEmail }
+let X = {}; // { dataDir, accounts, registry, chain, mailer, messages, siteConfig, adminEmail, tankGate, claim, payoutBlocked, sendActivate + now (tests) }
const DAY = 86400000;
const ABI = ['function activateFor(address account, uint32 sponsorId) returns (uint32)', 'function engineSigner() view returns (address)'];
const norm = e => String(e || '').trim().toLowerCase();
@@ -145,7 +145,15 @@ async function ensureOnChain(acct, depth, why) {
if (acct.email && isHeld(acct.email)) await waitUnheld(acct.email);
if (acct.email) { try { const fresh = await X.accounts.byEmail(acct.email); if (fresh && fresh.address) acct = fresh; } catch (e) {} }
try { const id = await X.chain.memberIdByAccount(acct.address); if (id) { if (Number(acct.memberId) !== Number(id)) await X.accounts.setMemberId(acct.email, id).catch(() => {}); return id; } } catch (e) {}
- if (!engineReady() || depth > 25) return 0;
+ // holding tank (2026-10-27, tank.gate): no sponsor here -> align to the network sponsor first (InstantAdPay knows one);
+ // nobody known and this is the member's OWN plain activation (wallet linked, admin seeding) -> held for an adopter, never
+ // bound under the fallback. A sponsor placed on the contract because someone below them is buying is never held.
+ if (!acct.sponsorRef && !(Number(acct.memberId) > 0) && X.tankGate) {
+ let g = null; try { g = await X.tankGate(acct, { own: depth === 0 && (why === 'wallet' || !!X.seeding) }); } catch (e) { g = null; }
+ if (g && g.aligned) { try { const fresh = await X.accounts.byEmail(acct.email); if (fresh) acct = fresh; } catch (e) {} }
+ else if (g && g.hold) { logEvent({ type: 'tankHold', email: acct.email, until: g.hold.until || null }); return 0; }
+ }
+ if (!sendReady() || depth > 25) return 0;
const me = norm(acct.email); inflight.add(me); let id = 0; // binding from here: the sponsor read below is the one the contract gets
let sponsorId = 0, txHash = null, lastErr = null; // read after the finally below, so declared out here (inside the try they were not defined there, 2026-10-22..27)
try {
@@ -155,16 +163,7 @@ async function ensureOnChain(acct, depth, why) {
}
if (!sponsorId) sponsorId = Number((X.siteConfig && X.siteConfig().defaultSponsorId) || 1) || 1;
try { if (sponsorId > await X.chain.memberCount()) sponsorId = 0; } catch (e) {} // first member on a fresh contract: no catch position exists yet
- // send with provider rotation; after ANY error re-read the chain first (2026-10-15 seed: six activations
- // mined while a 403 on the follow-up read logged them as failures and skipped their notices)
- for (let attempt = 0; attempt < 3 && !id; attempt++) {
- try {
- const w = signer(attempt); const ctr = new ethers.Contract(X.chain.getConfig().contract, ABI, w);
- const tx = await ctr.activateFor(acct.address, sponsorId, { gasLimit: 160000n }); txHash = tx.hash;
- await tx.wait(1);
- } catch (e) { lastErr = e; }
- for (let k = 0; k < 4 && !id; k++) { try { id = Number(await X.chain.memberIdByAccount(acct.address)) || 0; } catch (e) {} if (!id) await sleep(3000); }
- }
+ const sent = await (X.sendActivate || sendActivateFor)(acct.address, sponsorId); id = sent.id; txHash = sent.txHash; lastErr = sent.lastErr;
} finally { if (!id) inflight.delete(me); } // on success the flag stays until the member number is saved below
if (!id) { logEvent({ type: 'activateFailed', email: acct.email, error: String((lastErr && (lastErr.shortMessage || lastErr.message)) || 'not on-chain after send').slice(0, 160) }); return 0; }
logEvent({ type: 'activated', email: acct.email, id, sponsorId, tx: txHash });
@@ -175,6 +174,54 @@ async function ensureOnChain(acct, depth, why) {
await noticeActivated(acct, why);
return id;
}
+// send with provider rotation; after ANY error re-read the chain first (2026-10-15 seed: six activations
+// mined while a 403 on the follow-up read logged them as failures and skipped their notices)
+async function sendActivateFor(address, sponsorId) {
+ let id = 0, txHash = null, lastErr = null;
+ for (let attempt = 0; attempt < 3 && !id; attempt++) {
+ try {
+ const w = signer(attempt); const ctr = new ethers.Contract(X.chain.getConfig().contract, ABI, w);
+ const tx = await ctr.activateFor(address, sponsorId, { gasLimit: 160000n }); txHash = tx.hash;
+ await tx.wait(1);
+ } catch (e) { lastErr = e; }
+ for (let k = 0; k < 4 && !id; k++) { try { id = Number(await X.chain.memberIdByAccount(address)) || 0; } catch (e) {} if (!id) await sleep(3000); }
+ }
+ return { id, txHash, lastErr };
+}
+const sendReady = () => !!X.sendActivate || engineReady();
+
+// ---- holding tank: switch payouts on the moment a tank member gets a sponsor (Marty approved 2026-10-27) ----
+// An adoption (manual or the 24-hour rotation) or a network alignment gives a held member a sponsor; with a wallet linked,
+// the engine activates them right away UNDER THAT SPONSOR. Strict, unlike ensureOnChain: never the fallback position.
+// - already on the contract: nothing sent ({ id, already })
+// - the sponsor must be on the contract (the engine places a sponsor who has a wallet first, as ensureOnChain does) and not
+// on a no-payout chain; otherwise nothing is sent and the caller retries on its next tick ({ error, retry })
+// - one sender across app copies: a marks claim per member per 10-minute window (deploy overlap), plus the in-process flag
+// Returns { id, tx, sponsorId, sponsorEmail } when this call activated them.
+async function activateAssigned(email) {
+ let a = await X.accounts.byEmail(email); if (!a || !a.address) return { error: 'no wallet linked', retry: false };
+ if (isHeld(a.email)) { await waitUnheld(a.email); a = (await X.accounts.byEmail(email)) || a; }
+ let onId = 0; try { onId = Number(await X.chain.memberIdByAccount(a.address)) || 0; } catch (e) { return { error: 'chain read failed', retry: true }; }
+ if (onId) { if (Number(a.memberId) !== onId) await X.accounts.setMemberId(a.email, onId).catch(() => {}); return { id: onId, already: true }; }
+ if (!a.sponsorRef) return { error: 'no sponsor yet', retry: false };
+ let sp = await X.accounts.byCode(a.sponsorRef); if (!sp) sp = await X.accounts.byUsername(a.sponsorRef);
+ if (!sp) return { error: 'sponsor ' + a.sponsorRef + ' not found', retry: true };
+ if (!sp.address) return { error: 'sponsor has no wallet yet', retry: true };
+ if (!sendReady()) return { error: 'engine not configured', retry: true };
+ const me = norm(a.email); if (inflight.has(me)) return { error: 'activation already in flight', retry: true };
+ const sponsorId = await ensureOnChain(sp, 1);
+ if (!sponsorId) return { error: 'sponsor not on the contract yet', retry: true };
+ if (X.payoutBlocked && await Promise.resolve(X.payoutBlocked(sponsorId)).catch(() => true)) return { error: 'sponsor #' + sponsorId + ' is on a no-payout chain', retry: false };
+ if (X.claim && !(await Promise.resolve(X.claim('tankact:' + me + ':' + Math.floor((X.now ? X.now() : Date.now()) / 600000))).catch(() => false))) return { error: 'another app copy is sending it', retry: true };
+ inflight.add(me); let sent = { id: 0 };
+ try { sent = await (X.sendActivate || sendActivateFor)(a.address, sponsorId); }
+ finally { if (!sent.id) inflight.delete(me); }
+ if (!sent.id) { logEvent({ type: 'activateFailed', email: a.email, why: 'assigned', sponsorId, error: String((sent.lastErr && (sent.lastErr.shortMessage || sent.lastErr.message)) || 'not on-chain after send').slice(0, 160) }); return { error: 'activation failed', retry: true }; }
+ logEvent({ type: 'activated', email: a.email, id: sent.id, sponsorId, tx: sent.txHash, why: 'assigned' });
+ await X.accounts.setMemberId(a.email, sent.id).catch(() => {});
+ inflight.delete(me);
+ return { id: sent.id, tx: sent.txHash || null, sponsorId, sponsorEmail: sp.email };
+}
async function noticeActivated(acct, why) {
const own = X.seeding || why === 'wallet'; // switched on because their own wallet arrived, not because someone below them bought
await tell(acct.email, own ? 'Your LinkSpin payouts are switched on' : 'We set up your LinkSpin position so you would not miss a payout',
@@ -223,4 +270,4 @@ async function seedAll(limit) {
}
function status() { const s = state(); return { engine: engineReady(), claims: Object.values(s.claims || {}), log: (s.log || []).slice(-50).reverse(), claimDays: claimDays() }; }
-module.exports = { init, onJoin, resolveForChain, ensureOnChain, seedAll, status, engineReady, backfillMemberIds, hold, unhold, isHeld, isBinding };
+module.exports = { init, onJoin, resolveForChain, ensureOnChain, activateAssigned, seedAll, status, engineReady, backfillMemberIds, hold, unhold, isHeld, isBinding };
diff --git a/chatbot.js b/chatbot.js
index 376eb94..584a7c1 100644
--- a/chatbot.js
+++ b/chatbot.js
@@ -25,7 +25,7 @@ let DATA_DIR = null;
let chain = null;
const MODEL = process.env.OPENROUTER_MODEL || 'deepseek/deepseek-v4-flash:nitro';
const CONTRACT = '0x26Bdc556b94399bEdd69ae3ACA5aA6c54D946e8b';
-const KNOWLEDGE_DATE = '2026-10-26'; // the day the CANNED answers and FACTS below were last checked against the site
+const KNOWLEDGE_DATE = '2026-10-27'; // the day the CANNED answers and FACTS below were last checked against the site
function init(opts) {
if (opts && typeof opts.refuelOn === 'function') REFUEL_ON = opts.refuelOn; DATA_DIR = opts.dataDir; chain = opts.chain; return kb.init({ dataDir: DATA_DIR, seeds: seeds() }); }
@@ -130,9 +130,12 @@ const CANNED = [
{ id: 'control-room', title: 'The Control Room screens', q: ['Where do I find my links?', 'What is on the dashboard?', 'Which screen has my campaigns?'], tags: ['control room', 'dashboard', 'menu', 'tools'],
re: /(control room|dashboard|where (do|can) i (find|see)|which screen|menu|navigation|more tools|\/tools)/i,
a: 'Your Control Room has these screens: Links (spin links), Pages (the page builder), Zones (ad slots on your site plus Audiences), Ads (your campaigns and the daily ad set), Credits (buy packages, link your wallet, switch on payouts), Reports (every link in one view), Team (your line, three levels) and Wallet (what was paid to you). More, at ' + SITE_URL + '/tools, holds Promo tools, Training, the Pipeline follow-up board, My line and your Profile.' },
+ { id: 'tank-hold', title: 'Matched with a sponsor (payouts on hold)', q: ['Why can I not switch on payouts?', 'It says I am being matched with a sponsor'], tags: ['holding tank', 'switch on payouts', 'matched with a sponsor', 'ready to activate'],
+ re: /(being matched|matched with a sponsor|(can.?t|cannot|unable to) (i )?(switch on|turn on|activate) (my )?payouts|activate (button|payouts) (is )?(gone|missing|hidden)|ready to activate)/i,
+ a: 'You joined without a sponsor, so you are in the holding tank. The contract locks your sponsor for good the moment your payouts are switched on, so the site waits for a real member to pick you up instead of placing you under the company. First it checks the network: if InstantAdPay already has a sponsor for your email or wallet, you are placed under them right away. Otherwise members see you at the top of their holding tank with a Ready to activate badge once your wallet is linked, and if nobody adopts you within 24 hours the site assigns you to the next eligible member in turn (someone active with their own $25 package). As soon as you have a sponsor, the site switches your payouts on under them for you (no cost to you) and tells you, with the transaction link. Buying is never held: you can buy a package at any time, but a purchase made before you have a sponsor places you under the platform position for good.' },
{ id: 'holding-tank', title: 'Holding tank and adoptions', q: ['What is the holding tank?', 'How do I adopt a member?'], tags: ['holding tank', 'adopt', 'no sponsor'],
re: /(holding tank|adopt|no sponsor|without a sponsor|orphan)/i,
- a: 'Members who join from the public site with no sponsor wait in the holding tank under More, My line. A member who has switched on payouts and bought their own qualifying package can adopt one, first come, with a 7-day window for the new member to link a wallet or buy; otherwise they return to the tank. Adopting sets the sponsor, and their first purchase then binds to the adopter on the contract.' },
+ a: 'Members who join from the public site with no sponsor wait in the holding tank under More, My line, unless the network already knows their sponsor (the same email or wallet on InstantAdPay), in which case they are placed under that sponsor. A member who has switched on payouts and bought their own qualifying package can adopt one, first come, with a 7-day window for the new member to link a wallet or buy; otherwise they return to the tank. Adopting sets the sponsor, and their first purchase then binds to the adopter on the contract. Members who have linked a wallet show a Ready to activate badge with the hours left and sit at the top of the list; adopting one switches their payouts on under you right away. If nobody adopts them within 24 hours, the site assigns them to the next eligible adopter in turn (own $25 package, fewer than 2 open adoptions, signed in within the last 7 days); the one assigned least recently goes first. Someone waiting in the InstantAdPay tank as well is assigned there, and the adoption carries over to LinkSpin.' },
{ id: 'team', title: 'My line: the Team screen', q: ['How do I see my downline?', 'Who is in my team?'], tags: ['team', 'my line', 'downline', 'levels'],
re: /(my line|downline|my team|who (is|are) (in|on) my|three levels|level 1\b)/i,
a: 'Team shows your line as a working table, three levels deep: who joined through your link, who has switched on payouts, who has bought, and how many qualifying buyers each person has. The chip count is what opens your levels: two qualifying buyers ($25 or larger) open level 2, five open level 3.' },
@@ -171,6 +174,7 @@ ${refuelFact()}- PRODUCT, all free with an email account: SPIN LINKS (the rotato
- ACCOUNT: join at ${SITE_URL}/join with email only, a six-digit code, no password. Wallet linking happens inside the Control Room (Credits screen): one signature to link, then payouts switch on by activating (one transaction, gas only) or by buying any package. SafePal is the recommended wallet; MetaMask, Phantom (turn Polygon on first) and any WalletConnect wallet work; Trust Wallet blocks a buy that spends most of its POL. No card button on the site: members buy POL with a card on any major exchange or on-ramp, then send it to their own wallet on the Polygon network (guide at ${SITE_URL}/wallets); never name a specific exchange or on-ramp brand.
- SPONSOR: the invite link opened most recently sets the sponsor (30-day cookie), shown on the join page, locked when the account is created; the contract binds the buyer to that sponsor at the first purchase. CARRY-OVER: Crypto Team Build Network members who sign in with the email they use on InstantAdPay get their InstantAdPay sponsor from the network registry automatically when no invite link was used. Wrong sponsor before the first purchase: the admin can move the account. Members should switch on payouts before their people buy.
- CONTROL ROOM screens: Links, Pages, Zones (with Audiences), Ads, Credits, Reports, Team (three levels, who has payouts on, who bought, qualifying-buyer counts), Wallet (what was paid to this wallet, payout history). More at ${SITE_URL}/tools: Promo tools, Training, Pipeline (a follow-up board for prospects and directs), My line (including the holding tank: members who joined with no sponsor wait there and can be adopted by a member with payouts on and their own qualifying package), Profile.
+- HOLDING TANK ACTIVATION HOLD (2026-10-27): a member with no sponsor is first matched to their network sponsor (the same email or wallet with a sponsor on InstantAdPay). Nobody known: the free Switch on payouts waits for an adopter and the Credits screen says "You're being matched with a sponsor. Payouts switch on as soon as someone picks you up (within 24 hours)." with the time left; they show at the top of every holding tank with a green Ready to activate badge and the hours left, and the shared payments topic on Telegram is told. Nobody adopts in 24 hours: the site assigns them to the next eligible adopter in rotation (own $25+ package, fewer than 2 open adoptions, signed in within 7 days; least recently auto-assigned first), and the pickup is posted marked (auto-assigned). The moment they have a sponsor (adopted, assigned or matched), the site switches their payouts on under that sponsor (engine-paid) and sends them the transaction link. A PURCHASE IS NEVER HELD: a tank member can buy at any time; with no sponsor yet that purchase places them under the platform position for good. Someone who arrived through a sponsor link is never held.
- PRE-LAUNCH (since 2026-10-17): LinkSpin is open to everyone for pre-launch testing until the official launch on November 15, 2026. Everything is live and working (links, sources, zones, ads, credits, payouts), but features and screens may change while it is tested. A notice at the top of every member screen says so. If someone got a reminder email about a member they have not contacted, they can ignore it: nothing changed in their line.
- SUPPORT (LIVE 2026-10-16): members open Help in the Control Room (${SITE_URL}/help) to send Marty a ticket (pick a category, a subject, the message), see each ticket's status (Open, Waiting on you, Closed), and read and answer his replies; a badge on the Help item shows when he has replied, and replies also arrive by email. Anyone signed out or locked out uses the public form at ${SITE_URL}/support, gets a private link to follow the ticket without signing in, and can reply there. The chat can also pass a conversation to support ("Send this to support"). Marty answers every ticket himself; there is no support email address, point people to ${SITE_URL}/support instead. Tickets share one desk with the rest of the Crypto Team Build Network.
- Leaderboard at ${SITE_URL}/leaderboard ranks members by packages sold to direct referrals (weekly, monthly, all time; prizes are credits, never cash). Release notes and roadmap at ${SITE_URL}/whats-new.
diff --git a/public/admin.html b/public/admin.html
index c20e20b..2217f5b 100644
--- a/public/admin.html
+++ b/public/admin.html
@@ -535,6 +535,6 @@
-
+