-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCrowdFundRaise.sol
52 lines (32 loc) · 1.15 KB
/
CrowdFundRaise.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
47
48
49
50
51
52
pragma solidity ^0.4.0;
contract crowdfund{
struct funder{
address funderaddress;
uint fund;
}
struct needer{
address neederaddress;
uint goal;
uint raised;
uint funderamount;
mapping(uint => funder) fundermap;
}
uint neederamount = 0;
mapping(uint => needer) needermap;
function NewNeeder(address _neederaddress, uint _goal){
neederamount++;
needermap[neederamount] = needer(_neederaddress, _goal, 0, 0);
}
function contribute(address _address, uint _neederAmount) payable {
needer storage _needer = needermap[_neederAmount];
_needer.raised += msg.value;
_needer.funderamount ++;
_needer.fundermap[_needer.funderamount] = funder(_address, msg.value);
}
function isComplete(uint _neederAmount) {
needer storage _needer = needermap[_neederAmount];
if(_needer.raised >= _needer.goal) {
_needer.neederaddress.transfer(_needer.raised);
}
}
}