forked from CloinHQ/MinerDAO
-
Notifications
You must be signed in to change notification settings - Fork 1
/
contract.sol
45 lines (37 loc) · 1.26 KB
/
contract.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
pragma solidity ^0.4.2;
contract MiningDAO {
/* Define variable owner of the type address*/
address owner;
address[] public investors;
function MiningDAO(address[] investors_) {
owner = msg.sender;
investors = investors_;
}
/* The function without name is the default function that is called whenever anyone sends funds to a contract */
function () payable {
address contract_ = this;
uint256 balance = contract_.balance;
uint256 amount = (balance / investors.length) - 0.01 ether;
if(amount >= 0.2 ether) {
for(uint x = 0; x < investors.length; x++) {
if (!investors[x].send(amount)) {
revert();
}
}
}
}
/* Function to recover the funds on the contract */
function kill() {
if ( msg.sender == owner) {
address contract_ = this;
uint256 balance = contract_.balance;
uint256 amount = (balance / investors.length) - 0.01 ether;
if(amount >= 0.2 ether) {
for(uint x = 0; x < investors.length; x++) {
investors[x].transfer(amount);
}
}
selfdestruct(owner);
}
}
}