Last active
August 14, 2022 09:53
-
-
Save ac12644/2e2c7d6611662c9746e1acfd36be39fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function buyTokens(address _investor) public payable { | |
uint256 weiAmount = msg.value; | |
_preValidatePurchase(_investor, weiAmount); | |
// update state | |
weiRaised = weiRaised.add(weiAmount); | |
// Calculate the token amount | |
uint256 tokens = _calculateToken(weiAmount); | |
// Transfer them to the investor address | |
_processPurchase(_investor, tokens); | |
} | |
function _deliverTokens(address _investor, uint256 _tokenAmount) internal { | |
token.transfer(_investor, _tokenAmount); | |
} | |
function _processPurchase(address _investor, uint256 _tokenAmount) | |
internal | |
{ | |
_deliverTokens(_investor, _tokenAmount); | |
} | |
function _calculateToken(uint256 _weiAmount) | |
internal | |
view | |
returns (uint256) | |
{ | |
return _weiAmount.mul(rate); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment