Skip to content
8 changes: 6 additions & 2 deletions contracts/crowdsale/Crowdsale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,16 @@ contract Crowdsale {
return new MintableToken();
}


// fallback function can be used to buy tokens
function () external payable {
buyTokens(msg.sender);
}

// Override this method to have a way to add business logic to your crowdsale when buying
function getTokenAmount(uint256 weiAmount) internal view returns(uint256) {
return weiAmount.mul(rate);
}

// low level token purchase function
function buyTokens(address beneficiary) public payable {
require(beneficiary != address(0));
Expand All @@ -73,7 +77,7 @@ contract Crowdsale {
uint256 weiAmount = msg.value;

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

// update state
weiRaised = weiRaised.add(weiAmount);
Expand Down