-
Notifications
You must be signed in to change notification settings - Fork 0
/
send and withdraw Ethers - contract0
55 lines (41 loc) · 1.37 KB
/
send and withdraw Ethers - contract0
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
pragma solidity 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 _amount = 0;
function sendEth() public payable {
_amount = _amount +msg.value;
}
function withdraw() public onlyOwner {
address payable _owner = owner();
_owner.transfer(address(this).balance);
}
}