3

We're creating a crowdsale smart contract on ethreum and would like to know the code to modify the crowdsale such that when a token is bought, it also sends the same quantity of tokens to the founder's account so that they always control 50% of the project.

1 Answers1

2

Assuming that your solution is similar to open-zepellin crowdsale contract you need to add a single line that will mint tokens to the founder account:

function buyTokens(address beneficiary) payable {
    require(beneficiary != 0x0);
    require(validPurchase());

    uint256 weiAmount = msg.value;
    uint256 updatedWeiRaised = weiRaised.add(weiAmount);

    // calculate token amount to be created
    uint256 tokens = weiAmount.mul(rate);

    // update state
    weiRaised = updatedWeiRaised;

    token.mint(beneficiary, tokens);

    //Mint as well to the founder's account
    token.mint(founder, tokens);

    TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);

    forwardFunds();
  }
Jakub Wojciechowski
  • 6,399
  • 4
  • 18
  • 16