Skip to content

Instantly share code, notes, and snippets.

@mattkanwisher
Created May 9, 2018 11:45
Show Gist options
  • Save mattkanwisher/e11260f5f65d69bc2aa9d7d433bfd0fc to your computer and use it in GitHub Desktop.
Save mattkanwisher/e11260f5f65d69bc2aa9d7d433bfd0fc to your computer and use it in GitHub Desktop.
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