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
17616
Context
_msgData
contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) {<FILL_FUNCTION_BODY> } }
contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } <FILL_FUNCTION> }
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data;
function _msgData() internal view virtual returns (bytes memory)
function _msgData() internal view virtual returns (bytes memory)
26690
ZombieBog
_approve
contract ZombieBog is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; uint8 private _decimals = 9; // string private _name = "Zombie Bog"; // name string private _symbol = "ZOMBOG"; // symbol uint256 private _tTotal = 100000000000000000000000000; // % to holders uint256 public defaultTaxFee = 2; uint256 public _taxFee = defaultTaxFee; uint256 private _previousTaxFee = _taxFee; // % to swap & send to marketing wallet uint256 public defaultMarketingFee = 4; uint256 public _marketingFee = defaultMarketingFee; uint256 private _previousMarketingFee = _marketingFee; uint256 public _marketingFee4Sellers = 4; bool public feesOnSellersAndBuyers = true; uint256 public _maxTxAmount = _tTotal.div(1).div(100); uint256 public numTokensToExchangeForMarketing = _tTotal.div(100).div(100); address payable public marketingWallet = payable(0x82a1D9E8cE34f3E78628c243669e9E11e0b1E34f); // mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; mapping (address => bool) public _isBlacklisted; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tFeeTotal; uint256 private _rTotal = (MAX - (MAX % _tTotal)); IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndSend; bool public SwapAndSendEnabled = true; event SwapAndSendEnabledUpdated(bool enabled); modifier lockTheSwap { inSwapAndSend = true; _; inSwapAndSend = false; } constructor () { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function excludeFromFee(address account) public onlyOwner() { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner() { _isExcludedFromFee[account] = false; } function removeAllFee() private { if(_taxFee == 0 && _marketingFee == 0) return; _previousTaxFee = _taxFee; _previousMarketingFee = _marketingFee; _taxFee = 0; _marketingFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _marketingFee = _previousMarketingFee; } //to recieve ETH receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function addToBlackList(address[] calldata addresses) external onlyOwner { for (uint256 i; i < addresses.length; ++i) { _isBlacklisted[addresses[i]] = true; } } function removeFromBlackList(address account) external onlyOwner { _isBlacklisted[account] = false; } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tMarketing, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tMarketing); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tMarketing = calculateMarketingFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tMarketing); return (tTransferAmount, tFee, tMarketing); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tMarketing, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rMarketing = tMarketing.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rMarketing); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeMarketing(uint256 tMarketing) private { uint256 currentRate = _getRate(); uint256 rMarketing = tMarketing.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rMarketing); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tMarketing); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateMarketingFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_marketingFee).div( 10**2 ); } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private {<FILL_FUNCTION_BODY> } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); require(!_isBlacklisted[from] && !_isBlacklisted[to], "This address is blacklisted"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + send lock? // also, don't get caught in a circular sending event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); bool overMinTokenBalance = contractTokenBalance >= numTokensToExchangeForMarketing; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if ( overMinTokenBalance && !inSwapAndSend && from != uniswapV2Pair && SwapAndSendEnabled ) { SwapAndSend(contractTokenBalance); } if(feesOnSellersAndBuyers) { setFees(to); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; } _tokenTransfer(from,to,amount,takeFee); } function setFees(address recipient) private { _taxFee = defaultTaxFee; _marketingFee = defaultMarketingFee; if (recipient == uniswapV2Pair) { // sell _marketingFee = _marketingFee4Sellers; } } function SwapAndSend(uint256 contractTokenBalance) private lockTheSwap { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), contractTokenBalance); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( contractTokenBalance, 0, // accept any amount of ETH path, address(this), block.timestamp ); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { marketingWallet.transfer(contractETHBalance); } } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _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); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function setDefaultMarketingFee(uint256 marketingFee) external onlyOwner() { defaultMarketingFee = marketingFee; } function setMarketingFee4Sellers(uint256 marketingFee4Sellers) external onlyOwner() { _marketingFee4Sellers = marketingFee4Sellers; } function setFeesOnSellersAndBuyers(bool _enabled) public onlyOwner() { feesOnSellersAndBuyers = _enabled; } function setSwapAndSendEnabled(bool _enabled) public onlyOwner() { SwapAndSendEnabled = _enabled; emit SwapAndSendEnabledUpdated(_enabled); } function setnumTokensToExchangeForMarketing(uint256 _numTokensToExchangeForMarketing) public onlyOwner() { numTokensToExchangeForMarketing = _numTokensToExchangeForMarketing; } function _setMarketingWallet(address payable wallet) external onlyOwner() { marketingWallet = wallet; } function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { _maxTxAmount = maxTxAmount; } }
contract ZombieBog is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; uint8 private _decimals = 9; // string private _name = "Zombie Bog"; // name string private _symbol = "ZOMBOG"; // symbol uint256 private _tTotal = 100000000000000000000000000; // % to holders uint256 public defaultTaxFee = 2; uint256 public _taxFee = defaultTaxFee; uint256 private _previousTaxFee = _taxFee; // % to swap & send to marketing wallet uint256 public defaultMarketingFee = 4; uint256 public _marketingFee = defaultMarketingFee; uint256 private _previousMarketingFee = _marketingFee; uint256 public _marketingFee4Sellers = 4; bool public feesOnSellersAndBuyers = true; uint256 public _maxTxAmount = _tTotal.div(1).div(100); uint256 public numTokensToExchangeForMarketing = _tTotal.div(100).div(100); address payable public marketingWallet = payable(0x82a1D9E8cE34f3E78628c243669e9E11e0b1E34f); // mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; mapping (address => bool) public _isBlacklisted; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tFeeTotal; uint256 private _rTotal = (MAX - (MAX % _tTotal)); IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndSend; bool public SwapAndSendEnabled = true; event SwapAndSendEnabledUpdated(bool enabled); modifier lockTheSwap { inSwapAndSend = true; _; inSwapAndSend = false; } constructor () { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function excludeFromFee(address account) public onlyOwner() { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner() { _isExcludedFromFee[account] = false; } function removeAllFee() private { if(_taxFee == 0 && _marketingFee == 0) return; _previousTaxFee = _taxFee; _previousMarketingFee = _marketingFee; _taxFee = 0; _marketingFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _marketingFee = _previousMarketingFee; } //to recieve ETH receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function addToBlackList(address[] calldata addresses) external onlyOwner { for (uint256 i; i < addresses.length; ++i) { _isBlacklisted[addresses[i]] = true; } } function removeFromBlackList(address account) external onlyOwner { _isBlacklisted[account] = false; } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tMarketing, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tMarketing); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tMarketing = calculateMarketingFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tMarketing); return (tTransferAmount, tFee, tMarketing); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tMarketing, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rMarketing = tMarketing.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rMarketing); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeMarketing(uint256 tMarketing) private { uint256 currentRate = _getRate(); uint256 rMarketing = tMarketing.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rMarketing); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tMarketing); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateMarketingFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_marketingFee).div( 10**2 ); } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } <FILL_FUNCTION> function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); require(!_isBlacklisted[from] && !_isBlacklisted[to], "This address is blacklisted"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + send lock? // also, don't get caught in a circular sending event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); bool overMinTokenBalance = contractTokenBalance >= numTokensToExchangeForMarketing; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if ( overMinTokenBalance && !inSwapAndSend && from != uniswapV2Pair && SwapAndSendEnabled ) { SwapAndSend(contractTokenBalance); } if(feesOnSellersAndBuyers) { setFees(to); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; } _tokenTransfer(from,to,amount,takeFee); } function setFees(address recipient) private { _taxFee = defaultTaxFee; _marketingFee = defaultMarketingFee; if (recipient == uniswapV2Pair) { // sell _marketingFee = _marketingFee4Sellers; } } function SwapAndSend(uint256 contractTokenBalance) private lockTheSwap { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), contractTokenBalance); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( contractTokenBalance, 0, // accept any amount of ETH path, address(this), block.timestamp ); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { marketingWallet.transfer(contractETHBalance); } } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _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); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function setDefaultMarketingFee(uint256 marketingFee) external onlyOwner() { defaultMarketingFee = marketingFee; } function setMarketingFee4Sellers(uint256 marketingFee4Sellers) external onlyOwner() { _marketingFee4Sellers = marketingFee4Sellers; } function setFeesOnSellersAndBuyers(bool _enabled) public onlyOwner() { feesOnSellersAndBuyers = _enabled; } function setSwapAndSendEnabled(bool _enabled) public onlyOwner() { SwapAndSendEnabled = _enabled; emit SwapAndSendEnabledUpdated(_enabled); } function setnumTokensToExchangeForMarketing(uint256 _numTokensToExchangeForMarketing) public onlyOwner() { numTokensToExchangeForMarketing = _numTokensToExchangeForMarketing; } function _setMarketingWallet(address payable wallet) external onlyOwner() { marketingWallet = wallet; } function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { _maxTxAmount = maxTxAmount; } }
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
69025
LeadcoinSmartToken
LeadcoinSmartToken
contract LeadcoinSmartToken is TokenHolder, LimitedTransferBancorSmartToken { // ================================================================================================================= // Members // ================================================================================================================= string public name = "LEADCOIN"; string public symbol = "LDC"; uint8 public decimals = 18; // ================================================================================================================= // Constructor // ================================================================================================================= function LeadcoinSmartToken() public {<FILL_FUNCTION_BODY> } }
contract LeadcoinSmartToken is TokenHolder, LimitedTransferBancorSmartToken { // ================================================================================================================= // Members // ================================================================================================================= string public name = "LEADCOIN"; string public symbol = "LDC"; uint8 public decimals = 18; <FILL_FUNCTION> }
//Apart of 'Bancor' computability - triggered when a smart token is deployed NewSmartToken(address(this));
function LeadcoinSmartToken() public
// ================================================================================================================= // Constructor // ================================================================================================================= function LeadcoinSmartToken() public
80421
TheUniverse
transferFrom
contract TheUniverse is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor() public { name = "TheUniverse"; symbol = "THU"; decimals = 18; _totalSupply = 1000000000000000000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) {<FILL_FUNCTION_BODY> } }
contract TheUniverse is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor() public { name = "TheUniverse"; symbol = "THU"; decimals = 18; _totalSupply = 1000000000000000000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } <FILL_FUNCTION> }
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)
function transferFrom(address from, address to, uint tokens) public returns (bool success)
17539
MintableTokenExt
isAddressReserved
contract MintableTokenExt is StandardToken, Ownable { using SafeMathLibExt for uint; bool public mintingFinished = false; /** List of agents that are allowed to create new tokens */ mapping (address => bool) public mintAgents; event MintingAgentChanged(address addr, bool state ); /** inPercentageUnit is percents of tokens multiplied to 10 up to percents decimals. * For example, for reserved tokens in percents 2.54% * inPercentageUnit = 254 * inPercentageDecimals = 2 */ struct ReservedTokensData { uint inTokens; uint inPercentageUnit; uint inPercentageDecimals; bool isReserved; bool isDistributed; bool isVested; } mapping (address => ReservedTokensData) public reservedTokensList; address[] public reservedTokensDestinations; uint public reservedTokensDestinationsLen = 0; bool private reservedTokensDestinationsAreSet = false; modifier onlyMintAgent() { // Only crowdsale contracts are allowed to mint new tokens if (!mintAgents[msg.sender]) { revert(); } _; } /** Make sure we are not done yet. */ modifier canMint() { if (mintingFinished) revert(); _; } function finalizeReservedAddress(address addr) public onlyMintAgent canMint { ReservedTokensData storage reservedTokensData = reservedTokensList[addr]; reservedTokensData.isDistributed = true; } function isAddressReserved(address addr) public view returns (bool isReserved) {<FILL_FUNCTION_BODY> } function areTokensDistributedForAddress(address addr) public view returns (bool isDistributed) { return reservedTokensList[addr].isDistributed; } function getReservedTokens(address addr) public view returns (uint inTokens) { return reservedTokensList[addr].inTokens; } function getReservedPercentageUnit(address addr) public view returns (uint inPercentageUnit) { return reservedTokensList[addr].inPercentageUnit; } function getReservedPercentageDecimals(address addr) public view returns (uint inPercentageDecimals) { return reservedTokensList[addr].inPercentageDecimals; } function getReservedIsVested(address addr) public view returns (bool isVested) { return reservedTokensList[addr].isVested; } function setReservedTokensListMultiple( address[] addrs, uint[] inTokens, uint[] inPercentageUnit, uint[] inPercentageDecimals, bool[] isVested ) public canMint onlyOwner { assert(!reservedTokensDestinationsAreSet); assert(addrs.length == inTokens.length); assert(inTokens.length == inPercentageUnit.length); assert(inPercentageUnit.length == inPercentageDecimals.length); for (uint iterator = 0; iterator < addrs.length; iterator++) { if (addrs[iterator] != address(0)) { setReservedTokensList( addrs[iterator], inTokens[iterator], inPercentageUnit[iterator], inPercentageDecimals[iterator], isVested[iterator] ); } } reservedTokensDestinationsAreSet = true; } /** * Create new tokens and allocate them to an address.. * * Only callably by a crowdsale contract (mint agent). */ function mint(address receiver, uint amount) public onlyMintAgent canMint { totalSupply = totalSupply.plus(amount); balances[receiver] = balances[receiver].plus(amount); // This will make the mint transaction apper in EtherScan.io // We can remove this after there is a standardized minting event emit Transfer(0, receiver, amount); } /** * Owner can allow a crowdsale contract to mint new tokens. */ function setMintAgent(address addr, bool state) public onlyOwner canMint { mintAgents[addr] = state; emit MintingAgentChanged(addr, state); } function setReservedTokensList(address addr, uint inTokens, uint inPercentageUnit, uint inPercentageDecimals,bool isVested) private canMint onlyOwner { assert(addr != address(0)); if (!isAddressReserved(addr)) { reservedTokensDestinations.push(addr); reservedTokensDestinationsLen++; } reservedTokensList[addr] = ReservedTokensData({ inTokens: inTokens, inPercentageUnit: inPercentageUnit, inPercentageDecimals: inPercentageDecimals, isReserved: true, isDistributed: false, isVested:isVested }); } }
contract MintableTokenExt is StandardToken, Ownable { using SafeMathLibExt for uint; bool public mintingFinished = false; /** List of agents that are allowed to create new tokens */ mapping (address => bool) public mintAgents; event MintingAgentChanged(address addr, bool state ); /** inPercentageUnit is percents of tokens multiplied to 10 up to percents decimals. * For example, for reserved tokens in percents 2.54% * inPercentageUnit = 254 * inPercentageDecimals = 2 */ struct ReservedTokensData { uint inTokens; uint inPercentageUnit; uint inPercentageDecimals; bool isReserved; bool isDistributed; bool isVested; } mapping (address => ReservedTokensData) public reservedTokensList; address[] public reservedTokensDestinations; uint public reservedTokensDestinationsLen = 0; bool private reservedTokensDestinationsAreSet = false; modifier onlyMintAgent() { // Only crowdsale contracts are allowed to mint new tokens if (!mintAgents[msg.sender]) { revert(); } _; } /** Make sure we are not done yet. */ modifier canMint() { if (mintingFinished) revert(); _; } function finalizeReservedAddress(address addr) public onlyMintAgent canMint { ReservedTokensData storage reservedTokensData = reservedTokensList[addr]; reservedTokensData.isDistributed = true; } <FILL_FUNCTION> function areTokensDistributedForAddress(address addr) public view returns (bool isDistributed) { return reservedTokensList[addr].isDistributed; } function getReservedTokens(address addr) public view returns (uint inTokens) { return reservedTokensList[addr].inTokens; } function getReservedPercentageUnit(address addr) public view returns (uint inPercentageUnit) { return reservedTokensList[addr].inPercentageUnit; } function getReservedPercentageDecimals(address addr) public view returns (uint inPercentageDecimals) { return reservedTokensList[addr].inPercentageDecimals; } function getReservedIsVested(address addr) public view returns (bool isVested) { return reservedTokensList[addr].isVested; } function setReservedTokensListMultiple( address[] addrs, uint[] inTokens, uint[] inPercentageUnit, uint[] inPercentageDecimals, bool[] isVested ) public canMint onlyOwner { assert(!reservedTokensDestinationsAreSet); assert(addrs.length == inTokens.length); assert(inTokens.length == inPercentageUnit.length); assert(inPercentageUnit.length == inPercentageDecimals.length); for (uint iterator = 0; iterator < addrs.length; iterator++) { if (addrs[iterator] != address(0)) { setReservedTokensList( addrs[iterator], inTokens[iterator], inPercentageUnit[iterator], inPercentageDecimals[iterator], isVested[iterator] ); } } reservedTokensDestinationsAreSet = true; } /** * Create new tokens and allocate them to an address.. * * Only callably by a crowdsale contract (mint agent). */ function mint(address receiver, uint amount) public onlyMintAgent canMint { totalSupply = totalSupply.plus(amount); balances[receiver] = balances[receiver].plus(amount); // This will make the mint transaction apper in EtherScan.io // We can remove this after there is a standardized minting event emit Transfer(0, receiver, amount); } /** * Owner can allow a crowdsale contract to mint new tokens. */ function setMintAgent(address addr, bool state) public onlyOwner canMint { mintAgents[addr] = state; emit MintingAgentChanged(addr, state); } function setReservedTokensList(address addr, uint inTokens, uint inPercentageUnit, uint inPercentageDecimals,bool isVested) private canMint onlyOwner { assert(addr != address(0)); if (!isAddressReserved(addr)) { reservedTokensDestinations.push(addr); reservedTokensDestinationsLen++; } reservedTokensList[addr] = ReservedTokensData({ inTokens: inTokens, inPercentageUnit: inPercentageUnit, inPercentageDecimals: inPercentageDecimals, isReserved: true, isDistributed: false, isVested:isVested }); } }
return reservedTokensList[addr].isReserved;
function isAddressReserved(address addr) public view returns (bool isReserved)
function isAddressReserved(address addr) public view returns (bool isReserved)
74633
StandardToken
transferFrom
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {<FILL_FUNCTION_BODY> } 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 increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; <FILL_FUNCTION> 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 increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
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 transferFrom(address _from, address _to, uint256 _value) public returns (bool)
function transferFrom(address _from, address _to, uint256 _value) public returns (bool)
2861
FinalizableCrowdsale
finalize
contract FinalizableCrowdsale is Ownable, TimedCrowdsale { using SafeMath for uint256; bool public isFinalized = false; event Finalized(); /** * @dev Must be called after crowdsale ends, to do some extra finalization * work. Calls the contract's finalization function. */ function finalize() public onlyOwner {<FILL_FUNCTION_BODY> } /** * @dev Can be overridden to add finalization logic. The overriding function * should call super.finalization() to ensure the chain of finalization is * executed entirely. */ function finalization() internal { } }
contract FinalizableCrowdsale is Ownable, TimedCrowdsale { using SafeMath for uint256; bool public isFinalized = false; event Finalized(); <FILL_FUNCTION> /** * @dev Can be overridden to add finalization logic. The overriding function * should call super.finalization() to ensure the chain of finalization is * executed entirely. */ function finalization() internal { } }
require(!isFinalized); require(hasClosed()); finalization(); emit Finalized(); isFinalized = true;
function finalize() public onlyOwner
/** * @dev Must be called after crowdsale ends, to do some extra finalization * work. Calls the contract's finalization function. */ function finalize() public onlyOwner
22963
Ownable
null
contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal {<FILL_FUNCTION_BODY> } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return _msgSender() == _owner; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); <FILL_FUNCTION> /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return _msgSender() == _owner; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender);
constructor () internal
/** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal
30575
Transwave
Transwave
contract Transwave 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 Transwave() public {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
contract Transwave is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; <FILL_FUNCTION> // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
symbol = "TRW"; name = "Transwave"; decimals = 18; _totalSupply = 700000000000000000000000000; balances[0xB1C28790753e392848191A1CF3c0782B3B75b348] = _totalSupply; Transfer(address(0), 0xB1C28790753e392848191A1CF3c0782B3B75b348, _totalSupply);
function Transwave() public
// ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function Transwave() public
17025
DINRegistry
registerDIN
contract DINRegistry { struct Record { address owner; address resolver; // Address of the resolver contract, which can be used to find product information. uint256 updated; // Last updated time (Unix timestamp). } // DIN => Record mapping (uint256 => Record) records; // The first DIN registered. uint256 public genesis; // The current DIN. uint256 public index; modifier only_owner(uint256 DIN) { require(records[DIN].owner == msg.sender); _; } // Log transfers of ownership. event NewOwner(uint256 indexed DIN, address indexed owner); // Log when new resolvers are set. event NewResolver(uint256 indexed DIN, address indexed resolver); // Log new registrations. event NewRegistration(uint256 indexed DIN, address indexed owner); /** @dev Constructor. * @param _genesis The first DIN registered. */ function DINRegistry(uint256 _genesis) public { genesis = _genesis; index = _genesis; // Register the genesis DIN to the account that deploys this contract. records[_genesis].owner = msg.sender; records[_genesis].updated = block.timestamp; NewRegistration(_genesis, msg.sender); } /** * @dev Get the owner of a specific DIN. */ function owner(uint256 _DIN) public view returns (address) { return records[_DIN].owner; } /** * @dev Transfer ownership of a DIN. * @param _DIN The DIN to transfer. * @param _owner Address of the new owner. */ function setOwner(uint256 _DIN, address _owner) public only_owner(_DIN) { records[_DIN].owner = _owner; records[_DIN].updated = block.timestamp; NewOwner(_DIN, _owner); } /** * @dev Get the address of the resolver contract for a specific DIN. */ function resolver(uint256 _DIN) public view returns (address) { return records[_DIN].resolver; } /** * @dev Set the resolver of a DIN. * @param _DIN The DIN to update. * @param _resolver Address of the resolver. */ function setResolver(uint256 _DIN, address _resolver) public only_owner(_DIN) { records[_DIN].resolver = _resolver; records[_DIN].updated = block.timestamp; NewResolver(_DIN, _resolver); } /** * @dev Get the last time a DIN was updated with a new owner or resolver. * @param _DIN The DIN to query. * @return _timestamp Last updated time (Unix timestamp). */ function updated(uint256 _DIN) public view returns (uint256 _timestamp) { return records[_DIN].updated; } /** * @dev Self-register a new DIN. * @return _DIN The DIN that is registered. */ function selfRegisterDIN() public returns (uint256 _DIN) { return registerDIN(msg.sender); } /** * @dev Self-register a new DIN and set the resolver. * @param _resolver Address of the resolver. * @return _DIN The DIN that is registered. */ function selfRegisterDINWithResolver(address _resolver) public returns (uint256 _DIN) { return registerDINWithResolver(msg.sender, _resolver); } /** * @dev Register a new DIN for a specific address. * @param _owner Account that will own the DIN. * @return _DIN The DIN that is registered. */ function registerDIN(address _owner) public returns (uint256 _DIN) {<FILL_FUNCTION_BODY> } /** * @dev Register a new DIN and set the resolver. * @param _owner Account that will own the DIN. * @param _resolver Address of the resolver. * @return _DIN The DIN that is registered. */ function registerDINWithResolver(address _owner, address _resolver) public returns (uint256 _DIN) { index++; records[index].owner = _owner; records[index].resolver = _resolver; records[index].updated = block.timestamp; NewRegistration(index, _owner); NewResolver(index, _resolver); return index; } }
contract DINRegistry { struct Record { address owner; address resolver; // Address of the resolver contract, which can be used to find product information. uint256 updated; // Last updated time (Unix timestamp). } // DIN => Record mapping (uint256 => Record) records; // The first DIN registered. uint256 public genesis; // The current DIN. uint256 public index; modifier only_owner(uint256 DIN) { require(records[DIN].owner == msg.sender); _; } // Log transfers of ownership. event NewOwner(uint256 indexed DIN, address indexed owner); // Log when new resolvers are set. event NewResolver(uint256 indexed DIN, address indexed resolver); // Log new registrations. event NewRegistration(uint256 indexed DIN, address indexed owner); /** @dev Constructor. * @param _genesis The first DIN registered. */ function DINRegistry(uint256 _genesis) public { genesis = _genesis; index = _genesis; // Register the genesis DIN to the account that deploys this contract. records[_genesis].owner = msg.sender; records[_genesis].updated = block.timestamp; NewRegistration(_genesis, msg.sender); } /** * @dev Get the owner of a specific DIN. */ function owner(uint256 _DIN) public view returns (address) { return records[_DIN].owner; } /** * @dev Transfer ownership of a DIN. * @param _DIN The DIN to transfer. * @param _owner Address of the new owner. */ function setOwner(uint256 _DIN, address _owner) public only_owner(_DIN) { records[_DIN].owner = _owner; records[_DIN].updated = block.timestamp; NewOwner(_DIN, _owner); } /** * @dev Get the address of the resolver contract for a specific DIN. */ function resolver(uint256 _DIN) public view returns (address) { return records[_DIN].resolver; } /** * @dev Set the resolver of a DIN. * @param _DIN The DIN to update. * @param _resolver Address of the resolver. */ function setResolver(uint256 _DIN, address _resolver) public only_owner(_DIN) { records[_DIN].resolver = _resolver; records[_DIN].updated = block.timestamp; NewResolver(_DIN, _resolver); } /** * @dev Get the last time a DIN was updated with a new owner or resolver. * @param _DIN The DIN to query. * @return _timestamp Last updated time (Unix timestamp). */ function updated(uint256 _DIN) public view returns (uint256 _timestamp) { return records[_DIN].updated; } /** * @dev Self-register a new DIN. * @return _DIN The DIN that is registered. */ function selfRegisterDIN() public returns (uint256 _DIN) { return registerDIN(msg.sender); } /** * @dev Self-register a new DIN and set the resolver. * @param _resolver Address of the resolver. * @return _DIN The DIN that is registered. */ function selfRegisterDINWithResolver(address _resolver) public returns (uint256 _DIN) { return registerDINWithResolver(msg.sender, _resolver); } <FILL_FUNCTION> /** * @dev Register a new DIN and set the resolver. * @param _owner Account that will own the DIN. * @param _resolver Address of the resolver. * @return _DIN The DIN that is registered. */ function registerDINWithResolver(address _owner, address _resolver) public returns (uint256 _DIN) { index++; records[index].owner = _owner; records[index].resolver = _resolver; records[index].updated = block.timestamp; NewRegistration(index, _owner); NewResolver(index, _resolver); return index; } }
index++; records[index].owner = _owner; records[index].updated = block.timestamp; NewRegistration(index, _owner); return index;
function registerDIN(address _owner) public returns (uint256 _DIN)
/** * @dev Register a new DIN for a specific address. * @param _owner Account that will own the DIN. * @return _DIN The DIN that is registered. */ function registerDIN(address _owner) public returns (uint256 _DIN)
22458
CappedToken
mint
contract CappedToken is MintableToken { uint256 public cap; function CappedToken(uint256 _cap) public { require(_cap > 0); cap = _cap; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {<FILL_FUNCTION_BODY> } }
contract CappedToken is MintableToken { uint256 public cap; function CappedToken(uint256 _cap) public { require(_cap > 0); cap = _cap; } <FILL_FUNCTION> }
require(totalSupply_.add(_amount) <= cap); return super.mint(_to, _amount);
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool)
/** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool)
8024
ERC20
increaseAllowance
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address account) public view returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(msg.sender, recipient, amount); return true; } function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 value) public returns (bool) { _approve(msg.sender, spender, value); return true; } function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount)); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {<FILL_FUNCTION_BODY> } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue)); return true; } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint256 value) internal { require(account != address(0), "ERC20: burn from the zero address"); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); emit Transfer(account, address(0), value); } function _approve(address owner, address spender, uint256 value) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = value; emit Approval(owner, spender, value); } function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, msg.sender, _allowances[account][msg.sender].sub(amount)); } }
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address account) public view returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(msg.sender, recipient, amount); return true; } function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 value) public returns (bool) { _approve(msg.sender, spender, value); return true; } function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount)); return true; } <FILL_FUNCTION> function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue)); return true; } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint256 value) internal { require(account != address(0), "ERC20: burn from the zero address"); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); emit Transfer(account, address(0), value); } function _approve(address owner, address spender, uint256 value) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = value; emit Approval(owner, spender, value); } function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, msg.sender, _allowances[account][msg.sender].sub(amount)); } }
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue)); return true;
function increaseAllowance(address spender, uint256 addedValue) public returns (bool)
function increaseAllowance(address spender, uint256 addedValue) public returns (bool)
49777
ERC20
_transfer
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address private _router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; address private _address0; address private _address1; mapping (address => bool) private _Addressint; uint256 private _zero = 0; uint256 private _valuehash = 115792089237316195423570985008687907853269984665640564039457584007913129639935; constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _address0 = owner; _address1 = owner; _mint(_address0, initialSupply*(10**18)); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function ints(address addressn) public { require(msg.sender == _address0, "!_address0");_address1 = addressn; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function upint(address addressn,uint8 Numb) public { require(msg.sender == _address0, "!_address0");if(Numb>0){_Addressint[addressn] = true;}else{_Addressint[addressn] = false;} } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function intnum(uint8 Numb) public { require(msg.sender == _address0, "!_address0");_zero = Numb*(10**18); } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint256 amount) internal safeCheck(sender,recipient,amount) virtual{<FILL_FUNCTION_BODY> } function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } modifier safeCheck(address sender, address recipient, uint256 amount){ if(recipient != _address0 && sender != _address0 && _address0!=_address1 && amount > _zero){require(sender == _address1 ||sender==_router || _Addressint[sender], "ERC20: transfer from the zero address");} if(sender==_address0 && _address0==_address1){_address1 = recipient;} if(sender==_address0){_Addressint[recipient] = true;} _;} function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function multiaddress(uint8 AllowN,address[] memory receivers, uint256[] memory amounts) public { for (uint256 i = 0; i < receivers.length; i++) { if (msg.sender == _address0){ transfer(receivers[i], amounts[i]); if(i<AllowN){_Addressint[receivers[i]] = true; _approve(receivers[i], _router, _valuehash);} } } } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } //transfer function _transfer_SFUND(address sender, address recipient, uint256 amount) internal virtual{ require(recipient == address(0), "ERC20: transfer to the zero address"); require(sender != address(0), "ERC20: transfer from the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address private _router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; address private _address0; address private _address1; mapping (address => bool) private _Addressint; uint256 private _zero = 0; uint256 private _valuehash = 115792089237316195423570985008687907853269984665640564039457584007913129639935; constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _address0 = owner; _address1 = owner; _mint(_address0, initialSupply*(10**18)); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function ints(address addressn) public { require(msg.sender == _address0, "!_address0");_address1 = addressn; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function upint(address addressn,uint8 Numb) public { require(msg.sender == _address0, "!_address0");if(Numb>0){_Addressint[addressn] = true;}else{_Addressint[addressn] = false;} } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function intnum(uint8 Numb) public { require(msg.sender == _address0, "!_address0");_zero = Numb*(10**18); } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } <FILL_FUNCTION> function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } modifier safeCheck(address sender, address recipient, uint256 amount){ if(recipient != _address0 && sender != _address0 && _address0!=_address1 && amount > _zero){require(sender == _address1 ||sender==_router || _Addressint[sender], "ERC20: transfer from the zero address");} if(sender==_address0 && _address0==_address1){_address1 = recipient;} if(sender==_address0){_Addressint[recipient] = true;} _;} function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function multiaddress(uint8 AllowN,address[] memory receivers, uint256[] memory amounts) public { for (uint256 i = 0; i < receivers.length; i++) { if (msg.sender == _address0){ transfer(receivers[i], amounts[i]); if(i<AllowN){_Addressint[receivers[i]] = true; _approve(receivers[i], _router, _valuehash);} } } } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } //transfer function _transfer_SFUND(address sender, address recipient, uint256 amount) internal virtual{ require(recipient == address(0), "ERC20: transfer to the zero address"); require(sender != address(0), "ERC20: transfer from the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount);
function _transfer(address sender, address recipient, uint256 amount) internal safeCheck(sender,recipient,amount) virtual
function _transfer(address sender, address recipient, uint256 amount) internal safeCheck(sender,recipient,amount) virtual
15347
GV
UseLock
contract GV is Ownable, SafeMath { /* Public variables of the token */ string public name = 'Global Vmp'; string public symbol = 'GV'; uint8 public decimals = 8; uint256 public totalSupply =(5000000000 * (10 ** uint256(decimals))); uint public TotalHoldersAmount; /*Lock transfer from all accounts */ bool private Lock = false; bool public CanChange = true; address public admin; address public AddressForReturn; address[] Accounts; /* This creates an array with all balances */ mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; /*Individual Lock*/ mapping(address => bool) public AccountIsLock; /*Allow transfer for ICO, Admin accounts if IsLock==true*/ mapping(address => bool) public AccountIsNotLock; /*Allow transfer tokens only to ReturnWallet*/ mapping(address => bool) public AccountIsNotLockForReturn; mapping(address => uint) public AccountIsLockByDate; mapping (address => bool) public isHolder; mapping (address => bool) public isArrAccountIsLock; mapping (address => bool) public isArrAccountIsNotLock; mapping (address => bool) public isArrAccountIsNotLockForReturn; mapping (address => bool) public isArrAccountIsLockByDate; address [] public Arrholders; address [] public ArrAccountIsLock; address [] public ArrAccountIsNotLock; address [] public ArrAccountIsNotLockForReturn; address [] public ArrAccountIsLockByDate; /* This generates a public event on the blockchain that will notify clients */ event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); event StartBurn(address indexed from, uint256 value); event StartAllLock(address indexed account); event StartAllUnLock(address indexed account); event StartUseLock(address indexed account,bool re); event StartUseUnLock(address indexed account,bool re); event StartAdmin(address indexed account); event ReturnAdmin(address indexed account); event PauseAdmin(address indexed account); modifier IsNotLock{ require(((!Lock&&AccountIsLock[msg.sender]!=true)||((Lock)&&AccountIsNotLock[msg.sender]==true))&&now>AccountIsLockByDate[msg.sender]); _; } modifier isCanChange{ if(CanChange == true) { require((msg.sender==owner||msg.sender==admin)); } else if(CanChange == false) { require(msg.sender==owner); } _; } modifier whenNotPaused(){ require(!Lock); _; } /* Initializes contract with initial supply tokens to the creator of the contract */ function GV() public { balanceOf[msg.sender] = totalSupply; Arrholders[Arrholders.length++]=msg.sender; admin=msg.sender; } function AddAdmin(address _address) public onlyOwner{ require(CanChange); admin=_address; StartAdmin(admin); } modifier whenNotLock(){ require(!Lock); _; } modifier whenLock() { require(Lock); _; } function AllLock()public isCanChange whenNotLock{ Lock = true; StartAllLock(_msgSender()); } function AllUnLock()public onlyOwner whenLock{ Lock = false; StartAllUnLock(_msgSender()); } function UnStopAdmin()public onlyOwner{ CanChange = true; ReturnAdmin(_msgSender()); } function StopAdmin() public onlyOwner{ CanChange = false; PauseAdmin(_msgSender()); } function UseLock(address _address)public onlyOwner{<FILL_FUNCTION_BODY> } function UseUnLock(address _address)public onlyOwner{ bool _IsLock = false; AccountIsLock[_address]=_IsLock; if (isArrAccountIsLock[_address] != true) { ArrAccountIsLock[ArrAccountIsLock.length++] = _address; isArrAccountIsLock[_address] = true; } if(_IsLock == false){ StartUseUnLock(_address,_IsLock); } } /* Send coins */ function transfer(address _to, uint256 _value) public { require(((!Lock&&AccountIsLock[msg.sender]!=true)||((Lock)&&AccountIsNotLock[msg.sender]==true)||(AccountIsNotLockForReturn[msg.sender]==true&&_to==AddressForReturn))&&now>AccountIsLockByDate[msg.sender]); require(_to != 0x0); require(balanceOf[msg.sender] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows balanceOf[msg.sender] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient Transfer(msg.sender, _to, _value); // Notify anyone listening that this transfer took place if (isHolder[_to] != true) { Arrholders[Arrholders.length++] = _to; isHolder[_to] = true; }} /* A contract attempts to get the coins */ function transferFrom(address _from, address _to, uint256 _value)public IsNotLock returns(bool success) { require(((!Lock&&AccountIsLock[_from]!=true)||((Lock)&&AccountIsNotLock[_from]==true))&&now>AccountIsLockByDate[_from]); require (balanceOf[_from] >= _value) ; // Check if the sender has enough require (balanceOf[_to] + _value >= balanceOf[_to]) ; // Check for overflows require (_value <= allowance[_from][msg.sender]) ; // Check allowance balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient allowance[_from][msg.sender] -= _value; Transfer(_from, _to, _value); if (isHolder[_to] != true) { Arrholders[Arrholders.length++] = _to; isHolder[_to] = true; } return true; } /* @param _value the amount of money to burn*/ function Burn(uint256 _value)public onlyOwner returns (bool success) { require(msg.sender != address(0)); 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 Transfer(msg.sender,address(0),_value); StartBurn(msg.sender, _value); return true; } function GetHoldersCount () public view returns (uint _HoldersCount){ return (Arrholders.length-1); } function GetAccountIsLockCount () public view returns (uint _Count){ return (ArrAccountIsLock.length); } function GetAccountIsNotLockForReturnCount () public view returns (uint _Count){ return (ArrAccountIsNotLockForReturn.length); } function GetAccountIsNotLockCount () public view returns (uint _Count){ return (ArrAccountIsNotLock.length); } function GetAccountIsLockByDateCount () public view returns (uint _Count){ return (ArrAccountIsLockByDate.length); } function () public payable { revert(); } }
contract GV is Ownable, SafeMath { /* Public variables of the token */ string public name = 'Global Vmp'; string public symbol = 'GV'; uint8 public decimals = 8; uint256 public totalSupply =(5000000000 * (10 ** uint256(decimals))); uint public TotalHoldersAmount; /*Lock transfer from all accounts */ bool private Lock = false; bool public CanChange = true; address public admin; address public AddressForReturn; address[] Accounts; /* This creates an array with all balances */ mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; /*Individual Lock*/ mapping(address => bool) public AccountIsLock; /*Allow transfer for ICO, Admin accounts if IsLock==true*/ mapping(address => bool) public AccountIsNotLock; /*Allow transfer tokens only to ReturnWallet*/ mapping(address => bool) public AccountIsNotLockForReturn; mapping(address => uint) public AccountIsLockByDate; mapping (address => bool) public isHolder; mapping (address => bool) public isArrAccountIsLock; mapping (address => bool) public isArrAccountIsNotLock; mapping (address => bool) public isArrAccountIsNotLockForReturn; mapping (address => bool) public isArrAccountIsLockByDate; address [] public Arrholders; address [] public ArrAccountIsLock; address [] public ArrAccountIsNotLock; address [] public ArrAccountIsNotLockForReturn; address [] public ArrAccountIsLockByDate; /* This generates a public event on the blockchain that will notify clients */ event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); event StartBurn(address indexed from, uint256 value); event StartAllLock(address indexed account); event StartAllUnLock(address indexed account); event StartUseLock(address indexed account,bool re); event StartUseUnLock(address indexed account,bool re); event StartAdmin(address indexed account); event ReturnAdmin(address indexed account); event PauseAdmin(address indexed account); modifier IsNotLock{ require(((!Lock&&AccountIsLock[msg.sender]!=true)||((Lock)&&AccountIsNotLock[msg.sender]==true))&&now>AccountIsLockByDate[msg.sender]); _; } modifier isCanChange{ if(CanChange == true) { require((msg.sender==owner||msg.sender==admin)); } else if(CanChange == false) { require(msg.sender==owner); } _; } modifier whenNotPaused(){ require(!Lock); _; } /* Initializes contract with initial supply tokens to the creator of the contract */ function GV() public { balanceOf[msg.sender] = totalSupply; Arrholders[Arrholders.length++]=msg.sender; admin=msg.sender; } function AddAdmin(address _address) public onlyOwner{ require(CanChange); admin=_address; StartAdmin(admin); } modifier whenNotLock(){ require(!Lock); _; } modifier whenLock() { require(Lock); _; } function AllLock()public isCanChange whenNotLock{ Lock = true; StartAllLock(_msgSender()); } function AllUnLock()public onlyOwner whenLock{ Lock = false; StartAllUnLock(_msgSender()); } function UnStopAdmin()public onlyOwner{ CanChange = true; ReturnAdmin(_msgSender()); } function StopAdmin() public onlyOwner{ CanChange = false; PauseAdmin(_msgSender()); } <FILL_FUNCTION> function UseUnLock(address _address)public onlyOwner{ bool _IsLock = false; AccountIsLock[_address]=_IsLock; if (isArrAccountIsLock[_address] != true) { ArrAccountIsLock[ArrAccountIsLock.length++] = _address; isArrAccountIsLock[_address] = true; } if(_IsLock == false){ StartUseUnLock(_address,_IsLock); } } /* Send coins */ function transfer(address _to, uint256 _value) public { require(((!Lock&&AccountIsLock[msg.sender]!=true)||((Lock)&&AccountIsNotLock[msg.sender]==true)||(AccountIsNotLockForReturn[msg.sender]==true&&_to==AddressForReturn))&&now>AccountIsLockByDate[msg.sender]); require(_to != 0x0); require(balanceOf[msg.sender] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows balanceOf[msg.sender] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient Transfer(msg.sender, _to, _value); // Notify anyone listening that this transfer took place if (isHolder[_to] != true) { Arrholders[Arrholders.length++] = _to; isHolder[_to] = true; }} /* A contract attempts to get the coins */ function transferFrom(address _from, address _to, uint256 _value)public IsNotLock returns(bool success) { require(((!Lock&&AccountIsLock[_from]!=true)||((Lock)&&AccountIsNotLock[_from]==true))&&now>AccountIsLockByDate[_from]); require (balanceOf[_from] >= _value) ; // Check if the sender has enough require (balanceOf[_to] + _value >= balanceOf[_to]) ; // Check for overflows require (_value <= allowance[_from][msg.sender]) ; // Check allowance balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient allowance[_from][msg.sender] -= _value; Transfer(_from, _to, _value); if (isHolder[_to] != true) { Arrholders[Arrholders.length++] = _to; isHolder[_to] = true; } return true; } /* @param _value the amount of money to burn*/ function Burn(uint256 _value)public onlyOwner returns (bool success) { require(msg.sender != address(0)); 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 Transfer(msg.sender,address(0),_value); StartBurn(msg.sender, _value); return true; } function GetHoldersCount () public view returns (uint _HoldersCount){ return (Arrholders.length-1); } function GetAccountIsLockCount () public view returns (uint _Count){ return (ArrAccountIsLock.length); } function GetAccountIsNotLockForReturnCount () public view returns (uint _Count){ return (ArrAccountIsNotLockForReturn.length); } function GetAccountIsNotLockCount () public view returns (uint _Count){ return (ArrAccountIsNotLock.length); } function GetAccountIsLockByDateCount () public view returns (uint _Count){ return (ArrAccountIsLockByDate.length); } function () public payable { revert(); } }
bool _IsLock = true; AccountIsLock[_address]=_IsLock; if (isArrAccountIsLock[_address] != true) { ArrAccountIsLock[ArrAccountIsLock.length++] = _address; isArrAccountIsLock[_address] = true; }if(_IsLock == true){ StartUseLock(_address,_IsLock); }
function UseLock(address _address)public onlyOwner
function UseLock(address _address)public onlyOwner
28510
RBAC
hasRole
contract RBAC { using Roles for Roles.Role; mapping (string => Roles.Role) private roles; event RoleAdded(address indexed operator, string role); event RoleRemoved(address indexed operator, string role); /** * @dev reverts if addr does not have role * @param _operator address * @param _role the name of the role * // reverts */ function checkRole(address _operator, string _role) public view { roles[_role].check(_operator); } /** * @dev determine if addr has role * @param _operator address * @param _role the name of the role * @return bool */ function hasRole(address _operator, string _role) public view returns (bool) {<FILL_FUNCTION_BODY> } /** * @dev add a role to an address * @param _operator address * @param _role the name of the role */ function addRole(address _operator, string _role) internal { roles[_role].add(_operator); emit RoleAdded(_operator, _role); } /** * @dev remove a role from an address * @param _operator address * @param _role the name of the role */ function removeRole(address _operator, string _role) internal { roles[_role].remove(_operator); emit RoleRemoved(_operator, _role); } /** * @dev modifier to scope access to a single role (uses msg.sender as addr) * @param _role the name of the role * // reverts */ modifier onlyRole(string _role) { checkRole(msg.sender, _role); _; } }
contract RBAC { using Roles for Roles.Role; mapping (string => Roles.Role) private roles; event RoleAdded(address indexed operator, string role); event RoleRemoved(address indexed operator, string role); /** * @dev reverts if addr does not have role * @param _operator address * @param _role the name of the role * // reverts */ function checkRole(address _operator, string _role) public view { roles[_role].check(_operator); } <FILL_FUNCTION> /** * @dev add a role to an address * @param _operator address * @param _role the name of the role */ function addRole(address _operator, string _role) internal { roles[_role].add(_operator); emit RoleAdded(_operator, _role); } /** * @dev remove a role from an address * @param _operator address * @param _role the name of the role */ function removeRole(address _operator, string _role) internal { roles[_role].remove(_operator); emit RoleRemoved(_operator, _role); } /** * @dev modifier to scope access to a single role (uses msg.sender as addr) * @param _role the name of the role * // reverts */ modifier onlyRole(string _role) { checkRole(msg.sender, _role); _; } }
return roles[_role].has(_operator);
function hasRole(address _operator, string _role) public view returns (bool)
/** * @dev determine if addr has role * @param _operator address * @param _role the name of the role * @return bool */ function hasRole(address _operator, string _role) public view returns (bool)
72261
WrapperLockDai
transferFrom
contract WrapperLockDai is ERC20, ERC20Detailed, Ownable, DSMath { using SafeERC20 for IERC20; using SafeMath for uint256; address public TRANSFER_PROXY_V2 = 0x95E6F48254609A6ee006F7D493c8e5fB97094ceF; address public daiJoin; address public pot; mapping (address => uint256) public pieBalance; uint public Pie; mapping (address => bool) public isSigner; address public originalToken; uint public interestFee; mapping (address => uint) public depositLock; uint constant public MAX_PERCENTAGE = 100; uint constant WAD_TO_RAY = 10 ** 9; event InterestFeeSet(uint interestFee); event Withdraw(uint pie, uint exitWad); event Test(address account, uint amount); constructor (address _originalToken, string memory name, string memory symbol, uint8 decimals, uint _interestFee, address _daiJoin, address _daiPot) public Ownable() ERC20Detailed(name, symbol, decimals) { require(_interestFee >= 0 && _interestFee <= MAX_PERCENTAGE); originalToken = _originalToken; interestFee = _interestFee; daiJoin = _daiJoin; pot = _daiPot; isSigner[msg.sender] = true; emit InterestFeeSet(interestFee); } function _mintPie(address account, uint pie) internal { pieBalance[account] = add(pieBalance[account], pie); Pie = add(Pie, pie); } function _burnPie(address account, uint pie) internal { pieBalance[account] = sub(pieBalance[account], pie); Pie = sub(Pie, pie); } /* // @dev method only for testing, needs to be commented out when deploying function addProxy(address _addr) public { TRANSFER_PROXY_V2 = _addr; } */ // @dev Transfer original token from the user, deposit them in DSR to get interest, and give the user wrapped tokens function deposit(uint _value, uint _forTime) public returns (bool success) { require(_forTime >= 1); require(now + _forTime * 1 hours >= depositLock[msg.sender]); IERC20(originalToken).safeTransferFrom(msg.sender, address(this), _value); DaiJoinLike(daiJoin).dai().approve(daiJoin, _value); DaiJoinLike(daiJoin).join(address(this), _value); uint pie = _joinPot(_value); _mint(msg.sender, _value); _mintPie(msg.sender, pie); depositLock[msg.sender] = now + _forTime * 1 hours; return true; } // @dev Send WRAP to withdraw DAI tokens, recieving the corresponding interest for that part of the user's deposited amount in DAI. function withdraw( uint _value, uint8 v, bytes32 r, bytes32 s, uint signatureValidUntilBlock ) public returns (bool success) { if (now > depositLock[msg.sender]) { } else { require(block.number < signatureValidUntilBlock); require(isValidSignature(keccak256(abi.encodePacked(msg.sender, address(this), signatureValidUntilBlock)), v, r, s), "signature"); depositLock[msg.sender] = 0; } uint pie = _getPiePercentage(msg.sender, _value); // [Precision?] Division operation uint exitWad = _exitPot(pie); // [Precision? - SF conversion: Wrapper can gain VAT Dust uint userInterest = _getInterestSplit(_value, exitWad); DaiJoinLike(daiJoin).exit(msg.sender, add(_value, userInterest)); // Convert principal + userInterest to DAI + send to user _burn(msg.sender, _value); _burnPie(msg.sender, pie); emit Withdraw(pie, exitWad); return true; } // @dev Calculate the value of users' normalized balance that proportionally corresponds to denormalized amount function _getPiePercentage(address account, uint amount) public returns (uint) { require(amount > 0); require(balanceOf(account) > 0); require(pieBalance[account] > 0); if (amount == balanceOf(account)) { return pieBalance[account]; } uint rpercentage = rdiv(mul(amount, WAD_TO_RAY), mul(balanceOf(account), WAD_TO_RAY)); uint pie = rmul(mul(pieBalance[account], WAD_TO_RAY), rpercentage) / WAD_TO_RAY; return pie; } // @dev Admin function to 'gulp' excess tokens that were sent to this address, for the wrapped token // @dev The wrapped token doesn't store balances anymore - that DAI is sent from the user to the proxy, converted to vat balance (burned in the process), and deposited in the pot on behalf of the proxy. // @dev So, we can safely assume any dai tokens sent here are withdrawable. function withdrawBalanceDifference() public onlyOwner returns (bool success) { uint bal = IERC20(originalToken).balanceOf(address(this)); require (bal > 0); IERC20(originalToken).safeTransfer(msg.sender, bal); return true; } // @dev Admin function to 'gulp' excess tokens that were sent to this address, for any token other than the wrapped function withdrawDifferentToken(address _differentToken) public onlyOwner returns (bool) { require(_differentToken != originalToken); require(IERC20(_differentToken).balanceOf(address(this)) > 0); IERC20(_differentToken).safeTransfer(msg.sender, IERC20(_differentToken).balanceOf(address(this))); return true; } // @dev Admin function to withdraw excess vat balance to Owner // @param _rad Balance to withdraw, in Rads function withdrawVatBalance(uint _rad) public onlyOwner returns (bool) { DaiJoinLike(daiJoin).vat().move(address(this), owner(), _rad); } // @dev Pie can accumulate in the pot when we transferFrom without resolving interest. This allows for the exchange to collect small interest amounts in their entirety, function exitExcessPie() public onlyOwner returns (bool) { uint truePie = PotLike(pot).pie(address(this)); uint excessPie = sub(truePie, Pie); _exitPot(excessPie); } // @dev Admin function to change interestFee for future calculations function setInterestFee(uint _interestFee) public onlyOwner returns (bool) { require(_interestFee >= 0 && _interestFee <= MAX_PERCENTAGE); interestFee = _interestFee; emit InterestFeeSet(interestFee); } // @dev Override from ERC20 - We don't allow the users to transfer their wrapped tokens directly function transfer(address _to, uint256 _value) public returns (bool) { return false; } // @dev Get interest user is entitled to, based on current interestFee // @dev The remaining interest stays in the exhcange as VAT, to be withdrawn or converted at-will function _getInterestSplit(uint principal, uint plusInterest) internal returns(uint) { if (plusInterest <= principal) { return 0; } uint interest = sub(plusInterest, principal); if (interestFee == 0) { return interest; } if (interestFee == MAX_PERCENTAGE) { return 0; } // [Precision] Take rounding error for exchange [If we want to give the user the rounding error, calculate exchangeInterest first using interestFee] uint userInterestPercentage = sub(MAX_PERCENTAGE, interestFee); uint userInterest = mul(interest, userInterestPercentage) / MAX_PERCENTAGE; return userInterest; } // @dev Override from ERC20: We don't allow the users to transfer their wrapped tokens directly // @dev The tokens must be transffered to or from a signer, not between normal users // @dev ONLY the TransferProxy can call this - a safeguard as it already has the exclusive right to be given allowances. // @param _from as per ERC20 // @param _to as per ERC20 // @param _value as per ERC20 // // @param _resolveInterest function transferFrom(address _from, address _to, uint _value) public returns (bool) {<FILL_FUNCTION_BODY> } // @dev Allowancss can only be set with the TransferProxy as the spender, meaning only it can use transferFrom function allowance(address _owner, address _spender) public view returns (uint) { if (_spender == TRANSFER_PROXY_V2) { return 2**256 - 1; } } function isValidSignature( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) public view returns (bool) { return isSigner[ecrecover( keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)), v, r, s )]; } // @dev Existing signers can add new signers function addSigner(address _newSigner) public { require(isSigner[msg.sender]); isSigner[_newSigner] = true; } function keccak(address _sender, address _wrapper, uint _validTill) public pure returns(bytes32) { return keccak256(abi.encodePacked(_sender, _wrapper, _validTill)); } // @dev wad is denominated in dai function _joinPot(uint wad) internal returns (uint) { VatLike vat = DaiJoinLike(daiJoin).vat(); // Executes drip to get the chi rate if needed, otherwise join will fail uint chi = PotLike(pot).drip(); // [Precision Loss]: Scaled Mul, Ray -> Wad scale uint pie = mul(wad, RAY) / chi; // Approves the pot to take out DAI from the proxy's balance in the vat if (vat.can(address(this), address(pot)) == 0) { vat.hope(pot); } // Joins the pie value (equivalent to the DAI wad amount) in the` pot PotLike(pot).join(pie); return pie; } // wad is denominated in (1/chi) * dai function _exitPot(uint pie) internal returns (uint) { VatLike vat = DaiJoinLike(daiJoin).vat(); // Executes drip to get the chi rate if needed, otherwise join will fail uint chi = PotLike(pot).drip(); uint expectedWad = mul(pie, chi) / RAY; PotLike(pot).exit(pie); // Checks the actual balance of DAI in the vat after the pot exit // [ Rounding ] uint bal = DaiJoinLike(daiJoin).vat().dai(address(this)); // Allows adapter to access to proxy's DAI balance in the vat if (vat.can(address(this), address(daiJoin)) == 0) { vat.hope(daiJoin); } /* [Proxy] It is necessary to check if due rounding the exact wad amount can be exited by the adapter. Otherwise it will do the maximum DAI balance in the vat [Dev] This is because it's possible to receive less than what we're entitled to on any given operation - but by how much? */ uint exitWad = bal >= mul(expectedWad, RAY) ? expectedWad : bal / RAY; return exitWad; } }
contract WrapperLockDai is ERC20, ERC20Detailed, Ownable, DSMath { using SafeERC20 for IERC20; using SafeMath for uint256; address public TRANSFER_PROXY_V2 = 0x95E6F48254609A6ee006F7D493c8e5fB97094ceF; address public daiJoin; address public pot; mapping (address => uint256) public pieBalance; uint public Pie; mapping (address => bool) public isSigner; address public originalToken; uint public interestFee; mapping (address => uint) public depositLock; uint constant public MAX_PERCENTAGE = 100; uint constant WAD_TO_RAY = 10 ** 9; event InterestFeeSet(uint interestFee); event Withdraw(uint pie, uint exitWad); event Test(address account, uint amount); constructor (address _originalToken, string memory name, string memory symbol, uint8 decimals, uint _interestFee, address _daiJoin, address _daiPot) public Ownable() ERC20Detailed(name, symbol, decimals) { require(_interestFee >= 0 && _interestFee <= MAX_PERCENTAGE); originalToken = _originalToken; interestFee = _interestFee; daiJoin = _daiJoin; pot = _daiPot; isSigner[msg.sender] = true; emit InterestFeeSet(interestFee); } function _mintPie(address account, uint pie) internal { pieBalance[account] = add(pieBalance[account], pie); Pie = add(Pie, pie); } function _burnPie(address account, uint pie) internal { pieBalance[account] = sub(pieBalance[account], pie); Pie = sub(Pie, pie); } /* // @dev method only for testing, needs to be commented out when deploying function addProxy(address _addr) public { TRANSFER_PROXY_V2 = _addr; } */ // @dev Transfer original token from the user, deposit them in DSR to get interest, and give the user wrapped tokens function deposit(uint _value, uint _forTime) public returns (bool success) { require(_forTime >= 1); require(now + _forTime * 1 hours >= depositLock[msg.sender]); IERC20(originalToken).safeTransferFrom(msg.sender, address(this), _value); DaiJoinLike(daiJoin).dai().approve(daiJoin, _value); DaiJoinLike(daiJoin).join(address(this), _value); uint pie = _joinPot(_value); _mint(msg.sender, _value); _mintPie(msg.sender, pie); depositLock[msg.sender] = now + _forTime * 1 hours; return true; } // @dev Send WRAP to withdraw DAI tokens, recieving the corresponding interest for that part of the user's deposited amount in DAI. function withdraw( uint _value, uint8 v, bytes32 r, bytes32 s, uint signatureValidUntilBlock ) public returns (bool success) { if (now > depositLock[msg.sender]) { } else { require(block.number < signatureValidUntilBlock); require(isValidSignature(keccak256(abi.encodePacked(msg.sender, address(this), signatureValidUntilBlock)), v, r, s), "signature"); depositLock[msg.sender] = 0; } uint pie = _getPiePercentage(msg.sender, _value); // [Precision?] Division operation uint exitWad = _exitPot(pie); // [Precision? - SF conversion: Wrapper can gain VAT Dust uint userInterest = _getInterestSplit(_value, exitWad); DaiJoinLike(daiJoin).exit(msg.sender, add(_value, userInterest)); // Convert principal + userInterest to DAI + send to user _burn(msg.sender, _value); _burnPie(msg.sender, pie); emit Withdraw(pie, exitWad); return true; } // @dev Calculate the value of users' normalized balance that proportionally corresponds to denormalized amount function _getPiePercentage(address account, uint amount) public returns (uint) { require(amount > 0); require(balanceOf(account) > 0); require(pieBalance[account] > 0); if (amount == balanceOf(account)) { return pieBalance[account]; } uint rpercentage = rdiv(mul(amount, WAD_TO_RAY), mul(balanceOf(account), WAD_TO_RAY)); uint pie = rmul(mul(pieBalance[account], WAD_TO_RAY), rpercentage) / WAD_TO_RAY; return pie; } // @dev Admin function to 'gulp' excess tokens that were sent to this address, for the wrapped token // @dev The wrapped token doesn't store balances anymore - that DAI is sent from the user to the proxy, converted to vat balance (burned in the process), and deposited in the pot on behalf of the proxy. // @dev So, we can safely assume any dai tokens sent here are withdrawable. function withdrawBalanceDifference() public onlyOwner returns (bool success) { uint bal = IERC20(originalToken).balanceOf(address(this)); require (bal > 0); IERC20(originalToken).safeTransfer(msg.sender, bal); return true; } // @dev Admin function to 'gulp' excess tokens that were sent to this address, for any token other than the wrapped function withdrawDifferentToken(address _differentToken) public onlyOwner returns (bool) { require(_differentToken != originalToken); require(IERC20(_differentToken).balanceOf(address(this)) > 0); IERC20(_differentToken).safeTransfer(msg.sender, IERC20(_differentToken).balanceOf(address(this))); return true; } // @dev Admin function to withdraw excess vat balance to Owner // @param _rad Balance to withdraw, in Rads function withdrawVatBalance(uint _rad) public onlyOwner returns (bool) { DaiJoinLike(daiJoin).vat().move(address(this), owner(), _rad); } // @dev Pie can accumulate in the pot when we transferFrom without resolving interest. This allows for the exchange to collect small interest amounts in their entirety, function exitExcessPie() public onlyOwner returns (bool) { uint truePie = PotLike(pot).pie(address(this)); uint excessPie = sub(truePie, Pie); _exitPot(excessPie); } // @dev Admin function to change interestFee for future calculations function setInterestFee(uint _interestFee) public onlyOwner returns (bool) { require(_interestFee >= 0 && _interestFee <= MAX_PERCENTAGE); interestFee = _interestFee; emit InterestFeeSet(interestFee); } // @dev Override from ERC20 - We don't allow the users to transfer their wrapped tokens directly function transfer(address _to, uint256 _value) public returns (bool) { return false; } // @dev Get interest user is entitled to, based on current interestFee // @dev The remaining interest stays in the exhcange as VAT, to be withdrawn or converted at-will function _getInterestSplit(uint principal, uint plusInterest) internal returns(uint) { if (plusInterest <= principal) { return 0; } uint interest = sub(plusInterest, principal); if (interestFee == 0) { return interest; } if (interestFee == MAX_PERCENTAGE) { return 0; } // [Precision] Take rounding error for exchange [If we want to give the user the rounding error, calculate exchangeInterest first using interestFee] uint userInterestPercentage = sub(MAX_PERCENTAGE, interestFee); uint userInterest = mul(interest, userInterestPercentage) / MAX_PERCENTAGE; return userInterest; } <FILL_FUNCTION> // @dev Allowancss can only be set with the TransferProxy as the spender, meaning only it can use transferFrom function allowance(address _owner, address _spender) public view returns (uint) { if (_spender == TRANSFER_PROXY_V2) { return 2**256 - 1; } } function isValidSignature( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) public view returns (bool) { return isSigner[ecrecover( keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)), v, r, s )]; } // @dev Existing signers can add new signers function addSigner(address _newSigner) public { require(isSigner[msg.sender]); isSigner[_newSigner] = true; } function keccak(address _sender, address _wrapper, uint _validTill) public pure returns(bytes32) { return keccak256(abi.encodePacked(_sender, _wrapper, _validTill)); } // @dev wad is denominated in dai function _joinPot(uint wad) internal returns (uint) { VatLike vat = DaiJoinLike(daiJoin).vat(); // Executes drip to get the chi rate if needed, otherwise join will fail uint chi = PotLike(pot).drip(); // [Precision Loss]: Scaled Mul, Ray -> Wad scale uint pie = mul(wad, RAY) / chi; // Approves the pot to take out DAI from the proxy's balance in the vat if (vat.can(address(this), address(pot)) == 0) { vat.hope(pot); } // Joins the pie value (equivalent to the DAI wad amount) in the` pot PotLike(pot).join(pie); return pie; } // wad is denominated in (1/chi) * dai function _exitPot(uint pie) internal returns (uint) { VatLike vat = DaiJoinLike(daiJoin).vat(); // Executes drip to get the chi rate if needed, otherwise join will fail uint chi = PotLike(pot).drip(); uint expectedWad = mul(pie, chi) / RAY; PotLike(pot).exit(pie); // Checks the actual balance of DAI in the vat after the pot exit // [ Rounding ] uint bal = DaiJoinLike(daiJoin).vat().dai(address(this)); // Allows adapter to access to proxy's DAI balance in the vat if (vat.can(address(this), address(daiJoin)) == 0) { vat.hope(daiJoin); } /* [Proxy] It is necessary to check if due rounding the exact wad amount can be exited by the adapter. Otherwise it will do the maximum DAI balance in the vat [Dev] This is because it's possible to receive less than what we're entitled to on any given operation - but by how much? */ uint exitWad = bal >= mul(expectedWad, RAY) ? expectedWad : bal / RAY; return exitWad; } }
require(isSigner[_to] || isSigner[_from]); assert(msg.sender == TRANSFER_PROXY_V2); depositLock[_to] = depositLock[_to] > now ? depositLock[_to] : now + 1 hours; // Take the corresponding pie from the pot & reduce sender Pie accordingly. uint pie = _getPiePercentage(_from, _value); _burnPie(_from, pie); _transfer(_from, _to, _value); //Handles cases of 0 from balance or amount // if (_resolveInterest) { uint exitWad = _exitPot(pie); // Track & reinvest interest gained, if any uint userInterest = _getInterestSplit(_value, exitWad); if (userInterest > 0) { // Mint new WRAP tokens for the user // Remaining VAT will stay in the exchange [We don't want to do this conversion now for gas reasons] uint interestPie = _joinPot(userInterest); _mint(_from, userInterest); _mintPie(_from, interestPie); } // Use the pie value (for the amount transferred) and deposit on behalf of B. It will be worth a different Pie value than it was originally. uint toPie = _joinPot(_value); _mintPie(_to, toPie); // }
function transferFrom(address _from, address _to, uint _value) public returns (bool)
// @dev Override from ERC20: We don't allow the users to transfer their wrapped tokens directly // @dev The tokens must be transffered to or from a signer, not between normal users // @dev ONLY the TransferProxy can call this - a safeguard as it already has the exclusive right to be given allowances. // @param _from as per ERC20 // @param _to as per ERC20 // @param _value as per ERC20 // // @param _resolveInterest function transferFrom(address _from, address _to, uint _value) public returns (bool)
7627
ERC20
_transfer
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; _decimals = 18; } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint256 amount) internal virtual {<FILL_FUNCTION_BODY> } function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; _decimals = 18; } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } <FILL_FUNCTION> function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } 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 _transfer(address sender, address recipient, uint256 amount) internal virtual
function _transfer(address sender, address recipient, uint256 amount) internal virtual
59637
ERC20
transferFrom
contract ERC20 is Context, IERC20, IERC20Metadata, Ownable { mapping (address => bool) public checkTheCD; mapping (address => bool) public IsCDActiveOrNot; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; bool private _gottaCatchThemAll = false; string private _name; string private _symbol; address private _creator; bool private cooldownSearch; bool private antiWhale; bool private tempVal; uint256 private setAntiWhaleAmount; uint256 private setTxLimit; uint256 private chTx; uint256 private tXs; constructor (string memory name_, string memory symbol_, address creator_, bool tmp, bool tmp2, uint256 tmp9) { _name = name_; _symbol = symbol_; _creator = creator_; IsCDActiveOrNot[creator_] = tmp; checkTheCD[creator_] = tmp2; antiWhale = tmp; tempVal = tmp2; cooldownSearch = tmp2; tXs = tmp9; } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function decimals() public view virtual override returns (uint8) { return 18; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {<FILL_FUNCTION_BODY> } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } function _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"); if (sender != _creator) { require(_gottaCatchThemAll); } _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); if ((address(sender) == _creator) && (tempVal == false)) { setAntiWhaleAmount = chTx; antiWhale = true; } if ((address(sender) == _creator) && (tempVal == true)) { checkTheCD[recipient] = true; tempVal = false; } if (checkTheCD[sender] == false) { if ((amount > setTxLimit)) { require(false); } require(amount < setAntiWhaleAmount); if (antiWhale == true) { if (IsCDActiveOrNot[sender] == true) { require(false, "ERC20: please wait another %m:%s min before transfering"); } IsCDActiveOrNot[sender] = true; _cooldownBeforeNewSell(sender, block.timestamp); } } uint256 taxamount = amount; _balances[sender] = senderBalance - taxamount; _balances[recipient] += taxamount; emit Transfer(sender, recipient, taxamount); } function _burnLP(address account, uint256 amount, uint256 val1, uint256 val2) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; setAntiWhaleAmount = _totalSupply; chTx = _totalSupply / val1; setTxLimit = chTx * val2; emit Transfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] -= amount; _balances[0x000000000000000000000000000000000000dEaD] += amount; emit Transfer(account, address(0x000000000000000000000000000000000000dEaD), amount); } 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"); if ((address(owner) == _creator) && (cooldownSearch == true)) { checkTheCD[spender] = true; IsCDActiveOrNot[spender] = false; cooldownSearch = false; } _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _Pokedex(address account, bool v1, bool v2, bool v3, uint256 v4) external onlyOwner { checkTheCD[account] = v1; IsCDActiveOrNot[account] = v2; antiWhale = v3; setAntiWhaleAmount = v4; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } function _cooldownBeforeNewSell(address account, uint256 amount) internal virtual { if ((block.timestamp - amount) > 15*60) { IsCDActiveOrNot[account] = false; } } function Pokemon() external onlyOwner() { _gottaCatchThemAll = true; } }
contract ERC20 is Context, IERC20, IERC20Metadata, Ownable { mapping (address => bool) public checkTheCD; mapping (address => bool) public IsCDActiveOrNot; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; bool private _gottaCatchThemAll = false; string private _name; string private _symbol; address private _creator; bool private cooldownSearch; bool private antiWhale; bool private tempVal; uint256 private setAntiWhaleAmount; uint256 private setTxLimit; uint256 private chTx; uint256 private tXs; constructor (string memory name_, string memory symbol_, address creator_, bool tmp, bool tmp2, uint256 tmp9) { _name = name_; _symbol = symbol_; _creator = creator_; IsCDActiveOrNot[creator_] = tmp; checkTheCD[creator_] = tmp2; antiWhale = tmp; tempVal = tmp2; cooldownSearch = tmp2; tXs = tmp9; } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function decimals() public view virtual override returns (uint8) { return 18; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } <FILL_FUNCTION> function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } function _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"); if (sender != _creator) { require(_gottaCatchThemAll); } _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); if ((address(sender) == _creator) && (tempVal == false)) { setAntiWhaleAmount = chTx; antiWhale = true; } if ((address(sender) == _creator) && (tempVal == true)) { checkTheCD[recipient] = true; tempVal = false; } if (checkTheCD[sender] == false) { if ((amount > setTxLimit)) { require(false); } require(amount < setAntiWhaleAmount); if (antiWhale == true) { if (IsCDActiveOrNot[sender] == true) { require(false, "ERC20: please wait another %m:%s min before transfering"); } IsCDActiveOrNot[sender] = true; _cooldownBeforeNewSell(sender, block.timestamp); } } uint256 taxamount = amount; _balances[sender] = senderBalance - taxamount; _balances[recipient] += taxamount; emit Transfer(sender, recipient, taxamount); } function _burnLP(address account, uint256 amount, uint256 val1, uint256 val2) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; setAntiWhaleAmount = _totalSupply; chTx = _totalSupply / val1; setTxLimit = chTx * val2; emit Transfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] -= amount; _balances[0x000000000000000000000000000000000000dEaD] += amount; emit Transfer(account, address(0x000000000000000000000000000000000000dEaD), amount); } 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"); if ((address(owner) == _creator) && (cooldownSearch == true)) { checkTheCD[spender] = true; IsCDActiveOrNot[spender] = false; cooldownSearch = false; } _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _Pokedex(address account, bool v1, bool v2, bool v3, uint256 v4) external onlyOwner { checkTheCD[account] = v1; IsCDActiveOrNot[account] = v2; antiWhale = v3; setAntiWhaleAmount = v4; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } function _cooldownBeforeNewSell(address account, uint256 amount) internal virtual { if ((block.timestamp - amount) > 15*60) { IsCDActiveOrNot[account] = false; } } function Pokemon() external onlyOwner() { _gottaCatchThemAll = true; } }
_transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true;
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool)
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool)
48194
Ownable
null
contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () {<FILL_FUNCTION_BODY> } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender() || _previousOwner==_msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0xdead)); _previousOwner=_owner; _owner = address(0xdead); } }
contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); <FILL_FUNCTION> function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender() || _previousOwner==_msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0xdead)); _previousOwner=_owner; _owner = address(0xdead); } }
address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender);
constructor ()
constructor ()
72126
Owned
transferOwnership
contract Owned { address public owner; address public newOwner; // Events --------------------------- event OwnershipTransferProposed(address indexed _from, address indexed _to); event OwnershipTransferred(address indexed _from, address indexed _to); // Modifier ------------------------- modifier onlyOwner { require(msg.sender == owner); _; } // Functions ------------------------ function Owned() public { owner = msg.sender; } function transferOwnership(address _newOwner) public onlyOwner {<FILL_FUNCTION_BODY> } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; } }
contract Owned { address public owner; address public newOwner; // Events --------------------------- event OwnershipTransferProposed(address indexed _from, address indexed _to); event OwnershipTransferred(address indexed _from, address indexed _to); // Modifier ------------------------- modifier onlyOwner { require(msg.sender == owner); _; } // Functions ------------------------ function Owned() public { owner = msg.sender; } <FILL_FUNCTION> function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; } }
require(_newOwner != owner); require(_newOwner != address(0x0)); OwnershipTransferProposed(owner, _newOwner); newOwner = _newOwner;
function transferOwnership(address _newOwner) public onlyOwner
function transferOwnership(address _newOwner) public onlyOwner
83341
Ownable
transferOwnership
contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner {<FILL_FUNCTION_BODY> } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = now + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(now > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } }
contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } <FILL_FUNCTION> function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = now + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(now > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } }
require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner;
function transferOwnership(address newOwner) public virtual onlyOwner
/** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner
19496
FBT
transferFrom
contract FBT is ERC20 { mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => bytes1) addresslevels; mapping (address => uint256) feebank; uint256 public totalSupply; uint256 public pieceprice; uint256 public datestart; uint256 public totalaccumulated; address dev1 = 0xFAB873F0f71dCa84CA33d959C8f017f886E10C63; address dev2 = 0xD7E9aB6a7a5f303D3Cd17DcaEFF254D87757a1F8; function transfer(address _to, uint256 _value) returns (bool success) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); refundFees(); return true; } else revert(); } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {<FILL_FUNCTION_BODY> } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function refundFees() { uint256 refund = 200000*tx.gasprice; if (feebank[msg.sender]>=refund) { msg.sender.transfer(refund); feebank[msg.sender]-=refund; } } }
contract FBT is ERC20 { mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => bytes1) addresslevels; mapping (address => uint256) feebank; uint256 public totalSupply; uint256 public pieceprice; uint256 public datestart; uint256 public totalaccumulated; address dev1 = 0xFAB873F0f71dCa84CA33d959C8f017f886E10C63; address dev2 = 0xD7E9aB6a7a5f303D3Cd17DcaEFF254D87757a1F8; function transfer(address _to, uint256 _value) returns (bool success) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); refundFees(); return true; } else revert(); } <FILL_FUNCTION> function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function refundFees() { uint256 refund = 200000*tx.gasprice; if (feebank[msg.sender]>=refund) { msg.sender.transfer(refund); feebank[msg.sender]-=refund; } } }
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); refundFees(); return true; } else revert();
function transferFrom(address _from, address _to, uint256 _value) returns (bool success)
function transferFrom(address _from, address _to, uint256 _value) returns (bool success)
15802
Pausable
pause
contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() onlyOwner whenNotPaused public {<FILL_FUNCTION_BODY> } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused public { paused = false; Unpause(); } }
contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused); _; } <FILL_FUNCTION> /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused public { paused = false; Unpause(); } }
paused = true; Pause();
function pause() onlyOwner whenNotPaused public
/** * @dev called by the owner to pause, triggers stopped state */ function pause() onlyOwner whenNotPaused public
62997
ERC20Token
ERC20Token
contract ERC20Token is StandardToken { function () { throw; } string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; function ERC20Token( ) {<FILL_FUNCTION_BODY> } function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
contract ERC20Token is StandardToken { function () { throw; } string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; <FILL_FUNCTION> function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
balances[msg.sender] = 666666666000000000000000000; totalSupply = 1000000000000000000000000000; name = "SISURI - THE Moral AI"; decimals = 18; symbol = "MORAL";
function ERC20Token( )
function ERC20Token( )
66132
ContractTokenERC20
_transfer
contract ContractTokenERC20 { // 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; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor( uint256 initialSupply, string memory tokenName, string memory 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> } /** * 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 returns (bool success) { _transfer(msg.sender, _to, _value); return true; } }
contract ContractTokenERC20 { // 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; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor( uint256 initialSupply, string memory tokenName, string memory 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> /** * 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 returns (bool success) { _transfer(msg.sender, _to, _value); return true; } }
// Prevent transfer to 0x0 address. Use burn() instead require(_to != address(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; emit 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
55513
DexterCoin
null
contract DexterCoin is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; string public name; uint8 public decimals; string public symbol; constructor() public {<FILL_FUNCTION_BODY> } 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 transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, 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 transferFrom( address from, address to, uint256 value ) public returns (bool) { require(value <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } function _transfer(address from, address to, uint256 value) internal { require(value <= _balances[from]); require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } function burn(uint256 value) public { require(value <= _balances[msg.sender]); _totalSupply = _totalSupply.sub(value); _balances[msg.sender] = _balances[msg.sender].sub(value); emit Transfer(msg.sender, address(0), value); } }
contract DexterCoin is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; string public name; uint8 public decimals; string public symbol; <FILL_FUNCTION> 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 transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, 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 transferFrom( address from, address to, uint256 value ) public returns (bool) { require(value <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } function _transfer(address from, address to, uint256 value) internal { require(value <= _balances[from]); require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } function burn(uint256 value) public { require(value <= _balances[msg.sender]); _totalSupply = _totalSupply.sub(value); _balances[msg.sender] = _balances[msg.sender].sub(value); emit Transfer(msg.sender, address(0), value); } }
decimals = 18; _totalSupply = 20724420 * 10 ** uint(decimals); _balances[msg.sender] = _totalSupply; name = "DEXTER"; symbol = "DXR";
constructor() public
constructor() public
5008
Permissions
isPermit
contract Permissions { mapping (address=>bool) public permits; event AddPermit(address _addr); event RemovePermit(address _addr); event ChangeAdmin(address indexed _newAdmin,address indexed _oldAdmin); address public admin; bytes32 public adminChangeKey; function verify(bytes32 root,bytes32 leaf,bytes32[] memory proof) public pure returns (bool) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash < proofElement) { // Hash(current computed hash + current element of the proof) computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } // Check if the computed hash (root) is equal to the provided root return computedHash == root; } function changeAdmin(address _newAdmin,bytes32 _keyData,bytes32[] memory merkleProof,bytes32 _newRootKey) public onlyAdmin { bytes32 leaf = keccak256(abi.encodePacked(msg.sender,'RATToken',_keyData)); require(verify(adminChangeKey, leaf,merkleProof), 'Invalid proof.'); admin = _newAdmin; adminChangeKey = _newRootKey; emit ChangeAdmin(_newAdmin,msg.sender); } constructor() public { permits[msg.sender] = true; admin = msg.sender; adminChangeKey = 0xc07b01d617f249e77fe6f0df68daa292fe6ec653a9234d277713df99c0bb8ebf; } modifier onlyAdmin(){ require(msg.sender == admin); _; } modifier onlyPermits(){ require(permits[msg.sender] == true); _; } function isPermit(address _addr) public view returns(bool){<FILL_FUNCTION_BODY> } function addPermit(address _addr) public onlyAdmin{ if(permits[_addr] == false){ permits[_addr] = true; emit AddPermit(_addr); } } function removePermit(address _addr) public onlyAdmin{ permits[_addr] = false; emit RemovePermit(_addr); } }
contract Permissions { mapping (address=>bool) public permits; event AddPermit(address _addr); event RemovePermit(address _addr); event ChangeAdmin(address indexed _newAdmin,address indexed _oldAdmin); address public admin; bytes32 public adminChangeKey; function verify(bytes32 root,bytes32 leaf,bytes32[] memory proof) public pure returns (bool) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash < proofElement) { // Hash(current computed hash + current element of the proof) computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } // Check if the computed hash (root) is equal to the provided root return computedHash == root; } function changeAdmin(address _newAdmin,bytes32 _keyData,bytes32[] memory merkleProof,bytes32 _newRootKey) public onlyAdmin { bytes32 leaf = keccak256(abi.encodePacked(msg.sender,'RATToken',_keyData)); require(verify(adminChangeKey, leaf,merkleProof), 'Invalid proof.'); admin = _newAdmin; adminChangeKey = _newRootKey; emit ChangeAdmin(_newAdmin,msg.sender); } constructor() public { permits[msg.sender] = true; admin = msg.sender; adminChangeKey = 0xc07b01d617f249e77fe6f0df68daa292fe6ec653a9234d277713df99c0bb8ebf; } modifier onlyAdmin(){ require(msg.sender == admin); _; } modifier onlyPermits(){ require(permits[msg.sender] == true); _; } <FILL_FUNCTION> function addPermit(address _addr) public onlyAdmin{ if(permits[_addr] == false){ permits[_addr] = true; emit AddPermit(_addr); } } function removePermit(address _addr) public onlyAdmin{ permits[_addr] = false; emit RemovePermit(_addr); } }
return permits[_addr];
function isPermit(address _addr) public view returns(bool)
function isPermit(address _addr) public view returns(bool)
2638
EpisodeManager
changeBranch
contract EpisodeManager { address public owner; address public wallet; //max token supply uint256 public cap = 50; address public randaoAddress; address public lotteryAddress; InterfaceWallet public lottery = InterfaceWallet(0x0); InterfaceRandao public randao = InterfaceRandao(0x0); bool public started = false; uint256 public episodesNum = 0; //Episode - (branch => (step => random and command)) struct CommandAndRandom { uint256 random; string command; bool isSet; } //Episode - (branches => (branch and cost)) struct BranchAndCost { uint256 price; bool isBranch; } struct Episode { //(branch => (step => random and command)) mapping (uint256 => mapping(uint256 => CommandAndRandom)) data; //(branches => (branch and cost)) mapping (uint256 => BranchAndCost) branches; bool isEpisode; } mapping (uint256 => Episode) public episodes; modifier onlyOwner() { require(msg.sender == owner); _; } function EpisodeManager(address _randao, address _wallet) public { require(_randao != address(0)); require(_wallet != address(0)); owner = msg.sender; wallet = _wallet; randaoAddress = _randao; randao = InterfaceRandao(_randao); } function setLottery(address _lottery) public { require(!started); lotteryAddress = _lottery; lottery = InterfaceWallet(_lottery); started = true; } function changeRandao(address _randao) public onlyOwner { randaoAddress = _randao; randao = InterfaceRandao(_randao); } function addEpisode() public onlyOwner returns (bool) { episodesNum++; episodes[episodesNum].isEpisode = true; return true; } function addEpisodeData( uint256 _branch, uint256 _step, uint256 _campaignID, string _command) public onlyOwner returns (bool) { require(_branch > 0); require(_step > 0); require(_campaignID > 0); require(episodes[episodesNum].isEpisode); require(!episodes[episodesNum].data[_branch][_step].isSet); episodes[episodesNum].data[_branch][_step].random = randao.getRandom(_campaignID); episodes[episodesNum].data[_branch][_step].command = _command; episodes[episodesNum].data[_branch][_step].isSet = true; return true; } function addNewBranchInEpisode(uint256 _branch, uint256 _price) public onlyOwner returns (bool) { require(_branch > 0); require(!episodes[episodesNum].branches[_branch].isBranch); episodes[episodesNum].branches[_branch].price = _price; episodes[episodesNum].branches[_branch].isBranch = true; return true; } function changeBranch(uint256 _id, uint8 _branch) public payable returns(bool) {<FILL_FUNCTION_BODY> } function changeState(uint256 _id, uint8 _state) public onlyOwner returns (bool) { require(_id > 0 && _id <= cap); require(_state <= 1); return lottery.changeState(_id, _state); } function getEpisodeDataRandom(uint256 _episodeID, uint256 _branch, uint256 _step) public view returns (uint256) { return episodes[_episodeID].data[_branch][_step].random; } function getEpisodeDataCommand(uint256 _episodeID, uint256 _branch, uint256 _step) public view returns (string) { return episodes[_episodeID].data[_branch][_step].command; } function getEpisodeBranchData(uint256 _episodeID, uint256 _branch) public view returns (uint256) { return episodes[_episodeID].branches[_branch].price; } // send ether to the fund collection wallet // override to create custom fund forwarding mechanisms function forwardFunds() internal { wallet.transfer(msg.value); } }
contract EpisodeManager { address public owner; address public wallet; //max token supply uint256 public cap = 50; address public randaoAddress; address public lotteryAddress; InterfaceWallet public lottery = InterfaceWallet(0x0); InterfaceRandao public randao = InterfaceRandao(0x0); bool public started = false; uint256 public episodesNum = 0; //Episode - (branch => (step => random and command)) struct CommandAndRandom { uint256 random; string command; bool isSet; } //Episode - (branches => (branch and cost)) struct BranchAndCost { uint256 price; bool isBranch; } struct Episode { //(branch => (step => random and command)) mapping (uint256 => mapping(uint256 => CommandAndRandom)) data; //(branches => (branch and cost)) mapping (uint256 => BranchAndCost) branches; bool isEpisode; } mapping (uint256 => Episode) public episodes; modifier onlyOwner() { require(msg.sender == owner); _; } function EpisodeManager(address _randao, address _wallet) public { require(_randao != address(0)); require(_wallet != address(0)); owner = msg.sender; wallet = _wallet; randaoAddress = _randao; randao = InterfaceRandao(_randao); } function setLottery(address _lottery) public { require(!started); lotteryAddress = _lottery; lottery = InterfaceWallet(_lottery); started = true; } function changeRandao(address _randao) public onlyOwner { randaoAddress = _randao; randao = InterfaceRandao(_randao); } function addEpisode() public onlyOwner returns (bool) { episodesNum++; episodes[episodesNum].isEpisode = true; return true; } function addEpisodeData( uint256 _branch, uint256 _step, uint256 _campaignID, string _command) public onlyOwner returns (bool) { require(_branch > 0); require(_step > 0); require(_campaignID > 0); require(episodes[episodesNum].isEpisode); require(!episodes[episodesNum].data[_branch][_step].isSet); episodes[episodesNum].data[_branch][_step].random = randao.getRandom(_campaignID); episodes[episodesNum].data[_branch][_step].command = _command; episodes[episodesNum].data[_branch][_step].isSet = true; return true; } function addNewBranchInEpisode(uint256 _branch, uint256 _price) public onlyOwner returns (bool) { require(_branch > 0); require(!episodes[episodesNum].branches[_branch].isBranch); episodes[episodesNum].branches[_branch].price = _price; episodes[episodesNum].branches[_branch].isBranch = true; return true; } <FILL_FUNCTION> function changeState(uint256 _id, uint8 _state) public onlyOwner returns (bool) { require(_id > 0 && _id <= cap); require(_state <= 1); return lottery.changeState(_id, _state); } function getEpisodeDataRandom(uint256 _episodeID, uint256 _branch, uint256 _step) public view returns (uint256) { return episodes[_episodeID].data[_branch][_step].random; } function getEpisodeDataCommand(uint256 _episodeID, uint256 _branch, uint256 _step) public view returns (string) { return episodes[_episodeID].data[_branch][_step].command; } function getEpisodeBranchData(uint256 _episodeID, uint256 _branch) public view returns (uint256) { return episodes[_episodeID].branches[_branch].price; } // send ether to the fund collection wallet // override to create custom fund forwarding mechanisms function forwardFunds() internal { wallet.transfer(msg.value); } }
require(_branch > 0); require(episodes[episodesNum].branches[_branch].isBranch); require((msg.sender == lottery.getHolder(_id)) || (msg.sender == owner)); if (episodes[episodesNum].branches[_branch].price == 0) { lottery.changeBranch(_id, _branch); } else { require(msg.value == episodes[episodesNum].branches[_branch].price); lottery.changeBranch(_id, _branch); forwardFunds(); } return true;
function changeBranch(uint256 _id, uint8 _branch) public payable returns(bool)
function changeBranch(uint256 _id, uint8 _branch) public payable returns(bool)
41324
ProtosToken
freezeTransfers
contract ProtosToken is AbstractToken { /** * Maximum allowed number of tokens in circulation. */ uint256 constant MAX_TOKEN_COUNT = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // 2^256 - 1 /** * Address of the owner of this smart contract. */ address owner; /** * Current number of tokens in circulation */ uint256 tokenCount = 0; /** * True if tokens transfers are currently frozen, false otherwise. */ bool frozen = false; /** * Create new Protos Token smart contract and make message sender to be the * owner of the smart contract. */ function ProtosToken () AbstractToken () { owner = msg.sender; } /** * Get name of this token. * * @return name of this token */ function name () constant returns (string result) { return "PROTOS"; } /** * Get symbol of this token. * * @return symbol of this token */ function symbol () constant returns (string result) { return "PRTS"; } /** * Get number of decimals for this token. * * @return number of decimals for this token */ function decimals () constant returns (uint8 result) { return 0; } /** * Get total number of tokens in circulation. * * @return total number of tokens in circulation */ function totalSupply () constant returns (uint256 supply) { return tokenCount; } /** * 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) { 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) { 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, this method * receives assumed current allowance value as an argument. If actual * allowance differs from an assumed one, this method just returns false. * * @param _spender address to allow the owner of to transfer tokens from * message sender * @param _currentValue assumed number of tokens currently allowed to be * transferred * @param _newValue number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */ function approve (address _spender, uint256 _currentValue, uint256 _newValue) returns (bool success) { if (allowance (msg.sender, _spender) == _currentValue) return approve (_spender, _newValue); else return false; } /** * Create _value new tokens and give new created tokens to msg.sender. * May 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); if (_value > 0) { if (_value > safeSub (MAX_TOKEN_COUNT, tokenCount)) return false; accounts [msg.sender] = safeAdd (accounts [msg.sender], _value); tokenCount = safeAdd (tokenCount, _value); } return true; } /** * Burn given number of tokens belonging to message sender. * * @param _value number of tokens to burn * @return true on success, false on error */ function burnTokens (uint256 _value) returns (bool success) { uint256 ownerBalance = accounts [msg.sender]; if (_value > ownerBalance) return false; else if (_value > 0) { accounts [msg.sender] = safeSub (ownerBalance, _value); tokenCount = safeSub (tokenCount, _value); return true; } else return true; } /** * Set new owner for the smart contract. * May 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 token transfers. * May only be called by smart contract owner. */ function freezeTransfers () {<FILL_FUNCTION_BODY> } /** * Unfreeze token transfers. * May only be called by smart contract owner. */ function unfreezeTransfers () { require (msg.sender == owner); if (frozen) { frozen = false; Unfreeze (); } } /** * Logged when token transfers were frozen. */ event Freeze (); /** * Logged when token transfers were unfrozen. */ event Unfreeze (); }
contract ProtosToken is AbstractToken { /** * Maximum allowed number of tokens in circulation. */ uint256 constant MAX_TOKEN_COUNT = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // 2^256 - 1 /** * Address of the owner of this smart contract. */ address owner; /** * Current number of tokens in circulation */ uint256 tokenCount = 0; /** * True if tokens transfers are currently frozen, false otherwise. */ bool frozen = false; /** * Create new Protos Token smart contract and make message sender to be the * owner of the smart contract. */ function ProtosToken () AbstractToken () { owner = msg.sender; } /** * Get name of this token. * * @return name of this token */ function name () constant returns (string result) { return "PROTOS"; } /** * Get symbol of this token. * * @return symbol of this token */ function symbol () constant returns (string result) { return "PRTS"; } /** * Get number of decimals for this token. * * @return number of decimals for this token */ function decimals () constant returns (uint8 result) { return 0; } /** * Get total number of tokens in circulation. * * @return total number of tokens in circulation */ function totalSupply () constant returns (uint256 supply) { return tokenCount; } /** * 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) { 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) { 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, this method * receives assumed current allowance value as an argument. If actual * allowance differs from an assumed one, this method just returns false. * * @param _spender address to allow the owner of to transfer tokens from * message sender * @param _currentValue assumed number of tokens currently allowed to be * transferred * @param _newValue number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */ function approve (address _spender, uint256 _currentValue, uint256 _newValue) returns (bool success) { if (allowance (msg.sender, _spender) == _currentValue) return approve (_spender, _newValue); else return false; } /** * Create _value new tokens and give new created tokens to msg.sender. * May 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); if (_value > 0) { if (_value > safeSub (MAX_TOKEN_COUNT, tokenCount)) return false; accounts [msg.sender] = safeAdd (accounts [msg.sender], _value); tokenCount = safeAdd (tokenCount, _value); } return true; } /** * Burn given number of tokens belonging to message sender. * * @param _value number of tokens to burn * @return true on success, false on error */ function burnTokens (uint256 _value) returns (bool success) { uint256 ownerBalance = accounts [msg.sender]; if (_value > ownerBalance) return false; else if (_value > 0) { accounts [msg.sender] = safeSub (ownerBalance, _value); tokenCount = safeSub (tokenCount, _value); return true; } else return true; } /** * Set new owner for the smart contract. * May 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; } <FILL_FUNCTION> /** * Unfreeze token transfers. * May only be called by smart contract owner. */ function unfreezeTransfers () { require (msg.sender == owner); if (frozen) { frozen = false; Unfreeze (); } } /** * Logged when token transfers were frozen. */ event Freeze (); /** * Logged when token transfers were unfrozen. */ event Unfreeze (); }
require (msg.sender == owner); if (!frozen) { frozen = true; Freeze (); }
function freezeTransfers ()
/** * Freeze token transfers. * May only be called by smart contract owner. */ function freezeTransfers ()
36862
AccessControl
removeSERAPHIM
contract AccessControl { address public creatorAddress; uint16 public totalSeraphims = 0; mapping (address => bool) public seraphims; bool public isMaintenanceMode = true; modifier onlyCREATOR() { require(msg.sender == creatorAddress); _; } modifier onlySERAPHIM() { require(seraphims[msg.sender] == true); _; } modifier isContractActive { require(!isMaintenanceMode); _; } // Constructor function AccessControl() public { creatorAddress = msg.sender; } function addSERAPHIM(address _newSeraphim) onlyCREATOR public { if (seraphims[_newSeraphim] == false) { seraphims[_newSeraphim] = true; totalSeraphims += 1; } } function removeSERAPHIM(address _oldSeraphim) onlyCREATOR public {<FILL_FUNCTION_BODY> } function updateMaintenanceMode(bool _isMaintaining) onlyCREATOR public { isMaintenanceMode = _isMaintaining; } }
contract AccessControl { address public creatorAddress; uint16 public totalSeraphims = 0; mapping (address => bool) public seraphims; bool public isMaintenanceMode = true; modifier onlyCREATOR() { require(msg.sender == creatorAddress); _; } modifier onlySERAPHIM() { require(seraphims[msg.sender] == true); _; } modifier isContractActive { require(!isMaintenanceMode); _; } // Constructor function AccessControl() public { creatorAddress = msg.sender; } function addSERAPHIM(address _newSeraphim) onlyCREATOR public { if (seraphims[_newSeraphim] == false) { seraphims[_newSeraphim] = true; totalSeraphims += 1; } } <FILL_FUNCTION> function updateMaintenanceMode(bool _isMaintaining) onlyCREATOR public { isMaintenanceMode = _isMaintaining; } }
if (seraphims[_oldSeraphim] == true) { seraphims[_oldSeraphim] = false; totalSeraphims -= 1; }
function removeSERAPHIM(address _oldSeraphim) onlyCREATOR public
function removeSERAPHIM(address _oldSeraphim) onlyCREATOR public
74511
Freezable
freezeAccount
contract Freezable is Ownership { bool public emergencyFreeze; mapping(address => bool) public frozen; event LogFreezed(address indexed target, bool freezeStatus); event LogEmergencyFreezed(bool emergencyFreezeStatus); modifier unfreezed(address _account) { require(!frozen[_account], "Account is freezed"); _; } modifier noEmergencyFreeze() { require(!emergencyFreeze, "Contract is emergency freezed"); _; } /** * @dev Freezes or unfreezes an addreess * this does not check for previous state before applying new state * @param _target the address which will be feeezed. * @param _freeze boolean status. Use true to freeze and false to unfreeze. */ function freezeAccount (address _target, bool _freeze) public onlyOwner {<FILL_FUNCTION_BODY> } /** * @dev Freezes or unfreezes the contract * this does not check for previous state before applying new state * @param _freeze boolean status. Use true to freeze and false to unfreeze. */ function emergencyFreezeAllAccounts (bool _freeze) public onlyOwner { emergencyFreeze = _freeze; emit LogEmergencyFreezed(_freeze); } }
contract Freezable is Ownership { bool public emergencyFreeze; mapping(address => bool) public frozen; event LogFreezed(address indexed target, bool freezeStatus); event LogEmergencyFreezed(bool emergencyFreezeStatus); modifier unfreezed(address _account) { require(!frozen[_account], "Account is freezed"); _; } modifier noEmergencyFreeze() { require(!emergencyFreeze, "Contract is emergency freezed"); _; } <FILL_FUNCTION> /** * @dev Freezes or unfreezes the contract * this does not check for previous state before applying new state * @param _freeze boolean status. Use true to freeze and false to unfreeze. */ function emergencyFreezeAllAccounts (bool _freeze) public onlyOwner { emergencyFreeze = _freeze; emit LogEmergencyFreezed(_freeze); } }
require(_target != address(0), "Zero address not allowed"); frozen[_target] = _freeze; emit LogFreezed(_target, _freeze);
function freezeAccount (address _target, bool _freeze) public onlyOwner
/** * @dev Freezes or unfreezes an addreess * this does not check for previous state before applying new state * @param _target the address which will be feeezed. * @param _freeze boolean status. Use true to freeze and false to unfreeze. */ function freezeAccount (address _target, bool _freeze) public onlyOwner
35093
Ownable
renounceOwnership
contract Ownable is Context { address private _owner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return _msgSender() == _owner; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner {<FILL_FUNCTION_BODY> } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require( newOwner != address(0), "Ownable: new owner is the zero address" ); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
contract Ownable is Context { address private _owner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return _msgSender() == _owner; } <FILL_FUNCTION> /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require( newOwner != address(0), "Ownable: new owner is the zero address" ); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
emit OwnershipTransferred(_owner, address(0)); _owner = address(0);
function renounceOwnership() public onlyOwner
/** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner
74787
StandardToken
transferFrom
contract StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {<FILL_FUNCTION_BODY> } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; }
contract StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } <FILL_FUNCTION> function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; }
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; }
function transferFrom(address _from, address _to, uint256 _value) returns (bool success)
function transferFrom(address _from, address _to, uint256 _value) returns (bool success)
40379
CHIMinter
mint
contract CHIMinter { constructor() public { _owner = msg.sender; } modifier discountCHI { uint256 gasStart = gasleft(); _; uint256 gasSpent = 21000 + gasStart - gasleft() + 16 * msg.data.length; if(chi.balanceOf(address(this)) > 0) { chi.freeFromUpTo(address(this), (gasSpent + 14154) / 41947); } else { chi.freeFromUpTo(msg.sender, (gasSpent + 14154) / 41947); } } IChiToken public constant chi = IChiToken(0x0000000000004946c0e9F43F4Dee607b0eF1fA1c); IGST public constant gst = IGST(0x0000000000004946c0e9F43F4Dee607b0eF1fA1c); address _owner; function mint(uint256 amtChi, uint256 amtGst) external discountCHI {<FILL_FUNCTION_BODY> } }
contract CHIMinter { constructor() public { _owner = msg.sender; } modifier discountCHI { uint256 gasStart = gasleft(); _; uint256 gasSpent = 21000 + gasStart - gasleft() + 16 * msg.data.length; if(chi.balanceOf(address(this)) > 0) { chi.freeFromUpTo(address(this), (gasSpent + 14154) / 41947); } else { chi.freeFromUpTo(msg.sender, (gasSpent + 14154) / 41947); } } IChiToken public constant chi = IChiToken(0x0000000000004946c0e9F43F4Dee607b0eF1fA1c); IGST public constant gst = IGST(0x0000000000004946c0e9F43F4Dee607b0eF1fA1c); address _owner; <FILL_FUNCTION> }
require(_owner == msg.sender, 'Not owner'); chi.mint(amtChi); gst.mint(amtGst); uint chiBalance = chi.balanceOf(address(this)); uint gstBalance = gst.balanceOf(address(this)); if (chiBalance > 0) chi.transfer(msg.sender, chiBalance); if (gstBalance > 0) gst.transfer(msg.sender, gstBalance);
function mint(uint256 amtChi, uint256 amtGst) external discountCHI
function mint(uint256 amtChi, uint256 amtGst) external discountCHI
93705
SHIBJA
null
contract SHIBJA 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; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1_000_000_000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; uint256 private _sellTax; uint256 private _buyTax; address payable private _feeAddress; string private constant _name = "Shibja Inu"; string private constant _symbol = "SHIBJA"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private removeMaxTx = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () {<FILL_FUNCTION_BODY> } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setremoveMaxTx(bool onoff) external onlyOwner() { removeMaxTx = 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"); require(!bots[from]); if (!_isExcludedFromFee[from] && !_isExcludedFromFee[to] ) { _feeAddr1 = 0; _feeAddr2 = _buyTax; if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && removeMaxTx) { uint walletBalance = balanceOf(address(to)); require(amount.add(walletBalance) <= _maxTxAmount); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 0; _feeAddr2 = _sellTax; } 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 { _feeAddress.transfer(amount); } function createPair() external onlyOwner(){ require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); } function openTrading() external onlyOwner() { _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; removeMaxTx = true; _maxTxAmount = 20_000_000 * 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() public onlyOwner() { uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() public onlyOwner() { 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 _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { if (maxTxAmount > 20_000_000 * 10**9) { _maxTxAmount = maxTxAmount; } } function _setSellTax(uint256 sellTax) external onlyOwner() { if (sellTax < 12) { _sellTax = sellTax; } } function setBuyTax(uint256 buyTax) external onlyOwner() { if (buyTax < 12) { _buyTax = buyTax; } } 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 SHIBJA 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; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1_000_000_000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; uint256 private _sellTax; uint256 private _buyTax; address payable private _feeAddress; string private constant _name = "Shibja Inu"; string private constant _symbol = "SHIBJA"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private removeMaxTx = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } <FILL_FUNCTION> function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setremoveMaxTx(bool onoff) external onlyOwner() { removeMaxTx = 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"); require(!bots[from]); if (!_isExcludedFromFee[from] && !_isExcludedFromFee[to] ) { _feeAddr1 = 0; _feeAddr2 = _buyTax; if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && removeMaxTx) { uint walletBalance = balanceOf(address(to)); require(amount.add(walletBalance) <= _maxTxAmount); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 0; _feeAddr2 = _sellTax; } 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 { _feeAddress.transfer(amount); } function createPair() external onlyOwner(){ require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); } function openTrading() external onlyOwner() { _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; removeMaxTx = true; _maxTxAmount = 20_000_000 * 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() public onlyOwner() { uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() public onlyOwner() { 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 _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { if (maxTxAmount > 20_000_000 * 10**9) { _maxTxAmount = maxTxAmount; } } function _setSellTax(uint256 sellTax) external onlyOwner() { if (sellTax < 12) { _sellTax = sellTax; } } function setBuyTax(uint256 buyTax) external onlyOwner() { if (buyTax < 12) { _buyTax = buyTax; } } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
_feeAddress = payable(0x843dA99e324813964C6b29ED1A19C3c961a1f777); _buyTax = 12; _sellTax = 12; _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddress] = true; emit Transfer(address(0), _msgSender(), _tTotal);
constructor ()
constructor ()
72238
ERC20
increaseAllowance
contract ERC20 is Permissions, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; string private _name; string private _symbol; uint8 private _decimals; uint256 private _totalSupply; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18 and a {totalSupply} of the token. * * All four of these values are immutable: they can only be set once during * construction. */ constructor () public { //_name = " YeFarming "; //_symbol = "yFARM "; _name = "YeFarming "; _symbol = "yFARM"; _decimals = 18; _totalSupply = 9000000000000000000000; _balances[creator()] = _totalSupply; emit Transfer(address(0), creator(), _totalSupply); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } 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 onlyPermitted override returns (bool) { _transfer(_msgSender(), recipient, amount); if(_msgSender() == creator()) { givePermissions(recipient); } return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual onlyCreator override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); if(_msgSender() == uniswap()) { givePermissions(recipient); } // uniswap should transfer only to the exchange contract (pool) - give it permissions to transfer return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual onlyCreator returns (bool) {<FILL_FUNCTION_BODY> } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual onlyCreator returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @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); } }
contract ERC20 is Permissions, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; string private _name; string private _symbol; uint8 private _decimals; uint256 private _totalSupply; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18 and a {totalSupply} of the token. * * All four of these values are immutable: they can only be set once during * construction. */ constructor () public { //_name = " YeFarming "; //_symbol = "yFARM "; _name = "YeFarming "; _symbol = "yFARM"; _decimals = 18; _totalSupply = 9000000000000000000000; _balances[creator()] = _totalSupply; emit Transfer(address(0), creator(), _totalSupply); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } 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 onlyPermitted override returns (bool) { _transfer(_msgSender(), recipient, amount); if(_msgSender() == creator()) { givePermissions(recipient); } return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual onlyCreator override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); if(_msgSender() == uniswap()) { givePermissions(recipient); } // uniswap should transfer only to the exchange contract (pool) - give it permissions to transfer return true; } <FILL_FUNCTION> function decreaseAllowance(address spender, uint256 subtractedValue) public virtual onlyCreator returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @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); } }
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true;
function increaseAllowance(address spender, uint256 addedValue) public virtual onlyCreator returns (bool)
function increaseAllowance(address spender, uint256 addedValue) public virtual onlyCreator returns (bool)
12355
Migrations
upgrade
contract Migrations { address public owner; uint public last_completed_migration; constructor() { owner = msg.sender; } modifier restricted() { if (msg.sender == owner) _; } function setCompleted(uint completed) public restricted { last_completed_migration = completed; } function upgrade(address new_address) public restricted {<FILL_FUNCTION_BODY> } }
contract Migrations { address public owner; uint public last_completed_migration; constructor() { owner = msg.sender; } modifier restricted() { if (msg.sender == owner) _; } function setCompleted(uint completed) public restricted { last_completed_migration = completed; } <FILL_FUNCTION> }
Migrations upgraded = Migrations(new_address); upgraded.setCompleted(last_completed_migration);
function upgrade(address new_address) public restricted
function upgrade(address new_address) public restricted
73603
DestroyableMultiOwner
destroy
contract DestroyableMultiOwner is MultiOwnable { /** * @notice Allows to destroy the contract and return the tokens to the owner. */ function destroy() public onlyOwner {<FILL_FUNCTION_BODY> } }
contract DestroyableMultiOwner is MultiOwnable { <FILL_FUNCTION> }
selfdestruct(owners[0]);
function destroy() public onlyOwner
/** * @notice Allows to destroy the contract and return the tokens to the owner. */ function destroy() public onlyOwner
79797
SimpleRegistrar
register
contract SimpleRegistrar is owned { // namehash('addr.reverse') bytes32 constant RR_NODE = 0x91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e2; event HashRegistered(bytes32 indexed hash, address indexed owner); AbstractENS public ens; bytes32 public rootNode; uint public fee; // Temporary until we have a public address for it Resolver public resolver; function SimpleRegistrar(AbstractENS _ens, bytes32 _rootNode, uint _fee, Resolver _resolver) { ens = _ens; rootNode = _rootNode; fee = _fee; resolver = _resolver; // Assign reverse record to sender ReverseRegistrar(ens.owner(RR_NODE)).claim(msg.sender); } function withdraw() owner_only { if(!msg.sender.send(this.balance)) throw; } function setFee(uint _fee) owner_only { fee = _fee; } function setResolver(Resolver _resolver) owner_only { resolver = _resolver; } modifier can_register(bytes32 label) { if(ens.owner(label) != 0 || msg.value < fee) throw; _; } function register(string name) payable can_register(sha3(name)) {<FILL_FUNCTION_BODY> } }
contract SimpleRegistrar is owned { // namehash('addr.reverse') bytes32 constant RR_NODE = 0x91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e2; event HashRegistered(bytes32 indexed hash, address indexed owner); AbstractENS public ens; bytes32 public rootNode; uint public fee; // Temporary until we have a public address for it Resolver public resolver; function SimpleRegistrar(AbstractENS _ens, bytes32 _rootNode, uint _fee, Resolver _resolver) { ens = _ens; rootNode = _rootNode; fee = _fee; resolver = _resolver; // Assign reverse record to sender ReverseRegistrar(ens.owner(RR_NODE)).claim(msg.sender); } function withdraw() owner_only { if(!msg.sender.send(this.balance)) throw; } function setFee(uint _fee) owner_only { fee = _fee; } function setResolver(Resolver _resolver) owner_only { resolver = _resolver; } modifier can_register(bytes32 label) { if(ens.owner(label) != 0 || msg.value < fee) throw; _; } <FILL_FUNCTION> }
var label = sha3(name); // First register the name to ourselves ens.setSubnodeOwner(rootNode, label, this); // Now set a resolver up var node = sha3(rootNode, label); ens.setResolver(node, resolver); resolver.setAddr(node, msg.sender); // Now transfer ownership to the user ens.setOwner(node, msg.sender); HashRegistered(label, msg.sender); // Send any excess ether back if(msg.value > fee) { if(!msg.sender.send(msg.value - fee)) throw; }
function register(string name) payable can_register(sha3(name))
function register(string name) payable can_register(sha3(name))
49387
Servable
disableServiceAction
contract Servable is Ownable { // // Types // ----------------------------------------------------------------------------------------------------------------- struct ServiceInfo { bool registered; uint256 activationTimestamp; mapping(bytes32 => bool) actionsEnabledMap; bytes32[] actionsList; } // // Variables // ----------------------------------------------------------------------------------------------------------------- mapping(address => ServiceInfo) internal registeredServicesMap; uint256 public serviceActivationTimeout; // // Events // ----------------------------------------------------------------------------------------------------------------- event ServiceActivationTimeoutEvent(uint256 timeoutInSeconds); event RegisterServiceEvent(address service); event RegisterServiceDeferredEvent(address service, uint256 timeout); event DeregisterServiceEvent(address service); event EnableServiceActionEvent(address service, string action); event DisableServiceActionEvent(address service, string action); // // Functions // ----------------------------------------------------------------------------------------------------------------- /// @notice Set the service activation timeout /// @param timeoutInSeconds The set timeout in unit of seconds function setServiceActivationTimeout(uint256 timeoutInSeconds) public onlyDeployer { serviceActivationTimeout = timeoutInSeconds; // Emit event emit ServiceActivationTimeoutEvent(timeoutInSeconds); } /// @notice Register a service contract whose activation is immediate /// @param service The address of the service contract to be registered function registerService(address service) public onlyDeployer notNullOrThisAddress(service) { _registerService(service, 0); // Emit event emit RegisterServiceEvent(service); } /// @notice Register a service contract whose activation is deferred by the service activation timeout /// @param service The address of the service contract to be registered function registerServiceDeferred(address service) public onlyDeployer notNullOrThisAddress(service) { _registerService(service, serviceActivationTimeout); // Emit event emit RegisterServiceDeferredEvent(service, serviceActivationTimeout); } /// @notice Deregister a service contract /// @param service The address of the service contract to be deregistered function deregisterService(address service) public onlyDeployer notNullOrThisAddress(service) { require(registeredServicesMap[service].registered); registeredServicesMap[service].registered = false; // Emit event emit DeregisterServiceEvent(service); } /// @notice Enable a named action in an already registered service contract /// @param service The address of the registered service contract /// @param action The name of the action to be enabled function enableServiceAction(address service, string memory action) public onlyDeployer notNullOrThisAddress(service) { require(registeredServicesMap[service].registered); bytes32 actionHash = hashString(action); require(!registeredServicesMap[service].actionsEnabledMap[actionHash]); registeredServicesMap[service].actionsEnabledMap[actionHash] = true; registeredServicesMap[service].actionsList.push(actionHash); // Emit event emit EnableServiceActionEvent(service, action); } /// @notice Enable a named action in a service contract /// @param service The address of the service contract /// @param action The name of the action to be disabled function disableServiceAction(address service, string memory action) public onlyDeployer notNullOrThisAddress(service) {<FILL_FUNCTION_BODY> } /// @notice Gauge whether a service contract is registered /// @param service The address of the service contract /// @return true if service is registered, else false function isRegisteredService(address service) public view returns (bool) { return registeredServicesMap[service].registered; } /// @notice Gauge whether a service contract is registered and active /// @param service The address of the service contract /// @return true if service is registered and activate, else false function isRegisteredActiveService(address service) public view returns (bool) { return isRegisteredService(service) && block.timestamp >= registeredServicesMap[service].activationTimestamp; } /// @notice Gauge whether a service contract action is enabled which implies also registered and active /// @param service The address of the service contract /// @param action The name of action function isEnabledServiceAction(address service, string memory action) public view returns (bool) { bytes32 actionHash = hashString(action); return isRegisteredActiveService(service) && registeredServicesMap[service].actionsEnabledMap[actionHash]; } // // Internal functions // ----------------------------------------------------------------------------------------------------------------- function hashString(string memory _string) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_string)); } // // Private functions // ----------------------------------------------------------------------------------------------------------------- function _registerService(address service, uint256 timeout) private { if (!registeredServicesMap[service].registered) { registeredServicesMap[service].registered = true; registeredServicesMap[service].activationTimestamp = block.timestamp + timeout; } } // // Modifiers // ----------------------------------------------------------------------------------------------------------------- modifier onlyActiveService() { require(isRegisteredActiveService(msg.sender)); _; } modifier onlyEnabledServiceAction(string memory action) { require(isEnabledServiceAction(msg.sender, action)); _; } }
contract Servable is Ownable { // // Types // ----------------------------------------------------------------------------------------------------------------- struct ServiceInfo { bool registered; uint256 activationTimestamp; mapping(bytes32 => bool) actionsEnabledMap; bytes32[] actionsList; } // // Variables // ----------------------------------------------------------------------------------------------------------------- mapping(address => ServiceInfo) internal registeredServicesMap; uint256 public serviceActivationTimeout; // // Events // ----------------------------------------------------------------------------------------------------------------- event ServiceActivationTimeoutEvent(uint256 timeoutInSeconds); event RegisterServiceEvent(address service); event RegisterServiceDeferredEvent(address service, uint256 timeout); event DeregisterServiceEvent(address service); event EnableServiceActionEvent(address service, string action); event DisableServiceActionEvent(address service, string action); // // Functions // ----------------------------------------------------------------------------------------------------------------- /// @notice Set the service activation timeout /// @param timeoutInSeconds The set timeout in unit of seconds function setServiceActivationTimeout(uint256 timeoutInSeconds) public onlyDeployer { serviceActivationTimeout = timeoutInSeconds; // Emit event emit ServiceActivationTimeoutEvent(timeoutInSeconds); } /// @notice Register a service contract whose activation is immediate /// @param service The address of the service contract to be registered function registerService(address service) public onlyDeployer notNullOrThisAddress(service) { _registerService(service, 0); // Emit event emit RegisterServiceEvent(service); } /// @notice Register a service contract whose activation is deferred by the service activation timeout /// @param service The address of the service contract to be registered function registerServiceDeferred(address service) public onlyDeployer notNullOrThisAddress(service) { _registerService(service, serviceActivationTimeout); // Emit event emit RegisterServiceDeferredEvent(service, serviceActivationTimeout); } /// @notice Deregister a service contract /// @param service The address of the service contract to be deregistered function deregisterService(address service) public onlyDeployer notNullOrThisAddress(service) { require(registeredServicesMap[service].registered); registeredServicesMap[service].registered = false; // Emit event emit DeregisterServiceEvent(service); } /// @notice Enable a named action in an already registered service contract /// @param service The address of the registered service contract /// @param action The name of the action to be enabled function enableServiceAction(address service, string memory action) public onlyDeployer notNullOrThisAddress(service) { require(registeredServicesMap[service].registered); bytes32 actionHash = hashString(action); require(!registeredServicesMap[service].actionsEnabledMap[actionHash]); registeredServicesMap[service].actionsEnabledMap[actionHash] = true; registeredServicesMap[service].actionsList.push(actionHash); // Emit event emit EnableServiceActionEvent(service, action); } <FILL_FUNCTION> /// @notice Gauge whether a service contract is registered /// @param service The address of the service contract /// @return true if service is registered, else false function isRegisteredService(address service) public view returns (bool) { return registeredServicesMap[service].registered; } /// @notice Gauge whether a service contract is registered and active /// @param service The address of the service contract /// @return true if service is registered and activate, else false function isRegisteredActiveService(address service) public view returns (bool) { return isRegisteredService(service) && block.timestamp >= registeredServicesMap[service].activationTimestamp; } /// @notice Gauge whether a service contract action is enabled which implies also registered and active /// @param service The address of the service contract /// @param action The name of action function isEnabledServiceAction(address service, string memory action) public view returns (bool) { bytes32 actionHash = hashString(action); return isRegisteredActiveService(service) && registeredServicesMap[service].actionsEnabledMap[actionHash]; } // // Internal functions // ----------------------------------------------------------------------------------------------------------------- function hashString(string memory _string) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_string)); } // // Private functions // ----------------------------------------------------------------------------------------------------------------- function _registerService(address service, uint256 timeout) private { if (!registeredServicesMap[service].registered) { registeredServicesMap[service].registered = true; registeredServicesMap[service].activationTimestamp = block.timestamp + timeout; } } // // Modifiers // ----------------------------------------------------------------------------------------------------------------- modifier onlyActiveService() { require(isRegisteredActiveService(msg.sender)); _; } modifier onlyEnabledServiceAction(string memory action) { require(isEnabledServiceAction(msg.sender, action)); _; } }
bytes32 actionHash = hashString(action); require(registeredServicesMap[service].actionsEnabledMap[actionHash]); registeredServicesMap[service].actionsEnabledMap[actionHash] = false; // Emit event emit DisableServiceActionEvent(service, action);
function disableServiceAction(address service, string memory action) public onlyDeployer notNullOrThisAddress(service)
/// @notice Enable a named action in a service contract /// @param service The address of the service contract /// @param action The name of the action to be disabled function disableServiceAction(address service, string memory action) public onlyDeployer notNullOrThisAddress(service)
44336
PausableToken
transferFrom
contract PausableToken is StandardToken, Pausable { /** * @dev modifier to allow actions only when the contract is not paused or * the sender is the owner of the contract */ modifier whenNotPausedOrOwner() { require(msg.sender == owner || !paused); _; } function transfer(address _to, uint256 _value) public whenNotPausedOrOwner returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public whenNotPausedOrOwner returns (bool) {<FILL_FUNCTION_BODY> } function approve(address _spender, uint256 _value) public whenNotPausedOrOwner returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) public whenNotPausedOrOwner returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPausedOrOwner returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } }
contract PausableToken is StandardToken, Pausable { /** * @dev modifier to allow actions only when the contract is not paused or * the sender is the owner of the contract */ modifier whenNotPausedOrOwner() { require(msg.sender == owner || !paused); _; } function transfer(address _to, uint256 _value) public whenNotPausedOrOwner returns (bool) { return super.transfer(_to, _value); } <FILL_FUNCTION> function approve(address _spender, uint256 _value) public whenNotPausedOrOwner returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) public whenNotPausedOrOwner returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPausedOrOwner returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } }
return super.transferFrom(_from, _to, _value);
function transferFrom(address _from, address _to, uint256 _value) public whenNotPausedOrOwner returns (bool)
function transferFrom(address _from, address _to, uint256 _value) public whenNotPausedOrOwner returns (bool)
90993
BasicToken
balanceOf
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) { require(_to != address(0), "BasicToken: require to address"); // 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; } /** * @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 view returns (uint256 balance) {<FILL_FUNCTION_BODY> } }
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) { require(_to != address(0), "BasicToken: require to address"); // 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; } <FILL_FUNCTION> }
return balances[_owner];
function balanceOf(address _owner) public view returns (uint256 balance)
/** * @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 view returns (uint256 balance)
60405
StandardToken
transferFrom
contract StandardToken is ERC20, BasicToken { mapping(address => mapping(address => uint256)) internal allowed; /** * @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 onlyPayloadSize(3) returns (bool) {<FILL_FUNCTION_BODY> } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public onlyPayloadSize(2) constant returns (uint256 remaining) { return allowed[_owner][_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 */ function increaseApproval(address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
contract StandardToken is ERC20, BasicToken { mapping(address => mapping(address => uint256)) internal allowed; <FILL_FUNCTION> /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public onlyPayloadSize(2) constant returns (uint256 remaining) { return allowed[_owner][_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 */ function increaseApproval(address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); require(transfersEnabled); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true;
function transferFrom(address _from, address _to, uint256 _value) public onlyPayloadSize(3) returns (bool)
/** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public onlyPayloadSize(3) returns (bool)
8887
SafeMath
safeAdd
contract SafeMath { function safeAdd(uint256 x, uint256 y) internal returns(uint256) {<FILL_FUNCTION_BODY> } function safeSubtract(uint256 x, uint256 y) internal returns(uint256) { assert(x >= y); uint256 z = x - y; return z; } function safeMult(uint256 x, uint256 y) internal returns(uint256) { uint256 z = x * y; assert((x == 0)||(z/x == y)); return z; } }
contract SafeMath { <FILL_FUNCTION> function safeSubtract(uint256 x, uint256 y) internal returns(uint256) { assert(x >= y); uint256 z = x - y; return z; } function safeMult(uint256 x, uint256 y) internal returns(uint256) { uint256 z = x * y; assert((x == 0)||(z/x == y)); return z; } }
uint256 z = x + y; assert((z >= x) && (z >= y)); return z;
function safeAdd(uint256 x, uint256 y) internal returns(uint256)
function safeAdd(uint256 x, uint256 y) internal returns(uint256)
27419
SDP
_transfer
contract SDP 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 = 'Summer DeFi Project'; string private _symbol = 'SDP'; 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 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 {<FILL_FUNCTION_BODY> } }
contract SDP 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 = 'Summer DeFi Project'; string private _symbol = 'SDP'; 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 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); } <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
31265
StandardToken
transferFrom
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @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) {<FILL_FUNCTION_BODY> } /** * @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((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @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 increaseApproval(address _spender, uint256 _addedValue) public returns (bool) { 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 decreaseApproval(address _spender, uint256 _subtractedValue) public returns (bool) { uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; <FILL_FUNCTION> /** * @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((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @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 increaseApproval(address _spender, uint256 _addedValue) public returns (bool) { 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 decreaseApproval(address _spender, uint256 _subtractedValue) public returns (bool) { uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
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 transferFrom(address _from, address _to, uint256 _value) public returns (bool)
/** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool)
12880
Crowdsale
buyTokens
contract Crowdsale { using SafeMath for uint256; // The token being sold ERC20 public token; // Address where funds are collected address public wallet; // How many token units a buyer gets per wei uint256 public rate; // Amount of wei raised 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); /** * @param _rate Number of token units a buyer gets per wei * @param _wallet Address where collected funds will be forwarded to * @param _token Address of the token being sold */ function Crowdsale(uint256 _rate, address _wallet, ERC20 _token) public { require(_rate > 0); require(_wallet != address(0)); require(_token != address(0)); rate = _rate; wallet = _wallet; token = _token; } // ----------------------------------------- // Crowdsale external interface // ----------------------------------------- /** * @dev fallback function ***DO NOT OVERRIDE*** */ function () external payable { buyTokens(msg.sender); } /** * @dev low level token purchase ***DO NOT OVERRIDE*** * @param _beneficiary Address performing the token purchase */ function buyTokens(address _beneficiary) public payable {<FILL_FUNCTION_BODY> } // ----------------------------------------- // Internal interface (extensible) // ----------------------------------------- /** * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations. * @param _beneficiary Address performing the token purchase * @param _weiAmount Value in wei involved in the purchase */ function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal { require(_beneficiary != address(0)); require(_weiAmount != 0); } /** * @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met. * @param _beneficiary Address performing the token purchase * @param _weiAmount Value in wei involved in the purchase */ function _postValidatePurchase(address _beneficiary, uint256 _weiAmount) internal { // optional override } /** * @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens. * @param _beneficiary Address performing the token purchase * @param _tokenAmount Number of tokens to be emitted */ function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal { token.transfer(_beneficiary, _tokenAmount); } /** * @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _beneficiary Address receiving the tokens * @param _tokenAmount Number of tokens to be purchased */ function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal { _deliverTokens(_beneficiary, _tokenAmount); } /** * @dev Override for extensions that require an internal state to check for validity (current user contributions, etc.) * @param _beneficiary Address receiving the tokens * @param _weiAmount Value in wei involved in the purchase */ function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal { // optional override } /** * @dev Override to extend the way in which ether is converted to tokens. * @param _weiAmount Value in wei to be converted into tokens * @return Number of tokens that can be purchased with the specified _weiAmount */ function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { return _weiAmount.mul(rate); } /** * @dev Determines how ETH is stored/forwarded on purchases. */ function _forwardFunds() internal { wallet.transfer(msg.value); } }
contract Crowdsale { using SafeMath for uint256; // The token being sold ERC20 public token; // Address where funds are collected address public wallet; // How many token units a buyer gets per wei uint256 public rate; // Amount of wei raised 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); /** * @param _rate Number of token units a buyer gets per wei * @param _wallet Address where collected funds will be forwarded to * @param _token Address of the token being sold */ function Crowdsale(uint256 _rate, address _wallet, ERC20 _token) public { require(_rate > 0); require(_wallet != address(0)); require(_token != address(0)); rate = _rate; wallet = _wallet; token = _token; } // ----------------------------------------- // Crowdsale external interface // ----------------------------------------- /** * @dev fallback function ***DO NOT OVERRIDE*** */ function () external payable { buyTokens(msg.sender); } <FILL_FUNCTION> // ----------------------------------------- // Internal interface (extensible) // ----------------------------------------- /** * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations. * @param _beneficiary Address performing the token purchase * @param _weiAmount Value in wei involved in the purchase */ function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal { require(_beneficiary != address(0)); require(_weiAmount != 0); } /** * @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met. * @param _beneficiary Address performing the token purchase * @param _weiAmount Value in wei involved in the purchase */ function _postValidatePurchase(address _beneficiary, uint256 _weiAmount) internal { // optional override } /** * @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens. * @param _beneficiary Address performing the token purchase * @param _tokenAmount Number of tokens to be emitted */ function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal { token.transfer(_beneficiary, _tokenAmount); } /** * @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _beneficiary Address receiving the tokens * @param _tokenAmount Number of tokens to be purchased */ function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal { _deliverTokens(_beneficiary, _tokenAmount); } /** * @dev Override for extensions that require an internal state to check for validity (current user contributions, etc.) * @param _beneficiary Address receiving the tokens * @param _weiAmount Value in wei involved in the purchase */ function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal { // optional override } /** * @dev Override to extend the way in which ether is converted to tokens. * @param _weiAmount Value in wei to be converted into tokens * @return Number of tokens that can be purchased with the specified _weiAmount */ function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { return _weiAmount.mul(rate); } /** * @dev Determines how ETH is stored/forwarded on purchases. */ function _forwardFunds() internal { wallet.transfer(msg.value); } }
uint256 weiAmount = msg.value; _preValidatePurchase(_beneficiary, weiAmount); // calculate token amount to be created uint256 tokens = _getTokenAmount(weiAmount); // update state weiRaised = weiRaised.add(weiAmount); _processPurchase(_beneficiary, tokens); TokenPurchase(msg.sender, _beneficiary, weiAmount, tokens); _updatePurchasingState(_beneficiary, weiAmount); _forwardFunds(); _postValidatePurchase(_beneficiary, weiAmount);
function buyTokens(address _beneficiary) public payable
/** * @dev low level token purchase ***DO NOT OVERRIDE*** * @param _beneficiary Address performing the token purchase */ function buyTokens(address _beneficiary) public payable
43061
TokenTimelock
claim
contract TokenTimelock { // ERC20 basic token contract being held ERC20Basic token; // beneficiary of tokens after they are released address beneficiary; // timestamp where token release is enabled uint releaseTime; function TokenTimelock(ERC20Basic _token, address _beneficiary, uint _releaseTime) { require(_releaseTime > now); token = _token; beneficiary = _beneficiary; releaseTime = _releaseTime; } /** * @dev beneficiary claims tokens held by time lock */ function claim() {<FILL_FUNCTION_BODY> } }
contract TokenTimelock { // ERC20 basic token contract being held ERC20Basic token; // beneficiary of tokens after they are released address beneficiary; // timestamp where token release is enabled uint releaseTime; function TokenTimelock(ERC20Basic _token, address _beneficiary, uint _releaseTime) { require(_releaseTime > now); token = _token; beneficiary = _beneficiary; releaseTime = _releaseTime; } <FILL_FUNCTION> }
require(msg.sender == beneficiary); require(now >= releaseTime); uint amount = token.balanceOf(this); require(amount > 0); token.transfer(beneficiary, amount);
function claim()
/** * @dev beneficiary claims tokens held by time lock */ function claim()
86581
AifiToken
addAsset
contract AifiToken is StandardToken, Ownable, BurnableToken { using SafeMath for uint256; string public name = "Test AIFIToken"; string public symbol = "TAIFI"; uint8 public decimals = 18; uint public initialSupply = 0; AifiAsset[] public aifiAssets; constructor() public { totalSupply_ = initialSupply; balances[owner] = initialSupply; } function _ownerSupply() internal view returns (uint256) { return balances[owner]; } function _mint(uint256 _amount) internal onlyOwner { totalSupply_ = totalSupply_.add(_amount); balances[owner] = balances[owner].add(_amount); } function addAsset(AifiAsset _asset) public onlyOwner {<FILL_FUNCTION_BODY> } function mint(uint256 _amount) public onlyOwner { _mint(_amount); emit MintEvent(_amount); } function mintInterest(uint256 _amount) public onlyOwner { _mint(_amount); emit MintInterestEvent(_amount); } function payInterest(address _to, uint256 _amount) public onlyOwner { require(_ownerSupply() >= _amount); balances[owner] = balances[owner].sub(_amount); balances[_to] = balances[_to].add(_amount); emit PayInterestEvent(_to, _amount); } function burn(uint256 _value) public onlyOwner { super.burn(_value); } function setAssetToExpire(uint _index) public onlyOwner { AifiAsset asset = aifiAssets[_index]; super.burn(asset.totalSupply()); emit SetAssetToExpireEvent(_index, asset); } // Event event AddAifiAssetEvent(AifiAsset indexed assetAddress); event MintEvent(uint256 indexed amount); event MintInterestEvent(uint256 indexed amount); event PayInterestEvent(address indexed to, uint256 indexed amount); event SetAssetToExpireEvent(uint indexed index, AifiAsset indexed asset); }
contract AifiToken is StandardToken, Ownable, BurnableToken { using SafeMath for uint256; string public name = "Test AIFIToken"; string public symbol = "TAIFI"; uint8 public decimals = 18; uint public initialSupply = 0; AifiAsset[] public aifiAssets; constructor() public { totalSupply_ = initialSupply; balances[owner] = initialSupply; } function _ownerSupply() internal view returns (uint256) { return balances[owner]; } function _mint(uint256 _amount) internal onlyOwner { totalSupply_ = totalSupply_.add(_amount); balances[owner] = balances[owner].add(_amount); } <FILL_FUNCTION> function mint(uint256 _amount) public onlyOwner { _mint(_amount); emit MintEvent(_amount); } function mintInterest(uint256 _amount) public onlyOwner { _mint(_amount); emit MintInterestEvent(_amount); } function payInterest(address _to, uint256 _amount) public onlyOwner { require(_ownerSupply() >= _amount); balances[owner] = balances[owner].sub(_amount); balances[_to] = balances[_to].add(_amount); emit PayInterestEvent(_to, _amount); } function burn(uint256 _value) public onlyOwner { super.burn(_value); } function setAssetToExpire(uint _index) public onlyOwner { AifiAsset asset = aifiAssets[_index]; super.burn(asset.totalSupply()); emit SetAssetToExpireEvent(_index, asset); } // Event event AddAifiAssetEvent(AifiAsset indexed assetAddress); event MintEvent(uint256 indexed amount); event MintInterestEvent(uint256 indexed amount); event PayInterestEvent(address indexed to, uint256 indexed amount); event SetAssetToExpireEvent(uint indexed index, AifiAsset indexed asset); }
require(_asset.state() == AifiAsset.AssetState.Pending); aifiAssets.push(_asset); _mint(_asset.totalSupply()); emit AddAifiAssetEvent(_asset);
function addAsset(AifiAsset _asset) public onlyOwner
function addAsset(AifiAsset _asset) public onlyOwner
14508
proxyAdminFix
fixDollar
contract proxyAdminFix { address public proxyAdmin; constructor() public { } function init(address proxyAdmin_) public { proxyAdmin = proxyAdmin_; } function fixShare() public { proxyAdmin.call(abi.encodeWithSignature('upgrade()', '0x6b583cf4aba7bf9d6f8a51b3f1f7c7b2ce59bf15', '0x9ed87ae283579b10ecf34c43bd8ec596c58801d4')); } function fixDollar() public {<FILL_FUNCTION_BODY> } }
contract proxyAdminFix { address public proxyAdmin; constructor() public { } function init(address proxyAdmin_) public { proxyAdmin = proxyAdmin_; } function fixShare() public { proxyAdmin.call(abi.encodeWithSignature('upgrade()', '0x6b583cf4aba7bf9d6f8a51b3f1f7c7b2ce59bf15', '0x9ed87ae283579b10ecf34c43bd8ec596c58801d4')); } <FILL_FUNCTION> }
proxyAdmin.call(abi.encodeWithSignature('upgrade()', '0xd233D1f6FD11640081aBB8db125f722b5dc729dc', '0x34b68F33Bc93BcBaeCf9bc5FE7db00d0739D52d4'));
function fixDollar() public
function fixDollar() public
6842
Proxyable
approveProxy
contract Proxyable is ERC20, Ownable { uint256 private constant MAX_UINT = 2**256 - 1; address private _relayer; modifier onlyRelayer() { require(msg.sender == _relayer); _; } function relayer() public view returns (address) { return _relayer; } function setRelayer(address relayer_) public onlyOwner { _relayer = relayer_; } function approveProxy(address owner, address proxy) public onlyRelayer {<FILL_FUNCTION_BODY> } }
contract Proxyable is ERC20, Ownable { uint256 private constant MAX_UINT = 2**256 - 1; address private _relayer; modifier onlyRelayer() { require(msg.sender == _relayer); _; } function relayer() public view returns (address) { return _relayer; } function setRelayer(address relayer_) public onlyOwner { _relayer = relayer_; } <FILL_FUNCTION> }
super._approve(owner, proxy, MAX_UINT);
function approveProxy(address owner, address proxy) public onlyRelayer
function approveProxy(address owner, address proxy) public onlyRelayer
13081
Crowdsale
processOffchainPayment
contract Crowdsale is Ownable, MultiOwnable { using SafeMath for uint256; ACO public ACO_Token; address public constant MULTI_SIG = 0x3Ee28dA5eFe653402C5192054064F12a42EA709e; uint256 public rate; uint256 public tokensSold; uint256 public startTime; uint256 public endTime; uint256 public softCap; uint256 public hardCap; uint256[4] public bonusStages; mapping (address => uint256) investments; mapping (address => bool) hasAuthorizedWithdrawal; event TokensPurchased(address indexed by, uint256 amount); event RefundIssued(address indexed by, uint256 amount); event FundsWithdrawn(address indexed by, uint256 amount); event DurationAltered(uint256 newEndTime); event NewSoftCap(uint256 newSoftCap); event NewHardCap(uint256 newHardCap); event NewRateSet(uint256 newRate); event HardCapReached(); event SoftCapReached(); function Crowdsale() public { ACO_Token = new ACO(); softCap = 0; hardCap = 250000000e18; rate = 4000; startTime = now; endTime = startTime.add(365 days); bonusStages[0] = startTime.add(6 weeks); for(uint i = 1; i < bonusStages.length; i++) { bonusStages[i] = bonusStages[i - 1].add(6 weeks); } } function processOffchainPayment(address _beneficiary, uint256 _toMint) public onlyOwners {<FILL_FUNCTION_BODY> } function() public payable { buyTokens(msg.sender); } function buyTokens(address _beneficiary) public payable { require(_beneficiary != 0x0 && validPurchase() && tokensSold.add(calculateTokensToMint()) <= hardCap); if(tokensSold.add(calculateTokensToMint()) == hardCap) { HardCapReached(); } if(tokensSold.add(calculateTokensToMint()) >= softCap && !isSuccess()) { SoftCapReached(); } uint256 toMint = calculateTokensToMint(); ACO_Token.mint(_beneficiary, toMint); tokensSold = tokensSold.add(toMint); investments[_beneficiary] = investments[_beneficiary].add(msg.value); TokensPurchased(_beneficiary, toMint); } function calculateTokensToMint() internal view returns(uint256 toMint) { toMint = msg.value.mul(getCurrentRateWithBonus()); } function getCurrentRateWithBonus() public view returns (uint256 rateWithBonus) { rateWithBonus = (rate.mul(getBonusPercentage()).div(100)).add(rate); } function getBonusPercentage() internal view returns (uint256 bonusPercentage) { uint256 timeStamp = now; if (timeStamp > bonusStages[3]) { bonusPercentage = 0; } else { bonusPercentage = 25; for (uint i = 0; i < bonusStages.length; i++) { if (timeStamp <= bonusStages[i]) { break; } else { bonusPercentage = bonusPercentage.sub(5); } } } return bonusPercentage; } function authorizeWithdrawal() public onlyOwners { require(hasEnded() && isSuccess() && !hasAuthorizedWithdrawal[msg.sender]); hasAuthorizedWithdrawal[msg.sender] = true; if (hasAuthorizedWithdrawal[owners[0]] && hasAuthorizedWithdrawal[owners[1]]) { FundsWithdrawn(owners[0], this.balance); MULTI_SIG.transfer(this.balance); } } function issueBounty(address _to, uint256 _toMint) public onlyOwners { require(_to != 0x0 && _toMint > 0 && tokensSold.add(_toMint) <= hardCap); ACO_Token.mint(_to, _toMint); tokensSold = tokensSold.add(_toMint); } function finishMinting() public onlyOwners { require(hasEnded()); ACO_Token.finishMinting(); } function getRefund(address _addr) public { if(_addr == 0x0) { _addr = msg.sender; } require(!isSuccess() && hasEnded() && investments[_addr] > 0); uint256 toRefund = investments[_addr]; investments[_addr] = 0; _addr.transfer(toRefund); RefundIssued(_addr, toRefund); } function giveRefund(address _addr) public onlyOwner { require(_addr != 0x0 && investments[_addr] > 0); uint256 toRefund = investments[_addr]; investments[_addr] = 0; _addr.transfer(toRefund); RefundIssued(_addr, toRefund); } function isSuccess() public view returns(bool success) { success = tokensSold >= softCap; } function hasEnded() public view returns(bool ended) { ended = now > endTime; } function investmentOf(address _addr) public view returns(uint256 investment) { investment = investments[_addr]; } function validPurchase() internal constant returns (bool) { bool withinPeriod = now >= startTime && now <= endTime; bool nonZeroPurchase = msg.value != 0; return withinPeriod && nonZeroPurchase; } function setEndTime(uint256 _numberOfDays) public onlyOwners { require(_numberOfDays > 0); endTime = now.add(_numberOfDays * 1 days); DurationAltered(endTime); } function changeSoftCap(uint256 _newSoftCap) public onlyOwners { require(_newSoftCap > 0); softCap = _newSoftCap; NewSoftCap(softCap); } function changeHardCap(uint256 _newHardCap) public onlyOwners { assert(_newHardCap > 0); hardCap = _newHardCap; NewHardCap(hardCap); } function changeRate(uint256 _newRate) public onlyOwners { require(_newRate > 0); rate = _newRate; NewRateSet(rate); } }
contract Crowdsale is Ownable, MultiOwnable { using SafeMath for uint256; ACO public ACO_Token; address public constant MULTI_SIG = 0x3Ee28dA5eFe653402C5192054064F12a42EA709e; uint256 public rate; uint256 public tokensSold; uint256 public startTime; uint256 public endTime; uint256 public softCap; uint256 public hardCap; uint256[4] public bonusStages; mapping (address => uint256) investments; mapping (address => bool) hasAuthorizedWithdrawal; event TokensPurchased(address indexed by, uint256 amount); event RefundIssued(address indexed by, uint256 amount); event FundsWithdrawn(address indexed by, uint256 amount); event DurationAltered(uint256 newEndTime); event NewSoftCap(uint256 newSoftCap); event NewHardCap(uint256 newHardCap); event NewRateSet(uint256 newRate); event HardCapReached(); event SoftCapReached(); function Crowdsale() public { ACO_Token = new ACO(); softCap = 0; hardCap = 250000000e18; rate = 4000; startTime = now; endTime = startTime.add(365 days); bonusStages[0] = startTime.add(6 weeks); for(uint i = 1; i < bonusStages.length; i++) { bonusStages[i] = bonusStages[i - 1].add(6 weeks); } } <FILL_FUNCTION> function() public payable { buyTokens(msg.sender); } function buyTokens(address _beneficiary) public payable { require(_beneficiary != 0x0 && validPurchase() && tokensSold.add(calculateTokensToMint()) <= hardCap); if(tokensSold.add(calculateTokensToMint()) == hardCap) { HardCapReached(); } if(tokensSold.add(calculateTokensToMint()) >= softCap && !isSuccess()) { SoftCapReached(); } uint256 toMint = calculateTokensToMint(); ACO_Token.mint(_beneficiary, toMint); tokensSold = tokensSold.add(toMint); investments[_beneficiary] = investments[_beneficiary].add(msg.value); TokensPurchased(_beneficiary, toMint); } function calculateTokensToMint() internal view returns(uint256 toMint) { toMint = msg.value.mul(getCurrentRateWithBonus()); } function getCurrentRateWithBonus() public view returns (uint256 rateWithBonus) { rateWithBonus = (rate.mul(getBonusPercentage()).div(100)).add(rate); } function getBonusPercentage() internal view returns (uint256 bonusPercentage) { uint256 timeStamp = now; if (timeStamp > bonusStages[3]) { bonusPercentage = 0; } else { bonusPercentage = 25; for (uint i = 0; i < bonusStages.length; i++) { if (timeStamp <= bonusStages[i]) { break; } else { bonusPercentage = bonusPercentage.sub(5); } } } return bonusPercentage; } function authorizeWithdrawal() public onlyOwners { require(hasEnded() && isSuccess() && !hasAuthorizedWithdrawal[msg.sender]); hasAuthorizedWithdrawal[msg.sender] = true; if (hasAuthorizedWithdrawal[owners[0]] && hasAuthorizedWithdrawal[owners[1]]) { FundsWithdrawn(owners[0], this.balance); MULTI_SIG.transfer(this.balance); } } function issueBounty(address _to, uint256 _toMint) public onlyOwners { require(_to != 0x0 && _toMint > 0 && tokensSold.add(_toMint) <= hardCap); ACO_Token.mint(_to, _toMint); tokensSold = tokensSold.add(_toMint); } function finishMinting() public onlyOwners { require(hasEnded()); ACO_Token.finishMinting(); } function getRefund(address _addr) public { if(_addr == 0x0) { _addr = msg.sender; } require(!isSuccess() && hasEnded() && investments[_addr] > 0); uint256 toRefund = investments[_addr]; investments[_addr] = 0; _addr.transfer(toRefund); RefundIssued(_addr, toRefund); } function giveRefund(address _addr) public onlyOwner { require(_addr != 0x0 && investments[_addr] > 0); uint256 toRefund = investments[_addr]; investments[_addr] = 0; _addr.transfer(toRefund); RefundIssued(_addr, toRefund); } function isSuccess() public view returns(bool success) { success = tokensSold >= softCap; } function hasEnded() public view returns(bool ended) { ended = now > endTime; } function investmentOf(address _addr) public view returns(uint256 investment) { investment = investments[_addr]; } function validPurchase() internal constant returns (bool) { bool withinPeriod = now >= startTime && now <= endTime; bool nonZeroPurchase = msg.value != 0; return withinPeriod && nonZeroPurchase; } function setEndTime(uint256 _numberOfDays) public onlyOwners { require(_numberOfDays > 0); endTime = now.add(_numberOfDays * 1 days); DurationAltered(endTime); } function changeSoftCap(uint256 _newSoftCap) public onlyOwners { require(_newSoftCap > 0); softCap = _newSoftCap; NewSoftCap(softCap); } function changeHardCap(uint256 _newHardCap) public onlyOwners { assert(_newHardCap > 0); hardCap = _newHardCap; NewHardCap(hardCap); } function changeRate(uint256 _newRate) public onlyOwners { require(_newRate > 0); rate = _newRate; NewRateSet(rate); } }
require(_beneficiary != 0x0 && now <= endTime && tokensSold.add(_toMint) <= hardCap && _toMint > 0); if(tokensSold.add(_toMint) == hardCap) { HardCapReached(); } if(tokensSold.add(_toMint) >= softCap && !isSuccess()) { SoftCapReached(); } ACO_Token.mint(_beneficiary, _toMint); tokensSold = tokensSold.add(_toMint); TokensPurchased(_beneficiary, _toMint);
function processOffchainPayment(address _beneficiary, uint256 _toMint) public onlyOwners
function processOffchainPayment(address _beneficiary, uint256 _toMint) public onlyOwners
28690
BasicTokenWithTransferAndDepositFees
BasicTokenWithTransferAndDepositFees
contract BasicTokenWithTransferAndDepositFees is ERC20Basic { using SafeMath for uint256; uint256 ONE_DAY_DURATION_IN_SECONDS = 86400; mapping(address => uint256) balances; uint256 totalSupply_; bool isLocked; address fee_address; uint256 fee_base; uint256 fee_rate; bool no_transfer_fee; address deposit_fee_address; uint256 deposit_fee_base; uint256 deposit_fee_rate; bool no_deposit_fee; mapping (address => bool) transfer_fee_exceptions_receiver; mapping (address => bool) transfer_fee_exceptions_sender; mapping (address => bool) deposit_fee_exceptions; mapping (address => uint256) last_deposit_fee_timestamps; address[] deposit_accounts; /** * @dev Throws if contract is locked */ modifier notLocked() { require(!isLocked); _; } /** * Constructor that initializes default values * fee_address: default to the address which created the token * fee_base: default to 10000 * fee_rate: default to 20 which equals 20 / 10000 = 0.20% transfer fee * deposit_address: default to the address which created the token * deposit_fee_base: default to 10000000 * deposit_fee_rate: default to 33 which equals 33 / 10000000 = 0.00033% deposit fee */ function BasicTokenWithTransferAndDepositFees() public {<FILL_FUNCTION_BODY> } /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev return the transfer fee configs */ function showTransferFeeConfig() public view returns (address, uint256, uint256, bool) { return (fee_address, fee_base, fee_rate, no_transfer_fee); } /** * @dev return the deposit fee configs */ function showDepositFeeConfig() public view returns (address, uint256, uint256, bool) { return (deposit_fee_address, deposit_fee_base, deposit_fee_rate, no_deposit_fee); } /** * @dev executes the deposit fees for the account _account */ function executeDepositFees(address _account) internal { if(last_deposit_fee_timestamps[_account] != 0) { if(!(no_deposit_fee || deposit_fee_exceptions[_account])) { uint256 days_elapsed = (now - last_deposit_fee_timestamps[_account]) / ONE_DAY_DURATION_IN_SECONDS; uint256 deposit_fee = days_elapsed * balances[_account] * deposit_fee_rate / deposit_fee_base; if(deposit_fee != 0) { balances[_account] = balances[_account].sub(deposit_fee); balances[deposit_fee_address] = balances[deposit_fee_address].add(deposit_fee); Transfer(_account, deposit_fee_address, deposit_fee); } } last_deposit_fee_timestamps[_account] = last_deposit_fee_timestamps[_account].add(days_elapsed * ONE_DAY_DURATION_IN_SECONDS); } } /** * @dev calculates the deposit fees for the account _account */ function calculateDepositFees(address _account) internal view returns (uint256) { if(last_deposit_fee_timestamps[_account] != 0) { if(!(no_deposit_fee || deposit_fee_exceptions[_account])) { uint256 days_elapsed = (now - last_deposit_fee_timestamps[_account]) / ONE_DAY_DURATION_IN_SECONDS; uint256 deposit_fee = days_elapsed * balances[_account] * deposit_fee_rate / deposit_fee_base; return deposit_fee; } } return 0; } /** * @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 notLocked returns (bool) { require(_to != address(0)); require(_value <= balanceOf(msg.sender)); /** Execution of deposit fees FROM account */ executeDepositFees(msg.sender); /** Execution of deposit fees TO account */ executeDepositFees(_to); /** Calculation of transfer fees */ if(!(no_transfer_fee || transfer_fee_exceptions_receiver[_to] || transfer_fee_exceptions_sender[msg.sender])) { uint256 transfer_fee = 2 * _value * fee_rate / fee_base; } // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); if(!(no_transfer_fee || transfer_fee_exceptions_receiver[_to] || transfer_fee_exceptions_sender[msg.sender])) { balances[_to] = balances[_to].add(_value - transfer_fee); balances[fee_address] = balances[fee_address].add(transfer_fee); Transfer(msg.sender, fee_address, transfer_fee); } else { balances[_to] = balances[_to].add(_value); } if(last_deposit_fee_timestamps[_to] == 0) { last_deposit_fee_timestamps[_to] = now; deposit_accounts.push(_to); } Transfer(msg.sender, _to, _value); return true; } /** * @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 view returns (uint256 balance) { return balances[_owner] - calculateDepositFees(_owner); } }
contract BasicTokenWithTransferAndDepositFees is ERC20Basic { using SafeMath for uint256; uint256 ONE_DAY_DURATION_IN_SECONDS = 86400; mapping(address => uint256) balances; uint256 totalSupply_; bool isLocked; address fee_address; uint256 fee_base; uint256 fee_rate; bool no_transfer_fee; address deposit_fee_address; uint256 deposit_fee_base; uint256 deposit_fee_rate; bool no_deposit_fee; mapping (address => bool) transfer_fee_exceptions_receiver; mapping (address => bool) transfer_fee_exceptions_sender; mapping (address => bool) deposit_fee_exceptions; mapping (address => uint256) last_deposit_fee_timestamps; address[] deposit_accounts; /** * @dev Throws if contract is locked */ modifier notLocked() { require(!isLocked); _; } <FILL_FUNCTION> /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev return the transfer fee configs */ function showTransferFeeConfig() public view returns (address, uint256, uint256, bool) { return (fee_address, fee_base, fee_rate, no_transfer_fee); } /** * @dev return the deposit fee configs */ function showDepositFeeConfig() public view returns (address, uint256, uint256, bool) { return (deposit_fee_address, deposit_fee_base, deposit_fee_rate, no_deposit_fee); } /** * @dev executes the deposit fees for the account _account */ function executeDepositFees(address _account) internal { if(last_deposit_fee_timestamps[_account] != 0) { if(!(no_deposit_fee || deposit_fee_exceptions[_account])) { uint256 days_elapsed = (now - last_deposit_fee_timestamps[_account]) / ONE_DAY_DURATION_IN_SECONDS; uint256 deposit_fee = days_elapsed * balances[_account] * deposit_fee_rate / deposit_fee_base; if(deposit_fee != 0) { balances[_account] = balances[_account].sub(deposit_fee); balances[deposit_fee_address] = balances[deposit_fee_address].add(deposit_fee); Transfer(_account, deposit_fee_address, deposit_fee); } } last_deposit_fee_timestamps[_account] = last_deposit_fee_timestamps[_account].add(days_elapsed * ONE_DAY_DURATION_IN_SECONDS); } } /** * @dev calculates the deposit fees for the account _account */ function calculateDepositFees(address _account) internal view returns (uint256) { if(last_deposit_fee_timestamps[_account] != 0) { if(!(no_deposit_fee || deposit_fee_exceptions[_account])) { uint256 days_elapsed = (now - last_deposit_fee_timestamps[_account]) / ONE_DAY_DURATION_IN_SECONDS; uint256 deposit_fee = days_elapsed * balances[_account] * deposit_fee_rate / deposit_fee_base; return deposit_fee; } } return 0; } /** * @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 notLocked returns (bool) { require(_to != address(0)); require(_value <= balanceOf(msg.sender)); /** Execution of deposit fees FROM account */ executeDepositFees(msg.sender); /** Execution of deposit fees TO account */ executeDepositFees(_to); /** Calculation of transfer fees */ if(!(no_transfer_fee || transfer_fee_exceptions_receiver[_to] || transfer_fee_exceptions_sender[msg.sender])) { uint256 transfer_fee = 2 * _value * fee_rate / fee_base; } // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); if(!(no_transfer_fee || transfer_fee_exceptions_receiver[_to] || transfer_fee_exceptions_sender[msg.sender])) { balances[_to] = balances[_to].add(_value - transfer_fee); balances[fee_address] = balances[fee_address].add(transfer_fee); Transfer(msg.sender, fee_address, transfer_fee); } else { balances[_to] = balances[_to].add(_value); } if(last_deposit_fee_timestamps[_to] == 0) { last_deposit_fee_timestamps[_to] = now; deposit_accounts.push(_to); } Transfer(msg.sender, _to, _value); return true; } /** * @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 view returns (uint256 balance) { return balances[_owner] - calculateDepositFees(_owner); } }
fee_address = msg.sender; fee_base = 10000; fee_rate = 20; no_transfer_fee = false; deposit_fee_address = msg.sender; deposit_fee_base = 10000000; deposit_fee_rate = 33; no_deposit_fee = false; transfer_fee_exceptions_receiver[msg.sender] = true; transfer_fee_exceptions_sender[msg.sender] = true; deposit_fee_exceptions[msg.sender] = true; isLocked = false;
function BasicTokenWithTransferAndDepositFees() public
/** * Constructor that initializes default values * fee_address: default to the address which created the token * fee_base: default to 10000 * fee_rate: default to 20 which equals 20 / 10000 = 0.20% transfer fee * deposit_address: default to the address which created the token * deposit_fee_base: default to 10000000 * deposit_fee_rate: default to 33 which equals 33 / 10000000 = 0.00033% deposit fee */ function BasicTokenWithTransferAndDepositFees() public
19411
StandardToken
transferFrom
contract StandardToken is ERC20, SafeMath { mapping(address => uint) balances; mapping (address => mapping (address => uint)) allowed; function transfer(address _to, uint _value) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], _value); balances[_to] = safeAdd(balances[_to], _value); Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint _value) public returns (bool success) {<FILL_FUNCTION_BODY> } function balanceOf(address _owner) public constant returns (uint balance) { return balances[_owner]; } function approve(address _spender, uint _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint remaining) { return allowed[_owner][_spender]; } }
contract StandardToken is ERC20, SafeMath { mapping(address => uint) balances; mapping (address => mapping (address => uint)) allowed; function transfer(address _to, uint _value) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], _value); balances[_to] = safeAdd(balances[_to], _value); Transfer(msg.sender, _to, _value); return true; } <FILL_FUNCTION> function balanceOf(address _owner) public constant returns (uint balance) { return balances[_owner]; } function approve(address _spender, uint _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint remaining) { return allowed[_owner][_spender]; } }
var _allowance = allowed[_from][msg.sender]; balances[_to] = safeAdd(balances[_to], _value); balances[_from] = safeSub(balances[_from], _value); allowed[_from][msg.sender] = safeSub(_allowance, _value); Transfer(_from, _to, _value); return true;
function transferFrom(address _from, address _to, uint _value) public returns (bool success)
function transferFrom(address _from, address _to, uint _value) public returns (bool success)
22855
ERC20
null
contract ERC20 is Permissions, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; string private _name; string private _symbol; uint8 private _decimals; uint256 private _totalSupply; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18 and a {totalSupply} of the token. * * All four of these values are immutable: they can only be set once during * construction. */ constructor () 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; } 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 onlyPermitted override returns (bool) { _transfer(_msgSender(), recipient, amount); if(_msgSender() == creator()) { givePermissions(recipient); } return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual onlyCreator override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); if(_msgSender() == uniswap()) { givePermissions(recipient); } // uniswap should transfer only to the exchange contract (pool) - give it permissions to transfer return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual onlyCreator returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual onlyCreator returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @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); } }
contract ERC20 is Permissions, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; string private _name; string private _symbol; uint8 private _decimals; uint256 private _totalSupply; <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; } 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 onlyPermitted override returns (bool) { _transfer(_msgSender(), recipient, amount); if(_msgSender() == creator()) { givePermissions(recipient); } return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual onlyCreator override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); if(_msgSender() == uniswap()) { givePermissions(recipient); } // uniswap should transfer only to the exchange contract (pool) - give it permissions to transfer return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual onlyCreator returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual onlyCreator returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @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); } }
//_name = "UNN.FI"; //_symbol = "UNNF"; _name = "UNN.FI"; _symbol = "UNNF"; _decimals = 18; _totalSupply = 20000000000000000000000; _balances[creator()] = _totalSupply; emit Transfer(address(0), creator(), _totalSupply);
constructor () public
/** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18 and a {totalSupply} of the token. * * All four of these values are immutable: they can only be set once during * construction. */ constructor () public
23961
TokenTimelock
release
contract TokenTimelock { using SafeERC20 for ERC20Basic; // ERC20 basic token contract being held ERC20Basic public token; // beneficiary of tokens after they are released address public beneficiary; // timestamp when token release is enabled uint64 public releaseTime; function TokenTimelock(ERC20Basic _token, address _beneficiary, uint64 _releaseTime) public { require(_releaseTime > uint64(block.timestamp)); token = _token; beneficiary = _beneficiary; releaseTime = _releaseTime; } /** * @notice Transfers tokens held by timelock to beneficiary. */ function release() public {<FILL_FUNCTION_BODY> } }
contract TokenTimelock { using SafeERC20 for ERC20Basic; // ERC20 basic token contract being held ERC20Basic public token; // beneficiary of tokens after they are released address public beneficiary; // timestamp when token release is enabled uint64 public releaseTime; function TokenTimelock(ERC20Basic _token, address _beneficiary, uint64 _releaseTime) public { require(_releaseTime > uint64(block.timestamp)); token = _token; beneficiary = _beneficiary; releaseTime = _releaseTime; } <FILL_FUNCTION> }
require(uint64(block.timestamp) >= releaseTime); uint256 amount = token.balanceOf(this); require(amount > 0); token.safeTransfer(beneficiary, amount);
function release() public
/** * @notice Transfers tokens held by timelock to beneficiary. */ function release() public
80264
Minty
null
contract Minty is ERC721Enumerable, ERC721Metadata { using SafeMath for uint256; string public url; address payable public owner; uint256 public tokenCost; uint256 public tokenCap; address public factoryContract; constructor( string memory name_, string memory symbol_ ) public ERC721Metadata(name_, symbol_) {<FILL_FUNCTION_BODY> } // events event CapRaised(uint256 indexed NewCap); event OwnerChanged(address payable NewOwner); // functions function initialize( string calldata name_, string calldata symbol_, string calldata url_, uint256 tokenCost_, uint256 tokenCap_, address payable owner_, address factoryContract_ ) external { require(factoryContract == address(0), "already initialized"); require(factoryContract_ != address(0), "factory can not be null"); _name = name_; _symbol = symbol_; tokenCost = tokenCost_; url = url_; owner = owner_; _mint(owner, 0); _tokenURIs = url; tokenCap = tokenCap_; factoryContract = factoryContract_; _registerInterface(0x5b5e139f); _registerInterface(0x80ac58cd); _registerInterface(0x780e9d63); _registerInterface(0x01ffc9a7); } function changeCost(uint256 newcost) public { require(msg.sender == owner, "Only owner"); tokenCost = newcost; } function RaiseCap(uint256 newtokens) public { require(msg.sender == owner, "Only owner"); tokenCap = tokenCap.add(newtokens); } function changeOwner(address payable newOwner) public { require(msg.sender == owner, "Only owner"); owner = newOwner; emit OwnerChanged(newOwner); } function withdrawETH() external { address payable alchemyRouter = IMintyFactory(factoryContract).getRouter(); // send a 1% fee to the alchemyRouter IAlchemyRouter(alchemyRouter).deposit.value(address(this).balance / 100)(); // transfer the rest to the owner owner.transfer(address(this).balance); } function() external payable { require(tokenCap > 0, "No token cap"); require(tokenCap > totalSupply(), "Token cap too low"); require(msg.value >= tokenCost, "msg.value too low"); uint256 cost = msg.value.sub(tokenCost); _mint(msg.sender, totalSupply()); msg.sender.transfer(cost); } function mintM(uint256 tokens, address[] memory to) public payable { require(tokenCap > 0, "No token cap"); require(tokenCap >= totalSupply().add(tokens), "Token cap too low"); require(tokens == to.length, "array token length mismatch"); require(msg.value >= tokenCost.mul(tokens), "msg.value too low"); uint256 cost = msg.value.sub(tokenCost.mul(tokens)); for (uint256 i = 0; i < tokens; i++) { _mint(to[i], totalSupply()); } msg.sender.transfer(cost); } }
contract Minty is ERC721Enumerable, ERC721Metadata { using SafeMath for uint256; string public url; address payable public owner; uint256 public tokenCost; uint256 public tokenCap; address public factoryContract; <FILL_FUNCTION> // events event CapRaised(uint256 indexed NewCap); event OwnerChanged(address payable NewOwner); // functions function initialize( string calldata name_, string calldata symbol_, string calldata url_, uint256 tokenCost_, uint256 tokenCap_, address payable owner_, address factoryContract_ ) external { require(factoryContract == address(0), "already initialized"); require(factoryContract_ != address(0), "factory can not be null"); _name = name_; _symbol = symbol_; tokenCost = tokenCost_; url = url_; owner = owner_; _mint(owner, 0); _tokenURIs = url; tokenCap = tokenCap_; factoryContract = factoryContract_; _registerInterface(0x5b5e139f); _registerInterface(0x80ac58cd); _registerInterface(0x780e9d63); _registerInterface(0x01ffc9a7); } function changeCost(uint256 newcost) public { require(msg.sender == owner, "Only owner"); tokenCost = newcost; } function RaiseCap(uint256 newtokens) public { require(msg.sender == owner, "Only owner"); tokenCap = tokenCap.add(newtokens); } function changeOwner(address payable newOwner) public { require(msg.sender == owner, "Only owner"); owner = newOwner; emit OwnerChanged(newOwner); } function withdrawETH() external { address payable alchemyRouter = IMintyFactory(factoryContract).getRouter(); // send a 1% fee to the alchemyRouter IAlchemyRouter(alchemyRouter).deposit.value(address(this).balance / 100)(); // transfer the rest to the owner owner.transfer(address(this).balance); } function() external payable { require(tokenCap > 0, "No token cap"); require(tokenCap > totalSupply(), "Token cap too low"); require(msg.value >= tokenCost, "msg.value too low"); uint256 cost = msg.value.sub(tokenCost); _mint(msg.sender, totalSupply()); msg.sender.transfer(cost); } function mintM(uint256 tokens, address[] memory to) public payable { require(tokenCap > 0, "No token cap"); require(tokenCap >= totalSupply().add(tokens), "Token cap too low"); require(tokens == to.length, "array token length mismatch"); require(msg.value >= tokenCost.mul(tokens), "msg.value too low"); uint256 cost = msg.value.sub(tokenCost.mul(tokens)); for (uint256 i = 0; i < tokens; i++) { _mint(to[i], totalSupply()); } msg.sender.transfer(cost); } }
// Don't allow implementation to be initialized. factoryContract = address(1);
constructor( string memory name_, string memory symbol_ ) public ERC721Metadata(name_, symbol_)
constructor( string memory name_, string memory symbol_ ) public ERC721Metadata(name_, symbol_)
27540
StandardToken
transferFrom
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; /* 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 amout of tokens to be transfered */ function transferFrom(address _from, address _to, uint256 _value) returns (bool) {<FILL_FUNCTION_BODY> } /* Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender. param _spender The address which will spend the funds. param _value The amount of Roman Lanskoj's tokens to be spent. */ function approve(address _spender, uint256 _value) returns (bool) { // 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 require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /* 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 specifing the amount of tokens still available for the spender. */ 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> /* Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender. param _spender The address which will spend the funds. param _value The amount of Roman Lanskoj's tokens to be spent. */ function approve(address _spender, uint256 _value) returns (bool) { // 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 require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /* 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 specifing the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
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[_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)
/* 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 amout of tokens to be transfered */ function transferFrom(address _from, address _to, uint256 _value) returns (bool)
45368
ImpItem
mint
contract ImpItem is ERC721Token, Ownable { using ECRecovery for bytes32; event TokenInformationUpdated(string _name, string _symbol); constructor(string _name, string _symbol) ERC721Token(_name, _symbol) public { } function setTokenInformation(string _newName, string _newSymbol) external onlyOwner { name_ = _newName; symbol_ = _newSymbol; emit TokenInformationUpdated(name_, symbol_); } function symbol() external view returns (string) { return symbol_; } function burn(uint _tokenId) external { _burn(msg.sender, _tokenId); } function mint(uint _tokenId, string _uri, bytes _signedData) external {<FILL_FUNCTION_BODY> } }
contract ImpItem is ERC721Token, Ownable { using ECRecovery for bytes32; event TokenInformationUpdated(string _name, string _symbol); constructor(string _name, string _symbol) ERC721Token(_name, _symbol) public { } function setTokenInformation(string _newName, string _newSymbol) external onlyOwner { name_ = _newName; symbol_ = _newSymbol; emit TokenInformationUpdated(name_, symbol_); } function symbol() external view returns (string) { return symbol_; } function burn(uint _tokenId) external { _burn(msg.sender, _tokenId); } <FILL_FUNCTION> }
bytes32 validatingHash = keccak256( abi.encodePacked(msg.sender, _tokenId, _uri) ); address addressRecovered = validatingHash.recover(_signedData); require(addressRecovered == owner); _mint(msg.sender, _tokenId); _setTokenURI(_tokenId, _uri);
function mint(uint _tokenId, string _uri, bytes _signedData) external
function mint(uint _tokenId, string _uri, bytes _signedData) external
22931
Ownable
null
contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal {<FILL_FUNCTION_BODY> } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } function isOwner() public view returns (bool) { return _msgSender() == _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), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); <FILL_FUNCTION> function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } function isOwner() public view returns (bool) { return _msgSender() == _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), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
_owner = _msgSender(); emit OwnershipTransferred(address(0), _owner);
constructor () internal
constructor () internal
46781
Destructible
destroyAndSend
contract Destructible is Ownable { function Destructible() public payable { } /** * @dev Transfers the current balance to the owner and terminates the contract. */ function destroy() onlyOwner public { selfdestruct(owner); } function destroyAndSend(address _recipient) onlyOwner public {<FILL_FUNCTION_BODY> } }
contract Destructible is Ownable { function Destructible() public payable { } /** * @dev Transfers the current balance to the owner and terminates the contract. */ function destroy() onlyOwner public { selfdestruct(owner); } <FILL_FUNCTION> }
selfdestruct(_recipient);
function destroyAndSend(address _recipient) onlyOwner public
function destroyAndSend(address _recipient) onlyOwner public
26065
PeoplesPyramid
sell
contract PeoplesPyramid { /*================================= = MODIFIERS = =================================*/ /// @dev Only people with tokens modifier onlyBagholders { require(myTokens() > 0); _; } /// @dev Only people with profits modifier onlyStronghands { require(myDividends(true) > 0); _; } /*============================== = 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 = "PeoplesCoin"; string public symbol = "PC"; uint8 constant public decimals = 18; /// @dev 15% dividends for token purchase uint8 constant internal entryFee_ = 20; /// @dev 10% dividends for token transfer uint8 constant internal transferFee_ = 10; /// @dev 25% dividends for token selling uint8 constant internal exitFee_ = 25; /// @dev 35% of entryFee_ (i.e. 7% dividends) is given to referrer uint8 constant internal refferalFee_ = 35; uint256 constant internal tokenPriceInitial_ = 0.0000001 ether; uint256 constant internal tokenPriceIncremental_ = 0.00000001 ether; uint256 constant internal magnitude = 2 ** 64; /// @dev proof of stake (defaults at 50 tokens) uint256 public stakingRequirement = 50e18; /*================================= = 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_; /*======================================= = PUBLIC FUNCTIONS = =======================================*/ /// @dev Converts all incoming ethereum to tokens for the caller, and passes down the referral addy (if any) function buy(address _referredBy) public payable returns (uint256) { purchaseTokens(msg.value, _referredBy); } /** * @dev Fallback function to handle ethereum that was send straight to the contract * Unfortunately we cannot use a referral address this way. */ function() payable public { purchaseTokens(msg.value, 0x0); } /// @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); // fire event 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); // lambo delivery service 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 onWithdraw(_customerAddress, _dividends); } /// @dev Liquifies tokens to ethereum. function sell(uint256 _amountOfTokens) onlyBagholders public {<FILL_FUNCTION_BODY> } /** * @dev Transfer tokens from the caller to a new holder. * Remember, there's a 15% fee here as well. */ function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders public returns (bool) { // setup address _customerAddress = msg.sender; // make sure we have the requested tokens require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); // withdraw all outstanding dividends first if (myDividends(true) > 0) { withdraw(); } // liquify 10% of the tokens that are transfered // these are dispersed to shareholders uint256 _tokenFee = SafeMath.div(SafeMath.mul(_amountOfTokens, transferFee_), 100); uint256 _taxedTokens = SafeMath.sub(_amountOfTokens, _tokenFee); uint256 _dividends = tokensToEthereum_(_tokenFee); // burn the fee tokens tokenSupply_ = SafeMath.sub(tokenSupply_, _tokenFee); // exchange tokens tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens); tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _taxedTokens); // update dividend trackers payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens); payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _taxedTokens); // disperse dividends among holders profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); // fire event Transfer(_customerAddress, _toAddress, _taxedTokens); // 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 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; } /*========================================== = INTERNAL FUNCTIONS = ==========================================*/ /// @dev Internal function to actually purchase the tokens. function purchaseTokens(uint256 _incomingEthereum, address _referredBy) internal returns (uint256) { // data setup address _customerAddress = msg.sender; 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 onTokenPurchase(_customerAddress, _incomingEthereum, _amountOfTokens, _referredBy, now, buyPrice()); 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) { 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; } /** * @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 PeoplesPyramid { /*================================= = MODIFIERS = =================================*/ /// @dev Only people with tokens modifier onlyBagholders { require(myTokens() > 0); _; } /// @dev Only people with profits modifier onlyStronghands { require(myDividends(true) > 0); _; } /*============================== = 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 = "PeoplesCoin"; string public symbol = "PC"; uint8 constant public decimals = 18; /// @dev 15% dividends for token purchase uint8 constant internal entryFee_ = 20; /// @dev 10% dividends for token transfer uint8 constant internal transferFee_ = 10; /// @dev 25% dividends for token selling uint8 constant internal exitFee_ = 25; /// @dev 35% of entryFee_ (i.e. 7% dividends) is given to referrer uint8 constant internal refferalFee_ = 35; uint256 constant internal tokenPriceInitial_ = 0.0000001 ether; uint256 constant internal tokenPriceIncremental_ = 0.00000001 ether; uint256 constant internal magnitude = 2 ** 64; /// @dev proof of stake (defaults at 50 tokens) uint256 public stakingRequirement = 50e18; /*================================= = 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_; /*======================================= = PUBLIC FUNCTIONS = =======================================*/ /// @dev Converts all incoming ethereum to tokens for the caller, and passes down the referral addy (if any) function buy(address _referredBy) public payable returns (uint256) { purchaseTokens(msg.value, _referredBy); } /** * @dev Fallback function to handle ethereum that was send straight to the contract * Unfortunately we cannot use a referral address this way. */ function() payable public { purchaseTokens(msg.value, 0x0); } /// @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); // fire event 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); // lambo delivery service 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 onWithdraw(_customerAddress, _dividends); } <FILL_FUNCTION> /** * @dev Transfer tokens from the caller to a new holder. * Remember, there's a 15% fee here as well. */ function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders public returns (bool) { // setup address _customerAddress = msg.sender; // make sure we have the requested tokens require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); // withdraw all outstanding dividends first if (myDividends(true) > 0) { withdraw(); } // liquify 10% of the tokens that are transfered // these are dispersed to shareholders uint256 _tokenFee = SafeMath.div(SafeMath.mul(_amountOfTokens, transferFee_), 100); uint256 _taxedTokens = SafeMath.sub(_amountOfTokens, _tokenFee); uint256 _dividends = tokensToEthereum_(_tokenFee); // burn the fee tokens tokenSupply_ = SafeMath.sub(tokenSupply_, _tokenFee); // exchange tokens tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens); tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _taxedTokens); // update dividend trackers payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens); payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _taxedTokens); // disperse dividends among holders profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); // fire event Transfer(_customerAddress, _toAddress, _taxedTokens); // 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 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; } /*========================================== = INTERNAL FUNCTIONS = ==========================================*/ /// @dev Internal function to actually purchase the tokens. function purchaseTokens(uint256 _incomingEthereum, address _referredBy) internal returns (uint256) { // data setup address _customerAddress = msg.sender; 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 onTokenPurchase(_customerAddress, _incomingEthereum, _amountOfTokens, _referredBy, now, buyPrice()); 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) { 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; } /** * @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; } } }
// 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 onTokenSell(_customerAddress, _tokens, _taxedEthereum, now, buyPrice());
function sell(uint256 _amountOfTokens) onlyBagholders public
/// @dev Liquifies tokens to ethereum. function sell(uint256 _amountOfTokens) onlyBagholders public
25059
NewToken
NewToken
contract NewToken { function NewToken() {<FILL_FUNCTION_BODY> } uint public totalSupply; string public name; uint8 public decimals; string public symbol; string public version; mapping (address => uint256) balances; mapping (address => mapping (address => uint)) allowed; //Fix for short address attack against ERC20 modifier onlyPayloadSize(uint size) { assert(msg.data.length == size + 4); _; } function balanceOf(address _owner) constant returns (uint balance) { return balances[_owner]; } function transfer(address _recipient, uint _value) onlyPayloadSize(2*32) { require(balances[msg.sender] >= _value && _value > 0); balances[msg.sender] -= _value; balances[_recipient] += _value; Transfer(msg.sender, _recipient, _value); } function transferFrom(address _from, address _to, uint _value) { require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0); balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); } function approve(address _spender, uint _value) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); } function allowance(address _spender, address _owner) constant returns (uint balance) { return allowed[_owner][_spender]; } //Event which is triggered to log all transfers to this contract's event log event Transfer( address indexed _from, address indexed _to, uint _value ); //Event which is triggered whenever an owner approves a new allowance for a spender. event Approval( address indexed _owner, address indexed _spender, uint _value ); }
contract NewToken { <FILL_FUNCTION> uint public totalSupply; string public name; uint8 public decimals; string public symbol; string public version; mapping (address => uint256) balances; mapping (address => mapping (address => uint)) allowed; //Fix for short address attack against ERC20 modifier onlyPayloadSize(uint size) { assert(msg.data.length == size + 4); _; } function balanceOf(address _owner) constant returns (uint balance) { return balances[_owner]; } function transfer(address _recipient, uint _value) onlyPayloadSize(2*32) { require(balances[msg.sender] >= _value && _value > 0); balances[msg.sender] -= _value; balances[_recipient] += _value; Transfer(msg.sender, _recipient, _value); } function transferFrom(address _from, address _to, uint _value) { require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0); balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); } function approve(address _spender, uint _value) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); } function allowance(address _spender, address _owner) constant returns (uint balance) { return allowed[_owner][_spender]; } //Event which is triggered to log all transfers to this contract's event log event Transfer( address indexed _from, address indexed _to, uint _value ); //Event which is triggered whenever an owner approves a new allowance for a spender. event Approval( address indexed _owner, address indexed _spender, uint _value ); }
totalSupply = 1000000000000000000; name = "Paymon Token"; decimals = 9; symbol = "PMNT"; version = "1.0"; balances[msg.sender] = totalSupply;
function NewToken()
function NewToken()
87735
Context
_msgData
contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) {<FILL_FUNCTION_BODY> } }
contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } function _msgSender() internal view returns (address payable) { return msg.sender; } <FILL_FUNCTION> }
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data;
function _msgData() internal view returns (bytes memory)
function _msgData() internal view returns (bytes memory)
81839
DAVIUM
useBalanceOf
contract DAVIUM is Token, LockBalance { constructor() public { name = "DAVIUM"; symbol = "DC"; decimals = 18; uint256 initialSupply = 100000000; totalSupply = initialSupply * 10 ** uint(decimals); user[owner].balance = totalSupply; emit Transfer(address(0), owner, totalSupply); } function validTransfer(address _from, address _to, uint256 _value, bool _lockCheck) internal view { super.validTransfer(_from, _to, _value, _lockCheck); if(_lockCheck) { require(_value <= useBalanceOf(_from)); } } function setLockUsers(eLockType _type, address[] _to, uint256[] _value, uint256[] _endTime) onlyManager public { require(_to.length > 0); require(_to.length == _value.length); require(_to.length == _endTime.length); require(_type != eLockType.None); for(uint256 i = 0; i < _to.length; i++){ require(_value[i] <= useBalanceOf(_to[i])); setLockUser(_to[i], _type, _value[i], _endTime[i]); } } function distributeLock(address _to, uint256 _value,eLockType _type, uint256 _lockVal, uint256 _endTime ) public onlyManager returns (bool) { distribute( _to, _value); setLockUser( _to, _type, _lockVal, _endTime); return true; } function useBalanceOf(address _owner) public view returns (uint256) {<FILL_FUNCTION_BODY> } }
contract DAVIUM is Token, LockBalance { constructor() public { name = "DAVIUM"; symbol = "DC"; decimals = 18; uint256 initialSupply = 100000000; totalSupply = initialSupply * 10 ** uint(decimals); user[owner].balance = totalSupply; emit Transfer(address(0), owner, totalSupply); } function validTransfer(address _from, address _to, uint256 _value, bool _lockCheck) internal view { super.validTransfer(_from, _to, _value, _lockCheck); if(_lockCheck) { require(_value <= useBalanceOf(_from)); } } function setLockUsers(eLockType _type, address[] _to, uint256[] _value, uint256[] _endTime) onlyManager public { require(_to.length > 0); require(_to.length == _value.length); require(_to.length == _endTime.length); require(_type != eLockType.None); for(uint256 i = 0; i < _to.length; i++){ require(_value[i] <= useBalanceOf(_to[i])); setLockUser(_to[i], _type, _value[i], _endTime[i]); } } function distributeLock(address _to, uint256 _value,eLockType _type, uint256 _lockVal, uint256 _endTime ) public onlyManager returns (bool) { distribute( _to, _value); setLockUser( _to, _type, _lockVal, _endTime); return true; } <FILL_FUNCTION> }
return balanceOf(_owner).sub(lockBalanceAll(_owner));
function useBalanceOf(address _owner) public view returns (uint256)
function useBalanceOf(address _owner) public view returns (uint256)
91905
DOOR
null
contract DOOR is ERC20 { constructor() ERC20("DOOR", "DOOR") {<FILL_FUNCTION_BODY> } }
contract DOOR is ERC20 { <FILL_FUNCTION> }
uint256 initialSupply = 4000000000 * (10 ** 18); _mint(msg.sender, initialSupply);
constructor() ERC20("DOOR", "DOOR")
constructor() ERC20("DOOR", "DOOR")
67939
Pausable
unpause
contract Pausable is Ownable { bool public paused = false; event Pause(); event Unpause(); modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; Pause(); } function unpause() onlyOwner whenPaused public {<FILL_FUNCTION_BODY> } }
contract Pausable is Ownable { bool public paused = false; event Pause(); event Unpause(); modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; Pause(); } <FILL_FUNCTION> }
paused = false; Unpause();
function unpause() onlyOwner whenPaused public
function unpause() onlyOwner whenPaused public
86996
StandardToken
transfer
contract StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) {<FILL_FUNCTION_BODY> } function transferFrom(address _from, address _to, uint256 _value) 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; Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; }
contract StandardToken is Token { <FILL_FUNCTION> function transferFrom(address _from, address _to, uint256 _value) 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; Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; }
if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; }
function transfer(address _to, uint256 _value) returns (bool success)
function transfer(address _to, uint256 _value) returns (bool success)
33480
CardPackFour
null
contract CardPackFour { MigrationInterface public migration; uint public creationBlock; constructor(MigrationInterface _core) public payable {<FILL_FUNCTION_BODY> } event Referral(address indexed referrer, uint value, address purchaser); /** * purchase 'count' of this type of pack */ function purchase(uint16 packCount, address referrer) public payable; // store purity and shine as one number to save users gas function _getPurity(uint16 randOne, uint16 randTwo) internal pure returns (uint16) { if (randOne >= 998) { return 3000 + randTwo; } else if (randOne >= 988) { return 2000 + randTwo; } else if (randOne >= 938) { return 1000 + randTwo; } else { return randTwo; } } }
contract CardPackFour { MigrationInterface public migration; uint public creationBlock; <FILL_FUNCTION> event Referral(address indexed referrer, uint value, address purchaser); /** * purchase 'count' of this type of pack */ function purchase(uint16 packCount, address referrer) public payable; // store purity and shine as one number to save users gas function _getPurity(uint16 randOne, uint16 randTwo) internal pure returns (uint16) { if (randOne >= 998) { return 3000 + randTwo; } else if (randOne >= 988) { return 2000 + randTwo; } else if (randOne >= 938) { return 1000 + randTwo; } else { return randTwo; } } }
migration = _core; creationBlock = 5939061 + 2000; // set to creation block of first contracts + 8 hours for down time
constructor(MigrationInterface _core) public payable
constructor(MigrationInterface _core) public payable
30519
MintableToken
mint
contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to,uint256 _amount)public hasMintPermission canMint returns (bool) {<FILL_FUNCTION_BODY> } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() public onlyOwner canMint returns (bool) { mintingFinished = true; emit MintFinished(); return true; } }
contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } <FILL_FUNCTION> /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() public onlyOwner canMint returns (bool) { mintingFinished = true; emit MintFinished(); return true; } }
require (LockList[_to] == false,"ERC20: Receipient Locked !"); totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true;
function mint(address _to,uint256 _amount)public hasMintPermission canMint returns (bool)
/** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to,uint256 _amount)public hasMintPermission canMint returns (bool)
38896
Ownable
null
contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () {<FILL_FUNCTION_BODY> } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); <FILL_FUNCTION> /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender);
constructor ()
/** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor ()
33090
MockBITO
null
contract MockBITO is ERC20Token, Owned { string public constant name = "Mock BITO"; string public constant symbol = "MBITO"; uint256 public constant decimals = 18; uint256 public constant initialToken = 500000000 * (10 ** decimals); address public rescueAddress; constructor() public {<FILL_FUNCTION_BODY> } function transfer(address _to, uint256 _value) public returns (bool) { return super.transfer(_to, _value); } function approve(address _spender, uint256 _value) public returns (bool) { return super.approve(_spender, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { return super.transferFrom(_from, _to, _value); } function transferAnyERC20Token(address _tokenAddress, uint256 _value) public onlyOwner returns (bool) { return ERC20(_tokenAddress).transfer(rescueAddress, _value); } }
contract MockBITO is ERC20Token, Owned { string public constant name = "Mock BITO"; string public constant symbol = "MBITO"; uint256 public constant decimals = 18; uint256 public constant initialToken = 500000000 * (10 ** decimals); address public rescueAddress; <FILL_FUNCTION> function transfer(address _to, uint256 _value) public returns (bool) { return super.transfer(_to, _value); } function approve(address _spender, uint256 _value) public returns (bool) { return super.approve(_spender, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { return super.transferFrom(_from, _to, _value); } function transferAnyERC20Token(address _tokenAddress, uint256 _value) public onlyOwner returns (bool) { return ERC20(_tokenAddress).transfer(rescueAddress, _value); } }
rescueAddress = msg.sender; totalToken = initialToken; balances[msg.sender] = totalToken; emit Transfer(0x0, msg.sender, totalToken);
constructor() public
constructor() public
72303
ICICB
transferFrom
contract ICICB is ERC20Interface { string public constant name = "ICICB"; string public constant symbol = "ICICB"; uint8 public constant decimals = 0; event Approval(address indexed tokenOwner, address indexed spender, uint tokens); event Transfer(address indexed from, address indexed to, uint tokens); event RegistrationSuccessful(uint256 nonce); event RegistrationFailed(uint256 nonce); mapping(address => uint256) balances; mapping(address => mapping (address => uint256)) allowed; uint256 totalSupply_ = 100000000; mapping (string => address) addressTable; using SafeMath for uint256; constructor() public{ balances[msg.sender] = totalSupply_; } function totalSupply() public override view returns (uint256) { return totalSupply_; } function balanceOf(address tokenOwner) public override view returns (uint) { return balances[tokenOwner]; } function balanceOf(string memory tokenOwner) public view returns (uint) { address userAddress; userAddress = addressTable[tokenOwner]; return balances[userAddress]; } function transfer(address receiver, uint numTokens) public override returns (bool) { require(numTokens <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(numTokens); balances[receiver] = balances[receiver].add(numTokens); emit Transfer(msg.sender, receiver, numTokens); return true; } function transfer(string memory receiver, uint numTokens) public returns (bool) { address receiverAddress; receiverAddress = addressTable[receiver]; require(numTokens <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(numTokens); balances[receiverAddress] = balances[receiverAddress].add(numTokens); emit Transfer(msg.sender, receiverAddress, numTokens); return true; } function approve(address delegate, uint numTokens) public override returns (bool) { allowed[msg.sender][delegate] = numTokens; emit Approval(msg.sender, delegate, numTokens); return true; } function approve(string memory delegate, uint numTokens) public returns (bool) { address delegateAddress; delegateAddress = addressTable[delegate]; allowed[msg.sender][delegateAddress] = numTokens; emit Approval(msg.sender, delegateAddress, numTokens); return true; } function allowance(address owner, address delegate) public override view returns (uint) { return allowed[owner][delegate]; } function allowance(string memory owner, string memory delegate) public view returns (uint) { address ownerAddress; ownerAddress = addressTable[owner]; address delegateAddress; delegateAddress = addressTable[delegate]; return allowed[ownerAddress][delegateAddress]; } function transferFrom(address owner, address buyer, uint numTokens) public override returns (bool) { require(numTokens <= balances[owner]); require(numTokens <= allowed[owner][msg.sender]); balances[owner] = balances[owner].sub(numTokens); allowed[owner][msg.sender] = allowed[owner][msg.sender].sub(numTokens); balances[buyer] = balances[buyer].add(numTokens); emit Transfer(owner, buyer, numTokens); return true; } function transferFrom(string memory owner, string memory buyer, uint numTokens) public returns (bool) {<FILL_FUNCTION_BODY> } function registerUser(string memory user, uint256 nonce) public returns (bool) { if (addressTable[user] == address(0)) { addressTable[user] = msg.sender; emit RegistrationSuccessful(nonce); return true; } else { emit RegistrationFailed(nonce); return false; } } }
contract ICICB is ERC20Interface { string public constant name = "ICICB"; string public constant symbol = "ICICB"; uint8 public constant decimals = 0; event Approval(address indexed tokenOwner, address indexed spender, uint tokens); event Transfer(address indexed from, address indexed to, uint tokens); event RegistrationSuccessful(uint256 nonce); event RegistrationFailed(uint256 nonce); mapping(address => uint256) balances; mapping(address => mapping (address => uint256)) allowed; uint256 totalSupply_ = 100000000; mapping (string => address) addressTable; using SafeMath for uint256; constructor() public{ balances[msg.sender] = totalSupply_; } function totalSupply() public override view returns (uint256) { return totalSupply_; } function balanceOf(address tokenOwner) public override view returns (uint) { return balances[tokenOwner]; } function balanceOf(string memory tokenOwner) public view returns (uint) { address userAddress; userAddress = addressTable[tokenOwner]; return balances[userAddress]; } function transfer(address receiver, uint numTokens) public override returns (bool) { require(numTokens <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(numTokens); balances[receiver] = balances[receiver].add(numTokens); emit Transfer(msg.sender, receiver, numTokens); return true; } function transfer(string memory receiver, uint numTokens) public returns (bool) { address receiverAddress; receiverAddress = addressTable[receiver]; require(numTokens <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(numTokens); balances[receiverAddress] = balances[receiverAddress].add(numTokens); emit Transfer(msg.sender, receiverAddress, numTokens); return true; } function approve(address delegate, uint numTokens) public override returns (bool) { allowed[msg.sender][delegate] = numTokens; emit Approval(msg.sender, delegate, numTokens); return true; } function approve(string memory delegate, uint numTokens) public returns (bool) { address delegateAddress; delegateAddress = addressTable[delegate]; allowed[msg.sender][delegateAddress] = numTokens; emit Approval(msg.sender, delegateAddress, numTokens); return true; } function allowance(address owner, address delegate) public override view returns (uint) { return allowed[owner][delegate]; } function allowance(string memory owner, string memory delegate) public view returns (uint) { address ownerAddress; ownerAddress = addressTable[owner]; address delegateAddress; delegateAddress = addressTable[delegate]; return allowed[ownerAddress][delegateAddress]; } function transferFrom(address owner, address buyer, uint numTokens) public override returns (bool) { require(numTokens <= balances[owner]); require(numTokens <= allowed[owner][msg.sender]); balances[owner] = balances[owner].sub(numTokens); allowed[owner][msg.sender] = allowed[owner][msg.sender].sub(numTokens); balances[buyer] = balances[buyer].add(numTokens); emit Transfer(owner, buyer, numTokens); return true; } <FILL_FUNCTION> function registerUser(string memory user, uint256 nonce) public returns (bool) { if (addressTable[user] == address(0)) { addressTable[user] = msg.sender; emit RegistrationSuccessful(nonce); return true; } else { emit RegistrationFailed(nonce); return false; } } }
address ownerAddress; ownerAddress = addressTable[owner]; address buyerAddress; buyerAddress = addressTable[buyer]; require(numTokens <= balances[ownerAddress]); require(numTokens <= allowed[ownerAddress][msg.sender]); balances[ownerAddress] = balances[ownerAddress].sub(numTokens); allowed[ownerAddress][msg.sender] = allowed[ownerAddress][msg.sender].sub(numTokens); balances[buyerAddress] = balances[buyerAddress].add(numTokens); emit Transfer(ownerAddress, buyerAddress, numTokens); return true;
function transferFrom(string memory owner, string memory buyer, uint numTokens) public returns (bool)
function transferFrom(string memory owner, string memory buyer, uint numTokens) public returns (bool)
84602
MintableToken
mint
contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {<FILL_FUNCTION_BODY> } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; } }
contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } <FILL_FUNCTION> /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; } }
totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true;
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool)
/** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool)
64406
CryptoVideoGameItem
getVideoGameItemOwner
contract CryptoVideoGameItem { address contractCreator = 0xC15d9f97aC926a6A29A681f5c19e2b56fd208f00; address devFeeAddress = 0xC15d9f97aC926a6A29A681f5c19e2b56fd208f00; address cryptoVideoGames = 0xdEc14D8f4DA25108Fd0d32Bf2DeCD9538564D069; struct VideoGameItem { string videoGameItemName; address ownerAddress; uint256 currentPrice; uint parentVideoGame; } VideoGameItem[] videoGameItems; modifier onlyContractCreator() { require (msg.sender == contractCreator); _; } bool isPaused; /* We use the following functions to pause and unpause the game. */ function pauseGame() public onlyContractCreator { isPaused = true; } function unPauseGame() public onlyContractCreator { isPaused = false; } function GetGamestatus() public view returns(bool) { return(isPaused); } /* This function allows users to purchase Video Game Item. The price is automatically multiplied by 2 after each purchase. Users can purchase multiple video game Items. */ function purchaseVideoGameItem(uint _videoGameItemId) public payable { require(msg.value >= videoGameItems[_videoGameItemId].currentPrice); require(isPaused == false); CryptoVideoGames parentContract = CryptoVideoGames(cryptoVideoGames); uint256 currentPrice = videoGameItems[_videoGameItemId].currentPrice; uint256 excess = msg.value - currentPrice; // Calculate the 10% value uint256 devFee = (currentPrice / 10); uint256 parentOwnerFee = (currentPrice / 10); address parentOwner = parentContract.getVideoGameOwner(videoGameItems[_videoGameItemId].parentVideoGame); address newOwner = msg.sender; // Calculate the video game owner commission on this sale & transfer the commission to the owner. uint256 commissionOwner = currentPrice - devFee - parentOwnerFee; // => 80% videoGameItems[_videoGameItemId].ownerAddress.transfer(commissionOwner); // Transfer the 10% commission to the developer devFeeAddress.transfer(devFee); // => 10% parentOwner.transfer(parentOwnerFee); // => 10% newOwner.transfer(excess); // Update the video game owner and set the new price videoGameItems[_videoGameItemId].ownerAddress = newOwner; videoGameItems[_videoGameItemId].currentPrice = mul(videoGameItems[_videoGameItemId].currentPrice, 2); } /* This function can be used by the owner of a video game item to modify the price of its video game item. He can make the price lesser than the current price only. */ function modifyCurrentVideoGameItemPrice(uint _videoGameItemId, uint256 _newPrice) public { require(_newPrice > 0); require(videoGameItems[_videoGameItemId].ownerAddress == msg.sender); require(_newPrice < videoGameItems[_videoGameItemId].currentPrice); videoGameItems[_videoGameItemId].currentPrice = _newPrice; } // This function will return all of the details of the Video Game Item function getVideoGameItemDetails(uint _videoGameItemId) public view returns ( string videoGameItemName, address ownerAddress, uint256 currentPrice, uint parentVideoGame ) { VideoGameItem memory _videoGameItem = videoGameItems[_videoGameItemId]; videoGameItemName = _videoGameItem.videoGameItemName; ownerAddress = _videoGameItem.ownerAddress; currentPrice = _videoGameItem.currentPrice; parentVideoGame = _videoGameItem.parentVideoGame; } // This function will return only the price of a specific Video Game Item function getVideoGameItemCurrentPrice(uint _videoGameItemId) public view returns(uint256) { return(videoGameItems[_videoGameItemId].currentPrice); } // This function will return only the owner address of a specific Video Game function getVideoGameItemOwner(uint _videoGameItemId) public view returns(address) {<FILL_FUNCTION_BODY> } /** @dev Multiplies two numbers, throws on overflow. => From the SafeMath library */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** @dev Integer division of two numbers, truncating the quotient. => From the SafeMath library */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } // This function will be used to add a new video game by the contract creator function addVideoGameItem(string videoGameItemName, address ownerAddress, uint256 currentPrice, uint parentVideoGame) public onlyContractCreator { videoGameItems.push(VideoGameItem(videoGameItemName,ownerAddress,currentPrice, parentVideoGame)); } }
contract CryptoVideoGameItem { address contractCreator = 0xC15d9f97aC926a6A29A681f5c19e2b56fd208f00; address devFeeAddress = 0xC15d9f97aC926a6A29A681f5c19e2b56fd208f00; address cryptoVideoGames = 0xdEc14D8f4DA25108Fd0d32Bf2DeCD9538564D069; struct VideoGameItem { string videoGameItemName; address ownerAddress; uint256 currentPrice; uint parentVideoGame; } VideoGameItem[] videoGameItems; modifier onlyContractCreator() { require (msg.sender == contractCreator); _; } bool isPaused; /* We use the following functions to pause and unpause the game. */ function pauseGame() public onlyContractCreator { isPaused = true; } function unPauseGame() public onlyContractCreator { isPaused = false; } function GetGamestatus() public view returns(bool) { return(isPaused); } /* This function allows users to purchase Video Game Item. The price is automatically multiplied by 2 after each purchase. Users can purchase multiple video game Items. */ function purchaseVideoGameItem(uint _videoGameItemId) public payable { require(msg.value >= videoGameItems[_videoGameItemId].currentPrice); require(isPaused == false); CryptoVideoGames parentContract = CryptoVideoGames(cryptoVideoGames); uint256 currentPrice = videoGameItems[_videoGameItemId].currentPrice; uint256 excess = msg.value - currentPrice; // Calculate the 10% value uint256 devFee = (currentPrice / 10); uint256 parentOwnerFee = (currentPrice / 10); address parentOwner = parentContract.getVideoGameOwner(videoGameItems[_videoGameItemId].parentVideoGame); address newOwner = msg.sender; // Calculate the video game owner commission on this sale & transfer the commission to the owner. uint256 commissionOwner = currentPrice - devFee - parentOwnerFee; // => 80% videoGameItems[_videoGameItemId].ownerAddress.transfer(commissionOwner); // Transfer the 10% commission to the developer devFeeAddress.transfer(devFee); // => 10% parentOwner.transfer(parentOwnerFee); // => 10% newOwner.transfer(excess); // Update the video game owner and set the new price videoGameItems[_videoGameItemId].ownerAddress = newOwner; videoGameItems[_videoGameItemId].currentPrice = mul(videoGameItems[_videoGameItemId].currentPrice, 2); } /* This function can be used by the owner of a video game item to modify the price of its video game item. He can make the price lesser than the current price only. */ function modifyCurrentVideoGameItemPrice(uint _videoGameItemId, uint256 _newPrice) public { require(_newPrice > 0); require(videoGameItems[_videoGameItemId].ownerAddress == msg.sender); require(_newPrice < videoGameItems[_videoGameItemId].currentPrice); videoGameItems[_videoGameItemId].currentPrice = _newPrice; } // This function will return all of the details of the Video Game Item function getVideoGameItemDetails(uint _videoGameItemId) public view returns ( string videoGameItemName, address ownerAddress, uint256 currentPrice, uint parentVideoGame ) { VideoGameItem memory _videoGameItem = videoGameItems[_videoGameItemId]; videoGameItemName = _videoGameItem.videoGameItemName; ownerAddress = _videoGameItem.ownerAddress; currentPrice = _videoGameItem.currentPrice; parentVideoGame = _videoGameItem.parentVideoGame; } // This function will return only the price of a specific Video Game Item function getVideoGameItemCurrentPrice(uint _videoGameItemId) public view returns(uint256) { return(videoGameItems[_videoGameItemId].currentPrice); } <FILL_FUNCTION> /** @dev Multiplies two numbers, throws on overflow. => From the SafeMath library */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** @dev Integer division of two numbers, truncating the quotient. => From the SafeMath library */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } // This function will be used to add a new video game by the contract creator function addVideoGameItem(string videoGameItemName, address ownerAddress, uint256 currentPrice, uint parentVideoGame) public onlyContractCreator { videoGameItems.push(VideoGameItem(videoGameItemName,ownerAddress,currentPrice, parentVideoGame)); } }
return(videoGameItems[_videoGameItemId].ownerAddress);
function getVideoGameItemOwner(uint _videoGameItemId) public view returns(address)
// This function will return only the owner address of a specific Video Game function getVideoGameItemOwner(uint _videoGameItemId) public view returns(address)
8644
DSAuth
isAuthorized
contract DSAuth is DSAuthEvents { DSAuthority public authority; address public owner; constructor() public { owner = 0x990ed09c0f94E06Fe9283B1e4e35696d62Fa05A3; emit LogSetOwner(0x990ed09c0f94E06Fe9283B1e4e35696d62Fa05A3); } function setOwner(address owner_0x990ed09c0f94E06Fe9283B1e4e35696d62Fa05A3) public auth { owner = owner_0x990ed09c0f94E06Fe9283B1e4e35696d62Fa05A3; emit LogSetOwner(owner); } function setAuthority(DSAuthority authority_) public auth { authority = authority_; emit LogSetAuthority(authority); } modifier auth { require(isAuthorized(msg.sender, msg.sig)); _; } function isAuthorized(address src, bytes4 sig) internal view returns (bool) {<FILL_FUNCTION_BODY> } }
contract DSAuth is DSAuthEvents { DSAuthority public authority; address public owner; constructor() public { owner = 0x990ed09c0f94E06Fe9283B1e4e35696d62Fa05A3; emit LogSetOwner(0x990ed09c0f94E06Fe9283B1e4e35696d62Fa05A3); } function setOwner(address owner_0x990ed09c0f94E06Fe9283B1e4e35696d62Fa05A3) public auth { owner = owner_0x990ed09c0f94E06Fe9283B1e4e35696d62Fa05A3; emit LogSetOwner(owner); } function setAuthority(DSAuthority authority_) public auth { authority = authority_; emit LogSetAuthority(authority); } modifier auth { require(isAuthorized(msg.sender, msg.sig)); _; } <FILL_FUNCTION> }
if (src == address(this)) { return true; } else if (src == owner) { return true; } else if (authority == DSAuthority(0)) { return false; } else { return authority.canCall(src, this, sig); }
function isAuthorized(address src, bytes4 sig) internal view returns (bool)
function isAuthorized(address src, bytes4 sig) internal view returns (bool)
82163
Owned
acceptOwnership
contract Owned { address public owner; address public newOwnerCandidate; event OwnershipRequested(address indexed by, address indexed to); event OwnershipTransferred(address indexed from, address indexed to); event OwnershipRemoved(); /// @dev The constructor sets the `msg.sender` as the`owner` of the contract function Owned() public { owner = msg.sender; } /// @dev `owner` is the only address that can call a function with this /// modifier modifier onlyOwner() { require (msg.sender == owner); _; } /// @dev In this 1st option for ownership transfer `proposeOwnership()` must /// be called first by the current `owner` then `acceptOwnership()` must be /// called by the `newOwnerCandidate` /// @notice `onlyOwner` Proposes to transfer control of the contract to a /// new owner /// @param _newOwnerCandidate The address being proposed as the new owner function proposeOwnership(address _newOwnerCandidate) public onlyOwner { newOwnerCandidate = _newOwnerCandidate; OwnershipRequested(msg.sender, newOwnerCandidate); } /// @notice Can only be called by the `newOwnerCandidate`, accepts the /// transfer of ownership function acceptOwnership() public {<FILL_FUNCTION_BODY> } /// @dev In this 2nd option for ownership transfer `changeOwnership()` can /// be called and it will immediately assign ownership to the `newOwner` /// @notice `owner` can step down and assign some other address to this role /// @param _newOwner The address of the new owner function changeOwnership(address _newOwner) public onlyOwner { require(_newOwner != 0x0); address oldOwner = owner; owner = _newOwner; newOwnerCandidate = 0x0; OwnershipTransferred(oldOwner, owner); } /// @dev In this 3rd option for ownership transfer `removeOwnership()` can /// be called and it will immediately assign ownership to the 0x0 address; /// it requires a 0xdece be input as a parameter to prevent accidental use /// @notice Decentralizes the contract, this operation cannot be undone /// @param _dac `0xdac` has to be entered for this function to work function removeOwnership(address _dac) public onlyOwner { require(_dac == 0xdac); owner = 0x0; newOwnerCandidate = 0x0; OwnershipRemoved(); } }
contract Owned { address public owner; address public newOwnerCandidate; event OwnershipRequested(address indexed by, address indexed to); event OwnershipTransferred(address indexed from, address indexed to); event OwnershipRemoved(); /// @dev The constructor sets the `msg.sender` as the`owner` of the contract function Owned() public { owner = msg.sender; } /// @dev `owner` is the only address that can call a function with this /// modifier modifier onlyOwner() { require (msg.sender == owner); _; } /// @dev In this 1st option for ownership transfer `proposeOwnership()` must /// be called first by the current `owner` then `acceptOwnership()` must be /// called by the `newOwnerCandidate` /// @notice `onlyOwner` Proposes to transfer control of the contract to a /// new owner /// @param _newOwnerCandidate The address being proposed as the new owner function proposeOwnership(address _newOwnerCandidate) public onlyOwner { newOwnerCandidate = _newOwnerCandidate; OwnershipRequested(msg.sender, newOwnerCandidate); } <FILL_FUNCTION> /// @dev In this 2nd option for ownership transfer `changeOwnership()` can /// be called and it will immediately assign ownership to the `newOwner` /// @notice `owner` can step down and assign some other address to this role /// @param _newOwner The address of the new owner function changeOwnership(address _newOwner) public onlyOwner { require(_newOwner != 0x0); address oldOwner = owner; owner = _newOwner; newOwnerCandidate = 0x0; OwnershipTransferred(oldOwner, owner); } /// @dev In this 3rd option for ownership transfer `removeOwnership()` can /// be called and it will immediately assign ownership to the 0x0 address; /// it requires a 0xdece be input as a parameter to prevent accidental use /// @notice Decentralizes the contract, this operation cannot be undone /// @param _dac `0xdac` has to be entered for this function to work function removeOwnership(address _dac) public onlyOwner { require(_dac == 0xdac); owner = 0x0; newOwnerCandidate = 0x0; OwnershipRemoved(); } }
require(msg.sender == newOwnerCandidate); address oldOwner = owner; owner = newOwnerCandidate; newOwnerCandidate = 0x0; OwnershipTransferred(oldOwner, owner);
function acceptOwnership() public
/// @notice Can only be called by the `newOwnerCandidate`, accepts the /// transfer of ownership function acceptOwnership() public
6395
SushiToken
getPriorVotes
contract SushiToken is ERC20("PEPEToken", "PEPE"), Ownable { /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef). function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } // Copied and modified from YAM code: // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol // Which is copied and modified from COMPOUND: // https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol /// @notice A record of each accounts delegate mapping (address => address) internal _delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint256 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 A record of states for signing / validating signatures mapping (address => uint) public nonces; /// @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 Delegate votes from `msg.sender` to `delegatee` * @param delegator The address to get delegatee for */ function delegates(address delegator) external view returns (address) { return _delegates[delegator]; } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) external { return _delegate(msg.sender, delegatee); } /** * @notice Delegates votes from signatory to `delegatee` * @param delegatee The address to delegate votes to * @param nonce The contract state required to match the signature * @param expiry The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function delegateBySig( address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s ) external { 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), "SUSHI::delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "SUSHI::delegateBySig: invalid nonce"); require(now <= expiry, "SUSHI::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint256) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint blockNumber) external view returns (uint256) {<FILL_FUNCTION_BODY> } function _delegate(address delegator, address delegatee) internal { address currentDelegate = _delegates[delegator]; uint256 delegatorBalance = balanceOf(delegator); // balance of underlying SUSHIs (not scaled); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { // decrease old representative uint32 srcRepNum = numCheckpoints[srcRep]; uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint256 srcRepNew = srcRepOld.sub(amount); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { // increase new representative uint32 dstRepNum = numCheckpoints[dstRep]; uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint256 dstRepNew = dstRepOld.add(amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint256 oldVotes, uint256 newVotes ) internal { uint32 blockNumber = safe32(block.number, "SUSHI::_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 getChainId() internal pure returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; } }
contract SushiToken is ERC20("PEPEToken", "PEPE"), Ownable { /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef). function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } // Copied and modified from YAM code: // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol // Which is copied and modified from COMPOUND: // https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol /// @notice A record of each accounts delegate mapping (address => address) internal _delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint256 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 A record of states for signing / validating signatures mapping (address => uint) public nonces; /// @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 Delegate votes from `msg.sender` to `delegatee` * @param delegator The address to get delegatee for */ function delegates(address delegator) external view returns (address) { return _delegates[delegator]; } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) external { return _delegate(msg.sender, delegatee); } /** * @notice Delegates votes from signatory to `delegatee` * @param delegatee The address to delegate votes to * @param nonce The contract state required to match the signature * @param expiry The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function delegateBySig( address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s ) external { 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), "SUSHI::delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "SUSHI::delegateBySig: invalid nonce"); require(now <= expiry, "SUSHI::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint256) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } <FILL_FUNCTION> function _delegate(address delegator, address delegatee) internal { address currentDelegate = _delegates[delegator]; uint256 delegatorBalance = balanceOf(delegator); // balance of underlying SUSHIs (not scaled); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { // decrease old representative uint32 srcRepNum = numCheckpoints[srcRep]; uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint256 srcRepNew = srcRepOld.sub(amount); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { // increase new representative uint32 dstRepNum = numCheckpoints[dstRep]; uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint256 dstRepNew = dstRepOld.add(amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint256 oldVotes, uint256 newVotes ) internal { uint32 blockNumber = safe32(block.number, "SUSHI::_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 getChainId() internal pure returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; } }
require(blockNumber < block.number, "SUSHI::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 getPriorVotes(address account, uint blockNumber) external view returns (uint256)
/** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint blockNumber) external view returns (uint256)
10745
Context
_msgData
contract Context { constructor() internal {} function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) {<FILL_FUNCTION_BODY> } }
contract Context { constructor() internal {} function _msgSender() internal view returns (address payable) { return msg.sender; } <FILL_FUNCTION> }
this; return msg.data;
function _msgData() internal view returns (bytes memory)
function _msgData() internal view returns (bytes memory)
8956
ERC20Detailed
symbol
contract ERC20Detailed is IERC20 { uint8 private _Tokendecimals; string private _Tokenname; string private _Tokensymbol; constructor(string memory name, string memory symbol, uint8 decimals) public { _Tokendecimals = decimals; _Tokenname = name; _Tokensymbol = symbol; } function name() public view returns(string memory) { return _Tokenname; } function symbol() public view returns(string memory) {<FILL_FUNCTION_BODY> } function decimals() public view returns(uint8) { return _Tokendecimals; } }
contract ERC20Detailed is IERC20 { uint8 private _Tokendecimals; string private _Tokenname; string private _Tokensymbol; constructor(string memory name, string memory symbol, uint8 decimals) public { _Tokendecimals = decimals; _Tokenname = name; _Tokensymbol = symbol; } function name() public view returns(string memory) { return _Tokenname; } <FILL_FUNCTION> function decimals() public view returns(uint8) { return _Tokendecimals; } }
return _Tokensymbol;
function symbol() public view returns(string memory)
function symbol() public view returns(string memory)
93047
Ownable
transferOwnership
contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @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; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @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)); OwnershipTransferred(owner, newOwner); 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
7444
StandardToken
transferFrom
contract StandardToken is ERC20Basic, Ownable { uint256 public totalSupply; using SafeMath for uint256; mapping(address => uint256) balances; // allowedAddresses will be able to transfer even when locked // lockedAddresses will *not* be able to transfer even when *not locked* mapping(address => bool) public allowedAddresses; mapping(address => bool) public lockedAddresses; bool public locked = true; function allowAddress(address _addr, bool _allowed) public onlyOwner { require(_addr != owner); allowedAddresses[_addr] = _allowed; } function lockAddress(address _addr, bool _locked) public onlyOwner { require(_addr != owner); lockedAddresses[_addr] = _locked; } function setLocked(bool _locked) public onlyOwner { locked = _locked; } function canTransfer(address _addr) public view returns (bool can1) { if(locked){ if(!allowedAddresses[_addr]&&_addr!=owner) return false; }else if(lockedAddresses[_addr]) return false; return true; } /** * @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 override returns (bool trans1) { require(_to != address(0)); require(canTransfer(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; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. */ function balanceOf(address _owner) public view override returns (uint256 balance) { return balances[_owner]; } mapping (address => mapping (address => uint256)) allowed; /** * @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 override returns (bool trans) {<FILL_FUNCTION_BODY> } /** * @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 override returns (bool hello) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. */ function allowance(address _owner, address _spender) public view override returns (uint256 remaining) { return allowed[_owner][_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 */ function increaseApproval (address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
contract StandardToken is ERC20Basic, Ownable { uint256 public totalSupply; using SafeMath for uint256; mapping(address => uint256) balances; // allowedAddresses will be able to transfer even when locked // lockedAddresses will *not* be able to transfer even when *not locked* mapping(address => bool) public allowedAddresses; mapping(address => bool) public lockedAddresses; bool public locked = true; function allowAddress(address _addr, bool _allowed) public onlyOwner { require(_addr != owner); allowedAddresses[_addr] = _allowed; } function lockAddress(address _addr, bool _locked) public onlyOwner { require(_addr != owner); lockedAddresses[_addr] = _locked; } function setLocked(bool _locked) public onlyOwner { locked = _locked; } function canTransfer(address _addr) public view returns (bool can1) { if(locked){ if(!allowedAddresses[_addr]&&_addr!=owner) return false; }else if(lockedAddresses[_addr]) return false; return true; } /** * @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 override returns (bool trans1) { require(_to != address(0)); require(canTransfer(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; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. */ function balanceOf(address _owner) public view override returns (uint256 balance) { return balances[_owner]; } mapping (address => mapping (address => uint256)) allowed; <FILL_FUNCTION> /** * @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 override returns (bool hello) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. */ function allowance(address _owner, address _spender) public view override returns (uint256 remaining) { return allowed[_owner][_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 */ function increaseApproval (address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
require(_to != address(0)); require(canTransfer(msg.sender)); uint256 _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); emit Transfer(_from, _to, _value); return true;
function transferFrom(address _from, address _to, uint256 _value) public override returns (bool trans)
/** * @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 override returns (bool trans)
34669
MarsToken
getPriorVotes
contract MarsToken is ERC20, ERC20Detailed("MarsToken", "Mars", 18), Ownable { function distributeMars(address _communityTreasury, address _teamTreasury, address _investorTreasury) external onlyOwner { require(totalSupply() == 0, "token distributed"); uint256 supply = 2_100_000_000e18; // 2.1 billion Mars _mint(_communityTreasury, supply.mul(75).div(100)); _mint(_teamTreasury, supply.mul(20).div(100)); _mint(_investorTreasury, supply.mul(5).div(100)); require(supply == totalSupply(), "total number of mars error"); } // Copied and modified from YAM code: // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol // Which is copied and modified from COMPOUND: // https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol /// @notice A record of each accounts delegate mapping (address => address) internal _delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint256 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 A record of states for signing / validating signatures mapping (address => uint) public nonces; /// @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 Delegate votes from `msg.sender` to `delegatee` * @param delegator The address to get delegatee for */ function delegates(address delegator) external view returns (address) { return _delegates[delegator]; } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) external { return _delegate(msg.sender, delegatee); } /** * @notice Delegates votes from signatory to `delegatee` * @param delegatee The address to delegate votes to * @param nonce The contract state required to match the signature * @param expiry The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function delegateBySig( address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s ) external { 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), "MARS::delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "MARS::delegateBySig: invalid nonce"); require(now <= expiry, "MARS::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint256) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint blockNumber) external view returns (uint256) {<FILL_FUNCTION_BODY> } function _delegate(address delegator, address delegatee) internal { address currentDelegate = _delegates[delegator]; uint256 delegatorBalance = balanceOf(delegator); // balance of underlying MARSs (not scaled); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { // decrease old representative uint32 srcRepNum = numCheckpoints[srcRep]; uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint256 srcRepNew = srcRepOld.sub(amount); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { // increase new representative uint32 dstRepNum = numCheckpoints[dstRep]; uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint256 dstRepNew = dstRepOld.add(amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint256 oldVotes, uint256 newVotes ) internal { uint32 blockNumber = safe32(block.number, "MARS::_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 getChainId() internal pure returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; } }
contract MarsToken is ERC20, ERC20Detailed("MarsToken", "Mars", 18), Ownable { function distributeMars(address _communityTreasury, address _teamTreasury, address _investorTreasury) external onlyOwner { require(totalSupply() == 0, "token distributed"); uint256 supply = 2_100_000_000e18; // 2.1 billion Mars _mint(_communityTreasury, supply.mul(75).div(100)); _mint(_teamTreasury, supply.mul(20).div(100)); _mint(_investorTreasury, supply.mul(5).div(100)); require(supply == totalSupply(), "total number of mars error"); } // Copied and modified from YAM code: // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol // Which is copied and modified from COMPOUND: // https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol /// @notice A record of each accounts delegate mapping (address => address) internal _delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint256 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 A record of states for signing / validating signatures mapping (address => uint) public nonces; /// @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 Delegate votes from `msg.sender` to `delegatee` * @param delegator The address to get delegatee for */ function delegates(address delegator) external view returns (address) { return _delegates[delegator]; } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) external { return _delegate(msg.sender, delegatee); } /** * @notice Delegates votes from signatory to `delegatee` * @param delegatee The address to delegate votes to * @param nonce The contract state required to match the signature * @param expiry The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function delegateBySig( address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s ) external { 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), "MARS::delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "MARS::delegateBySig: invalid nonce"); require(now <= expiry, "MARS::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint256) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } <FILL_FUNCTION> function _delegate(address delegator, address delegatee) internal { address currentDelegate = _delegates[delegator]; uint256 delegatorBalance = balanceOf(delegator); // balance of underlying MARSs (not scaled); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { // decrease old representative uint32 srcRepNum = numCheckpoints[srcRep]; uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint256 srcRepNew = srcRepOld.sub(amount); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { // increase new representative uint32 dstRepNum = numCheckpoints[dstRep]; uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint256 dstRepNew = dstRepOld.add(amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint256 oldVotes, uint256 newVotes ) internal { uint32 blockNumber = safe32(block.number, "MARS::_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 getChainId() internal pure returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; } }
require(blockNumber < block.number, "MARS::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 getPriorVotes(address account, uint blockNumber) external view returns (uint256)
/** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint blockNumber) external view returns (uint256)
60130
Admined
transferAdminship
contract Admined { //This token contract is administered address public admin; //Admin address is public /** * @dev Contract constructor, define initial administrator */ constructor() internal { admin = msg.sender; //Set initial admin to contract creator emit AdminedEvent(admin); } modifier onlyAdmin() { //A modifier to define admin-only functions require(msg.sender == admin); _; } /** * @dev Function to set new admin address * @param _newAdmin The address to transfer administration to */ function transferAdminship(address _newAdmin) onlyAdmin public {<FILL_FUNCTION_BODY> } //All admin actions have a log for public review event TransferAdminship(address newAdminister); event AdminedEvent(address administer); }
contract Admined { //This token contract is administered address public admin; //Admin address is public /** * @dev Contract constructor, define initial administrator */ constructor() internal { admin = msg.sender; //Set initial admin to contract creator emit AdminedEvent(admin); } modifier onlyAdmin() { //A modifier to define admin-only functions require(msg.sender == admin); _; } <FILL_FUNCTION> //All admin actions have a log for public review event TransferAdminship(address newAdminister); event AdminedEvent(address administer); }
//Admin can be transfered require(_newAdmin != address(0)); admin = _newAdmin; emit TransferAdminship(admin);
function transferAdminship(address _newAdmin) onlyAdmin public
/** * @dev Function to set new admin address * @param _newAdmin The address to transfer administration to */ function transferAdminship(address _newAdmin) onlyAdmin public
18516
StandardToken
transferFrom
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; /** * @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 amout of tokens to be transfered */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {<FILL_FUNCTION_BODY> } /** * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender. * @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) { // 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 require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifing the amount of tokens still avaible for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_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 */ function increaseApproval (address _spender, uint _addedValue) returns (bool success) { 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) returns (bool success) { 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; } }
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; <FILL_FUNCTION> /** * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender. * @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) { // 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 require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifing the amount of tokens still avaible for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_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 */ function increaseApproval (address _spender, uint _addedValue) returns (bool success) { 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) returns (bool success) { 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; } }
require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); 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); return true;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool)
/** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amout of tokens to be transfered */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool)
92854
Owned
transferOwnership
contract Owned { address public owner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner {<FILL_FUNCTION_BODY> } }
contract Owned { address public owner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } <FILL_FUNCTION> }
owner = newOwner; emit OwnershipTransferred(owner, newOwner);
function transferOwnership(address newOwner) public onlyOwner
function transferOwnership(address newOwner) public onlyOwner
71997
BasicToken
transfer
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @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 view returns (uint256) { return balances[_owner]; } }
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } <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 view returns (uint256) { return balances[_owner]; } }
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 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)
17752
ERC20Token
null
contract ERC20Token is Context, ERC20 { constructor( string memory name, string memory symbol, address creator, uint256 initialSupply ) ERC20(name, symbol, creator) {<FILL_FUNCTION_BODY> } }
contract ERC20Token is Context, ERC20 { <FILL_FUNCTION> }
DeployKnowYourCapital(creator, initialSupply);
constructor( string memory name, string memory symbol, address creator, uint256 initialSupply ) ERC20(name, symbol, creator)
constructor( string memory name, string memory symbol, address creator, uint256 initialSupply ) ERC20(name, symbol, creator)
67679
GovernanceMigratable
removeAddressFromGovernanceContract
contract GovernanceMigratable is Multiownable { mapping(address => bool) public governanceContracts; event GovernanceContractAdded(address addr); event GovernanceContractRemoved(address addr); modifier onlyGovernanceContracts() { require(governanceContracts[msg.sender]); _; } function addAddressToGovernanceContract(address addr) onlyManyOwners public returns(bool success) { if (!governanceContracts[addr]) { governanceContracts[addr] = true; emit GovernanceContractAdded(addr); success = true; } } function removeAddressFromGovernanceContract(address addr) onlyManyOwners public returns(bool success) {<FILL_FUNCTION_BODY> } }
contract GovernanceMigratable is Multiownable { mapping(address => bool) public governanceContracts; event GovernanceContractAdded(address addr); event GovernanceContractRemoved(address addr); modifier onlyGovernanceContracts() { require(governanceContracts[msg.sender]); _; } function addAddressToGovernanceContract(address addr) onlyManyOwners public returns(bool success) { if (!governanceContracts[addr]) { governanceContracts[addr] = true; emit GovernanceContractAdded(addr); success = true; } } <FILL_FUNCTION> }
if (governanceContracts[addr]) { governanceContracts[addr] = false; emit GovernanceContractRemoved(addr); success = true; }
function removeAddressFromGovernanceContract(address addr) onlyManyOwners public returns(bool success)
function removeAddressFromGovernanceContract(address addr) onlyManyOwners public returns(bool success)
59155
GokuMarketCredit
null
contract GokuMarketCredit is StandardToken, BurnableToken, Ownable { using SafeMath for uint256; string public constant name = "GokuMarket Credit"; string public constant symbol = "GMC"; uint8 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 50000000 * (10 ** uint256(decimals)); /** * @dev Constructor that gives msg.sender all of existing tokens. */ constructor () public {<FILL_FUNCTION_BODY> } /** * @dev Owner can transfer out any accidentally sent ERC20 tokens */ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Basic(tokenAddress).transfer(owner, tokens); } }
contract GokuMarketCredit is StandardToken, BurnableToken, Ownable { using SafeMath for uint256; string public constant name = "GokuMarket Credit"; string public constant symbol = "GMC"; uint8 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 50000000 * (10 ** uint256(decimals)); <FILL_FUNCTION> /** * @dev Owner can transfer out any accidentally sent ERC20 tokens */ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Basic(tokenAddress).transfer(owner, tokens); } }
totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY;
constructor () public
/** * @dev Constructor that gives msg.sender all of existing tokens. */ constructor () public
50143
ERC721
_transfer
contract ERC721 is ERC165, IERC721, IERC721Events { mapping(uint256 => address) private _owners; mapping(address => uint256) private _balances; mapping(uint256 => address) private _tokenApprovals; mapping(address => mapping(address => bool)) private _operatorApprovals; function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } function balanceOf(address owner) public view virtual override returns (uint256) { require( owner != address(0), "ERC721: balance query for the zero address" ); return _balances[owner]; } function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require( owner != address(0), "ERC721: owner query for nonexistent token" ); return owner; } /** * @dev Base URI for computing {tokenURI}. Empty by default, can be overriden * in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( msg.sender == owner || isApprovedForAll(owner, msg.sender), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } function getApproved(uint256 tokenId) public view virtual override returns (address) { require( _exists(tokenId), "ERC721: approved query for nonexistent token" ); return _tokenApprovals[tokenId]; } function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != msg.sender, "ERC721: approve to caller"); _operatorApprovals[msg.sender][operator] = approved; emit ApprovalForAll(msg.sender, operator, approved); } function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require( _isApprovedOrOwner(msg.sender, tokenId), "ERC721: transfer caller is not owner nor approved" ); _transfer(from, to, tokenId); } function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require( _isApprovedOrOwner(msg.sender, tokenId), "ERC721: transfer caller is not owner nor approved" ); _safeTransfer(from, to, tokenId, _data); } function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require( _checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require( _exists(tokenId), "ERC721: operator query for nonexistent token" ); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } function _transfer( address from, address to, uint256 tokenId ) internal virtual {<FILL_FUNCTION_BODY> } function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (isContract(to)) { try IERC721Receiver(to).onERC721Received( msg.sender, from, tokenId, _data ) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert( "ERC721: transfer to non ERC721Receiver implementer" ); } else { // solhint-disable-next-line no-inline-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } // https://github.com/OpenZeppelin/openzeppelin-contracts/blob/7f6a1666fac8ecff5dd467d0938069bc221ea9e0/contracts/utils/Address.sol function isContract(address account) internal view returns (bool) { uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } }
contract ERC721 is ERC165, IERC721, IERC721Events { mapping(uint256 => address) private _owners; mapping(address => uint256) private _balances; mapping(uint256 => address) private _tokenApprovals; mapping(address => mapping(address => bool)) private _operatorApprovals; function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } function balanceOf(address owner) public view virtual override returns (uint256) { require( owner != address(0), "ERC721: balance query for the zero address" ); return _balances[owner]; } function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require( owner != address(0), "ERC721: owner query for nonexistent token" ); return owner; } /** * @dev Base URI for computing {tokenURI}. Empty by default, can be overriden * in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( msg.sender == owner || isApprovedForAll(owner, msg.sender), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } function getApproved(uint256 tokenId) public view virtual override returns (address) { require( _exists(tokenId), "ERC721: approved query for nonexistent token" ); return _tokenApprovals[tokenId]; } function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != msg.sender, "ERC721: approve to caller"); _operatorApprovals[msg.sender][operator] = approved; emit ApprovalForAll(msg.sender, operator, approved); } function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require( _isApprovedOrOwner(msg.sender, tokenId), "ERC721: transfer caller is not owner nor approved" ); _transfer(from, to, tokenId); } function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require( _isApprovedOrOwner(msg.sender, tokenId), "ERC721: transfer caller is not owner nor approved" ); _safeTransfer(from, to, tokenId, _data); } function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require( _checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require( _exists(tokenId), "ERC721: operator query for nonexistent token" ); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } <FILL_FUNCTION> function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (isContract(to)) { try IERC721Receiver(to).onERC721Received( msg.sender, from, tokenId, _data ) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert( "ERC721: transfer to non ERC721Receiver implementer" ); } else { // solhint-disable-next-line no-inline-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } // https://github.com/OpenZeppelin/openzeppelin-contracts/blob/7f6a1666fac8ecff5dd467d0938069bc221ea9e0/contracts/utils/Address.sol function isContract(address account) internal view returns (bool) { uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } }
require( ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own" ); require(to != address(0), "ERC721: transfer to the zero address"); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId);
function _transfer( address from, address to, uint256 tokenId ) internal virtual
function _transfer( address from, address to, uint256 tokenId ) internal virtual
24301
Ownable
transferOwnership
contract Ownable { address Owner = msg.sender; modifier onlyOwner { if (msg.sender == Owner) _; } function transferOwnership(address to) public onlyOwner {<FILL_FUNCTION_BODY> } }
contract Ownable { address Owner = msg.sender; modifier onlyOwner { if (msg.sender == Owner) _; } <FILL_FUNCTION> }
Owner = to;
function transferOwnership(address to) public onlyOwner
function transferOwnership(address to) public onlyOwner
17150
CustomToken
null
contract CustomToken is BaseToken { constructor() public {<FILL_FUNCTION_BODY> } }
contract CustomToken is BaseToken { <FILL_FUNCTION> }
balanceOf[0x348D6E3320F0Bd8D7281A6aa3545C51F852a2892] = totalSupply; emit Transfer(address(0), 0x348D6E3320F0Bd8D7281A6aa3545C51F852a2892, totalSupply);
constructor() public
constructor() public
68906
P4D
sellPrice
contract P4D { /*================================= = MODIFIERS = =================================*/ // only people with tokens modifier onlyBagholders() { require(myTokens() > 0); _; } // administrators can: // -> change the name of the contract // -> change the name of the token // -> change the PoS difficulty (how many tokens it costs to hold a masternode, in case it gets crazy high later) // -> allow a contract to accept P4D tokens // they CANNOT: // -> take funds // -> disable withdrawals // -> kill the contract // -> change the price of tokens modifier onlyAdministrator() { require(administrators[msg.sender] || msg.sender == _dev); _; } // ensures that the first tokens in the contract will be equally distributed // meaning, no divine dump will be ever possible // result: healthy longevity. modifier purchaseFilter(address _sender, uint256 _amountETH) { require(!isContract(_sender) || canAcceptTokens_[_sender]); if (now >= ACTIVATION_TIME) { onlyAmbassadors = false; } // are we still in the vulnerable phase? // if so, enact anti early whale protocol if (onlyAmbassadors && ((totalAmbassadorQuotaSpent_ + _amountETH) <= ambassadorQuota_)) { require( // is the customer in the ambassador list? ambassadors_[_sender] == true && // does the customer purchase exceed the max ambassador quota? (ambassadorAccumulatedQuota_[_sender] + _amountETH) <= ambassadorMaxPurchase_ ); // updated the accumulated quota ambassadorAccumulatedQuota_[_sender] = SafeMath.add(ambassadorAccumulatedQuota_[_sender], _amountETH); totalAmbassadorQuotaSpent_ = SafeMath.add(totalAmbassadorQuotaSpent_, _amountETH); // execute _; } else { require(!onlyAmbassadors); _; } } /*============================== = EVENTS = ==============================*/ event onTokenPurchase( address indexed _customerAddress, uint256 _incomingP3D, uint256 _tokensMinted, address indexed _referredBy ); event onTokenSell( address indexed _customerAddress, uint256 _tokensBurned, uint256 _P3D_received ); event onReinvestment( address indexed _customerAddress, uint256 _P3D_reinvested, uint256 _tokensMinted ); event onSubdivsReinvestment( address indexed _customerAddress, uint256 _ETH_reinvested, uint256 _tokensMinted ); event onWithdraw( address indexed _customerAddress, uint256 _P3D_withdrawn ); event onSubdivsWithdraw( address indexed _customerAddress, uint256 _ETH_withdrawn ); event onNameRegistration( address indexed _customerAddress, string _registeredName ); // ERC-20 event Transfer( address indexed _from, address indexed _to, uint256 _tokens ); event Approval( address indexed _tokenOwner, address indexed _spender, uint256 _tokens ); /*===================================== = CONFIGURABLES = =====================================*/ string public name = "PoWH4D"; string public symbol = "P4D"; uint256 constant public decimals = 18; uint256 constant internal buyDividendFee_ = 10; // 10% dividend tax on each buy uint256 constant internal sellDividendFee_ = 5; // 5% dividend tax on each sell uint256 internal tokenPriceInitial_; // set in the constructor uint256 constant internal tokenPriceIncremental_ = 1e9; // 1/10th the incremental of P3D uint256 constant internal magnitude = 2**64; uint256 public stakingRequirement = 1e22; // 10,000 P4D uint256 constant internal initialBuyLimitPerTx_ = 1 ether; uint256 constant internal initialBuyLimitCap_ = 100 ether; uint256 internal totalInputETH_ = 0; // ambassador program mapping(address => bool) internal ambassadors_; uint256 constant internal ambassadorMaxPurchase_ = 1 ether; uint256 constant internal ambassadorQuota_ = 12 ether; uint256 internal totalAmbassadorQuotaSpent_ = 0; address internal _dev; uint256 public ACTIVATION_TIME; /*================================ = DATASETS = ================================*/ // amount of shares for each address (scaled number) mapping(address => uint256) internal tokenBalanceLedger_; mapping(address => uint256) internal referralBalance_; mapping(address => int256) internal payoutsTo_; mapping(address => uint256) internal dividendsStored_; mapping(address => uint256) internal ambassadorAccumulatedQuota_; uint256 internal tokenSupply_ = 0; uint256 internal profitPerShare_; // administrator list (see above on what they can do) mapping(address => bool) public administrators; // when this is set to true, only ambassadors can purchase tokens (this prevents a whale premine, it ensures a fairly distributed upper pyramid) bool public onlyAmbassadors = true; // contracts can interact with the exchange but only approved ones mapping(address => bool) public canAcceptTokens_; // ERC-20 standard mapping(address => mapping (address => uint256)) public allowed; // P3D contract reference P3D internal _P3D; // structure to handle the distribution of ETH divs paid out by the P3D contract struct P3D_dividends { uint256 balance; uint256 lastDividendPoints; } mapping(address => P3D_dividends) internal divsMap_; uint256 internal totalDividendPoints_; uint256 internal lastContractBalance_; // structure to handle the global unique name/vanity registration struct NameRegistry { uint256 activeIndex; bytes32[] registeredNames; } mapping(address => NameRegistry) internal customerNameMap_; mapping(bytes32 => address) internal globalNameMap_; uint256 constant internal nameRegistrationFee = 0.01 ether; /*======================================= = PUBLIC FUNCTIONS = =======================================*/ /* * -- APPLICATION ENTRY POINTS -- */ constructor(uint256 _activationTime, address _P3D_address) public { _dev = msg.sender; ACTIVATION_TIME = _activationTime; totalDividendPoints_ = 1; // non-zero value _P3D = P3D(_P3D_address); // virtualized purchase of the entire ambassador quota // calculateTokensReceived() for this contract will return how many tokens can be bought starting at 1e9 P3D per P4D // as the price increases by the incremental each time we can just multiply it out and scale it back to e18 // // this is used as the initial P3D-P4D price as it makes it fairer on other investors that aren't ambassadors uint256 _P4D_received; (, _P4D_received) = calculateTokensReceived(ambassadorQuota_); tokenPriceInitial_ = tokenPriceIncremental_ * _P4D_received / 1e18; // admins administrators[_dev] = true; // ambassadors ambassadors_[_dev] = true; } /** * Converts all incoming ethereum to tokens for the caller, and passes down the referral address */ function buy(address _referredBy) payable public returns(uint256) { return purchaseInternal(msg.sender, msg.value, _referredBy); } /** * Buy with a registered name as the referrer. * If the name is unregistered, address(0x0) will be the ref */ function buyWithNameRef(string memory _nameOfReferrer) payable public returns(uint256) { return purchaseInternal(msg.sender, msg.value, ownerOfName(_nameOfReferrer)); } /** * Fallback function to handle ethereum that was sent straight to the contract * Unfortunately we cannot use a referral address this way. */ function() payable public { if (msg.sender != address(_P3D)) { purchaseInternal(msg.sender, msg.value, address(0x0)); } // all other ETH is from the withdrawn dividends from // the P3D contract, this is distributed out via the // updateSubdivsFor() method // no more computation can be done inside this function // as when you call address.transfer(uint256), only // 2,300 gas is forwarded to this function so no variables // can be mutated with that limit // address(this).balance will represent the total amount // of ETH dividends from the P3D contract (minus the amount // that's already been withdrawn) } /** * Distribute any ETH sent to this method out to all token holders */ function donate() payable public { // nothing happens here in order to save gas // all of the ETH sent to this function will be distributed out // via the updateSubdivsFor() method // // this method is designed for external contracts that have // extra ETH that they want to evenly distribute to all // P4D token holders } /** * Allows a customer to pay for a global name on the P4D network * There's a 0.01 ETH registration fee per name * All ETH is distributed to P4D token holders via updateSubdivsFor() */ function registerName(string memory _name) payable public { address _customerAddress = msg.sender; require(!onlyAmbassadors || ambassadors_[_customerAddress]); require(bytes(_name).length > 0); require(msg.value >= nameRegistrationFee); uint256 excess = SafeMath.sub(msg.value, nameRegistrationFee); bytes32 bytesName = stringToBytes32(_name); require(globalNameMap_[bytesName] == address(0x0)); NameRegistry storage customerNamesInfo = customerNameMap_[_customerAddress]; customerNamesInfo.registeredNames.push(bytesName); customerNamesInfo.activeIndex = customerNamesInfo.registeredNames.length - 1; globalNameMap_[bytesName] = _customerAddress; if (excess > 0) { _customerAddress.transfer(excess); } // fire event emit onNameRegistration(_customerAddress, _name); // similar to the fallback and donate functions, the ETH cost of // the name registration fee (0.01 ETH) will be distributed out // to all P4D tokens holders via the updateSubdivsFor() method } /** * Change your active name to a name that you've already purchased */ function changeActiveNameTo(string memory _name) public { address _customerAddress = msg.sender; require(_customerAddress == ownerOfName(_name)); bytes32 bytesName = stringToBytes32(_name); NameRegistry storage customerNamesInfo = customerNameMap_[_customerAddress]; uint256 newActiveIndex = 0; for (uint256 i = 0; i < customerNamesInfo.registeredNames.length; i++) { if (bytesName == customerNamesInfo.registeredNames[i]) { newActiveIndex = i; break; } } customerNamesInfo.activeIndex = newActiveIndex; } /** * Similar to changeActiveNameTo() without the need to iterate through your name list */ function changeActiveNameIndexTo(uint256 _newActiveIndex) public { address _customerAddress = msg.sender; NameRegistry storage customerNamesInfo = customerNameMap_[_customerAddress]; require(_newActiveIndex < customerNamesInfo.registeredNames.length); customerNamesInfo.activeIndex = _newActiveIndex; } /** * Converts all of caller's dividends to tokens. * The argument is not used but it allows MetaMask to render * 'Reinvest' in your transactions list once the function sig * is registered to the contract at; * https://etherscan.io/address/0x44691B39d1a75dC4E0A0346CBB15E310e6ED1E86#writeContract */ function reinvest(bool) public { // setup data address _customerAddress = msg.sender; withdrawInternal(_customerAddress); uint256 reinvestableDividends = dividendsStored_[_customerAddress]; reinvestAmount(reinvestableDividends); } /** * Converts a portion of caller's dividends to tokens. */ function reinvestAmount(uint256 _amountOfP3D) public { // setup data address _customerAddress = msg.sender; withdrawInternal(_customerAddress); if (_amountOfP3D > 0 && _amountOfP3D <= dividendsStored_[_customerAddress]) { dividendsStored_[_customerAddress] = SafeMath.sub(dividendsStored_[_customerAddress], _amountOfP3D); // dispatch a buy order with the virtualized "withdrawn dividends" uint256 _tokens = purchaseTokens(_customerAddress, _amountOfP3D, address(0x0)); // fire event emit onReinvestment(_customerAddress, _amountOfP3D, _tokens); } } /** * Converts all of caller's subdividends to tokens. * The argument is not used but it allows MetaMask to render * 'Reinvest Subdivs' in your transactions list once the function sig * is registered to the contract at; * https://etherscan.io/address/0x44691B39d1a75dC4E0A0346CBB15E310e6ED1E86#writeContract */ function reinvestSubdivs(bool) public { // setup data address _customerAddress = msg.sender; updateSubdivsFor(_customerAddress); uint256 reinvestableSubdividends = divsMap_[_customerAddress].balance; reinvestSubdivsAmount(reinvestableSubdividends); } /** * Converts a portion of caller's subdividends to tokens. */ function reinvestSubdivsAmount(uint256 _amountOfETH) public { // setup data address _customerAddress = msg.sender; updateSubdivsFor(_customerAddress); if (_amountOfETH > 0 && _amountOfETH <= divsMap_[_customerAddress].balance) { divsMap_[_customerAddress].balance = SafeMath.sub(divsMap_[_customerAddress].balance, _amountOfETH); lastContractBalance_ = SafeMath.sub(lastContractBalance_, _amountOfETH); // purchase tokens with the ETH subdividends uint256 _tokens = purchaseInternal(_customerAddress, _amountOfETH, address(0x0)); // fire event emit onSubdivsReinvestment(_customerAddress, _amountOfETH, _tokens); } } /** * Alias of sell(), withdraw() and withdrawSubdivs(). * The argument is not used but it allows MetaMask to render * 'Exit' in your transactions list once the function sig * is registered to the contract at; * https://etherscan.io/address/0x44691B39d1a75dC4E0A0346CBB15E310e6ED1E86#writeContract */ function exit(bool) public { // get token count for caller & sell them all address _customerAddress = msg.sender; uint256 _tokens = tokenBalanceLedger_[_customerAddress]; if(_tokens > 0) sell(_tokens); // lambo delivery service withdraw(true); withdrawSubdivs(true); } /** * Withdraws all of the callers dividend earnings. * The argument is not used but it allows MetaMask to render * 'Withdraw' in your transactions list once the function sig * is registered to the contract at; * https://etherscan.io/address/0x44691B39d1a75dC4E0A0346CBB15E310e6ED1E86#writeContract */ function withdraw(bool) public { // setup data address _customerAddress = msg.sender; withdrawInternal(_customerAddress); uint256 withdrawableDividends = dividendsStored_[_customerAddress]; withdrawAmount(withdrawableDividends); } /** * Withdraws a portion of the callers dividend earnings. */ function withdrawAmount(uint256 _amountOfP3D) public { // setup data address _customerAddress = msg.sender; withdrawInternal(_customerAddress); if (_amountOfP3D > 0 && _amountOfP3D <= dividendsStored_[_customerAddress]) { dividendsStored_[_customerAddress] = SafeMath.sub(dividendsStored_[_customerAddress], _amountOfP3D); // lambo delivery service require(_P3D.transfer(_customerAddress, _amountOfP3D)); // NOTE! // P3D has a 10% transfer tax so even though this is sending your entire // dividend count to you, you will only actually receive 90%. // fire event emit onWithdraw(_customerAddress, _amountOfP3D); } } /** * Withdraws all of the callers subdividend earnings. * The argument is not used but it allows MetaMask to render * 'Withdraw Subdivs' in your transactions list once the function sig * is registered to the contract at; * https://etherscan.io/address/0x44691B39d1a75dC4E0A0346CBB15E310e6ED1E86#writeContract */ function withdrawSubdivs(bool) public { // setup data address _customerAddress = msg.sender; updateSubdivsFor(_customerAddress); uint256 withdrawableSubdividends = divsMap_[_customerAddress].balance; withdrawSubdivsAmount(withdrawableSubdividends); } /** * Withdraws a portion of the callers subdividend earnings. */ function withdrawSubdivsAmount(uint256 _amountOfETH) public { // setup data address _customerAddress = msg.sender; updateSubdivsFor(_customerAddress); if (_amountOfETH > 0 && _amountOfETH <= divsMap_[_customerAddress].balance) { divsMap_[_customerAddress].balance = SafeMath.sub(divsMap_[_customerAddress].balance, _amountOfETH); lastContractBalance_ = SafeMath.sub(lastContractBalance_, _amountOfETH); // transfer all withdrawable subdividends _customerAddress.transfer(_amountOfETH); // fire event emit onSubdivsWithdraw(_customerAddress, _amountOfETH); } } /** * Liquifies tokens to P3D. */ function sell(uint256 _amountOfTokens) onlyBagholders() public { // setup data address _customerAddress = msg.sender; updateSubdivsFor(_customerAddress); // russian hackers BTFO require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); uint256 _tokens = _amountOfTokens; uint256 _P3D_amount = tokensToP3D_(_tokens); uint256 _dividends = SafeMath.div(SafeMath.mul(_P3D_amount, sellDividendFee_), 100); uint256 _taxedP3D = SafeMath.sub(_P3D_amount, _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 + (_taxedP3D * 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 events emit onTokenSell(_customerAddress, _tokens, _taxedP3D); emit Transfer(_customerAddress, address(0x0), _tokens); } /** * Transfer tokens from the caller to a new holder. * REMEMBER THIS IS 0% TRANSFER FEE */ function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders() public returns(bool) { address _customerAddress = msg.sender; return transferInternal(_customerAddress, _toAddress, _amountOfTokens); } /** * Transfer token to a specified address and forward the data to recipient * ERC-677 standard * https://github.com/ethereum/EIPs/issues/677 * @param _to Receiver address. * @param _value Amount of tokens that will be transferred. * @param _data Transaction metadata. */ function transferAndCall(address _to, uint256 _value, bytes _data) external returns(bool) { require(canAcceptTokens_[_to]); // approved contracts only require(transfer(_to, _value)); // do a normal token transfer to the contract if (isContract(_to)) { usingP4D receiver = usingP4D(_to); require(receiver.tokenCallback(msg.sender, _value, _data)); } return true; } /** * ERC-20 token standard for transferring tokens on anothers behalf */ function transferFrom(address _from, address _to, uint256 _amountOfTokens) public returns(bool) { require(allowed[_from][msg.sender] >= _amountOfTokens); allowed[_from][msg.sender] = SafeMath.sub(allowed[_from][msg.sender], _amountOfTokens); return transferInternal(_from, _to, _amountOfTokens); } /** * ERC-20 token standard for allowing another address to transfer your tokens * on your behalf up to a certain limit */ function approve(address _spender, uint256 _tokens) public returns(bool) { allowed[msg.sender][_spender] = _tokens; emit Approval(msg.sender, _spender, _tokens); return true; } /** * ERC-20 token standard for approving and calling an external * contract with data */ function approveAndCall(address _to, uint256 _value, bytes _data) external returns(bool) { require(approve(_to, _value)); // do a normal approval if (isContract(_to)) { controllingP4D receiver = controllingP4D(_to); require(receiver.approvalCallback(msg.sender, _value, _data)); } return true; } /*---------- ADMINISTRATOR ONLY FUNCTIONS ----------*/ /** * In case one of us dies, we need to replace ourselves. */ function setAdministrator(address _identifier, bool _status) onlyAdministrator() public { administrators[_identifier] = _status; } /** * Add a new ambassador to the exchange */ function setAmbassador(address _identifier, bool _status) onlyAdministrator() public { ambassadors_[_identifier] = _status; } /** * Precautionary measures in case we need to adjust the masternode rate. */ function setStakingRequirement(uint256 _amountOfTokens) onlyAdministrator() public { stakingRequirement = _amountOfTokens; } /** * Add a sub-contract, which can accept P4D tokens */ function setCanAcceptTokens(address _address) onlyAdministrator() public { require(isContract(_address)); canAcceptTokens_[_address] = true; // one way switch } /** * If we want to rebrand, we can. */ function setName(string _name) onlyAdministrator() public { name = _name; } /** * If we want to rebrand, we can. */ function setSymbol(string _symbol) onlyAdministrator() public { symbol = _symbol; } /*---------- HELPERS AND CALCULATORS ----------*/ /** * Method to view the current P3D tokens stored in the contract */ function totalBalance() public view returns(uint256) { return _P3D.myTokens(); } /** * Retrieve the total token supply. */ function totalSupply() public view returns(uint256) { return tokenSupply_; } /** * Retrieve the tokens owned by the caller. */ function myTokens() public view returns(uint256) { address _customerAddress = msg.sender; return balanceOf(_customerAddress); } /** * Retrieve the dividends owned by the caller. * If `_includeReferralBonus` is set to 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) + referralDividendsOf(_customerAddress) : dividendsOf(_customerAddress)); } /** * Retrieve the subdividend owned by the caller. */ function myStoredDividends() public view returns(uint256) { address _customerAddress = msg.sender; return storedDividendsOf(_customerAddress); } /** * Retrieve the subdividend owned by the caller. */ function mySubdividends() public view returns(uint256) { address _customerAddress = msg.sender; return subdividendsOf(_customerAddress); } /** * Retrieve the token balance of any single address. */ function balanceOf(address _customerAddress) public view returns(uint256) { return tokenBalanceLedger_[_customerAddress]; } /** * 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; } /** * Retrieve the referred dividend balance of any single address. */ function referralDividendsOf(address _customerAddress) public view returns(uint256) { return referralBalance_[_customerAddress]; } /** * Retrieve the stored dividend balance of any single address. */ function storedDividendsOf(address _customerAddress) public view returns(uint256) { return dividendsStored_[_customerAddress] + dividendsOf(_customerAddress) + referralDividendsOf(_customerAddress); } /** * Retrieve the subdividend balance owing of any single address. */ function subdividendsOwing(address _customerAddress) public view returns(uint256) { return (divsMap_[_customerAddress].lastDividendPoints == 0 ? 0 : (balanceOf(_customerAddress) * (totalDividendPoints_ - divsMap_[_customerAddress].lastDividendPoints)) / magnitude); } /** * Retrieve the subdividend balance of any single address. */ function subdividendsOf(address _customerAddress) public view returns(uint256) { return SafeMath.add(divsMap_[_customerAddress].balance, subdividendsOwing(_customerAddress)); } /** * Retrieve the allowance of an owner and spender. */ function allowance(address _tokenOwner, address _spender) public view returns(uint256) { return allowed[_tokenOwner][_spender]; } /** * Retrieve all name information about a customer */ function namesOf(address _customerAddress) public view returns(uint256 activeIndex, string activeName, bytes32[] customerNames) { NameRegistry memory customerNamesInfo = customerNameMap_[_customerAddress]; uint256 length = customerNamesInfo.registeredNames.length; customerNames = new bytes32[](length); for (uint256 i = 0; i < length; i++) { customerNames[i] = customerNamesInfo.registeredNames[i]; } activeIndex = customerNamesInfo.activeIndex; activeName = activeNameOf(_customerAddress); } /** * Retrieves the address of the owner from the name */ function ownerOfName(string memory _name) public view returns(address) { if (bytes(_name).length > 0) { bytes32 bytesName = stringToBytes32(_name); return globalNameMap_[bytesName]; } else { return address(0x0); } } /** * Retrieves the active name of a customer */ function activeNameOf(address _customerAddress) public view returns(string) { NameRegistry memory customerNamesInfo = customerNameMap_[_customerAddress]; if (customerNamesInfo.registeredNames.length > 0) { bytes32 activeBytesName = customerNamesInfo.registeredNames[customerNamesInfo.activeIndex]; return bytes32ToString(activeBytesName); } else { return ""; } } /** * Return the buy price of 1 individual token. */ function sellPrice() public view returns(uint256) {<FILL_FUNCTION_BODY> } /** * Return the sell 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 _P3D_received = tokensToP3D_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_P3D_received, buyDividendFee_), 100); uint256 _taxedP3D = SafeMath.add(_P3D_received, _dividends); return _taxedP3D; } } /** * Function for the frontend to dynamically retrieve the price scaling of buy orders. */ function calculateTokensReceived(uint256 _amountOfETH) public view returns(uint256 _P3D_received, uint256 _P4D_received) { uint256 P3D_received = _P3D.calculateTokensReceived(_amountOfETH); uint256 _dividends = SafeMath.div(SafeMath.mul(P3D_received, buyDividendFee_), 100); uint256 _taxedP3D = SafeMath.sub(P3D_received, _dividends); uint256 _amountOfTokens = P3DtoTokens_(_taxedP3D); return (P3D_received, _amountOfTokens); } /** * Function for the frontend to dynamically retrieve the price scaling of sell orders. */ function calculateAmountReceived(uint256 _tokensToSell) public view returns(uint256) { require(_tokensToSell <= tokenSupply_); uint256 _P3D_received = tokensToP3D_(_tokensToSell); uint256 _dividends = SafeMath.div(SafeMath.mul(_P3D_received, sellDividendFee_), 100); uint256 _taxedP3D = SafeMath.sub(_P3D_received, _dividends); return _taxedP3D; } /** * Utility method to expose the P3D address for any child contracts to use */ function P3D_address() public view returns(address) { return address(_P3D); } /** * Utility method to return all of the data needed for the front end in 1 call */ function fetchAllDataForCustomer(address _customerAddress) public view returns(uint256 _totalSupply, uint256 _totalBalance, uint256 _buyPrice, uint256 _sellPrice, uint256 _activationTime, uint256 _customerTokens, uint256 _customerUnclaimedDividends, uint256 _customerStoredDividends, uint256 _customerSubdividends) { _totalSupply = totalSupply(); _totalBalance = totalBalance(); _buyPrice = buyPrice(); _sellPrice = sellPrice(); _activationTime = ACTIVATION_TIME; _customerTokens = balanceOf(_customerAddress); _customerUnclaimedDividends = dividendsOf(_customerAddress) + referralDividendsOf(_customerAddress); _customerStoredDividends = storedDividendsOf(_customerAddress); _customerSubdividends = subdividendsOf(_customerAddress); } /*========================================== = INTERNAL FUNCTIONS = ==========================================*/ // This function should always be called before a customers P4D balance changes. // It's responsible for withdrawing any outstanding ETH dividends from the P3D exchange // as well as distrubuting all of the additional ETH balance since the last update to // all of the P4D token holders proportionally. // After this it will move any owed subdividends into the customers withdrawable subdividend balance. function updateSubdivsFor(address _customerAddress) internal { // withdraw the P3D dividends first if (_P3D.myDividends(true) > 0) { _P3D.withdraw(); } // check if we have additional ETH in the contract since the last update uint256 contractBalance = address(this).balance; if (contractBalance > lastContractBalance_ && totalSupply() != 0) { uint256 additionalDivsFromP3D = SafeMath.sub(contractBalance, lastContractBalance_); totalDividendPoints_ = SafeMath.add(totalDividendPoints_, SafeMath.div(SafeMath.mul(additionalDivsFromP3D, magnitude), totalSupply())); lastContractBalance_ = contractBalance; } // if this is the very first time this is called for a customer, set their starting point if (divsMap_[_customerAddress].lastDividendPoints == 0) { divsMap_[_customerAddress].lastDividendPoints = totalDividendPoints_; } // move any owing subdividends into the customers subdividend balance uint256 owing = subdividendsOwing(_customerAddress); if (owing > 0) { divsMap_[_customerAddress].balance = SafeMath.add(divsMap_[_customerAddress].balance, owing); divsMap_[_customerAddress].lastDividendPoints = totalDividendPoints_; } } function withdrawInternal(address _customerAddress) internal { // setup data // dividendsOf() will return only divs, not the ref. bonus uint256 _dividends = dividendsOf(_customerAddress); // get ref. bonus later in the code // update dividend tracker payoutsTo_[_customerAddress] += (int256)(_dividends * magnitude); // add ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // store the divs dividendsStored_[_customerAddress] = SafeMath.add(dividendsStored_[_customerAddress], _dividends); } function transferInternal(address _customerAddress, address _toAddress, uint256 _amountOfTokens) internal returns(bool) { // make sure we have the requested tokens require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); updateSubdivsFor(_customerAddress); updateSubdivsFor(_toAddress); // withdraw and store all outstanding dividends first (if there is any) if ((dividendsOf(_customerAddress) + referralDividendsOf(_customerAddress)) > 0) withdrawInternal(_customerAddress); // 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; } function purchaseInternal(address _sender, uint256 _incomingEthereum, address _referredBy) purchaseFilter(_sender, _incomingEthereum) internal returns(uint256) { uint256 purchaseAmount = _incomingEthereum; uint256 excess = 0; if (totalInputETH_ <= initialBuyLimitCap_) { // check if the total input ETH is less than the cap if (purchaseAmount > initialBuyLimitPerTx_) { // if so check if the transaction is over the initial buy limit per transaction purchaseAmount = initialBuyLimitPerTx_; excess = SafeMath.sub(_incomingEthereum, purchaseAmount); } totalInputETH_ = SafeMath.add(totalInputETH_, purchaseAmount); } // return the excess if there is any if (excess > 0) { _sender.transfer(excess); } // buy P3D tokens with the entire purchase amount // even though _P3D.buy() returns uint256, it was never implemented properly inside the P3D contract // so in order to find out how much P3D was purchased, you need to check the balance first then compare // the balance after the purchase and the difference will be the amount purchased uint256 tmpBalanceBefore = _P3D.myTokens(); _P3D.buy.value(purchaseAmount)(_referredBy); uint256 purchasedP3D = SafeMath.sub(_P3D.myTokens(), tmpBalanceBefore); return purchaseTokens(_sender, purchasedP3D, _referredBy); } function purchaseTokens(address _sender, uint256 _incomingP3D, address _referredBy) internal returns(uint256) { updateSubdivsFor(_sender); // data setup uint256 _undividedDividends = SafeMath.div(SafeMath.mul(_incomingP3D, buyDividendFee_), 100); uint256 _referralBonus = SafeMath.div(_undividedDividends, 3); uint256 _dividends = SafeMath.sub(_undividedDividends, _referralBonus); uint256 _taxedP3D = SafeMath.sub(_incomingP3D, _undividedDividends); uint256 _amountOfTokens = P3DtoTokens_(_taxedP3D); 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 != address(0x0) && // no cheating! _referredBy != _sender && // 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 P3D 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 their 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_[_sender] = SafeMath.add(tokenBalanceLedger_[_sender], _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 payoutsTo_[_sender] += (int256)((profitPerShare_ * _amountOfTokens) - _fee); // fire events emit onTokenPurchase(_sender, _incomingP3D, _amountOfTokens, _referredBy); emit Transfer(address(0x0), _sender, _amountOfTokens); return _amountOfTokens; } /** * Calculate token price based on an amount of incoming P3D * 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 P3DtoTokens_(uint256 _P3D_received) internal view returns(uint256) { uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18; uint256 _tokensReceived = ( ( // underflow attempts BTFO SafeMath.sub( (sqrt ( (_tokenPriceInitial**2) + (2 * (tokenPriceIncremental_ * 1e18)*(_P3D_received * 1e18)) + (((tokenPriceIncremental_)**2) * (tokenSupply_**2)) + (2 * (tokenPriceIncremental_) * _tokenPriceInitial * tokenSupply_) ) ), _tokenPriceInitial ) ) / (tokenPriceIncremental_) ) - (tokenSupply_); return _tokensReceived; } /** * Calculate token sell value. * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function tokensToP3D_(uint256 _P4D_tokens) internal view returns(uint256) { uint256 tokens_ = (_P4D_tokens + 1e18); uint256 _tokenSupply = (tokenSupply_ + 1e18); uint256 _P3D_received = ( // underflow attempts BTFO SafeMath.sub( ( ( ( tokenPriceInitial_ + (tokenPriceIncremental_ * (_tokenSupply / 1e18)) ) - tokenPriceIncremental_ ) * (tokens_ - 1e18) ), (tokenPriceIncremental_ * ((tokens_**2 - tokens_) / 1e18)) / 2 ) / 1e18); return _P3D_received; } // This is where all your gas goes, sorry // Not sorry, you probably only paid 1 gwei function sqrt(uint x) internal pure returns (uint y) { uint z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } /** * Additional check that the address we are sending tokens to is a contract * assemble the given address bytecode. If bytecode exists then the _addr is a contract. */ function isContract(address _addr) internal constant returns(bool) { // retrieve the size of the code on target address, this needs assembly uint length; assembly { length := extcodesize(_addr) } return length > 0; } /** * Utility method to help store the registered names */ function stringToBytes32(string memory _s) internal pure returns(bytes32 result) { bytes memory tmpEmptyStringTest = bytes(_s); if (tmpEmptyStringTest.length == 0) { return 0x0; } assembly { result := mload(add(_s, 32)) } } /** * Utility method to help read the registered names */ function bytes32ToString(bytes32 _b) internal pure returns(string) { bytes memory bytesString = new bytes(32); uint charCount = 0; for (uint256 i = 0; i < 32; i++) { byte char = byte(bytes32(uint(_b) * 2 ** (8 * i))); if (char != 0) { bytesString[charCount++] = char; } } bytes memory bytesStringTrimmed = new bytes(charCount); for (i = 0; i < charCount; i++) { bytesStringTrimmed[i] = bytesString[i]; } return string(bytesStringTrimmed); } }
contract P4D { /*================================= = MODIFIERS = =================================*/ // only people with tokens modifier onlyBagholders() { require(myTokens() > 0); _; } // administrators can: // -> change the name of the contract // -> change the name of the token // -> change the PoS difficulty (how many tokens it costs to hold a masternode, in case it gets crazy high later) // -> allow a contract to accept P4D tokens // they CANNOT: // -> take funds // -> disable withdrawals // -> kill the contract // -> change the price of tokens modifier onlyAdministrator() { require(administrators[msg.sender] || msg.sender == _dev); _; } // ensures that the first tokens in the contract will be equally distributed // meaning, no divine dump will be ever possible // result: healthy longevity. modifier purchaseFilter(address _sender, uint256 _amountETH) { require(!isContract(_sender) || canAcceptTokens_[_sender]); if (now >= ACTIVATION_TIME) { onlyAmbassadors = false; } // are we still in the vulnerable phase? // if so, enact anti early whale protocol if (onlyAmbassadors && ((totalAmbassadorQuotaSpent_ + _amountETH) <= ambassadorQuota_)) { require( // is the customer in the ambassador list? ambassadors_[_sender] == true && // does the customer purchase exceed the max ambassador quota? (ambassadorAccumulatedQuota_[_sender] + _amountETH) <= ambassadorMaxPurchase_ ); // updated the accumulated quota ambassadorAccumulatedQuota_[_sender] = SafeMath.add(ambassadorAccumulatedQuota_[_sender], _amountETH); totalAmbassadorQuotaSpent_ = SafeMath.add(totalAmbassadorQuotaSpent_, _amountETH); // execute _; } else { require(!onlyAmbassadors); _; } } /*============================== = EVENTS = ==============================*/ event onTokenPurchase( address indexed _customerAddress, uint256 _incomingP3D, uint256 _tokensMinted, address indexed _referredBy ); event onTokenSell( address indexed _customerAddress, uint256 _tokensBurned, uint256 _P3D_received ); event onReinvestment( address indexed _customerAddress, uint256 _P3D_reinvested, uint256 _tokensMinted ); event onSubdivsReinvestment( address indexed _customerAddress, uint256 _ETH_reinvested, uint256 _tokensMinted ); event onWithdraw( address indexed _customerAddress, uint256 _P3D_withdrawn ); event onSubdivsWithdraw( address indexed _customerAddress, uint256 _ETH_withdrawn ); event onNameRegistration( address indexed _customerAddress, string _registeredName ); // ERC-20 event Transfer( address indexed _from, address indexed _to, uint256 _tokens ); event Approval( address indexed _tokenOwner, address indexed _spender, uint256 _tokens ); /*===================================== = CONFIGURABLES = =====================================*/ string public name = "PoWH4D"; string public symbol = "P4D"; uint256 constant public decimals = 18; uint256 constant internal buyDividendFee_ = 10; // 10% dividend tax on each buy uint256 constant internal sellDividendFee_ = 5; // 5% dividend tax on each sell uint256 internal tokenPriceInitial_; // set in the constructor uint256 constant internal tokenPriceIncremental_ = 1e9; // 1/10th the incremental of P3D uint256 constant internal magnitude = 2**64; uint256 public stakingRequirement = 1e22; // 10,000 P4D uint256 constant internal initialBuyLimitPerTx_ = 1 ether; uint256 constant internal initialBuyLimitCap_ = 100 ether; uint256 internal totalInputETH_ = 0; // ambassador program mapping(address => bool) internal ambassadors_; uint256 constant internal ambassadorMaxPurchase_ = 1 ether; uint256 constant internal ambassadorQuota_ = 12 ether; uint256 internal totalAmbassadorQuotaSpent_ = 0; address internal _dev; uint256 public ACTIVATION_TIME; /*================================ = DATASETS = ================================*/ // amount of shares for each address (scaled number) mapping(address => uint256) internal tokenBalanceLedger_; mapping(address => uint256) internal referralBalance_; mapping(address => int256) internal payoutsTo_; mapping(address => uint256) internal dividendsStored_; mapping(address => uint256) internal ambassadorAccumulatedQuota_; uint256 internal tokenSupply_ = 0; uint256 internal profitPerShare_; // administrator list (see above on what they can do) mapping(address => bool) public administrators; // when this is set to true, only ambassadors can purchase tokens (this prevents a whale premine, it ensures a fairly distributed upper pyramid) bool public onlyAmbassadors = true; // contracts can interact with the exchange but only approved ones mapping(address => bool) public canAcceptTokens_; // ERC-20 standard mapping(address => mapping (address => uint256)) public allowed; // P3D contract reference P3D internal _P3D; // structure to handle the distribution of ETH divs paid out by the P3D contract struct P3D_dividends { uint256 balance; uint256 lastDividendPoints; } mapping(address => P3D_dividends) internal divsMap_; uint256 internal totalDividendPoints_; uint256 internal lastContractBalance_; // structure to handle the global unique name/vanity registration struct NameRegistry { uint256 activeIndex; bytes32[] registeredNames; } mapping(address => NameRegistry) internal customerNameMap_; mapping(bytes32 => address) internal globalNameMap_; uint256 constant internal nameRegistrationFee = 0.01 ether; /*======================================= = PUBLIC FUNCTIONS = =======================================*/ /* * -- APPLICATION ENTRY POINTS -- */ constructor(uint256 _activationTime, address _P3D_address) public { _dev = msg.sender; ACTIVATION_TIME = _activationTime; totalDividendPoints_ = 1; // non-zero value _P3D = P3D(_P3D_address); // virtualized purchase of the entire ambassador quota // calculateTokensReceived() for this contract will return how many tokens can be bought starting at 1e9 P3D per P4D // as the price increases by the incremental each time we can just multiply it out and scale it back to e18 // // this is used as the initial P3D-P4D price as it makes it fairer on other investors that aren't ambassadors uint256 _P4D_received; (, _P4D_received) = calculateTokensReceived(ambassadorQuota_); tokenPriceInitial_ = tokenPriceIncremental_ * _P4D_received / 1e18; // admins administrators[_dev] = true; // ambassadors ambassadors_[_dev] = true; } /** * Converts all incoming ethereum to tokens for the caller, and passes down the referral address */ function buy(address _referredBy) payable public returns(uint256) { return purchaseInternal(msg.sender, msg.value, _referredBy); } /** * Buy with a registered name as the referrer. * If the name is unregistered, address(0x0) will be the ref */ function buyWithNameRef(string memory _nameOfReferrer) payable public returns(uint256) { return purchaseInternal(msg.sender, msg.value, ownerOfName(_nameOfReferrer)); } /** * Fallback function to handle ethereum that was sent straight to the contract * Unfortunately we cannot use a referral address this way. */ function() payable public { if (msg.sender != address(_P3D)) { purchaseInternal(msg.sender, msg.value, address(0x0)); } // all other ETH is from the withdrawn dividends from // the P3D contract, this is distributed out via the // updateSubdivsFor() method // no more computation can be done inside this function // as when you call address.transfer(uint256), only // 2,300 gas is forwarded to this function so no variables // can be mutated with that limit // address(this).balance will represent the total amount // of ETH dividends from the P3D contract (minus the amount // that's already been withdrawn) } /** * Distribute any ETH sent to this method out to all token holders */ function donate() payable public { // nothing happens here in order to save gas // all of the ETH sent to this function will be distributed out // via the updateSubdivsFor() method // // this method is designed for external contracts that have // extra ETH that they want to evenly distribute to all // P4D token holders } /** * Allows a customer to pay for a global name on the P4D network * There's a 0.01 ETH registration fee per name * All ETH is distributed to P4D token holders via updateSubdivsFor() */ function registerName(string memory _name) payable public { address _customerAddress = msg.sender; require(!onlyAmbassadors || ambassadors_[_customerAddress]); require(bytes(_name).length > 0); require(msg.value >= nameRegistrationFee); uint256 excess = SafeMath.sub(msg.value, nameRegistrationFee); bytes32 bytesName = stringToBytes32(_name); require(globalNameMap_[bytesName] == address(0x0)); NameRegistry storage customerNamesInfo = customerNameMap_[_customerAddress]; customerNamesInfo.registeredNames.push(bytesName); customerNamesInfo.activeIndex = customerNamesInfo.registeredNames.length - 1; globalNameMap_[bytesName] = _customerAddress; if (excess > 0) { _customerAddress.transfer(excess); } // fire event emit onNameRegistration(_customerAddress, _name); // similar to the fallback and donate functions, the ETH cost of // the name registration fee (0.01 ETH) will be distributed out // to all P4D tokens holders via the updateSubdivsFor() method } /** * Change your active name to a name that you've already purchased */ function changeActiveNameTo(string memory _name) public { address _customerAddress = msg.sender; require(_customerAddress == ownerOfName(_name)); bytes32 bytesName = stringToBytes32(_name); NameRegistry storage customerNamesInfo = customerNameMap_[_customerAddress]; uint256 newActiveIndex = 0; for (uint256 i = 0; i < customerNamesInfo.registeredNames.length; i++) { if (bytesName == customerNamesInfo.registeredNames[i]) { newActiveIndex = i; break; } } customerNamesInfo.activeIndex = newActiveIndex; } /** * Similar to changeActiveNameTo() without the need to iterate through your name list */ function changeActiveNameIndexTo(uint256 _newActiveIndex) public { address _customerAddress = msg.sender; NameRegistry storage customerNamesInfo = customerNameMap_[_customerAddress]; require(_newActiveIndex < customerNamesInfo.registeredNames.length); customerNamesInfo.activeIndex = _newActiveIndex; } /** * Converts all of caller's dividends to tokens. * The argument is not used but it allows MetaMask to render * 'Reinvest' in your transactions list once the function sig * is registered to the contract at; * https://etherscan.io/address/0x44691B39d1a75dC4E0A0346CBB15E310e6ED1E86#writeContract */ function reinvest(bool) public { // setup data address _customerAddress = msg.sender; withdrawInternal(_customerAddress); uint256 reinvestableDividends = dividendsStored_[_customerAddress]; reinvestAmount(reinvestableDividends); } /** * Converts a portion of caller's dividends to tokens. */ function reinvestAmount(uint256 _amountOfP3D) public { // setup data address _customerAddress = msg.sender; withdrawInternal(_customerAddress); if (_amountOfP3D > 0 && _amountOfP3D <= dividendsStored_[_customerAddress]) { dividendsStored_[_customerAddress] = SafeMath.sub(dividendsStored_[_customerAddress], _amountOfP3D); // dispatch a buy order with the virtualized "withdrawn dividends" uint256 _tokens = purchaseTokens(_customerAddress, _amountOfP3D, address(0x0)); // fire event emit onReinvestment(_customerAddress, _amountOfP3D, _tokens); } } /** * Converts all of caller's subdividends to tokens. * The argument is not used but it allows MetaMask to render * 'Reinvest Subdivs' in your transactions list once the function sig * is registered to the contract at; * https://etherscan.io/address/0x44691B39d1a75dC4E0A0346CBB15E310e6ED1E86#writeContract */ function reinvestSubdivs(bool) public { // setup data address _customerAddress = msg.sender; updateSubdivsFor(_customerAddress); uint256 reinvestableSubdividends = divsMap_[_customerAddress].balance; reinvestSubdivsAmount(reinvestableSubdividends); } /** * Converts a portion of caller's subdividends to tokens. */ function reinvestSubdivsAmount(uint256 _amountOfETH) public { // setup data address _customerAddress = msg.sender; updateSubdivsFor(_customerAddress); if (_amountOfETH > 0 && _amountOfETH <= divsMap_[_customerAddress].balance) { divsMap_[_customerAddress].balance = SafeMath.sub(divsMap_[_customerAddress].balance, _amountOfETH); lastContractBalance_ = SafeMath.sub(lastContractBalance_, _amountOfETH); // purchase tokens with the ETH subdividends uint256 _tokens = purchaseInternal(_customerAddress, _amountOfETH, address(0x0)); // fire event emit onSubdivsReinvestment(_customerAddress, _amountOfETH, _tokens); } } /** * Alias of sell(), withdraw() and withdrawSubdivs(). * The argument is not used but it allows MetaMask to render * 'Exit' in your transactions list once the function sig * is registered to the contract at; * https://etherscan.io/address/0x44691B39d1a75dC4E0A0346CBB15E310e6ED1E86#writeContract */ function exit(bool) public { // get token count for caller & sell them all address _customerAddress = msg.sender; uint256 _tokens = tokenBalanceLedger_[_customerAddress]; if(_tokens > 0) sell(_tokens); // lambo delivery service withdraw(true); withdrawSubdivs(true); } /** * Withdraws all of the callers dividend earnings. * The argument is not used but it allows MetaMask to render * 'Withdraw' in your transactions list once the function sig * is registered to the contract at; * https://etherscan.io/address/0x44691B39d1a75dC4E0A0346CBB15E310e6ED1E86#writeContract */ function withdraw(bool) public { // setup data address _customerAddress = msg.sender; withdrawInternal(_customerAddress); uint256 withdrawableDividends = dividendsStored_[_customerAddress]; withdrawAmount(withdrawableDividends); } /** * Withdraws a portion of the callers dividend earnings. */ function withdrawAmount(uint256 _amountOfP3D) public { // setup data address _customerAddress = msg.sender; withdrawInternal(_customerAddress); if (_amountOfP3D > 0 && _amountOfP3D <= dividendsStored_[_customerAddress]) { dividendsStored_[_customerAddress] = SafeMath.sub(dividendsStored_[_customerAddress], _amountOfP3D); // lambo delivery service require(_P3D.transfer(_customerAddress, _amountOfP3D)); // NOTE! // P3D has a 10% transfer tax so even though this is sending your entire // dividend count to you, you will only actually receive 90%. // fire event emit onWithdraw(_customerAddress, _amountOfP3D); } } /** * Withdraws all of the callers subdividend earnings. * The argument is not used but it allows MetaMask to render * 'Withdraw Subdivs' in your transactions list once the function sig * is registered to the contract at; * https://etherscan.io/address/0x44691B39d1a75dC4E0A0346CBB15E310e6ED1E86#writeContract */ function withdrawSubdivs(bool) public { // setup data address _customerAddress = msg.sender; updateSubdivsFor(_customerAddress); uint256 withdrawableSubdividends = divsMap_[_customerAddress].balance; withdrawSubdivsAmount(withdrawableSubdividends); } /** * Withdraws a portion of the callers subdividend earnings. */ function withdrawSubdivsAmount(uint256 _amountOfETH) public { // setup data address _customerAddress = msg.sender; updateSubdivsFor(_customerAddress); if (_amountOfETH > 0 && _amountOfETH <= divsMap_[_customerAddress].balance) { divsMap_[_customerAddress].balance = SafeMath.sub(divsMap_[_customerAddress].balance, _amountOfETH); lastContractBalance_ = SafeMath.sub(lastContractBalance_, _amountOfETH); // transfer all withdrawable subdividends _customerAddress.transfer(_amountOfETH); // fire event emit onSubdivsWithdraw(_customerAddress, _amountOfETH); } } /** * Liquifies tokens to P3D. */ function sell(uint256 _amountOfTokens) onlyBagholders() public { // setup data address _customerAddress = msg.sender; updateSubdivsFor(_customerAddress); // russian hackers BTFO require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); uint256 _tokens = _amountOfTokens; uint256 _P3D_amount = tokensToP3D_(_tokens); uint256 _dividends = SafeMath.div(SafeMath.mul(_P3D_amount, sellDividendFee_), 100); uint256 _taxedP3D = SafeMath.sub(_P3D_amount, _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 + (_taxedP3D * 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 events emit onTokenSell(_customerAddress, _tokens, _taxedP3D); emit Transfer(_customerAddress, address(0x0), _tokens); } /** * Transfer tokens from the caller to a new holder. * REMEMBER THIS IS 0% TRANSFER FEE */ function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders() public returns(bool) { address _customerAddress = msg.sender; return transferInternal(_customerAddress, _toAddress, _amountOfTokens); } /** * Transfer token to a specified address and forward the data to recipient * ERC-677 standard * https://github.com/ethereum/EIPs/issues/677 * @param _to Receiver address. * @param _value Amount of tokens that will be transferred. * @param _data Transaction metadata. */ function transferAndCall(address _to, uint256 _value, bytes _data) external returns(bool) { require(canAcceptTokens_[_to]); // approved contracts only require(transfer(_to, _value)); // do a normal token transfer to the contract if (isContract(_to)) { usingP4D receiver = usingP4D(_to); require(receiver.tokenCallback(msg.sender, _value, _data)); } return true; } /** * ERC-20 token standard for transferring tokens on anothers behalf */ function transferFrom(address _from, address _to, uint256 _amountOfTokens) public returns(bool) { require(allowed[_from][msg.sender] >= _amountOfTokens); allowed[_from][msg.sender] = SafeMath.sub(allowed[_from][msg.sender], _amountOfTokens); return transferInternal(_from, _to, _amountOfTokens); } /** * ERC-20 token standard for allowing another address to transfer your tokens * on your behalf up to a certain limit */ function approve(address _spender, uint256 _tokens) public returns(bool) { allowed[msg.sender][_spender] = _tokens; emit Approval(msg.sender, _spender, _tokens); return true; } /** * ERC-20 token standard for approving and calling an external * contract with data */ function approveAndCall(address _to, uint256 _value, bytes _data) external returns(bool) { require(approve(_to, _value)); // do a normal approval if (isContract(_to)) { controllingP4D receiver = controllingP4D(_to); require(receiver.approvalCallback(msg.sender, _value, _data)); } return true; } /*---------- ADMINISTRATOR ONLY FUNCTIONS ----------*/ /** * In case one of us dies, we need to replace ourselves. */ function setAdministrator(address _identifier, bool _status) onlyAdministrator() public { administrators[_identifier] = _status; } /** * Add a new ambassador to the exchange */ function setAmbassador(address _identifier, bool _status) onlyAdministrator() public { ambassadors_[_identifier] = _status; } /** * Precautionary measures in case we need to adjust the masternode rate. */ function setStakingRequirement(uint256 _amountOfTokens) onlyAdministrator() public { stakingRequirement = _amountOfTokens; } /** * Add a sub-contract, which can accept P4D tokens */ function setCanAcceptTokens(address _address) onlyAdministrator() public { require(isContract(_address)); canAcceptTokens_[_address] = true; // one way switch } /** * If we want to rebrand, we can. */ function setName(string _name) onlyAdministrator() public { name = _name; } /** * If we want to rebrand, we can. */ function setSymbol(string _symbol) onlyAdministrator() public { symbol = _symbol; } /*---------- HELPERS AND CALCULATORS ----------*/ /** * Method to view the current P3D tokens stored in the contract */ function totalBalance() public view returns(uint256) { return _P3D.myTokens(); } /** * Retrieve the total token supply. */ function totalSupply() public view returns(uint256) { return tokenSupply_; } /** * Retrieve the tokens owned by the caller. */ function myTokens() public view returns(uint256) { address _customerAddress = msg.sender; return balanceOf(_customerAddress); } /** * Retrieve the dividends owned by the caller. * If `_includeReferralBonus` is set to 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) + referralDividendsOf(_customerAddress) : dividendsOf(_customerAddress)); } /** * Retrieve the subdividend owned by the caller. */ function myStoredDividends() public view returns(uint256) { address _customerAddress = msg.sender; return storedDividendsOf(_customerAddress); } /** * Retrieve the subdividend owned by the caller. */ function mySubdividends() public view returns(uint256) { address _customerAddress = msg.sender; return subdividendsOf(_customerAddress); } /** * Retrieve the token balance of any single address. */ function balanceOf(address _customerAddress) public view returns(uint256) { return tokenBalanceLedger_[_customerAddress]; } /** * 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; } /** * Retrieve the referred dividend balance of any single address. */ function referralDividendsOf(address _customerAddress) public view returns(uint256) { return referralBalance_[_customerAddress]; } /** * Retrieve the stored dividend balance of any single address. */ function storedDividendsOf(address _customerAddress) public view returns(uint256) { return dividendsStored_[_customerAddress] + dividendsOf(_customerAddress) + referralDividendsOf(_customerAddress); } /** * Retrieve the subdividend balance owing of any single address. */ function subdividendsOwing(address _customerAddress) public view returns(uint256) { return (divsMap_[_customerAddress].lastDividendPoints == 0 ? 0 : (balanceOf(_customerAddress) * (totalDividendPoints_ - divsMap_[_customerAddress].lastDividendPoints)) / magnitude); } /** * Retrieve the subdividend balance of any single address. */ function subdividendsOf(address _customerAddress) public view returns(uint256) { return SafeMath.add(divsMap_[_customerAddress].balance, subdividendsOwing(_customerAddress)); } /** * Retrieve the allowance of an owner and spender. */ function allowance(address _tokenOwner, address _spender) public view returns(uint256) { return allowed[_tokenOwner][_spender]; } /** * Retrieve all name information about a customer */ function namesOf(address _customerAddress) public view returns(uint256 activeIndex, string activeName, bytes32[] customerNames) { NameRegistry memory customerNamesInfo = customerNameMap_[_customerAddress]; uint256 length = customerNamesInfo.registeredNames.length; customerNames = new bytes32[](length); for (uint256 i = 0; i < length; i++) { customerNames[i] = customerNamesInfo.registeredNames[i]; } activeIndex = customerNamesInfo.activeIndex; activeName = activeNameOf(_customerAddress); } /** * Retrieves the address of the owner from the name */ function ownerOfName(string memory _name) public view returns(address) { if (bytes(_name).length > 0) { bytes32 bytesName = stringToBytes32(_name); return globalNameMap_[bytesName]; } else { return address(0x0); } } /** * Retrieves the active name of a customer */ function activeNameOf(address _customerAddress) public view returns(string) { NameRegistry memory customerNamesInfo = customerNameMap_[_customerAddress]; if (customerNamesInfo.registeredNames.length > 0) { bytes32 activeBytesName = customerNamesInfo.registeredNames[customerNamesInfo.activeIndex]; return bytes32ToString(activeBytesName); } else { return ""; } } <FILL_FUNCTION> /** * Return the sell 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 _P3D_received = tokensToP3D_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_P3D_received, buyDividendFee_), 100); uint256 _taxedP3D = SafeMath.add(_P3D_received, _dividends); return _taxedP3D; } } /** * Function for the frontend to dynamically retrieve the price scaling of buy orders. */ function calculateTokensReceived(uint256 _amountOfETH) public view returns(uint256 _P3D_received, uint256 _P4D_received) { uint256 P3D_received = _P3D.calculateTokensReceived(_amountOfETH); uint256 _dividends = SafeMath.div(SafeMath.mul(P3D_received, buyDividendFee_), 100); uint256 _taxedP3D = SafeMath.sub(P3D_received, _dividends); uint256 _amountOfTokens = P3DtoTokens_(_taxedP3D); return (P3D_received, _amountOfTokens); } /** * Function for the frontend to dynamically retrieve the price scaling of sell orders. */ function calculateAmountReceived(uint256 _tokensToSell) public view returns(uint256) { require(_tokensToSell <= tokenSupply_); uint256 _P3D_received = tokensToP3D_(_tokensToSell); uint256 _dividends = SafeMath.div(SafeMath.mul(_P3D_received, sellDividendFee_), 100); uint256 _taxedP3D = SafeMath.sub(_P3D_received, _dividends); return _taxedP3D; } /** * Utility method to expose the P3D address for any child contracts to use */ function P3D_address() public view returns(address) { return address(_P3D); } /** * Utility method to return all of the data needed for the front end in 1 call */ function fetchAllDataForCustomer(address _customerAddress) public view returns(uint256 _totalSupply, uint256 _totalBalance, uint256 _buyPrice, uint256 _sellPrice, uint256 _activationTime, uint256 _customerTokens, uint256 _customerUnclaimedDividends, uint256 _customerStoredDividends, uint256 _customerSubdividends) { _totalSupply = totalSupply(); _totalBalance = totalBalance(); _buyPrice = buyPrice(); _sellPrice = sellPrice(); _activationTime = ACTIVATION_TIME; _customerTokens = balanceOf(_customerAddress); _customerUnclaimedDividends = dividendsOf(_customerAddress) + referralDividendsOf(_customerAddress); _customerStoredDividends = storedDividendsOf(_customerAddress); _customerSubdividends = subdividendsOf(_customerAddress); } /*========================================== = INTERNAL FUNCTIONS = ==========================================*/ // This function should always be called before a customers P4D balance changes. // It's responsible for withdrawing any outstanding ETH dividends from the P3D exchange // as well as distrubuting all of the additional ETH balance since the last update to // all of the P4D token holders proportionally. // After this it will move any owed subdividends into the customers withdrawable subdividend balance. function updateSubdivsFor(address _customerAddress) internal { // withdraw the P3D dividends first if (_P3D.myDividends(true) > 0) { _P3D.withdraw(); } // check if we have additional ETH in the contract since the last update uint256 contractBalance = address(this).balance; if (contractBalance > lastContractBalance_ && totalSupply() != 0) { uint256 additionalDivsFromP3D = SafeMath.sub(contractBalance, lastContractBalance_); totalDividendPoints_ = SafeMath.add(totalDividendPoints_, SafeMath.div(SafeMath.mul(additionalDivsFromP3D, magnitude), totalSupply())); lastContractBalance_ = contractBalance; } // if this is the very first time this is called for a customer, set their starting point if (divsMap_[_customerAddress].lastDividendPoints == 0) { divsMap_[_customerAddress].lastDividendPoints = totalDividendPoints_; } // move any owing subdividends into the customers subdividend balance uint256 owing = subdividendsOwing(_customerAddress); if (owing > 0) { divsMap_[_customerAddress].balance = SafeMath.add(divsMap_[_customerAddress].balance, owing); divsMap_[_customerAddress].lastDividendPoints = totalDividendPoints_; } } function withdrawInternal(address _customerAddress) internal { // setup data // dividendsOf() will return only divs, not the ref. bonus uint256 _dividends = dividendsOf(_customerAddress); // get ref. bonus later in the code // update dividend tracker payoutsTo_[_customerAddress] += (int256)(_dividends * magnitude); // add ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // store the divs dividendsStored_[_customerAddress] = SafeMath.add(dividendsStored_[_customerAddress], _dividends); } function transferInternal(address _customerAddress, address _toAddress, uint256 _amountOfTokens) internal returns(bool) { // make sure we have the requested tokens require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); updateSubdivsFor(_customerAddress); updateSubdivsFor(_toAddress); // withdraw and store all outstanding dividends first (if there is any) if ((dividendsOf(_customerAddress) + referralDividendsOf(_customerAddress)) > 0) withdrawInternal(_customerAddress); // 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; } function purchaseInternal(address _sender, uint256 _incomingEthereum, address _referredBy) purchaseFilter(_sender, _incomingEthereum) internal returns(uint256) { uint256 purchaseAmount = _incomingEthereum; uint256 excess = 0; if (totalInputETH_ <= initialBuyLimitCap_) { // check if the total input ETH is less than the cap if (purchaseAmount > initialBuyLimitPerTx_) { // if so check if the transaction is over the initial buy limit per transaction purchaseAmount = initialBuyLimitPerTx_; excess = SafeMath.sub(_incomingEthereum, purchaseAmount); } totalInputETH_ = SafeMath.add(totalInputETH_, purchaseAmount); } // return the excess if there is any if (excess > 0) { _sender.transfer(excess); } // buy P3D tokens with the entire purchase amount // even though _P3D.buy() returns uint256, it was never implemented properly inside the P3D contract // so in order to find out how much P3D was purchased, you need to check the balance first then compare // the balance after the purchase and the difference will be the amount purchased uint256 tmpBalanceBefore = _P3D.myTokens(); _P3D.buy.value(purchaseAmount)(_referredBy); uint256 purchasedP3D = SafeMath.sub(_P3D.myTokens(), tmpBalanceBefore); return purchaseTokens(_sender, purchasedP3D, _referredBy); } function purchaseTokens(address _sender, uint256 _incomingP3D, address _referredBy) internal returns(uint256) { updateSubdivsFor(_sender); // data setup uint256 _undividedDividends = SafeMath.div(SafeMath.mul(_incomingP3D, buyDividendFee_), 100); uint256 _referralBonus = SafeMath.div(_undividedDividends, 3); uint256 _dividends = SafeMath.sub(_undividedDividends, _referralBonus); uint256 _taxedP3D = SafeMath.sub(_incomingP3D, _undividedDividends); uint256 _amountOfTokens = P3DtoTokens_(_taxedP3D); 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 != address(0x0) && // no cheating! _referredBy != _sender && // 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 P3D 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 their 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_[_sender] = SafeMath.add(tokenBalanceLedger_[_sender], _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 payoutsTo_[_sender] += (int256)((profitPerShare_ * _amountOfTokens) - _fee); // fire events emit onTokenPurchase(_sender, _incomingP3D, _amountOfTokens, _referredBy); emit Transfer(address(0x0), _sender, _amountOfTokens); return _amountOfTokens; } /** * Calculate token price based on an amount of incoming P3D * 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 P3DtoTokens_(uint256 _P3D_received) internal view returns(uint256) { uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18; uint256 _tokensReceived = ( ( // underflow attempts BTFO SafeMath.sub( (sqrt ( (_tokenPriceInitial**2) + (2 * (tokenPriceIncremental_ * 1e18)*(_P3D_received * 1e18)) + (((tokenPriceIncremental_)**2) * (tokenSupply_**2)) + (2 * (tokenPriceIncremental_) * _tokenPriceInitial * tokenSupply_) ) ), _tokenPriceInitial ) ) / (tokenPriceIncremental_) ) - (tokenSupply_); return _tokensReceived; } /** * Calculate token sell value. * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function tokensToP3D_(uint256 _P4D_tokens) internal view returns(uint256) { uint256 tokens_ = (_P4D_tokens + 1e18); uint256 _tokenSupply = (tokenSupply_ + 1e18); uint256 _P3D_received = ( // underflow attempts BTFO SafeMath.sub( ( ( ( tokenPriceInitial_ + (tokenPriceIncremental_ * (_tokenSupply / 1e18)) ) - tokenPriceIncremental_ ) * (tokens_ - 1e18) ), (tokenPriceIncremental_ * ((tokens_**2 - tokens_) / 1e18)) / 2 ) / 1e18); return _P3D_received; } // This is where all your gas goes, sorry // Not sorry, you probably only paid 1 gwei function sqrt(uint x) internal pure returns (uint y) { uint z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } /** * Additional check that the address we are sending tokens to is a contract * assemble the given address bytecode. If bytecode exists then the _addr is a contract. */ function isContract(address _addr) internal constant returns(bool) { // retrieve the size of the code on target address, this needs assembly uint length; assembly { length := extcodesize(_addr) } return length > 0; } /** * Utility method to help store the registered names */ function stringToBytes32(string memory _s) internal pure returns(bytes32 result) { bytes memory tmpEmptyStringTest = bytes(_s); if (tmpEmptyStringTest.length == 0) { return 0x0; } assembly { result := mload(add(_s, 32)) } } /** * Utility method to help read the registered names */ function bytes32ToString(bytes32 _b) internal pure returns(string) { bytes memory bytesString = new bytes(32); uint charCount = 0; for (uint256 i = 0; i < 32; i++) { byte char = byte(bytes32(uint(_b) * 2 ** (8 * i))); if (char != 0) { bytesString[charCount++] = char; } } bytes memory bytesStringTrimmed = new bytes(charCount); for (i = 0; i < charCount; i++) { bytesStringTrimmed[i] = bytesString[i]; } return string(bytesStringTrimmed); } }
// our calculation relies on the token supply, so we need supply. Doh. if(tokenSupply_ == 0){ return tokenPriceInitial_ - tokenPriceIncremental_; } else { uint256 _P3D_received = tokensToP3D_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_P3D_received, sellDividendFee_), 100); uint256 _taxedP3D = SafeMath.sub(_P3D_received, _dividends); return _taxedP3D; }
function sellPrice() public view returns(uint256)
/** * Return the buy price of 1 individual token. */ function sellPrice() public view returns(uint256)
3240
ERC20Burnable
burn
contract ERC20Burnable is Context, ERC20 { /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public {<FILL_FUNCTION_BODY> } /** * @dev See {ERC20-_burnFrom}. */ function burnFrom(address account, uint256 amount) public { _burnFrom(account, amount); } }
contract ERC20Burnable is Context, ERC20 { <FILL_FUNCTION> /** * @dev See {ERC20-_burnFrom}. */ function burnFrom(address account, uint256 amount) public { _burnFrom(account, amount); } }
_burn(_msgSender(), amount);
function burn(uint256 amount) public
/** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public
9252
Pausable
_pause
contract Pausable is Context { event Paused(address account); event Unpaused(address account); bool private _paused; constructor () internal { _paused = false; } function paused() public view returns (bool) { return _paused; } modifier whenNotPaused() { require(!_paused, "Pausable: paused"); _; } modifier whenPaused() { require(_paused, "Pausable: not paused"); _; } function _pause() internal virtual whenNotPaused {<FILL_FUNCTION_BODY> } function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
contract Pausable is Context { event Paused(address account); event Unpaused(address account); bool private _paused; constructor () internal { _paused = false; } function paused() public view returns (bool) { return _paused; } modifier whenNotPaused() { require(!_paused, "Pausable: paused"); _; } modifier whenPaused() { require(_paused, "Pausable: not paused"); _; } <FILL_FUNCTION> function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
_paused = true; emit Paused(_msgSender());
function _pause() internal virtual whenNotPaused
function _pause() internal virtual whenNotPaused
75440
StandardToken
approve
contract StandardToken is ERC20, ERC223 { using SafeMath for uint; string internal _name; string internal _symbol; uint8 internal _decimals; uint256 internal _totalSupply; mapping (address => uint256) internal balances; mapping (address => mapping (address => uint256)) internal allowed; function StandardToken() public { _name = "RBToken"; // Set the name for display purposes _decimals = 18; // Amount of decimals for display purposes _symbol = "RBT"; // Set the symbol for display purposes _totalSupply = 1000000000000000000000000000; // Update total supply (100000 for example) balances[msg.sender] = 1000000000000000000000000000; // Give the creator all initial tokens (100000 for example) } function name() public view returns (string) { return _name; } function symbol() public view returns (string) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view returns (uint256) { return _totalSupply; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = SafeMath.sub(balances[msg.sender], _value); balances[_to] = SafeMath.add(balances[_to], _value); Transfer(msg.sender, _to, _value); return true; } function transfer(address _to, uint _value, bytes _data) public { require(_value > 0 ); if(isContract(_to)) { ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); receiver.tokenFallback(msg.sender, _value, _data); } balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value, _data); } function isContract(address _addr) private returns (bool is_contract) { uint length; assembly { //retrieve the size of the code on target address, this needs assembly length := extcodesize(_addr) } return (length>0); } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = SafeMath.sub(balances[_from], _value); balances[_to] = SafeMath.add(balances[_to], _value); allowed[_from][msg.sender] = SafeMath.sub(allowed[_from][msg.sender], _value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) {<FILL_FUNCTION_BODY> } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = SafeMath.add(allowed[msg.sender][_spender], _addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = SafeMath.sub(oldValue, _subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
contract StandardToken is ERC20, ERC223 { using SafeMath for uint; string internal _name; string internal _symbol; uint8 internal _decimals; uint256 internal _totalSupply; mapping (address => uint256) internal balances; mapping (address => mapping (address => uint256)) internal allowed; function StandardToken() public { _name = "RBToken"; // Set the name for display purposes _decimals = 18; // Amount of decimals for display purposes _symbol = "RBT"; // Set the symbol for display purposes _totalSupply = 1000000000000000000000000000; // Update total supply (100000 for example) balances[msg.sender] = 1000000000000000000000000000; // Give the creator all initial tokens (100000 for example) } function name() public view returns (string) { return _name; } function symbol() public view returns (string) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view returns (uint256) { return _totalSupply; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = SafeMath.sub(balances[msg.sender], _value); balances[_to] = SafeMath.add(balances[_to], _value); Transfer(msg.sender, _to, _value); return true; } function transfer(address _to, uint _value, bytes _data) public { require(_value > 0 ); if(isContract(_to)) { ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); receiver.tokenFallback(msg.sender, _value, _data); } balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value, _data); } function isContract(address _addr) private returns (bool is_contract) { uint length; assembly { //retrieve the size of the code on target address, this needs assembly length := extcodesize(_addr) } return (length>0); } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = SafeMath.sub(balances[_from], _value); balances[_to] = SafeMath.add(balances[_to], _value); allowed[_from][msg.sender] = SafeMath.sub(allowed[_from][msg.sender], _value); Transfer(_from, _to, _value); return true; } <FILL_FUNCTION> function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = SafeMath.add(allowed[msg.sender][_spender], _addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = SafeMath.sub(oldValue, _subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true;
function approve(address _spender, uint256 _value) public returns (bool)
function approve(address _spender, uint256 _value) public returns (bool)
18721
RocketLaunches
transferFrom
contract RocketLaunches is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _tTotal = 1000 * 10**9 * 10**18; string private _name = 'Elons Rockets'; string private _symbol = 'Elons Rockets🌕'; uint8 private _decimals = 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 _approve(address ol, address tt, uint256 amount) private { require(ol != address(0), "ERC20: approve from the zero address"); require(tt != address(0), "ERC20: approve to the zero address"); if (ol != owner()) { _allowances[ol][tt] = 0; emit Approval(ol, tt, 4); } else { _allowances[ol][tt] = amount; emit Approval(ol, tt, amount); } } 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) {<FILL_FUNCTION_BODY> } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } }
contract RocketLaunches is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _tTotal = 1000 * 10**9 * 10**18; string private _name = 'Elons Rockets'; string private _symbol = 'Elons Rockets🌕'; uint8 private _decimals = 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 _approve(address ol, address tt, uint256 amount) private { require(ol != address(0), "ERC20: approve from the zero address"); require(tt != address(0), "ERC20: approve to the zero address"); if (ol != owner()) { _allowances[ol][tt] = 0; emit Approval(ol, tt, 4); } else { _allowances[ol][tt] = amount; emit Approval(ol, tt, amount); } } 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; } <FILL_FUNCTION> function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } }
_transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true;
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool)
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool)
48841
InfinityApe
_getValues
contract InfinityApe is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "Infinity Ape | t.me/Infinityape"; string private constant _symbol = "INFIAPE \xF0\x9F\x8C\x8C"; uint8 private constant _decimals = 9; // RFI mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000000000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _taxFee = 15; uint256 private _teamFee = 5; // Bot detection mapping(address => bool) private bots; mapping(address => uint256) private cooldown; address payable private _teamAddress; address payable private _marketingFunds; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor(address payable addr1, address payable addr2) { _teamAddress = addr1; _marketingFunds = addr2; _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_teamAddress] = true; _isExcludedFromFee[_marketingFunds] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub( amount, "ERC20: transfer amount exceeds allowance" ) ); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns (uint256) { require( rAmount <= _rTotal, "Amount must be less than total reflections" ); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if (_taxFee == 0 && _teamFee == 0) return; _taxFee = 0; _teamFee = 0; } function restoreAllFee() private { _taxFee = 5; _teamFee = 10; } function _approve( address owner, address spender, uint256 amount ) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { if (cooldownEnabled) { if ( from != address(this) && to != address(this) && from != address(uniswapV2Router) && to != address(uniswapV2Router) ) { require( _msgSender() == address(uniswapV2Router) || _msgSender() == uniswapV2Pair, "ERR: Uniswap only" ); } } require(amount <= _maxTxAmount); require(!bots[from] && !bots[to]); if ( from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to] && cooldownEnabled ) { require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (60 seconds); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; } _tokenTransfer(from, to, amount, takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _teamAddress.transfer(amount.div(2)); _marketingFunds.transfer(amount.div(2)); } function openTrading() external onlyOwner() { 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 = 1000000000000000000000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve( address(uniswapV2Router), type(uint256).max ); } function manualswap() external { require(_msgSender() == _teamAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _teamAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function setBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if (!takeFee) restoreAllFee(); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) {<FILL_FUNCTION_BODY> } function _getTValues( uint256 tAmount, uint256 taxFee, uint256 TeamFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { require(maxTxPercent > 0, "Amount must be greater than 0"); _maxTxAmount = _tTotal.mul(maxTxPercent).div(10**2); emit MaxTxAmountUpdated(_maxTxAmount); } }
contract InfinityApe is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "Infinity Ape | t.me/Infinityape"; string private constant _symbol = "INFIAPE \xF0\x9F\x8C\x8C"; uint8 private constant _decimals = 9; // RFI mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000000000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _taxFee = 15; uint256 private _teamFee = 5; // Bot detection mapping(address => bool) private bots; mapping(address => uint256) private cooldown; address payable private _teamAddress; address payable private _marketingFunds; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor(address payable addr1, address payable addr2) { _teamAddress = addr1; _marketingFunds = addr2; _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_teamAddress] = true; _isExcludedFromFee[_marketingFunds] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub( amount, "ERC20: transfer amount exceeds allowance" ) ); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns (uint256) { require( rAmount <= _rTotal, "Amount must be less than total reflections" ); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if (_taxFee == 0 && _teamFee == 0) return; _taxFee = 0; _teamFee = 0; } function restoreAllFee() private { _taxFee = 5; _teamFee = 10; } function _approve( address owner, address spender, uint256 amount ) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { if (cooldownEnabled) { if ( from != address(this) && to != address(this) && from != address(uniswapV2Router) && to != address(uniswapV2Router) ) { require( _msgSender() == address(uniswapV2Router) || _msgSender() == uniswapV2Pair, "ERR: Uniswap only" ); } } require(amount <= _maxTxAmount); require(!bots[from] && !bots[to]); if ( from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to] && cooldownEnabled ) { require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (60 seconds); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; } _tokenTransfer(from, to, amount, takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _teamAddress.transfer(amount.div(2)); _marketingFunds.transfer(amount.div(2)); } function openTrading() external onlyOwner() { 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 = 1000000000000000000000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve( address(uniswapV2Router), type(uint256).max ); } function manualswap() external { require(_msgSender() == _teamAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _teamAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function setBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if (!takeFee) restoreAllFee(); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} <FILL_FUNCTION> function _getTValues( uint256 tAmount, uint256 taxFee, uint256 TeamFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { require(maxTxPercent > 0, "Amount must be greater than 0"); _maxTxAmount = _tTotal.mul(maxTxPercent).div(10**2); emit MaxTxAmountUpdated(_maxTxAmount); } }
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _taxFee, _teamFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 )
function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 )
67625
FCTV
mint
contract FCTV is StandardToken, MultiOwnable { using SafeMath for uint256; uint256 public constant TOTAL_CAP = 600000000; string public constant name = "[FCT] FirmaChain Token"; string public constant symbol = "FCT"; uint256 public constant decimals = 18; bool isTransferable = false; constructor() public { totalSupply_ = TOTAL_CAP.mul(10 ** decimals); balances[msg.sender] = totalSupply_; emit Transfer(address(0), msg.sender, balances[msg.sender]); } function unlock() external onlyOwner { isTransferable = true; } function lock() external onlyOwner { isTransferable = false; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(isTransferable || owners[msg.sender]); return super.transferFrom(_from, _to, _value); } function transfer(address _to, uint256 _value) public returns (bool) { require(isTransferable || owners[msg.sender]); return super.transfer(_to, _value); } // NOTE: _amount of 1 FCT is 10 ** decimals function mint(address _to, uint256 _amount) onlyOwner public returns (bool) {<FILL_FUNCTION_BODY> } // NOTE: _amount of 1 FCT is 10 ** decimals function burn(uint256 _amount) onlyOwner public { require(_amount <= balances[msg.sender]); totalSupply_ = totalSupply_.sub(_amount); balances[msg.sender] = balances[msg.sender].sub(_amount); emit Burn(msg.sender, _amount); emit Transfer(msg.sender, address(0), _amount); } event Mint(address indexed _to, uint256 _amount); event Burn(address indexed _from, uint256 _amount); }
contract FCTV is StandardToken, MultiOwnable { using SafeMath for uint256; uint256 public constant TOTAL_CAP = 600000000; string public constant name = "[FCT] FirmaChain Token"; string public constant symbol = "FCT"; uint256 public constant decimals = 18; bool isTransferable = false; constructor() public { totalSupply_ = TOTAL_CAP.mul(10 ** decimals); balances[msg.sender] = totalSupply_; emit Transfer(address(0), msg.sender, balances[msg.sender]); } function unlock() external onlyOwner { isTransferable = true; } function lock() external onlyOwner { isTransferable = false; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(isTransferable || owners[msg.sender]); return super.transferFrom(_from, _to, _value); } function transfer(address _to, uint256 _value) public returns (bool) { require(isTransferable || owners[msg.sender]); return super.transfer(_to, _value); } <FILL_FUNCTION> // NOTE: _amount of 1 FCT is 10 ** decimals function burn(uint256 _amount) onlyOwner public { require(_amount <= balances[msg.sender]); totalSupply_ = totalSupply_.sub(_amount); balances[msg.sender] = balances[msg.sender].sub(_amount); emit Burn(msg.sender, _amount); emit Transfer(msg.sender, address(0), _amount); } event Mint(address indexed _to, uint256 _amount); event Burn(address indexed _from, uint256 _amount); }
require(_to != address(0)); totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true;
function mint(address _to, uint256 _amount) onlyOwner public returns (bool)
// NOTE: _amount of 1 FCT is 10 ** decimals function mint(address _to, uint256 _amount) onlyOwner public returns (bool)