Crowdsale
contract Crowdsale
Crowdsale is a base contract for managing a token crowdsale, allowing investors to purchase tokens with ether. This contract implements such functionality in its most fundamental form and can be extended to provide additional functionality and/or custom behavior. The external interface represents the basic interface for purchasing tokens, and conform the base architecture for crowdsales. They are *not* intended to be modified / overriden. The internal interface conforms the extensible and modifiable surface of crowdsales. Override the methods to add functionality. Consider using 'super' where appropiate to concatenate behavior.
Index
Reference
Events
TokenPurchase
event TokenPurchase(address purchaser, address beneficiary, uint256 value, uint256 amount)
Event for token purchase logging.
- Parameters:
purchaser
- who paid for the tokensbeneficiary
- who got the tokensvalue
- weis paid for purchaseamount
- amount of tokens purchased
Functions
Crowdsale
function Crowdsale(uint256 _rate, address _wallet, ERC20 _token) public
- Parameters:
_rate
- Number of token units a buyer gets per wei_wallet
- Address where collected funds will be forwarded to_token
- Address of the token being sold
_deliverTokens
function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal
Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens.
- Parameters:
_beneficiary
- Address performing the token purchase_tokenAmount
- Number of tokens to be emitted
_forwardFunds
function _forwardFunds() internal
Determines how ETH is stored/forwarded on purchases.
_getTokenAmount
function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256)
Override to extend the way in which ether is converted to tokens.
- Parameters:
_weiAmount
- Value in wei to be converted into tokens- Returns:
- Number of tokens that can be purchased with the specified _weiAmount
_postValidatePurchase
function _postValidatePurchase(address _beneficiary, uint256 _weiAmount) internal
Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met.
- Parameters:
_beneficiary
- Address performing the token purchase_weiAmount
- Value in wei involved in the purchase
_preValidatePurchase
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal
Validation of an incoming purchase. Use require statemens to revert state when conditions are not met. Use super to concatenate validations.
- Parameters:
_beneficiary
- Address performing the token purchase_weiAmount
- Value in wei involved in the purchase
_processPurchase
function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal
Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens.
- Parameters:
_beneficiary
- Address receiving the tokens_tokenAmount
- Number of tokens to be purchased
_updatePurchasingState
function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal
Override for extensions that require an internal state to check for validity (current user contributions, etc.).
- Parameters:
_beneficiary
- Address receiving the tokens_weiAmount
- Value in wei involved in the purchase
buyTokens
function buyTokens(address _beneficiary) public payable
Low level token purchase ***DO NOT OVERRIDE***.
- Parameters:
_beneficiary
- Address performing the token purchase
fallback
function () external payable
Fallback function ***DO NOT OVERRIDE***.