-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimelock.sol
29 lines (21 loc) · 836 Bytes
/
timelock.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
pragma solidity ^0.8.11;
contract FundLock {
mapping(address => uint) public balances;
mapping(address => uint) public lockTime;
function deposit() external payable {
require(msg.value >= 1 ether, "Minimum Lock is 1 Ether");
balances[msg.sender] += msg.value;
lockTime[msg.sender] = block.timestamp + 1 weeks;
}
function increaseLockTime(uint _seconds) public {
lockTime[msg.sender] += _seconds;
}
function withdraw() public {
require(balances[msg.sender] > 0, "Insufficient Balance");
require(block.timestamp > lockTime[msg.sender], "LockTime Not Reached");
uint amount = balances[msg.sender];
balances[msg.sender] = 0;
(bool sent, ) = msg.sender.call{value: amount}("");
require(sent, "Failed To send Ether");
}
}