Last active
July 22, 2021 11:44
-
-
Save andrew-fleming/0dba12c6de8a9d21a22c537dd712c649 to your computer and use it in GitHub Desktop.
Stake function
This file contains 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
pragma solidity 0.8.4; | |
contract PmknFarm { | |
function stake() public payable { | |
require( | |
msg.value > 0, | |
"You cannot stake zero tokens" | |
); | |
if(isStaking[msg.sender] == true){ | |
uint256 toTransfer = calculateYieldTotal(msg.sender); | |
pmknBalance[msg.sender] += toTransfer; | |
} | |
stakingBalance[msg.sender] += msg.value; | |
startTime[msg.sender] = block.timestamp; | |
isStaking[msg.sender] = true; | |
emit Stake(msg.sender, msg.value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment