Rewards contract
Last updated
Last updated
The Rewards contract manages token distribution for user participation in the Humanity Protocol ecosystem, including genesis, daily, and referral rewards.
Testnet:
The Rewards contract issues tokens to users based on their participation and referral activity. It uses a time-based epoch system to track daily claims and implements a sophisticated referral reward mechanism.
Multiple reward types: Genesis, daily, and referral rewards
Time-based epochs: Claims tracked on a daily basis
Adaptive reward scaling: Rewards decrease as total user count increases
Referral buffering: Holds pending referral rewards for claiming
Contract lifecycle management: Admin can start/stop rewards distribution
_contractActive
: Whether the contract is currently distributing rewards
_cycleStartTimestamp
: When the current reward cycle started
_previousCycleLastEpochID
: The last epoch ID before contract was stopped
_userClaims
: Tracks per-user claim status for each epoch
_genesisClaims
: Tracks whether users have claimed their genesis reward
_userBuffers
: Stores buffered referral rewards for each user
Genesis rewards are one-time rewards when a user is verified. The amount scales based on total users:
Daily rewards can be claimed once per epoch (day):
When a user claims a reward, referral rewards are buffered for their referrers:
The first referrer receives 50% of the claimed amount
Each subsequent referrer receives half of the previous referrer's amount
Rewards are only buffered if the referrer claimed their own reward in the previous epoch
User calls claimReward()
Contract checks:
Contract is active
User is verified (via VC contract)
User hasn't already claimed for current epoch
If this is the user's first claim, they receive a genesis reward
Otherwise, they receive a daily reward based on total user count
Referral rewards are buffered for the user's referrers
A RewardClaimed
event is emitted
User calls claimBuffer()
Contract checks:
Contract is active
User is verified (via VC contract)
User has a non-zero buffer amount
The buffered amount is transferred to the user
User's buffer is reset to zero
A RewardClaimed
event with RewardType.REFERRAL
is emitted