-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTicketing_3.sol
46 lines (37 loc) · 1.08 KB
/
Ticketing_3.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
pragma solidity ^0.4.25;
/*************************************
* Only the manager is allowed to retrieve the list
*/
contract Event {
address public manager; //Owner of the Event
string title;
uint price;
address[] private purchasedTickets;
modifier ManagerOnly() {
require(manager == msg.sender);
_;
}
constructor (string name, uint eventPrice) public {
manager = msg.sender;
title = name;
price = eventPrice;
}
function buyTicket() public {
address eventAddr = address(this);
address newTicket = new Ticket(eventAddr, msg.sender, manager);
purchasedTickets.push(newTicket);
}
function getTickets() public view ManagerOnly returns (address[]) {
return purchasedTickets;
}
}
contract Ticket {
address public owner;
address public manager;
address public eventAddress;
constructor (address _eventAddr, address _buyer, address _manager) public {
owner = _buyer;
manager = _manager;
eventAddress = _eventAddr;
}
}