-
Notifications
You must be signed in to change notification settings - Fork 0
/
timstamp-contract2
65 lines (50 loc) · 1.75 KB
/
timstamp-contract2
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//smart contract collecting ether with time period before which use cant withdraw
pragma solidity >=0.5.0 <0.6.0;
contract Ownable {
address payable private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () internal {
_owner = msg.sender;
emit OwnershipTransferred(address(0), _owner);
}
function owner() public view returns (address payable) {
return _owner;
}
modifier onlyOwner() {
require(isOwner(), "Ownable: caller is not the owner");
_;
}
function isOwner() public view returns (bool) {
return msg.sender == _owner;
}
function renounceOwnership() public onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address payable newOwner) public onlyOwner {
_transferOwnership(newOwner);
}
function _transferOwnership(address payable newOwner) internal {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
contract EtherSendWithdraw is Ownable{
uint256 public delay = 0;
uint256 public amount;
mapping (address => uint256) public balance;
function deposits() public payable {
amount = msg.value;
balance[msg.sender] = amount;
}
function setDeadline(uint _delay) public onlyOwner {
delay = block.timestamp + (_delay * 60 );
}
function withdraw() public {
require(block.timestamp > delay);
address payable _invoker = msg.sender;
require(balance[_invoker] > 0);
_invoker.transfer(amount);
}
}