I have a crowdsale contract, that seems to be working fine. It receives funds, and returns a token in exchange.

However, once its past the deadline, and I run the checkGoal() function, the contract remains in a "Waiting for transaction to be mined" state indefinitely.

modifier afterDeadline() { if (now >= deadline) _; }
function checkGoalReached() afterDeadline{
        if (amountRaised >= fundingGoal) {
            fundingGoalReached = true; 
        crowdsaleClosed = true; 

I don't understand what it is about this particular function that seems to lock the contract up.

Any ideas?


I'm not sure why checking the goal is only valid after the deadline and I'm not sure why only the admin is allowed to.

If the sender is NOT admin, then what? If just drops out of the if block and nothing happens.

Nothing is ever returned. It's setting state variables. That's quite different from the idea of "check" as the name implies. Check implies a read-only function and as a bonus, it can be constant.

Just a sketchy idea of a different approach:

pragma solidity 0.4.11;

contract CrowdFund {

    uint deadline;
    uint goal;
    uint raised;
    address owner;

    function CrowdFund(uint _deadline, uint _goal) {
        owner = msg.sender;
        deadline = _deadline;
        goal = _goal;

    function checkGoalReached() public constant returns(bool isIndeed) {
        return (raised >= goal);

    function checkDeadlinePassed() public constant returns(bool hasIndeed) {
        return(now > deadline);


Hope it helps.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.