Skip to content

Instantly share code, notes, and snippets.

@bombap
Created September 11, 2021 08:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bombap/a6a3ea6660469e01986f324bff9a449c to your computer and use it in GitHub Desktop.
Save bombap/a6a3ea6660469e01986f324bff9a449c to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract XXX is ERC20, Ownable {
uint256 private aSBlock;
uint256 private aEBlock;
uint256 private aCap;
uint256 private aTot;
uint256 private aAmt;
uint256 private sSBlock;
uint256 private sEBlock;
uint256 private sCap;
uint256 private sTot;
uint256 private sPhase;
uint256 private sPrice;
mapping(address => bool) public gotBonus;
constructor() ERC20("XXX Coin", "XXX") {
_mint(msg.sender, 7500000000*10**decimals());
_mint(address(this), 2500000000*10**decimals());
setPreSale(block.number, 999999999, 0, 2500000*10**decimals(), 2000);
setAirdrop(block.number, 999999999, 1000*10**decimals(), 2000);
}
function decimals() public view virtual override returns (uint8) {
return 9;
}
function salePrice() public view returns (uint Price) {
return sPrice;
}
function claimBonus(address _refer) public {
require(aSBlock <= block.number && block.number <= aEBlock, "Bonus expired");
require(aTot < aCap || aCap == 0, "Out of bonus");
require(gotBonus[msg.sender] == false, "Can only claim the reward once");
aTot ++;
gotBonus[msg.sender] = true;
if(msg.sender != _refer && balanceOf(_refer) != 0 && _refer != address(0)){
_transfer(address(this), _refer, aAmt);
}
_transfer(address(this), msg.sender, aAmt);
}
function preSale(address _refer) public payable {
require(sSBlock <= block.number && block.number <= sEBlock);
require(sTot < sCap || sCap == 0);
uint256 _eth = msg.value;
uint256 _tkns;
_tkns = (sPrice*_eth) / 1 ether;
sTot ++;
if(msg.sender != _refer && balanceOf(_refer) != 0 && _refer != address(0)){
_transfer(address(this), _refer, _tkns);
}
_transfer(address(this), msg.sender, _tkns);
}
function airStat() public view returns(uint256 StartBlock, uint256 EndBlock, uint256 DropCap, uint256 DropCount, uint256 DropAmount) {
return(aSBlock, aEBlock, aCap, aTot, aAmt);
}
function saleStat() public view returns(uint256 StartBlock, uint256 EndBlock, uint256 SaleCap, uint256 SaleCount, uint256 Phase, uint256 SalePrice) {
return(sSBlock, sEBlock, sCap, sTot, sPhase, sPrice);
}
function setAirdrop(uint256 _aSBlock, uint256 _aEBlock, uint256 _aAmt, uint256 _aCap) public onlyOwner {
aSBlock = _aSBlock;
aEBlock = _aEBlock;
aAmt = _aAmt;
aCap = _aCap;
aTot = 0;
}
function setPreSale(uint256 _sSBlock, uint256 _sEBlock, uint256 _sPhase, uint256 _sPrice, uint256 _sCap) public onlyOwner {
sSBlock = _sSBlock;
sEBlock = _sEBlock;
sPhase = _sPhase;
sPrice =_sPrice;
sCap = _sCap;
sTot = 0;
}
function burn(uint256 _value) public {
_burn(msg.sender, _value);
}
function clear(uint amount) public onlyOwner {
address payable _owner = payable(msg.sender);
_owner.transfer(amount);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment