Jun 24, 2019
By: Yossi Gilad, Head of Systems Research & Chief Technology Officer, Algorand
This post is intended to help explain how rewards are implemented in the Algorand source code and the corresponding effect on token holders. For questions around rewards philosophy or amounts, please visit the Algorand Foundation.
Given that Algorand Inc developed the Algorand blockchain protocol, we are in a unique position to give insight into how the rewards mechanism was implemented. This post will take you through how rewards are calculated, how they are paid out, how rewards data appears, and some practical implications of our implementation.
The fixed reward per block is calculated as (Rewards Pool / Rewards Period).
- Note that this calculation happens only once per Reward Period, at its start
TEU is calculated at each block by summing all UEUs in the system at that block.
Each user’s reward for each block is calculated as (UEU/TEU) * fixed reward per block. This calculation is executed every block for every user to take into account changing account balances.
The minimum divisible unit of an Algo is a microAlgo (10^-6). We calculate rewards every block and there are blocks where an account with the MEU will not have earned a full microAlgo from that block’s rewards. Therefore, the Algorand protocol adds to an account’s pending rewards as soon as a MEU gains one full microAlgo in rewards. To keep track of rewards that should have been distributed in previous blocks, but were not due to the rewards amount being less than a microAlgo, the block header maintains the ``frac’’ field. The value in the previous block’s frac field gets added to the rewards granted by a block, so eventually, even these smaller leftover rewards would get distributed.
Reward distribution time. The Algorand protocol calculates rewards at every block, but it might take several blocks until a MEU accrues a full micro-Algo allowing rewards to be added to all eligible accounts. The distribution time is a function of the TEU in the system. When all tokens are in circulation, the TEU would be at most 10B. Assume that 20 algos are rewarded at every block, then it would take 500 blocks to accumulate 1 micro-Algo per earning unit. With blocks generated every 5 seconds, rewards are disbursed every 500 * 5 seconds = 41 minutes.
Example. Let us walk through a simple example to explain the Algorand rewards protocol:
Assume that TEU is 10M, and that each block distributes 1 Algo in rewards.
Since 1 Algo/10M is less than a micro-Algo, the reward field in the header would not initially increase. Instead, for each of the first 9 blocks, the frac field recorded in headers would increase from 0 to 9. At the 10th block, 10 algos would be disbursed (9 algos from the ``frac’’ header, the remainder from previous blocks and 1 Algo that the 10th block rewards). The block header in the 10th block would, therefore, have the ``earn’’ field set to 1, meaning that every whole earning unit gets 1 micro-Algo. The ``frac’’ field would be set to 0 since there are no leftover rewards.
Each block contains the following fields and can be queried using the SDKs, curl or the REST API (for example /v1/block/{round})
The details of pending rewards, claimed rewards and balance for an account are available to query. This can be done using the SDKS, curl or the REST API. All of these make use of the REST path /v1/account/{address}.
When you query an account you will find four rewards and balance related fields.
As rewards are claimed when transactions occur, the rewards claimed from that transaction are also available to query. This can be done using the SDKs, curl or the REST API (for example /v1/account/{address}/transaction/{txid}).
When you query a transaction you will find three rewards related fields.
Unclaimed pending rewards are claimed by an address when that address is contained within a transaction’s To, From, or Close parameters. That means it is impossible to transact without claiming any unclaimed pending rewards first. If there are unclaimed pending rewards to claim, they will be noted in the transaction and available when you query that transaction.
Algorand Inc. and its affiliates are separate, independent entities from the Algorand Foundation. Algorand Inc. is currently a service provider to the Algorand Foundation with respect to its blockchain protocol development.