-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLottery.sol
More file actions
59 lines (44 loc) · 1.72 KB
/
Copy pathLottery.sol
File metadata and controls
59 lines (44 loc) · 1.72 KB
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
//SPDX-License-Identifier:MIT
pragma solidity ^0.8.0;
contract Lottery {
struct Lottery {
string Name;
address creator;
uint startTime;
uint endTime;
uint tickerPrice;
}
address owner;
Lottery public lotery;
uint totalTicketsSold = 0;
// Ticket to Address of Buyer Mapping
mapping(uint => address) lotteryBuyer;
constructor(string memory name, uint _startTime, uint _endTime) {
owner = msg.sender;
lotery = Lottery({Name: name, creator: msg.sender, startTime: block.timestamp + _startTime, endTime: block.timestamp + _endTime, tickerPrice: 1 ether});
}
function buyTickets(uint quantity ) payable external {
// Check whether the user is paying required ethers to buy x amount of tickets
// should permit ticket buying after startTIme and before endTime of the Lottery
// Owner cannot buy tickets
// Max tickets is 20
// User should be able to buy tickets
// Store the information about the tickets about.
}
function findWinner() external {
// restrict access to this function only to Owner
// should be executed only after the endTime of the Lottery
// rand = random number generation code
// winnerId = rand % totalTicketsSold;
}
function winnerWithdraw() external {
// Only the winner can withdraw funds
// Should allow the winner to withdraw only 80% of the funds collected
// Winner can withdraw only once.
}
function ownerWithdraw() external {
// Only the owner can withdraw funds
// Should allow the owner to withdraw only 20% of the funds collected
// Winner can withdraw only once.
}
}