Skip to content

Instantly share code, notes, and snippets.

@yaronvel
Last active June 14, 2019 06:56
Show Gist options
  • Save yaronvel/a0d6ab0c40122a43ef700e7222efd7d2 to your computer and use it in GitHub Desktop.
Save yaronvel/a0d6ab0c40122a43ef700e7222efd7d2 to your computer and use it in GitHub Desktop.
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