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:
| Field | Meaning | Example |
|---|---|---|
total_token | Total amount distributed across the whole event (smallest unit) | 1_000_000_000_000 (1M tokens at 6 decimals) |
duration_seconds | How long the event runs | 28_800 (8 hours) |
periodicity_seconds | How often each present viewer gets credited | 3_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:
- The frontend creates the distributor PDA via
new_distributorand funds the token vault. - It then
POST /distributions-api/registers the resulting PDA, mint, and parameters with the backend. - 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:
- The operator (you, or the BitView team) calls
POST /distributions-api/{id}/finalize(admin endpoint). - The merkle-tree builder serializes the ledger into a tree
(
distributor/cli create-merkle-tree). - The root is published on-chain (
distributor/cli new-distributorwas called in step 2;set_enable_slotflips claims on). - 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.