Skip to content
This repository has been archived by the owner on Oct 17, 2022. It is now read-only.

crowsale example issue. #799

Open
leochan007 opened this issue Mar 5, 2018 · 4 comments
Open

crowsale example issue. #799

leochan007 opened this issue Mar 5, 2018 · 4 comments

Comments

@leochan007
Copy link

function () payable {
require(!crowdsaleClosed);
uint amount = msg.value;
balanceOf[msg.sender] += amount;
amountRaised += amount;
tokenReward.transfer(msg.sender, amount / price);
FundTransfer(msg.sender, amount, true);
}

is this correct for crowsale??

 tokenReward.transfer(msg.sender, amount / price);

anyone who wanna buytoken may don't have token at all. how to transfer the token to himself?

@samsoft00
Copy link

I'm currently facing the same issue, crowdsales execution terminate at the point tokenReward.transfer(msg.sender, amount / price); it give me the following error

  • Errored: VM Exception while processing transaction: revert"
  • "The constructor should be payable if you send value.

Are you able to work around it? Please help!

@leochan007
Copy link
Author

@leochan007
Copy link
Author

leochan007 commented Mar 16, 2018

@samsoft00 create token first. create crowdsale. then u have to approve tokenwallet to crowdsale.

@360disrupt
Copy link

360disrupt commented Aug 30, 2018

I think there are two more issues with the example.

  1. Rounding: e.g. if I have an etherCostOfEachToken = 2 and I send 1 ether to the contract the contract takes the 1 ether as a donation and leaves me without any tokens.

  2. The last person has to buy the exact amount of remaining tokens otherwise the contract will fail.

@leochan007 can you explain how to use the code you posted. On the example of the ethereum homepage, I 1st create a token, 2nd I transfer all the tokens to the crowdSale contract's address, 3rd buyers send ether to the crowdSale contract, 4th after the deadline I need to call safeWithdrawal

How does this change with the allowance, does it solve the problems I mentioned above (I see it has a remainingTokens function)? Many thx

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants