You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would it be better to transfer the _stake amount to contract address itself instead of burn in createStake() ? https://github.com/HQ20/StakingToken/blob/master/contracts/StakingToken.sol#L50
_burn subtracts the totalSupply and hence the suggestion.
Similarly for removeStake(), transfer back the amount from contract address to the msg.sender
Example:
mapping(address => uint256) public staked;
function stake(uint256 amount) external {
require(balanceOf(msg.sender) >= amount, "staking amount is more than balance");
transfer(address(this), amount);
staked[msg.sender] += amount;
}
function unstake(uint256 amount) external {
require(staked[msg.sender] >= amount, "staked amount is less than withdrawl amount");
staked[msg.sender] -= amount;
_transfer(address(this), msg.sender, amount);
}
The text was updated successfully, but these errors were encountered:
Would it be better to transfer the _stake amount to contract address itself instead of burn in createStake() ?
https://github.com/HQ20/StakingToken/blob/master/contracts/StakingToken.sol#L50
_burn subtracts the totalSupply and hence the suggestion.
Similarly for removeStake(), transfer back the amount from contract address to the msg.sender
Example:
The text was updated successfully, but these errors were encountered: