-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSmartContract
59 lines (44 loc) · 1.32 KB
/
SmartContract
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
pragma solidity ^0.4.17;
contract PatreonFactory {
address[] public deployedPatreons;
function createPatreon(string title, string description) public {
address newPatreon = new Patreon(title, description, msg.sender);
deployedPatreons.push(newPatreon);
}
function getDeployedPatreon() public view returns (address[]) {
return deployedPatreons;
}
}
contract Patreon {
address public manager;
uint public contributors;
string patreonTitle;
string patreonDescription;
function Patreon(string title, string description, address creator) public {
manager = creator;
patreonTitle = title;
patreonDescription = description;
}
function pay() public payable {
require(msg.value > .01 ether);
contributors += 1;
}
function cashOut() public {
require(msg.sender == manager);
manager.transfer(this.balance);
}
function destroy() public {
require(msg.sender == manager);
selfdestruct(manager);
}
function getInfo() public view returns (
string, string, uint, address
) {
return (
patreonTitle,
patreonDescription,
contributors,
manager
);
}
}