Campaigns
One giveaways engine. Giveaways, instant wins, photo contests, referral programmes, list growth, and coupon drops are the same object with different configuration — a second engine would only ever exist to be correlated with this one.
A campaign lives at /{handle}/{slug} and the engine is internal/campaigns.
The public entrant page is a separate island bundle (web/src/campaign/main.tsx),
so a stranger joining a giveaway never downloads the dashboard.
Model
| Concept | What it is |
|---|---|
| Campaign | A dated window under your handle: prizes, entry actions, participants, terms |
| Action | One entry mechanic — "follow us", "submit a photo", "bring a friend". Provided by the server's registry |
| Prize | What is being given away: a quantity, a number of winners, and optional alternates |
| Participant | An entrant: an email plus a verification code, scoped to one campaign. Not an account |
| Entry | One ledger row, append-only. Completions adjust a balance; the ledger is the record |
| Draw | Winners chosen from a recorded seed and the eligible pool it read |
| Winner | A selected seat with a claim window, then claimed, declined, or expired |
Rules the engine keeps
- Actions are generic. An action's
kindis a registry key owned by the server (internal/campaigns/actions); the client renders what the registry describes and never interprets configuration itself. Adding a platform is one provider file and no migration. A duplicate kind panics at boot. - Integrity lives in the database. A participant's repeat limit is a partial unique index per recurrence — single, hourly, daily, unlimited — not a count in code, so two concurrent requests cannot both take the last slot.
- Draws replay. Every draw records its seed together with the eligible pool
it read, and
VerifyDrawre-derives the winners from both. A reroll excludes the winners already chosen, so "replace this winner" is not a fresh lottery against the same pool. - Alternates cover lapses, not only declines. A winner who lets the claim window run out promotes the next alternate exactly like a decline does.
- Participant identity is a signed token scoped to one campaign, never a dashboard session, so no method on the public service can reach another campaign's data.
- Status is honest. Draft, scheduled, active, paused, ended, archived — an unopened or paused campaign reads as unlisted to a visitor, never as an error a stranger can learn from.
Entry actions
Every kind below is a provider in the registry. An action carries how many entries a completion is worth, whether it is required, its own availability window, and a sort order — the rest is the provider's config, validated on write and never interpreted by the client.
| Kind | Entry mechanic |
|---|---|
visit_url | Visit a page — the referral handoff |
social_follow | Follow or subscribe, self-confirmed |
social_follow_verified | Follow or subscribe, verified against the platform |
youtube_subscribe | Subscribe on YouTube, verified |
app_download | Download the app |
verified_email | Prove an inbox with a one-time code |
secret_code | Enter a code you issued |
coupon | Redeem a coupon code |
question_choice | Answer a multiple-choice question |
submit_url | Submit a link you made |
submit_media | Submit a photo |
upload_file | Upload a file |
crypto_wallet | Submit a crypto wallet |
referral_count | Bring friends who join through your link |
viral_share | Share this campaign |
promote | Promote this campaign elsewhere |
bonus | Free entry, granted automatically |
timed_bonus | Free entry, inside a time limit |
An action can carry extra obligations: requires_verified demands a proven
contact point (inbox or phone) rather than only a human-presence check,
required_count holds every other action locked until the entrant holds that
many verified completions, unlocks_others makes one action the prerequisite
that reveals the rest, and requires_purchase marks the entry route that
triggers the alternative-method-of-entry obligation below.
Prizes and the draw
A prize carries a quantity, a number of winners, a rank, a display value label,
a digital/physical flag, and alternates (backup_count) drawn behind each
winner and promoted in order when somebody declines or lets the claim window
close. auto_draw fills a prize at the end of its window without anyone
pressing a button; claim_deadline_days is how long a selected winner has to
claim.
Draw methods are random (weighted by entry balance — the fairest default),
most_entries (the leaderboard, with ties still broken by the recorded seed),
and manual (a person choosing, still seeded, still audited, and never dressed
up as algorithmic). The weight column each winner was read from is recorded too,
so a replay after the campaign's actions have changed still reproduces the
numbers. A method the database does not know is refused rather than quietly
treated as random.
Public page appearance
The public page at /{handle}/{slug} is server-rendered, but its look is data
on the campaign rather than a template fork. The dashboard's Design panel
edits three fields, and the same fields travel on the campaign RPC shapes:
| Field | Values | Default |
|---|---|---|
public_theme | editorial, midnight, sunrise, mono | editorial |
public_accent | empty, or a #RRGGBB colour | empty (the theme's own accent) |
public_hero | split, banner, minimal | split |
editorial and split reproduce the original page byte-for-byte, so a campaign
created before appearance existed keeps its look. A theme sets the page's paper,
ink, card, and signal tokens; public_accent overrides the signal/action colour
and the server derives the CTA, focus, and link variants from it, with contrast
floors so host text keeps its AA ratio. The accent picker in the dashboard is a
curated palette, not a free colour field.
These are ConnectRPC fields today (Campaign.public_theme,
Campaign.public_accent, Campaign.public_hero). They are not part of the
public REST API until the campaign resource ships; see
Where REST stands.
Branding follows the owner's plan. remove_branding drops the lsg.bio
masthead and footer from the campaign page; the embed frame always drops them,
because a widget inside somebody else's page must not carry a second brand.
After an entry
A successful join can hand the entrant to two optional destinations:
| Field | What it does |
|---|---|
post_entry_redirect_url | Sends a newly joined entrant to an https page instead of leaving them on the success state |
post_entry_email_subject | Subject of a one-off transactional email sent after the entry commits |
post_entry_email_body | Plain-text body, with {name} and {campaign} placeholders |
All three are empty by default. An empty subject or body disables the email.
The redirect is validated on write (absolute https only) and is also carried
on JoinCampaignResponse, so a client cannot invent a destination the server
never accepted. The follow-up is transactional rather than a campaign
announcement: it is not rate-limited by the announcement budget, and a send
failure is logged without unwinding the entry.
Embedding
/embed/{campaign}.js renders a teaser card on a third-party page. Setting
data-mode="iframe" renders the hosted campaign page itself in a frame with
?embed=1: the real join form, Turnstile, rules, and uploads, with no second
implementation of the entry flow. The frame reports its height back to the
host page. Both the script and the framed page carry a cross-origin policy;
every other surface keeps frame-ancestors 'none'.
Comment picker
Social comment giveaways are usually run from an export, because not every
platform exposes comments. The dashboard's Comment picker
(/dashboard/campaigns/comment-picker) accepts a pasted list or a handle, comment CSV, removes duplicate handles, draws with the browser's
crypto.getRandomValues, and exports the winners. Nothing is uploaded. It is a
local utility, not a campaign draw: a regulated sweepstakes should use the
campaign's seeded, replayable draw instead.
Compliance
The engine treats a giveaway as something a regulator may ask about, so the obligations are data rather than copy:
- Alternative method of entry —
free_entry_enabledplus the countries it is offered in and what a free entrant receives, in entries. An empty country list means everywhere; it never silently withdraws a lawful entry route. - Official rules — a structured document rendered on the public page, in the winner's email, and in the CSV export. Whether you have written them at all is tracked separately, because "no rules" is a reportable state and an empty form must not look like a finished one.
- Age gate — none, a self-declared age floor, or a real date of birth the owner can never read back.
- Submission rights — what the host may do with an entrant's uploads, captured at entry, because a photo contest has no clear reuse right without it.
- Data rights — export and erasure for a participant, with the erasure trail kept rather than pruned.
Where REST stands
campaigns:read, campaigns:write, and campaigns:delete are defined in
Permissions & scopes and mintable today. The REST routes for campaigns
are not live yet — the dashboard is the surface, as noted in the
Introduction — so a token carrying a campaigns scope is armed rather
than useful.
Non-goals
- A second giveaways feature to correlate with this one. Instant wins are campaigns; see Instant-win campaigns.
- Arbitrary user-authored providers. The registry is server-owned, which is what
makes
PublicViewsafe to render. - Draws that cannot be replayed. A mode that loses the recorded seed is not a different mode, it is a way of losing the advantage over everyone else.