pragma solidity ^0.4.16;
interface token {
function mintToken(address receiver, uint amount);
}
contract Owned {
address owner;
/*this function is executed at initialization and sets the owner of the contract */
function owned() { owner = msg.sender; }
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
}
contract Selfdestroy is Owned {
/* Function to recover the funds on the contract */
function Destroy() onlyOwner() {
selfdestruct(owner);
}
}
contract Crowdsale is Owned,Selfdestroy {
address public beneficiary;
uint public fundingGoal;
uint public amountRaised;
uint public deadline;
uint public price;
token public tokenReward;
mapping(address => uint256) public balanceOf;
bool crowdsaleClosed = false;
event GoalReached(address recipient, uint totalAmountRaised);
event FundTransfer(address backer, uint amount, bool isContribution);
/**
* Constrctor function
*
* Setup the owner
*/
function Crowdsale(
address ifSuccessfulSendTo,
uint fundingGoalInEthers,
uint durationInMinutes,
uint etherCostOfEachToken,
address addressOfTokenUsedAsReward
) {
beneficiary = ifSuccessfulSendTo;
fundingGoal = fundingGoalInEthers * 1 ether;
deadline = now + durationInMinutes * 1 minutes;
price = etherCostOfEachToken;
tokenReward = token(addressOfTokenUsedAsReward);
}
/**
* Fallback function
*
* The function without name is the default function that is called whenever anyone sends funds to a contract
*/
function () payable {
uint amount = msg.value;
balanceOf[msg.sender] += amount;
amountRaised += amount;
tokenReward.mintToken(msg.sender, amount / price);
FundTransfer(msg.sender, amount, true);
}
/**
* Withdraw the funds
*/
function OwnerWithdrawal() onlyOwner {
beneficiary.transfer(amountRaised);
}
}
I edit the function OwnerWithdrawal to withdraw eth from contract , but it's can't execute on second time. Is there any way to execute many time I want?