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
| pragma solidity ^0.4.23;
contract campaign{ struct funder{ address funderaddress; uint Tomoney; }
struct needer{ address Neederaddress; uint goal; uint amount; uint funderAcoount; mapping(uint => funder) map; }
uint neederAmount; mapping(uint=> needer) needmap;
function NewNeeder(address _Neederaddress, uint _goal ){ neederAmount++; needmap[neederAmount] = needer(_Neederaddress,_goal,0,0); }
function contribute( address _address, uint _neederAmount) payable{ needer storage _needer = needmap[_neederAmount]; _needer.amount += msg.value; _needer.funderAcoount++; _needer.map[ _needer.funderAcoount] = funder(_address , msg.value ); }
function ISconpelete( uint _neederAmount){ needer storage _needer = needmap[_neederAmount]; if(_needer.amount >=_needer.goal ){ _needer.Neederaddress.transfer(_needer.amount); } }
function test() view returns(uint,uint,uint){ return (needmap[1].goal, needmap[1].amount,needmap[1].funderAcoount); } }
|