1

I'm reading the crowdsale template, and I'm wondering if I'm reading certain things correctly.

Okay, the first part I want to ask about.

 /* checks if the goal or time limit has been reached and ends the campaign  
 */    function checkGoalReached() afterDeadline {

This section looks like a simple date deadline function, using a new variable couldn't we also determine if some one trys to buy tokens BEFORE the crowdsale? Something like StartTime = now + 1 years - 50 weeks, meaning this crowdsale is going to start in 2 weeks from now? (https://solidity.readthedocs.io/en/latest/units-and-global-variables.html)

Q1: Wouldn't this be a good approach for these ICOs? This way they can publish their real crowdsale address before the ICO begins?

I know some people lost a lot of ETH because of poorly communicated token addresses...

Q2: This part confuses me as well, is it used for freezing eth? Are ETH going into this contract address available to the creator? Or does that have to be specifically coded into the contract?

   function safeWithdrawal() afterDeadline {  
        if (!fundingGoalReached) {  
            uint amount = balanceOf[msg.sender];  
            balanceOf[msg.sender] = 0;  
            if (amount > 0) {  
                if (msg.sender.send(amount)) {  
                    FundTransfer(msg.sender, amount, false);  
                } else {  
                    balanceOf[msg.sender] = amount;  
                }
            }
        }   if (fundingGoalReached && beneficiary == msg.sender) {  
            if (beneficiary.send(amountRaised)) {  
                FundTransfer(beneficiary, amountRaised, false);  
            } else {  
                //If we fail to send the funds to beneficiary, unlock funders    balance
                fundingGoalReached = false;  
            }  
        }  
    }   }

I appreciate the time and answers. I have an idea I'd like to try to make happen, its not life changing and not meant to be the next big thing... I just really want to learn.

I guess what I'm trying to accomplish is a smart contract that will allow me to pull the ETH at any time, and that will provide participants with a flat rate of exchange for a new token. Anyone have any examples? The code is fairly easy to read, just trying to find resources at this time.

2

Remember, the examples are meant to illustrate specific aspects of the language and implementation but they don't cover every possible application of those principles.

Q1: Yes, that seems like a valid approach.

Q2: Success is not assured when sending Ether from a contract. That creates the possibility of funds marooned in the contract if the beneficiary is unable to receive for some reason. The example shows one possible approach to resolving this edge case. They try once, and if the funds are rejected, they make the funds available for funders to recover.

Hope it helps.

  • it did, thank you. – BigElittles Jun 2 '17 at 15:12

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.