0

I've been struggling with how to do this for quite some time and hoping this community could help.

I know that it should be added or something similar, so tokens balance of the investor address can be changed after investment.

enter image description here

I tried to modify buy() in a few ways by adding this for example:

require(tokenReward.transfer(msg.sender, numTokens));
require(tokenReward.transferFrom(ASSET_MANAGER_WALLET, msg.sender, numTokens));

require(tokenReward.transferFrom(tokenReward.owner(), msg.sender, numTokens));

if (tokenReward.transferFrom(tokenReward.owner(), msg.sender, numTokens))

tokenReward.transferFrom(tokenReward.owner(), msg.sender, amount.mul(rate));

if (tokenReward.transferFrom(tokenReward.owner(), msg.sender, amount.mul(RATE))) {
       revert();
     }

if (tokenReward.transferFrom(tokenReward.owner(), msg.sender,  numTokens)) {
       revert();
     }

No success.

AND THIS IS VERY IMPORTANT !

Without this line of code,

require(tokenReward.transferFrom(tokenReward.owner(), msg.sender, numTokens));

I could send eth and balanceOf and amountRised were CORRECTLY CALCULATED BUT THE INVESTOR BALANCE WAS NOT CORRECT.

After adding this line of code, require(tokenReward.transferFrom(tokenReward.owner(), msg.sender, numTokens)); I can not do anything. When sending eth to crowdsale, I get this from Myetherwallet, enter image description here

Is there anyone here who could help solve this problem. Thank you, Robert

Token Contract
https://ropsten.etherscan.io/address/0x2aa448505f3ba5359e2537113e0fe1293aea9ecb#code

Crowdsale Contract
https://ropsten.etherscan.io/address/0xf70142870fe11e39af3539005e5f02b31e60fb4c#code

  • You need to rephrase your question, I couldn't understand what is your problem, you say too many things but nowhere your problem is stated clearly, for instance buy() function should be in the body of your question. – Jaime Jun 1 '18 at 14:41
  • Hi, why can't send eth to crowdsale contract after adding a line require(tokenReward.transferFrom(tokenReward.owner(), msg.sender, numTokens)); – Robert Jun 1 '18 at 16:13
0

The problem is you are using an external owned account as tokenReward.

In etherscan page of your token sale the tokenReward address is 0x79b67dff9fb21d2550937d879ec2eacb2f377da0 which is a regular non contract account.

Since you can only modify the tokenReward address in the constructor the only option left is to redeploy your sale contract.

  • Thank you for your answer. You mean deploy again the same the crowdsale contract. Can You be more specific because I do not really understand how to do it. Robert – Robert Jun 4 '18 at 9:13
  • The constructor of your token sale ParadiseTokenSale has a parameter addressOfTokenUsedAsReward that should point to your token ParadiseToken. You cannot fix it in your deployed contracts because the code doesn't allow it, you will have to redeploy them again. – Ismael Jun 4 '18 at 13:38
  • You were right. The problem was external owned account as tokenReward. I changed to ParadiseToken. It works but the investor's balance is incorrect. – Robert Jun 4 '18 at 19:42

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.