-
Notifications
You must be signed in to change notification settings - Fork 0
/
lotery_sample.sol
34 lines (27 loc) · 1.02 KB
/
lotery_sample.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
pragma solidity ^0.8.0;
contract Lottery {
// инициализация переменных и событий
address public operator;
address[] public participants;
uint public Block;
mapping (address => uint) private participantID;
event Bet(address who);
event Round(uint numBlock)
// функция для проведения раунда лотереи
function playLottery(uint number) public {
if (msg.sender != operator) {
participantID[msg.sender] = number;
participants.push(msg.sender);
Bet(msg.sender);
} else {
require(block.number - Block > 3);
Block - block.number;
for (uint k = 0; k < participants.length; k++) {
if (participantID[participants[k]] == number) {
betters[participants[k]].active = true;
MakeBet(participants[k], betters[participants[k]]);
}
}
}
}
}