-
Notifications
You must be signed in to change notification settings - Fork 4
/
RelayersContest.sol
43 lines (38 loc) · 1.39 KB
/
RelayersContest.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
pragma solidity 0.5.13;
pragma experimental ABIEncoderV2;
contract RelayersContest {
mapping(string => bool) public participants;
string[] public participantsArray;
uint256 endRegistration;
uint256 endContest;
address public owner;
string[] public winners;
bool isWinnersSet = false;
event Register(string participant);
event Winners(string[] winners);
constructor(uint256 _endRegistration, uint256 _endContest) public {
require(_endRegistration > now);
require(_endContest > _endRegistration + 3 days);
endRegistration = _endRegistration;
owner = msg.sender;
endContest = _endContest;
}
function register(string memory _ipOrDomain) public {
require(now <= endRegistration, 'registration is over');
require(!participants[_ipOrDomain], 'already registred');
participants[_ipOrDomain] = true;
participantsArray.push(_ipOrDomain);
emit Register(_ipOrDomain);
}
function setWinners(string[] memory _winners) public {
require(msg.sender == owner);
require(now > endContest, 'too early');
require(!isWinnersSet);
for(uint i = 0; i < _winners.length; i++) {
require(participants[_winners[i]], 'not participant');
winners.push(_winners[i]);
}
isWinnersSet = true;
emit Winners(_winners);
}
}