Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save percybolmer/1484ae52a20bb89557d8d2d3efcdcf8d to your computer and use it in GitHub Desktop.
Save percybolmer/1484ae52a20bb89557d8d2d3efcdcf8d to your computer and use it in GitHub Desktop.
Method to add stakeholder
/**
* @notice _addStakeholder takes care of adding a stakeholder to the stakeholders array
*/
function _addStakeholder(address staker) internal returns (uint256){
// Push a empty item to the Array to make space for our new stakeholder
stakeholders.push();
// Calculate the index of the last item in the array by Len-1
uint256 userIndex = stakeholders.length - 1;
// Assign the address to the new index
stakeholders[userIndex].user = staker;
// Add index to the stakeHolders
stakes[staker] = userIndex;
return userIndex;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment