0

Retrying the question, OBTAINED ANSWER DOES NOT RESOLVE THE PROBLEM. I sent some eth to crowdsale contract but balance Of does not change. (to call the function I'm using Remix Ropsten test net).

The code is here: https://ropsten.etherscan.io/address/0xc3ec072c279043ad2e56f4b5683b78337ed614d9#code

The suggestion of one of the members was to change,

enter image description here

I think the problem lies somewhere else, here;

function () payable public { }

function buy () payable public  whenNotPaused beforeDeadline afterStartTime saleNotClosed {
    require(msg.value >= minContribution);

    // Update the sender's balance of wei contributed and the amount raised
    uint amount = msg.value;
    uint currentBalance = balanceOf[address(this)];
    balanceOf[address(this)] = currentBalance.add(amount);
    amountRaised = amountRaised.add(amount);

    // Compute the number of tokens to be rewarded to the sender
    // Note: it's important for this calculation that both wei
    // and PDT have the same number of decimal places (18)
    uint numTokens = amount.mul(rate);

    // Transfer the tokens from the crowdsale supply to the sender
    if (tokenReward.transferFrom(tokenReward.owner(), msg.sender, numTokens)) {
        FundTransfer(msg.sender, amount, true);
        // Check if the funding goal or cap have been reached
        // TODO check impact on gas cost
        checkFundingGoal();
        checkFundingCap();
    }
    else {
        revert();
    }
}

I tried to change so and nothing, like this;

uint currentBalance = balanceOf[address(this)];

balanceOf[address(this)] = currentBalance.add(amount);

and ; enter image description here

Is there anyone here who will tell me directly without guessing where the problem lies?

Any help is very much appreciated.

  • What is your question? You have two contracts a Token and a TokenSale both have a balance one in tokens and the other in ether. – Ismael May 8 '18 at 13:58
  • Hi. the question is why a balance Of and the amount raised does not is updated( I'm call this function in Remix) after some ether was sent to the crowdsale contract?Thanks for the aswer. – Robert May 8 '18 at 15:54
  • That is because you ar calling the fallback function, and that function does nothing. You have to call the buy function. – Ismael May 8 '18 at 16:10
  • I thought its gonna be updated automatically.Buy function(Remix)- give me this- "Gas estimation failed" and then ropsten.etherscan.io/tx/… Why is there any error in the code? – Robert May 8 '18 at 16:35
  • That is because you send 0 ether but in your code you have require(msg.value >= minContribution); and it will fail there. – Ismael May 8 '18 at 16:53

Your Answer

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

Browse other questions tagged or ask your own question.