Last active
June 14, 2019 06:56
-
-
Save yaronvel/a0d6ab0c40122a43ef700e7222efd7d2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mapping(address=>uint[5]) user_reward; | |
uint start_time = now; | |
uint seconds_per_week = 1234; // put real number | |
function send_reward(address user, uint time) { | |
uint week_index = (time - start_time) / seconds_per_week; | |
if(user_reward[user][week_index] > 0 || week_index > 4) return 0; | |
uint reward = 1; | |
if(week_index > 0) reward += user_reward[user][week_index - 1]; | |
user_reward[user][week_index] = reward; | |
return reward; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment