Created
May 9, 2018 11:45
-
-
Save mattkanwisher/e11260f5f65d69bc2aa9d7d433bfd0fc 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
pragma solidity ^0.4.18; | |
import "zeppelin-solidity/contracts/crowdsale/Crowdsale.sol"; | |
import "zeppelin-solidity/contracts/ownership/Ownable.sol"; | |
contract LoomSale is Crowdsale, Ownable { | |
using SafeMath for uint256; | |
function LoomSale(uint256 _rate, address _wallet, ERC20 _loomTokenAddr) public | |
Crowdsale(_rate, _wallet, _loomTokenAddr) {} | |
// Owner Withdraw, Loom take out their ether | |
function ownerWithdraw() public onlyOwner { | |
uint256 amount = address(this).balance; | |
require(amount > 0); | |
wallet.transfer(amount); | |
} | |
function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { | |
return _weiAmount.div(rate).mul(1000); | |
} | |
event PreValidate(uint256 loomTokenLeft, uint256 weiAmount); | |
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal { | |
require(_beneficiary != address(0)); | |
require(_weiAmount != 0); | |
require(token.balanceOf(this) >= _getTokenAmount(_weiAmount)); | |
PreValidate(token.balanceOf(this), _getTokenAmount(_weiAmount)); | |
} | |
// Don't forward on buy wait for owner withdraw | |
function _forwardFunds() internal {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment