Last active
September 21, 2018 12:12
-
-
Save vasa-develop/4ee0b3213d13cb9a28ad73c66eda495a to your computer and use it in GitHub Desktop.
DO NOT USE THIS CODE. THIS CODE IS USED TO DEMONSTRATE A VULNERABILITY IN A SOLIDITY CODE.
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
contract TimeLock { | |
mapping(address => uint) public balances; | |
mapping(address => uint) public lockTime; | |
function deposit() public payable { | |
balances[msg.sender] += msg.value; | |
lockTime[msg.sender] = now + 1 weeks; | |
} | |
function increaseLockTime(uint _secondsToIncrease) public { | |
lockTime[msg.sender] += _secondsToIncrease; | |
} | |
function withdraw() public { | |
require(balances[msg.sender] > 0); | |
require(now > lockTime[msg.sender]); | |
msg.sender.transfer(balances[msg.sender]); | |
balances[msg.sender] = 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment