Skip to content

Distribute Subscriptions

System smart contract that starts the procedure of redistribution premium pool's income generated by suscriptions.

An operation can be initiated by any account, but the network will only accept one transaction every 24 hours.


# Find all unprocessed subscriptions
subscriptions = [ account.getUnprocessedSubscriptions() in system.accounts if

for subscription in subscriptions:
  # Get watch duration as a list of tuples (broadcaster, duration) where:
  # - broadcaster: broadcaster's account
  # - duration: total duration of watching broadcaster's content by
  #   subscription.owner during the specified period
  # This data is retrieved from the layer 2
  watchDuration = getWatchDuration(

  # Get total duration
  totalDuration = 0
  for (broadcaster, duration) in watchDuration:
    totalDuration += duration

  # The amount of tokens to distribute among broadcasters is stored in
  # the "broadcastersShare" field of the subscription
  tokensToDistribute = subscription.broadcastersShare

  # Distribute tokens to broadcasters proportionally to the watch duration
  for (broadcaster, duration) in watchDuration:
    addTokens(broadcaster, tokensToDistribute * duration / totalDuration)

  # Remove processed subscription from the ledger

The brief description

  • find all unprocessed subscriptions (these are subscriptions that have expired, but the income from them has not yet been distributed to brodcasters) and perform the following:
    • get information from the second level about time spent for watching during the subscription (which pool’s Broadcasters the subscriber had been watching and for how long)
    • get tokens from broadcastersShare field of subcriotion and redistribute them among Broadcasters in proportion to watching time
    • delete processed subscription