Skip to main content

Create a distribution

You are a streamer, you have a community, you want to reward the people who actually show up.

What you need

  • A Solana wallet with enough SOL for rent and a vault funding tx.
  • An SPL token mint you control (or pick one of the BitView-provided demo mints).
  • A Twitch login that matches the channel you want to reward viewers on.

Step 1 — Plan the event

Pick three numbers:

FieldMeaningExample
total_tokenTotal amount distributed across the whole event (smallest unit)1_000_000_000_000 (1M tokens at 6 decimals)
duration_secondsHow long the event runs28_800 (8 hours)
periodicity_secondsHow often each present viewer gets credited3_600 (every hour)

The maximum a single viewer can earn (without max_per_viewer) is roughly:

total_token / (duration_seconds / periodicity_seconds)

…shared with however many viewers happen to be present in that tick. Set max_per_viewer to put an explicit upper bound.

Step 2 — Create the distribution on-chain

From the BitView app streamer page, click Create Distribution:

  1. The frontend creates the distributor PDA via new_distributor and funds the token vault.
  2. It then POST /distributions-api/registers the resulting PDA, mint, and parameters with the backend.
  3. The backend joins your Twitch chat (if it isn't already) and starts the accrual loop.

Step 3 — Stream

That's it. As long as your stream is live and the bot is up, the backend credits present, linked viewers every periodicity_seconds.

Step 4 — Finalize

After the event ends:

  1. The operator (you, or the BitView team) calls POST /distributions-api/{id}/finalize (admin endpoint).
  2. The merkle-tree builder serializes the ledger into a tree (distributor/cli create-merkle-tree).
  3. The root is published on-chain (distributor/cli new-distributor was called in step 2; set_enable_slot flips claims on).
  4. Your distribution becomes claimable. Viewers can now claim.

Optional — clawback

If a meaningful amount of the pool is left unclaimed past clawback_start_ts, you can recover it with clawback. By default clawback_start_ts is end_at + 30 days. Configure that explicitly when you call new_distributor.