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 asks the backend to build an unsigned init_distributor transaction (bundled with streamer-vault::withdraw_for_distribution for Identity-tier STREAM distributions) and the streamer's wallet signs and submits it to create the distributor PDA and fund its vault.
  2. The frontend then POST /distributions-api/s the resulting PDA, mint, and parameters to 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 bot's bitview-snapshot module reads the accruals collection and builds a SHA256 merkle tree (same shape the distributor/cli create-merkle-tree command produces).
  3. set_enable_slot (signed by the streamer or operator) flips claims on at the desired slot.
  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 init_distributor.