0

I just try to implement a standard token with a basic crowdsale from open zeppelin.

I have everything up and running but the transaction always reverts and I tracked it down to this line:

token.transfer(_beneficiary, _tokenAmount);

So within the token contract I get msg.sender to be the Crowdsale contract. However, since the crowdsale contract get's deployed after the token contract, all the tokens are at the address that created the token contract and my guess is that this is causing the revert - because the crowdsale does not have any tokens.

Hence, I have 3 questions:

  • is this correct?
  • does this simply mean that I need to transfer all tokens to the crowdsale contract?
  • is there a way to automate this?
  • 2
    It is correct, that is the problem and I need to transfer all the tokens to the crowdsale contract. – shredding Apr 11 '18 at 15:15
1

One solution is to assign all tokens to the creator of the Token and after deployment of the crowdsale the creator will transfer all tokens to the crowdsale

// Create 1000 token assigned to 0xOwnerAddress
tokenAddress = deploy_token(1000, { from: "0xOwnerAddress" })

// Deploy crowdsale
crowdsaleAddress = deploy_crowdsale(tokenAddress, { from: "0xOwnerAddress" })

// Transfer tokens to crowdsale
token.transfer(crowdsaleAddress, 1000, { from: "0xOwnerAddress" })
  • Yup. I managed to do so in the testuite. – shredding Apr 14 '18 at 9:10

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.