File size: 1,528 Bytes
dec6d5d |
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 60 61 62 63 64 65 66 67 68 |
contract Accrual_account
{
address admin = msg.sender;
uint targetAmount = 1 ether;
mapping(address => uint) public investors;
event FundsMove(uint amount,bytes32 typeAct,address adr);
function changeAdmin(address _new)
{
if(_new==0x0)throw;
if(msg.sender!=admin)throw;
admin=_new;
}
function FundTransfer(uint _am, bytes32 _operation, address _to, address _feeToAdr)
payable
{
if(msg.sender != address(this)) throw;
if(_operation=="In")
{
FundsMove(msg.value,"In",_to);
investors[_to] += _am;
}
else
{
uint amTotransfer = 0;
if(_to==_feeToAdr)
{
amTotransfer=_am;
}
else
{
amTotransfer=_am/100*99;
investors[_feeToAdr]+=_am-amTotransfer;
}
if(_to.call.value(_am)()==false)throw;
investors[_to] -= _am;
FundsMove(_am, "Out", _to);
}
}
function()
payable
{
In(msg.sender);
}
function Out(uint amount)
payable
{
if(investors[msg.sender]<targetAmount)throw;
if(investors[msg.sender]<amount)throw;
this.FundTransfer(amount,"",msg.sender,admin);
}
function In(address to)
payable
{
if(to==0x0)to = admin;
if(msg.sender!=tx.origin)throw;
this.FundTransfer(msg.value, "In", to,admin);
}
} |