Skip to content

Instantly share code, notes, and snippets.

@vasa-develop
Last active September 21, 2018 12:12
Show Gist options
  • Save vasa-develop/4ee0b3213d13cb9a28ad73c66eda495a to your computer and use it in GitHub Desktop.
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.
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